Menu

[r10367]: / legacy / www / system_proxy.php  Maximize  Restore  History

Download this file

241 lines (213 with data), 10.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/usr/local/bin/php
<?php
/*
system_proxy.php
Copyright (C) 2006-2010 Volker Theile (votdev@gmx.de)
All rights reserved.
part of FreeNAS (http://www.freenas.org)
Copyright (C) 2005-2010 Olivier Cochard <olivier@freenas.org>.
All rights reserved.
Based on m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require("auth.inc");
require("guiconfig.inc");
$pgtitle = array(gettext("System"),gettext("Advanced"),gettext("Proxy"));
if (!is_array($config['system']['proxy']['http'])) {
$config['system']['proxy']['http'] = array();
}
if (!is_array($config['system']['proxy']['ftp'])) {
$config['system']['proxy']['ftp'] = array();
}
$pconfig['http_enable'] = isset($config['system']['proxy']['http']['enable']);
$pconfig['http_address'] = $config['system']['proxy']['http']['address'];
$pconfig['http_port'] = $config['system']['proxy']['http']['port'];
$pconfig['http_auth'] = isset($config['system']['proxy']['http']['auth']);
$pconfig['http_username'] = $config['system']['proxy']['http']['username'];
$pconfig['http_password'] = $config['system']['proxy']['http']['password'];
$pconfig['ftp_enable'] = isset($config['system']['proxy']['ftp']['enable']);
$pconfig['ftp_address'] = $config['system']['proxy']['ftp']['address'];
$pconfig['ftp_port'] = $config['system']['proxy']['ftp']['port'];
$pconfig['ftp_auth'] = isset($config['system']['proxy']['ftp']['auth']);
$pconfig['ftp_username'] = $config['system']['proxy']['ftp']['username'];
$pconfig['ftp_password'] = $config['system']['proxy']['ftp']['password'];
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
$reqdfields = array();
$reqdfieldsn = array();
$reqdfieldst = array();
if ($_POST['http_enable']) {
$reqdfields = array_merge($reqdfields, explode(" ", "http_address http_port"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Address"),gettext("Port")));
$reqdfieldst = array_merge($reqdfieldst,array("string","numeric"));
if ($_POST['http_auth']) {
$reqdfields = array_merge($reqdfields, explode(" ", "http_username http_password"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("User"),gettext("Password")));
$reqdfieldst = array_merge($reqdfieldst,array("string","password"));
}
}
if ($_POST['ftp_enable']) {
$reqdfields = array_merge($reqdfields, explode(" ", "ftp_address ftp_port"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Address"),gettext("Port")));
$reqdfieldst = array_merge($reqdfieldst,array("string","numeric"));
if ($_POST['ftp_auth']) {
$reqdfields = array_merge($reqdfields, explode(" ", "ftp_username ftp_password"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("User"),gettext("Password")));
$reqdfieldst = array_merge($reqdfieldst,array("string","password"));
}
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
if ($_POST['http_auth']) {
if (($_POST['password'] && !is_validpassword($_POST['password']))) {
$input_errors[] = gettext("The password contains the illegal character ':'.");
}
}
if (!$input_errors) {
$config['system']['proxy']['http']['enable'] = $pconfig['http_enable'] ? true : false;
$config['system']['proxy']['http']['address'] = $pconfig['http_address'];
$config['system']['proxy']['http']['port'] = $pconfig['http_port'];
$config['system']['proxy']['http']['auth'] = $pconfig['http_auth'] ? true : false;
$config['system']['proxy']['http']['username'] = $pconfig['http_username'];
$config['system']['proxy']['http']['password'] = $pconfig['http_password'];
$config['system']['proxy']['ftp']['enable'] = $pconfig['ftp_enable'] ? true : false;
$config['system']['proxy']['ftp']['address'] = $pconfig['ftp_address'];
$config['system']['proxy']['ftp']['port'] = $pconfig['ftp_port'];
$config['system']['proxy']['ftp']['auth'] = $pconfig['ftp_auth'] ? true : false;
$config['system']['proxy']['ftp']['username'] = $pconfig['ftp_username'];
$config['system']['proxy']['ftp']['password'] = $pconfig['ftp_password'];
write_config();
touch($d_sysrebootreqd_path);
}
}
?>
<?php include("fbegin.inc");?>
<script type="text/javascript">
<!--
function enable_change(enable_change) {
if (enable_change.name == "http_enable") {
var endis = !enable_change.checked;
document.iform.http_address.disabled = endis;
document.iform.http_port.disabled = endis;
document.iform.http_auth.disabled = endis;
document.iform.http_username.disabled = endis;
document.iform.http_password.disabled = endis;
} else if (enable_change.name == "ftp_enable") {
var endis = !enable_change.checked;
document.iform.ftp_address.disabled = endis;
document.iform.ftp_port.disabled = endis;
document.iform.ftp_auth.disabled = endis;
document.iform.ftp_username.disabled = endis;
document.iform.ftp_password.disabled = endis;
} else {
var endis = !(document.iform.http_enable.checked || enable_change);
document.iform.http_address.disabled = endis;
document.iform.http_port.disabled = endis;
document.iform.http_auth.disabled = endis;
document.iform.http_username.disabled = endis;
document.iform.http_password.disabled = endis;
endis = !(document.iform.ftp_enable.checked || enable_change);
document.iform.ftp_address.disabled = endis;
document.iform.ftp_port.disabled = endis;
document.iform.ftp_auth.disabled = endis;
document.iform.ftp_username.disabled = endis;
document.iform.ftp_password.disabled = endis;
}
}
function proxy_auth_change() {
switch(document.iform.http_auth.checked) {
case false:
showElementById('http_username_tr','hide');
showElementById('http_password_tr','hide');
break;
case true:
showElementById('http_username_tr','show');
showElementById('http_password_tr','show');
break;
}
switch(document.iform.ftp_auth.checked) {
case false:
showElementById('ftp_username_tr','hide');
showElementById('ftp_password_tr','hide');
break;
case true:
showElementById('ftp_username_tr','show');
showElementById('ftp_password_tr','show');
break;
}
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabnavtbl">
<ul id="tabnav">
<li class="tabinact"><a href="system_advanced.php"><span><?=gettext("Advanced");?></span></a></li>
<li class="tabinact"><a href="system_email.php"><span><?=gettext("Email");?></span></a></li>
<li class="tabact"><a href="system_proxy.php" title="<?=gettext("Reload page");?>"><span><?=gettext("Proxy");?></span></a></li>
<li class="tabinact"><a href="system_swap.php"><span><?=gettext("Swap");?></span></a></li>
<li class="tabinact"><a href="system_rc.php"><span><?=gettext("Command scripts");?></span></a></li>
<li class="tabinact"><a href="system_cron.php"><span><?=gettext("Cron");?></span></a></li>
<li class="tabinact"><a href="system_rcconf.php"><span><?=gettext("rc.conf");?></span></a></li>
<li class="tabinact"><a href="system_sysctl.php"><span><?=gettext("sysctl.conf");?></span></a></li>
</ul>
</td>
</tr>
<tr>
<td class="tabcont">
<form action="system_proxy.php" method="post" name="iform" id="iform">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<?php if (file_exists($d_sysrebootreqd_path)) print_info_box(get_std_save_message(0));?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<?php html_titleline_checkbox("http_enable", gettext("HTTP Proxy"), $pconfig['http_enable'] ? true : false, gettext("Enable"), "enable_change(this)");?>
<?php html_inputbox("http_address", gettext("Address"), $pconfig['http_address'], "", true, 40);?>
<?php html_inputbox("http_port", gettext("Port"), $pconfig['http_port'], "", true, 10);?>
<?php html_checkbox("http_auth", gettext("Authentication"), $pconfig['http_auth'] ? true : false, gettext("Enable proxy authentication."), "", false, "proxy_auth_change()");?>
<?php html_inputbox("http_username", gettext("User"), $pconfig['http_username'], "", true, 20);?>
<?php html_inputbox("http_password", gettext("Password"), $pconfig['http_password'], "", true, 20);?>
<?php html_separator();?>
<?php html_titleline_checkbox("ftp_enable", gettext("FTP Proxy"), $pconfig['ftp_enable'] ? true : false, gettext("Enable"), "enable_change(this)");?>
<?php html_inputbox("ftp_address", gettext("Address"), $pconfig['ftp_address'], "", true, 40);?>
<?php html_inputbox("ftp_port", gettext("Port"), $pconfig['ftp_port'], "", true, 10);?>
<?php html_checkbox("ftp_auth", gettext("Authentication"), $pconfig['ftp_auth'] ? true : false, gettext("Enable proxy authentication."), "", false, "proxy_auth_change()");?>
<?php html_inputbox("ftp_username", gettext("User"), $pconfig['ftp_username'], "", true, 20);?>
<?php html_inputbox("ftp_password", gettext("Password"), $pconfig['ftp_password'], "", true, 20);?>
</table>
<div id="submit">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
</div>
<div id="remarks">
<?php html_remark("note", gettext("Note"), gettext("If the server is behind a proxy set this parameters to give local services access to the internet via proxy."));?>
</div>
<?php include("formend.inc");?>
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
proxy_auth_change();
enable_change(false);
//-->
</script>
<?php include("fend.inc");?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.