+for ($n=0; $n<=@useragentlist; $n = $n + $i) {
+ for ($i=0; $i<=3; $i++) {
+ if ($i eq 0) { print "<tr>\n"; }
+ if (($n+$i) < @useragentlist) {
+ @useragent = split(/,/,@useragentlist[$n+$i]);
+ print "<td width='15%'>@useragent[1]:<\/td>\n";
+ print "<td width='10%'><input type='checkbox' name='UA_@useragent[0]' $checked{'UA_'.@useragent[0]}{'on'} /></td>\n";
+ }
+ if ($i eq 3) { print "<\/tr>\n"; }
+ }
+}
+
+print <<END
+</table>
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td><b>$Lang::tr{'advproxy privacy'}</b></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy fake useragent'}: <img src='/blob.gif' alt='*' /></td>
+</tr>
+<tr>
+ <td><input type='text' name='FAKE_USERAGENT' value='$proxysettings{'FAKE_USERAGENT'}' size='56' /></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy fake referer'}: <img src='/blob.gif' alt='*' /></td>
+</tr>
+<tr>
+ <td><input type='text' name='FAKE_REFERER' value='$proxysettings{'FAKE_REFERER'}' size='56' /></td>
+</tr>
+</table>
+<hr size='1'>
+END
+;
+
+if ($urlfilter_addon) {
+ print <<END
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy url filter'}</b></td>
+</tr>
+<tr>
+ <td class='base' width='25%'>$Lang::tr{'advproxy enabled'}:</td>
+ <td><input type='checkbox' name='ENABLE_FILTER' $checked{'ENABLE_FILTER'}{'on'} /></td>
+ <td> </td>
+ <td> </td>
+</tr>
+</table>
+<hr size='1'>
+END
+; }
+
+if (($updacclrtr_addon) && (!($urlfilter_addon))) {
+ print <<END
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy update accelerator'}</b></td>
+</tr>
+<tr>
+ <td class='base' width='25%'>$Lang::tr{'advproxy enabled'}:</td>
+ <td><input type='checkbox' name='ENABLE_UPDACCEL' $checked{'ENABLE_UPDACCEL'}{'on'} /></td>
+ <td> </td>
+ <td> </td>
+</tr>
+</table>
+<hr size='1'>
+END
+; }
+
+print <<END
+<table width='100%'>
+<tr>
+ <td colspan='5'><b>$Lang::tr{'advproxy AUTH method'}</b></td>
+</tr>
+<tr>
+ <td width='16%' class='base'><input type='radio' name='AUTH_METHOD' value='none' $checked{'AUTH_METHOD'}{'none'} />$Lang::tr{'advproxy AUTH method none'}</td>
+ <td width='16%' class='base'><input type='radio' name='AUTH_METHOD' value='ncsa' $checked{'AUTH_METHOD'}{'ncsa'} />$Lang::tr{'advproxy AUTH method ncsa'}</td>
+ <td width='16%' class='base'><input type='radio' name='AUTH_METHOD' value='ident' $checked{'AUTH_METHOD'}{'ident'} />$Lang::tr{'advproxy AUTH method ident'}</td>
+ <td width='16%' class='base'><input type='radio' name='AUTH_METHOD' value='ldap' $checked{'AUTH_METHOD'}{'ldap'} />$Lang::tr{'advproxy AUTH method ldap'}</td>
+ <td width='16%' class='base'><input type='radio' name='AUTH_METHOD' value='ntlm' $checked{'AUTH_METHOD'}{'ntlm'} />$Lang::tr{'advproxy AUTH method ntlm'}</td>
+ <td width='16%' class='base'><input type='radio' name='AUTH_METHOD' value='radius' $checked{'AUTH_METHOD'}{'radius'} />$Lang::tr{'advproxy AUTH method radius'}</td>
+</tr>
+</table>
+END
+;
+
+if (!($proxysettings{'AUTH_METHOD'} eq 'none')) { if (!($proxysettings{'AUTH_METHOD'} eq 'ident')) { print <<END
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy AUTH global settings'}</b></td>
+</tr>
+<tr>
+ <td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy AUTH number of auth processes'}:</td>
+ <td><input type='text' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}' size='5' /></td>
+ <td colspan='2' rowspan= '6' valign='top' class='base'>
+ <table cellpadding='0' cellspacing='0'>
+ <tr>
+ <td class='base'>$Lang::tr{'advproxy AUTH realm'}: <img src='/blob.gif' alt='*' /></td>
+ </tr>
+ <tr>
+ <!-- intentionally left empty -->
+ </tr>
+ <tr>
+ <!-- intentionally left empty -->
+ </tr>
+ <tr>
+ <td><input type='text' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}' size='40' /></td>
+ </tr>
+ <tr>
+ <!-- intentionally left empty -->
+ </tr>
+ <tr>
+ <!-- intentionally left empty -->
+ </tr>
+ <tr>
+ <td>$Lang::tr{'advproxy AUTH no auth'}: <img src='/blob.gif' alt='*' /></td>
+ </tr>
+ <tr>
+ <!-- intentionally left empty -->
+ </tr>
+ <tr>
+ <!-- intentionally left empty -->
+ </tr>
+ <tr>
+ <td><textarea name='DST_NOAUTH' cols='32' rows='6' wrap='off'>
+END
+;
+
+print $proxysettings{'DST_NOAUTH'};
+
+print <<END
+</textarea></td>
+ </tr>
+ </table>
+ </td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy AUTH auth cache TTL'}:</td>
+ <td><input type='text' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy AUTH limit of IP addresses'}: <img src='/blob.gif' alt='*' /></td>
+ <td><input type='text' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy AUTH user IP cache TTL'}:</td>
+ <td><input type='text' name='AUTH_IPCACHE_TTL' value='$proxysettings{'AUTH_IPCACHE_TTL'}' size='5' /></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy AUTH always required'}:</td>
+ <td><input type='checkbox' name='AUTH_ALWAYS_REQUIRED' $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} /></td>
+</tr>
+<tr>
+ <td colspan='2'> </td>
+</tr>
+</table>
+END
+;
+}
+
+# ===================================================================
+# NCSA auth settings
+# ===================================================================
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ncsa') {
+print <<END
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy NCSA auth'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy NCSA min password length'}:</td>
+ <td width='20%'><input type='text' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}' size='5' /></td>
+ <td width='25%' class='base'>$Lang::tr{'advproxy NCSA redirector bypass'} \'$Lang::tr{'advproxy NCSA grp extended'}\':</td>
+ <td width='20%'><input type='checkbox' name='NCSA_BYPASS_REDIR' $checked{'NCSA_BYPASS_REDIR'}{'on'} /></td>
+</tr>
+<tr>
+ <td colspan='2'><br> <input type='submit' name='ACTION' value='$Lang::tr{'advproxy NCSA user management'}'></td>
+ <td> </td>
+ <td> </td>
+</tr>
+</table>
+END
+; }
+
+# ===================================================================
+# IDENTD auth settings
+# ===================================================================
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident') {
+print <<END
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy IDENT identd settings'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy IDENT required'}:</td>
+ <td width='20%'><input type='checkbox' name='IDENT_REQUIRED' $checked{'IDENT_REQUIRED'}{'on'} /></td>
+ <td width='25%' class='base'>$Lang::tr{'advproxy AUTH always required'}:</td>
+ <td width='30%'><input type='checkbox' name='AUTH_ALWAYS_REQUIRED' $checked{'AUTH_ALWAYS_REQUIRED'}{'on'} /></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy IDENT timeout'}:</td>
+ <td><input type='text' name='IDENT_TIMEOUT' value='$proxysettings{'IDENT_TIMEOUT'}' size='5' /></td>
+ <td> </td>
+ <td> </td>
+</tr>
+<tr>
+ <td colspan='2' class='base'>$Lang::tr{'advproxy IDENT aware hosts'}:</td>
+ <td colspan='2' class='base'>$Lang::tr{'advproxy AUTH no auth'}: <img src='/blob.gif' alt='*' /></td>
+</tr>
+<tr>
+ <td colspan='2'><textarea name='IDENT_HOSTS' cols='32' rows='6' wrap='off'>
+END
+;
+if (!$proxysettings{'IDENT_HOSTS'}) {
+ print "$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}\n";
+ if ($netsettings{'BLUE_DEV'}) {
+ print "$netsettings{'BLUE_NETADDRESS'}\/$netsettings{'BLUE_NETMASK'}\n";
+ }
+} else {
+ print $proxysettings{'IDENT_HOSTS'};
+}
+
+print <<END
+</textarea></td>
+ <td colspan='2'><textarea name='DST_NOAUTH' cols='32' rows='6' wrap='off'>
+END
+;
+
+print $proxysettings{'DST_NOAUTH'};
+
+print <<END
+</textarea></td>
+</tr>
+</table>
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy IDENT user based access restrictions'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
+ <td width='20%'><input type='checkbox' name='IDENT_ENABLE_ACL' $checked{'IDENT_ENABLE_ACL'}{'on'} /></td>
+ <td width='25%'> </td>
+ <td width='30%'> </td>
+</tr>
+<tr>
+ <td colspan='2'><input type='radio' name='IDENT_USER_ACL' value='positive' $checked{'IDENT_USER_ACL'}{'positive'} />
+ $Lang::tr{'advproxy IDENT use positive access list'}:</td>
+ <td colspan='2'><input type='radio' name='IDENT_USER_ACL' value='negative' $checked{'IDENT_USER_ACL'}{'negative'} />
+ $Lang::tr{'advproxy IDENT use negative access list'}:</td>
+</tr>
+<tr>
+ <td colspan='2'>$Lang::tr{'advproxy IDENT authorized users'}</td>
+ <td colspan='2'>$Lang::tr{'advproxy IDENT unauthorized users'}</td>
+</tr>
+<tr>
+ <td colspan='2'><textarea name='IDENT_ALLOW_USERS' cols='32' rows='6' wrap='off'>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print $proxysettings{'IDENT_ALLOW_USERS'}; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print <<END
+</textarea></td>
+ <td colspan='2'><textarea name='IDENT_DENY_USERS' cols='32' rows='6' wrap='off'>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print $proxysettings{'IDENT_DENY_USERS'}; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident') { print <<END
+</textarea></td>
+</tr>
+</table>
+END
+; }
+
+# ===================================================================
+# NTLM auth settings
+# ===================================================================
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ntlm') {
+print <<END
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td colspan='6'><b>$Lang::tr{'advproxy NTLM domain settings'}</b></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy NTLM domain'}:</td>
+ <td><input type='text' name='NTLM_DOMAIN' value='$proxysettings{'NTLM_DOMAIN'}' size='15' /></td>
+ <td class='base'>$Lang::tr{'advproxy NTLM PDC hostname'}:</td>
+ <td><input type='text' name='NTLM_PDC' value='$proxysettings{'NTLM_PDC'}' size='14' /></td>
+ <td class='base'>$Lang::tr{'advproxy NTLM BDC hostname'}: <img src='/blob.gif' alt='*' /></td>
+ <td><input type='text' name='NTLM_BDC' value='$proxysettings{'NTLM_BDC'}' size='14' /></td>
+</tr>
+</table>
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='3'><b>$Lang::tr{'advproxy NTLM auth mode'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base' width='25%'>$Lang::tr{'advproxy NTLM use integrated auth'}:</td>
+ <td width='20%'><input type='checkbox' name='NTLM_ENABLE_INT_AUTH' $checked{'NTLM_ENABLE_INT_AUTH'}{'on'} /></td>
+ <td> </td>
+</tr>
+</table>
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy NTLM user based access restrictions'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
+ <td width='20%'><input type='checkbox' name='NTLM_ENABLE_ACL' $checked{'NTLM_ENABLE_ACL'}{'on'} /></td>
+ <td width='25%'> </td>
+ <td width='30%'> </td>
+</tr>
+<tr>
+ <td colspan='2'><input type='radio' name='NTLM_USER_ACL' value='positive' $checked{'NTLM_USER_ACL'}{'positive'} />
+ $Lang::tr{'advproxy NTLM use positive access list'}:</td>
+ <td colspan='2'><input type='radio' name='NTLM_USER_ACL' value='negative' $checked{'NTLM_USER_ACL'}{'negative'} />
+ $Lang::tr{'advproxy NTLM use negative access list'}:</td>
+</tr>
+<tr>
+ <td colspan='2'>$Lang::tr{'advproxy NTLM authorized users'}</td>
+ <td colspan='2'>$Lang::tr{'advproxy NTLM unauthorized users'}</td>
+</tr>
+<tr>
+ <td colspan='2'><textarea name='NTLM_ALLOW_USERS' cols='32' rows='6' wrap='off'>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ntlm') { print $proxysettings{'NTLM_ALLOW_USERS'}; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ntlm') { print <<END
+</textarea></td>
+ <td colspan='2'><textarea name='NTLM_DENY_USERS' cols='32' rows='6' wrap='off'>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ntlm') { print $proxysettings{'NTLM_DENY_USERS'}; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ntlm') { print <<END
+</textarea></td>
+</tr>
+</table>
+END
+; }
+
+# ===================================================================
+# LDAP auth settings
+# ===================================================================
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ldap') {
+print <<END
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy LDAP common settings'}</b></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy LDAP basedn'}:</td>
+ <td><input type='text' name='LDAP_BASEDN' value='$proxysettings{'LDAP_BASEDN'}' size='37' /></td>
+ <td class='base'>$Lang::tr{'advproxy LDAP type'}:</td>
+ <td class='base'><select name='LDAP_TYPE'>
+ <option value='ADS' $selected{'LDAP_TYPE'}{'ADS'}>$Lang::tr{'advproxy LDAP ADS'}</option>
+ <option value='NDS' $selected{'LDAP_TYPE'}{'NDS'}>$Lang::tr{'advproxy LDAP NDS'}</option>
+ <option value='V2' $selected{'LDAP_TYPE'}{'V2'}>$Lang::tr{'advproxy LDAP V2'}</option>
+ <option value='V3' $selected{'LDAP_TYPE'}{'V3'}>$Lang::tr{'advproxy LDAP V3'}</option>
+ </select></td>
+</tr>
+<tr>
+ <td width='20%' class='base'>$Lang::tr{'advproxy LDAP server'}:</td>
+ <td width='40%'><input type='text' name='LDAP_SERVER' value='$proxysettings{'LDAP_SERVER'}' size='14' /></td>
+ <td width='20%' class='base'>$Lang::tr{'advproxy LDAP port'}:</td>
+ <td><input type='text' name='LDAP_PORT' value='$proxysettings{'LDAP_PORT'}' size='3' /></td>
+</tr>
+</table>
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy LDAP binddn settings'}</b></td>
+</tr>
+<tr>
+ <td width='20%' class='base'>$Lang::tr{'advproxy LDAP binddn username'}:</td>
+ <td width='40%'><input type='text' name='LDAP_BINDDN_USER' value='$proxysettings{'LDAP_BINDDN_USER'}' size='37' /></td>
+ <td width='20%' class='base'>$Lang::tr{'advproxy LDAP binddn password'}:</td>
+ <td><input type='password' name='LDAP_BINDDN_PASS' value='$proxysettings{'LDAP_BINDDN_PASS'}' size='14' /></td>
+</tr>
+</table>
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy LDAP group access control'}</b></td>
+</tr>
+<tr>
+ <td width='20%' class='base'>$Lang::tr{'advproxy LDAP group required'}: <img src='/blob.gif' alt='*' /></td>
+ <td width='40%'><input type='text' name='LDAP_GROUP' value='$proxysettings{'LDAP_GROUP'}' size='37' /></td>
+ <td> </td>
+ <td> </td>
+</tr>
+</table>
+END
+; }
+
+# ===================================================================
+# RADIUS auth settings
+# ===================================================================
+
+if ($proxysettings{'AUTH_METHOD'} eq 'radius') {
+print <<END
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy RADIUS radius settings'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy RADIUS server'}:</td>
+ <td width='20%'><input type='text' name='RADIUS_SERVER' value='$proxysettings{'RADIUS_SERVER'}' size='14' /></td>
+ <td width='25%' class='base'>$Lang::tr{'advproxy RADIUS port'}:</td>
+ <td width='30%'><input type='text' name='RADIUS_PORT' value='$proxysettings{'RADIUS_PORT'}' size='3' /></td>
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy RADIUS identifier'}: <img src='/blob.gif' alt='*' /></td>
+ <td><input type='text' name='RADIUS_IDENTIFIER' value='$proxysettings{'RADIUS_IDENTIFIER'}' size='14' /></td>
+ <td class='base'>$Lang::tr{'advproxy RADIUS secret'}:</td>
+ <td><input type='password' name='RADIUS_SECRET' value='$proxysettings{'RADIUS_SECRET'}' size='14' /></td>
+</tr>
+</table>
+<hr size ='1'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy RADIUS user based access restrictions'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy enabled'}:</td>
+ <td width='20%'><input type='checkbox' name='RADIUS_ENABLE_ACL' $checked{'RADIUS_ENABLE_ACL'}{'on'} /></td>
+ <td width='25%'> </td>
+ <td width='30%'> </td>
+</tr>
+<tr>
+ <td colspan='2'><input type='radio' name='RADIUS_USER_ACL' value='positive' $checked{'RADIUS_USER_ACL'}{'positive'} />
+ $Lang::tr{'advproxy RADIUS use positive access list'}:</td>
+ <td colspan='2'><input type='radio' name='RADIUS_USER_ACL' value='negative' $checked{'RADIUS_USER_ACL'}{'negative'} />
+ $Lang::tr{'advproxy RADIUS use negative access list'}:</td>
+</tr>
+<tr>
+ <td colspan='2'>$Lang::tr{'advproxy RADIUS authorized users'}</td>
+ <td colspan='2'>$Lang::tr{'advproxy RADIUS unauthorized users'}</td>
+</tr>
+<tr>
+ <td colspan='2'><textarea name='RADIUS_ALLOW_USERS' cols='32' rows='6' wrap='off'>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print $proxysettings{'RADIUS_ALLOW_USERS'}; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print <<END
+</textarea></td>
+ <td colspan='2'><textarea name='RADIUS_DENY_USERS' cols='32' rows='6' wrap='off'>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print $proxysettings{'RADIUS_DENY_USERS'}; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'radius') { print <<END
+</textarea></td>
+</tr>
+</table>
+END
+; }
+
+# ===================================================================
+
+}
+
+print "<table>\n";
+
+if ($proxysettings{'AUTH_METHOD'} eq 'none') {
+print <<END
+<td><input type='hidden' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}'></td>
+<td><input type='hidden' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
+<td><input type='hidden' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
+<td><input type='hidden' name='AUTH_IPCACHE_TTL' value='$proxysettings{'AUTH_IPCACHE_TTL'}' size='5' /></td>
+<td><input type='hidden' name='AUTH_ALWAYS_REQUIRED' value='$proxysettings{'AUTH_ALWAYS_REQUIRED'}'></td>
+<td><input type='hidden' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}'></td>
+<td><input type='hidden' name='DST_NOAUTH' value='$proxysettings{'DST_NOAUTH'}'></td>
+END
+; }
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident') {
+print <<END
+<td><input type='hidden' name='AUTH_CHILDREN' value='$proxysettings{'AUTH_CHILDREN'}'></td>
+<td><input type='hidden' name='AUTH_CACHE_TTL' value='$proxysettings{'AUTH_CACHE_TTL'}' size='5' /></td>
+<td><input type='hidden' name='AUTH_MAX_USERIP' value='$proxysettings{'AUTH_MAX_USERIP'}' size='5' /></td>
+<td><input type='hidden' name='AUTH_IPCACHE_TTL' value='$proxysettings{'AUTH_IPCACHE_TTL'}' size='5' /></td>
+<td><input type='hidden' name='AUTH_REALM' value='$proxysettings{'AUTH_REALM'}'></td>
+END
+; }
+
+if (!($proxysettings{'AUTH_METHOD'} eq 'ncsa')) {
+print <<END
+<td><input type='hidden' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}'></td>
+<td><input type='hidden' name='NCSA_BYPASS_REDIR' value='$proxysettings{'NCSA_BYPASS_REDIR'}'></td>
+END
+; }
+
+if (!($proxysettings{'AUTH_METHOD'} eq 'ident')) {
+print <<END
+<td><input type='hidden' name='IDENT_REQUIRED' value='$proxysettings{'IDENT_REQUIRED'}'></td>
+<td><input type='hidden' name='IDENT_TIMEOUT' value='$proxysettings{'IDENT_TIMEOUT'}'></td>
+<td><input type='hidden' name='IDENT_HOSTS' value='$proxysettings{'IDENT_HOSTS'}'></td>
+<td><input type='hidden' name='IDENT_ENABLE_ACL' value='$proxysettings{'IDENT_ENABLE_ACL'}'></td>
+<td><input type='hidden' name='IDENT_USER_ACL' value='$proxysettings{'IDENT_USER_ACL'}'></td>
+<td><input type='hidden' name='IDENT_ALLOW_USERS' value='$proxysettings{'IDENT_ALLOW_USERS'}'></td>
+<td><input type='hidden' name='IDENT_DENY_USERS' value='$proxysettings{'IDENT_DENY_USERS'}'></td>
+END
+; }
+
+if (!($proxysettings{'AUTH_METHOD'} eq 'ldap')) {
+print <<END
+<td><input type='hidden' name='LDAP_BASEDN' value='$proxysettings{'LDAP_BASEDN'}'></td>
+<td><input type='hidden' name='LDAP_TYPE' value='$proxysettings{'LDAP_TYPE'}'></td>
+<td><input type='hidden' name='LDAP_SERVER' value='$proxysettings{'LDAP_SERVER'}'></td>
+<td><input type='hidden' name='LDAP_PORT' value='$proxysettings{'LDAP_PORT'}'></td>
+<td><input type='hidden' name='LDAP_BINDDN_USER' value='$proxysettings{'LDAP_BINDDN_USER'}'></td>
+<td><input type='hidden' name='LDAP_BINDDN_PASS' value='$proxysettings{'LDAP_BINDDN_PASS'}'></td>
+<td><input type='hidden' name='LDAP_GROUP' value='$proxysettings{'LDAP_GROUP'}'></td>
+END
+; }
+
+if (!($proxysettings{'AUTH_METHOD'} eq 'ntlm')) {
+print <<END
+<td><input type='hidden' name='NTLM_DOMAIN' value='$proxysettings{'NTLM_DOMAIN'}'></td>
+<td><input type='hidden' name='NTLM_PDC' value='$proxysettings{'NTLM_PDC'}'></td>
+<td><input type='hidden' name='NTLM_BDC' value='$proxysettings{'NTLM_BDC'}'></td>
+<td><input type='hidden' name='NTLM_ENABLE_INT_AUTH' value='$proxysettings{'NTLM_ENABLE_INT_AUTH'}'></td>
+<td><input type='hidden' name='NTLM_ENABLE_ACL' value='$proxysettings{'NTLM_ENABLE_ACL'}'></td>
+<td><input type='hidden' name='NTLM_USER_ACL' value='$proxysettings{'NTLM_USER_ACL'}'></td>
+<td><input type='hidden' name='NTLM_ALLOW_USERS' value='$proxysettings{'NTLM_ALLOW_USERS'}'></td>
+<td><input type='hidden' name='NTLM_DENY_USERS' value='$proxysettings{'NTLM_DENY_USERS'}'></td>
+END
+; }
+
+if (!($proxysettings{'AUTH_METHOD'} eq 'radius')) {
+print <<END
+<td><input type='hidden' name='RADIUS_SERVER' value='$proxysettings{'RADIUS_SERVER'}'></td>
+<td><input type='hidden' name='RADIUS_PORT' value='$proxysettings{'RADIUS_PORT'}'></td>
+<td><input type='hidden' name='RADIUS_IDENTIFIER' value='$proxysettings{'RADIUS_IDENTIFIER'}'></td>
+<td><input type='hidden' name='RADIUS_SECRET' value='$proxysettings{'RADIUS_SECRET'}'></td>
+<td><input type='hidden' name='RADIUS_ENABLE_ACL' value='$proxysettings{'RADIUS_ENABLE_ACL'}'></td>
+<td><input type='hidden' name='RADIUS_USER_ACL' value='$proxysettings{'RADIUS_USER_ACL'}'></td>
+<td><input type='hidden' name='RADIUS_ALLOW_USERS' value='$proxysettings{'RADIUS_ALLOW_USERS'}'></td>
+<td><input type='hidden' name='RADIUS_DENY_USERS' value='$proxysettings{'RADIUS_DENY_USERS'}'></td>
+END
+; }
+
+print "</table>\n";
+
+print <<END
+<hr size='1'>
+END
+;
+
+print <<END
+<table width='100%'>
+<tr>
+ <td> </td>
+ <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
+ <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'advproxy save and restart'}' /></td>
+ <td align='center'><input type='submit' name='ACTION' value='$Lang::tr{'clear cache'}' /></td>
+ <td> </td>
+</tr>
+
+</table>
+<br />
+<table width='100%'>
+<tr>
+ <td><img src='/blob.gif' align='top' alt='*' />
+ <font class='base'>$Lang::tr{'this field may be blank'}</font>
+ </td>
+ <td align='right'>
+ <sup><small><a href='http://www.advproxy.net' target='_blank'>Advanced Proxy $advproxyversion</a></small></sup>
+ </td>
+</tr>
+</table>
+</form>
+END
+;
+
+&Header::closebox();
+
+} else {
+
+# ===================================================================
+# NCSA user management
+# ===================================================================
+
+&Header::openbox('100%', 'left', "$Lang::tr{'advproxy NCSA auth'}");
+print <<END
+<form method='post' action='$ENV{'SCRIPT_NAME'}'>
+<table width='100%'>
+<tr>
+ <td colspan='4'><b>$Lang::tr{'advproxy NCSA user management'}</b></td>
+</tr>
+<tr>
+ <td width='25%' class='base'>$Lang::tr{'advproxy NCSA username'}:</td>
+ <td width='25%'><input type='text' name='NCSA_USERNAME' value='$proxysettings{'NCSA_USERNAME'}' size='12'
+END
+;
+ if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) { print " readonly "; }
+ print <<END
+ /></td>
+ <td width='25%' class='base'>$Lang::tr{'advproxy NCSA group'}:</td>
+ <td class='base'>
+ <select name='NCSA_GROUP'>
+ <option value='standard' $selected{'NCSA_GROUP'}{'standard'}>$Lang::tr{'advproxy NCSA grp standard'}</option>
+ <option value='extended' $selected{'NCSA_GROUP'}{'extended'}>$Lang::tr{'advproxy NCSA grp extended'}</option>
+ <option value='disabled' $selected{'NCSA_GROUP'}{'disabled'}>$Lang::tr{'advproxy NCSA grp disabled'}</option>
+ </select>
+ </td>
+
+</tr>
+<tr>
+ <td class='base'>$Lang::tr{'advproxy NCSA password'}:</td>
+ <td><input type='password' name='NCSA_PASS' value='$proxysettings{'NCSA_PASS'}' size='14' /></td>
+ <td class='base'>$Lang::tr{'advproxy NCSA password confirm'}:</td>
+ <td><input type='password' name='NCSA_PASS_CONFIRM' value='$proxysettings{'NCSA_PASS_CONFIRM'}' size='14' /></td>
+</tr>
+</table>
+<br>
+<table>
+<tr>
+ <td> </td>
+ <td><input type='submit' name='SUBMIT' value='$ncsa_buttontext' /></td>
+ <td><input type='hidden' name='ACTION' value='$Lang::tr{'add'}' /></td>
+ <td><input type='hidden' name='NCSA_MIN_PASS_LEN' value='$proxysettings{'NCSA_MIN_PASS_LEN'}'></td>
+END
+;
+ if ($proxysettings{'ACTION'} eq $Lang::tr{'edit'}) {
+ print "<td><input type='reset' name='ACTION' value='$Lang::tr{'advproxy reset'}' /></td>\n";
+ }
+
+print <<END
+ <td> </td>
+ <td> </td>
+ <td><input type='button' name='return2main' value='$Lang::tr{'advproxy back to main page'}' onClick='self.location.href="$ENV{'SCRIPT_NAME'}"'></td>
+</tr>
+</table>
+</form>
+<hr size='1'>
+<table width='100%'>
+<tr>
+ <td><b>$Lang::tr{'advproxy NCSA user accounts'}:</b></td>
+</tr>
+</table>
+<table width='100%' align='center'>
+END
+;
+
+if (-e $extgrp)
+{
+ open(FILE, $extgrp); @grouplist = <FILE>; close(FILE);
+ foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":extended"); }
+}
+if (-e $stdgrp)
+{
+ open(FILE, $stdgrp); @grouplist = <FILE>; close(FILE);
+ foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":standard"); }
+}
+if (-e $disgrp)
+{
+ open(FILE, $disgrp); @grouplist = <FILE>; close(FILE);
+ foreach $user (@grouplist) { chomp($user); push(@userlist,$user.":disabled"); }
+}
+
+@userlist = sort(@userlist);
+
+# If the password file contains entries, print entries and action icons
+
+if (! -z "$userdb") {
+ print <<END
+ <tr>
+ <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA username'}</i></b></td>
+ <td width='30%' class='boldbase' align='center'><b><i>$Lang::tr{'advproxy NCSA group membership'}</i></b></td>
+ <td class='boldbase' colspan='2' align='center'> </td>
+ </tr>
+END
+;
+ $id = 0;
+ foreach $line (@userlist)
+ {
+ $id++;
+ chomp($line);
+ @temp = split(/:/,$line);
+ if($proxysettings{'ACTION'} eq $Lang::tr{'edit'} && $proxysettings{'ID'} eq $line) {
+ print "<tr bgcolor='$Header::colouryellow'>\n"; }
+ elsif ($id % 2) {
+ print "<tr bgcolor='$Header::table1colour'>\n"; }
+ else {
+ print "<tr bgcolor='$Header::table2colour'>\n"; }
+
+ print <<END
+ <td align='center'>$temp[0]</td>
+ <td align='center'>
+END
+;
+ if ($temp[1] eq 'standard') {
+ print $Lang::tr{'advproxy NCSA grp standard'};
+ } elsif ($temp[1] eq 'extended') {
+ print $Lang::tr{'advproxy NCSA grp extended'};
+ } elsif ($temp[1] eq 'disabled') {
+ print $Lang::tr{'advproxy NCSA grp disabled'}; }
+ print <<END
+ </td>
+ <td width='8%' align='center'>
+ <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' title='$Lang::tr{'edit'}' alt='$Lang::tr{'edit'}' />
+ <input type='hidden' name='ID' value='$line' />
+ <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
+ </form>
+ </td>
+
+ <td width='8%' align='center'>
+ <form method='post' name='frmb$id' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' title='$Lang::tr{'remove'}' alt='$Lang::tr{'remove'}' />
+ <input type='hidden' name='ID' value='$temp[0]' />
+ <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
+ </form>
+ </td>
+ </tr>
+END
+;
+ }
+
+print <<END
+</table>
+<br>
+<table witdh='100%'>
+<tr>
+ <td class='boldbase'> <b>$Lang::tr{'legend'}:</b></td>
+ <td> <img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
+ <td class='base'>$Lang::tr{'edit'}</td>
+ <td> <img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
+ <td class='base'>$Lang::tr{'remove'}</td>
+</tr>
+END
+;
+} else {
+ print <<END
+ <tr>
+ <td><i>$Lang::tr{'advproxy NCSA no accounts'}</i></td>
+ </tr>
+END
+;
+}
+
+print <<END
+</table>
+END
+;
+
+&Header::closebox();
+
+}
+
+# ===================================================================
+
+&Header::closebigbox();
+
+&Header::closepage();
+
+# -------------------------------------------------------------------
+
+sub read_acls
+{
+ if (-e "$acl_src_subnets") {
+ open(FILE,"$acl_src_subnets");
+ delete $proxysettings{'SRC_SUBNETS'};
+ while (<FILE>) { $proxysettings{'SRC_SUBNETS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$acl_src_banned_ip") {
+ open(FILE,"$acl_src_banned_ip");
+ delete $proxysettings{'SRC_BANNED_IP'};
+ while (<FILE>) { $proxysettings{'SRC_BANNED_IP'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$acl_src_banned_mac") {
+ open(FILE,"$acl_src_banned_mac");
+ delete $proxysettings{'SRC_BANNED_MAC'};
+ while (<FILE>) { $proxysettings{'SRC_BANNED_MAC'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$acl_src_unrestricted_ip") {
+ open(FILE,"$acl_src_unrestricted_ip");
+ delete $proxysettings{'SRC_UNRESTRICTED_IP'};
+ while (<FILE>) { $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$acl_src_unrestricted_mac") {
+ open(FILE,"$acl_src_unrestricted_mac");
+ delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
+ while (<FILE>) { $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$acl_dst_nocache") {
+ open(FILE,"$acl_dst_nocache");
+ delete $proxysettings{'DST_NOCACHE'};
+ while (<FILE>) { $proxysettings{'DST_NOCACHE'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$acl_dst_noauth") {
+ open(FILE,"$acl_dst_noauth");
+ delete $proxysettings{'DST_NOAUTH'};
+ while (<FILE>) { $proxysettings{'DST_NOAUTH'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$mimetypes") {
+ open(FILE,"$mimetypes");
+ delete $proxysettings{'MIME_TYPES'};
+ while (<FILE>) { $proxysettings{'MIME_TYPES'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$ntlmdir/msntauth.allowusers") {
+ open(FILE,"$ntlmdir/msntauth.allowusers");
+ delete $proxysettings{'NTLM_ALLOW_USERS'};
+ while (<FILE>) { $proxysettings{'NTLM_ALLOW_USERS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$ntlmdir/msntauth.denyusers") {
+ open(FILE,"$ntlmdir/msntauth.denyusers");
+ delete $proxysettings{'NTLM_DENY_USERS'};
+ while (<FILE>) { $proxysettings{'NTLM_DENY_USERS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$raddir/radauth.allowusers") {
+ open(FILE,"$raddir/radauth.allowusers");
+ delete $proxysettings{'RADIUS_ALLOW_USERS'};
+ while (<FILE>) { $proxysettings{'RADIUS_ALLOW_USERS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$raddir/radauth.denyusers") {
+ open(FILE,"$raddir/radauth.denyusers");
+ delete $proxysettings{'RADIUS_DENY_USERS'};
+ while (<FILE>) { $proxysettings{'RADIUS_DENY_USERS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$identdir/identauth.allowusers") {
+ open(FILE,"$identdir/identauth.allowusers");
+ delete $proxysettings{'IDENT_ALLOW_USERS'};
+ while (<FILE>) { $proxysettings{'IDENT_ALLOW_USERS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$identdir/identauth.denyusers") {
+ open(FILE,"$identdir/identauth.denyusers");
+ delete $proxysettings{'IDENT_DENY_USERS'};
+ while (<FILE>) { $proxysettings{'IDENT_DENY_USERS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$identhosts") {
+ open(FILE,"$identhosts");
+ delete $proxysettings{'IDENT_HOSTS'};
+ while (<FILE>) { $proxysettings{'IDENT_HOSTS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$cre_groups") {
+ open(FILE,"$cre_groups");
+ delete $proxysettings{'CRE_GROUPS'};
+ while (<FILE>) { $proxysettings{'CRE_GROUPS'} .= $_ };
+ close(FILE);
+ }
+ if (-e "$cre_svhosts") {
+ open(FILE,"$cre_svhosts");
+ delete $proxysettings{'CRE_SVHOSTS'};
+ while (<FILE>) { $proxysettings{'CRE_SVHOSTS'} .= $_ };
+ close(FILE);
+ }
+}
+
+# -------------------------------------------------------------------
+
+sub check_acls
+{
+ @temp = split(/\n/,$proxysettings{'SRC_SUBNETS'});
+ undef $proxysettings{'SRC_SUBNETS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_)
+ {
+ unless (&General::validipandmask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
+ $proxysettings{'SRC_SUBNETS'} .= $_."\n";
+ }
+ }
+
+ @temp = split(/\n/,$proxysettings{'SRC_BANNED_IP'});
+ undef $proxysettings{'SRC_BANNED_IP'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_)
+ {
+ unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
+ $proxysettings{'SRC_BANNED_IP'} .= $_."\n";
+ }
+ }
+
+ @temp = split(/\n/,$proxysettings{'SRC_BANNED_MAC'});
+ undef $proxysettings{'SRC_BANNED_MAC'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g; s/-/:/g;
+ if ($_)
+ {
+ unless (&General::validmac($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid mac'}; }
+ $proxysettings{'SRC_BANNED_MAC'} .= $_."\n";
+ }
+ }
+
+ @temp = split(/\n/,$proxysettings{'SRC_UNRESTRICTED_IP'});
+ undef $proxysettings{'SRC_UNRESTRICTED_IP'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_)
+ {
+ unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
+ $proxysettings{'SRC_UNRESTRICTED_IP'} .= $_."\n";
+ }
+ }
+
+ @temp = split(/\n/,$proxysettings{'SRC_UNRESTRICTED_MAC'});
+ undef $proxysettings{'SRC_UNRESTRICTED_MAC'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g; s/-/:/g;
+ if ($_)
+ {
+ unless (&General::validmac($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid mac'}; }
+ $proxysettings{'SRC_UNRESTRICTED_MAC'} .= $_."\n";
+ }
+ }
+
+ if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
+ {
+ @temp = split(/\n/,$proxysettings{'NTLM_ALLOW_USERS'});
+ undef $proxysettings{'NTLM_ALLOW_USERS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_) { $proxysettings{'NTLM_ALLOW_USERS'} .= $_."\n"; }
+ }
+ if ($proxysettings{'NTLM_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
+ }
+
+ if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'negative'))
+ {
+ @temp = split(/\n/,$proxysettings{'NTLM_DENY_USERS'});
+ undef $proxysettings{'NTLM_DENY_USERS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_) { $proxysettings{'NTLM_DENY_USERS'} .= $_."\n"; }
+ }
+ if ($proxysettings{'NTLM_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
+ }
+
+ if (($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') && ($proxysettings{'IDENT_USER_ACL'} eq 'positive'))
+ {
+ @temp = split(/\n/,$proxysettings{'IDENT_ALLOW_USERS'});
+ undef $proxysettings{'IDENT_ALLOW_USERS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_) { $proxysettings{'IDENT_ALLOW_USERS'} .= $_."\n"; }
+ }
+ if ($proxysettings{'IDENT_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
+ }
+
+ if (($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') && ($proxysettings{'IDENT_USER_ACL'} eq 'negative'))
+ {
+ @temp = split(/\n/,$proxysettings{'IDENT_DENY_USERS'});
+ undef $proxysettings{'IDENT_DENY_USERS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_) { $proxysettings{'IDENT_DENY_USERS'} .= $_."\n"; }
+ }
+ if ($proxysettings{'IDENT_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
+ }
+
+ if (($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') && ($proxysettings{'RADIUS_USER_ACL'} eq 'positive'))
+ {
+ @temp = split(/\n/,$proxysettings{'RADIUS_ALLOW_USERS'});
+ undef $proxysettings{'RADIUS_ALLOW_USERS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_) { $proxysettings{'RADIUS_ALLOW_USERS'} .= $_."\n"; }
+ }
+ if ($proxysettings{'RADIUS_ALLOW_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
+ }
+
+ if (($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') && ($proxysettings{'RADIUS_USER_ACL'} eq 'negative'))
+ {
+ @temp = split(/\n/,$proxysettings{'RADIUS_DENY_USERS'});
+ undef $proxysettings{'RADIUS_DENY_USERS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_) { $proxysettings{'RADIUS_DENY_USERS'} .= $_."\n"; }
+ }
+ if ($proxysettings{'RADIUS_DENY_USERS'} eq '') { $errormessage = $Lang::tr{'advproxy errmsg acl cannot be empty'}; }
+ }
+
+ @temp = split(/\n/,$proxysettings{'IDENT_HOSTS'});
+ undef $proxysettings{'IDENT_HOSTS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_)
+ {
+ unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
+ $proxysettings{'IDENT_HOSTS'} .= $_."\n";
+ }
+ }
+
+ @temp = split(/\n/,$proxysettings{'CRE_SVHOSTS'});
+ undef $proxysettings{'CRE_SVHOSTS'};
+ foreach (@temp)
+ {
+ s/^\s+//g; s/\s+$//g;
+ if ($_)
+ {
+ unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg invalid ip or mask'}; }
+ $proxysettings{'CRE_SVHOSTS'} .= $_."\n";
+ }
+ }
+}
+
+
+# -------------------------------------------------------------------
+
+sub write_acls
+{
+ open(FILE, ">$acl_src_subnets");
+ flock(FILE, 2);
+ print FILE $proxysettings{'SRC_SUBNETS'};
+ close(FILE);
+
+ open(FILE, ">$acl_src_banned_ip");
+ flock(FILE, 2);
+ print FILE $proxysettings{'SRC_BANNED_IP'};
+ close(FILE);
+
+ open(FILE, ">$acl_src_banned_mac");
+ flock(FILE, 2);
+ print FILE $proxysettings{'SRC_BANNED_MAC'};
+ close(FILE);
+
+ open(FILE, ">$acl_src_unrestricted_ip");
+ flock(FILE, 2);
+ print FILE $proxysettings{'SRC_UNRESTRICTED_IP'};
+ close(FILE);
+
+ open(FILE, ">$acl_src_unrestricted_mac");
+ flock(FILE, 2);
+ print FILE $proxysettings{'SRC_UNRESTRICTED_MAC'};
+ close(FILE);
+
+ open(FILE, ">$acl_dst_nocache");
+ flock(FILE, 2);
+ print FILE $proxysettings{'DST_NOCACHE'};
+ close(FILE);
+
+ open(FILE, ">$acl_dst_noauth");
+ flock(FILE, 2);
+ print FILE $proxysettings{'DST_NOAUTH'};
+ close(FILE);
+
+ open(FILE, ">$acl_dst_throttle");
+ flock(FILE, 2);
+ if ($proxysettings{'THROTTLE_BINARY'} eq 'on')
+ {
+ @temp = split(/\|/,$throttle_binary);
+ foreach (@temp) { print FILE "\\.$_\$\n"; }
+ }
+ if ($proxysettings{'THROTTLE_DSKIMG'} eq 'on')
+ {
+ @temp = split(/\|/,$throttle_dskimg);
+ foreach (@temp) { print FILE "\\.$_\$\n"; }
+ }
+ if ($proxysettings{'THROTTLE_MMEDIA'} eq 'on')
+ {
+ @temp = split(/\|/,$throttle_mmedia);
+ foreach (@temp) { print FILE "\\.$_\$\n"; }
+ }
+ if (-s $throttled_urls)
+ {
+ open(URLFILE, $throttled_urls);
+ @temp = <URLFILE>;
+ close(URLFILE);
+ foreach (@temp) { print FILE; }
+ }
+ close(FILE);
+
+ open(FILE, ">$mimetypes");
+ flock(FILE, 2);
+ print FILE $proxysettings{'MIME_TYPES'};
+ close(FILE);
+
+ open(FILE, ">$ntlmdir/msntauth.allowusers");
+ flock(FILE, 2);
+ print FILE $proxysettings{'NTLM_ALLOW_USERS'};
+ close(FILE);
+
+ open(FILE, ">$ntlmdir/msntauth.denyusers");
+ flock(FILE, 2);
+ print FILE $proxysettings{'NTLM_DENY_USERS'};
+ close(FILE);
+
+ open(FILE, ">$raddir/radauth.allowusers");
+ flock(FILE, 2);
+ print FILE $proxysettings{'RADIUS_ALLOW_USERS'};
+ close(FILE);
+
+ open(FILE, ">$raddir/radauth.denyusers");
+ flock(FILE, 2);
+ print FILE $proxysettings{'RADIUS_DENY_USERS'};
+ close(FILE);
+
+ open(FILE, ">$identdir/identauth.allowusers");
+ flock(FILE, 2);
+ print FILE $proxysettings{'IDENT_ALLOW_USERS'};
+ close(FILE);
+
+ open(FILE, ">$identdir/identauth.denyusers");
+ flock(FILE, 2);
+ print FILE $proxysettings{'IDENT_DENY_USERS'};
+ close(FILE);
+
+ open(FILE, ">$identhosts");
+ flock(FILE, 2);
+ print FILE $proxysettings{'IDENT_HOSTS'};
+ close(FILE);
+
+ open(FILE, ">$cre_groups");
+ flock(FILE, 2);
+ print FILE $proxysettings{'CRE_GROUPS'};
+ close(FILE);
+
+ open(FILE, ">$cre_svhosts");
+ flock(FILE, 2);
+ print FILE $proxysettings{'CRE_SVHOSTS'};
+ close(FILE);
+}
+
+# -------------------------------------------------------------------
+
+sub writepacfile
+{
+ open(FILE, ">/home/httpd/html/proxy.pac");
+ flock(FILE, 2);
+ print FILE "function FindProxyForURL(url, host)\n";
+ print FILE "{\n";
+ if (($proxysettings{'ENABLE'} eq 'on') || ($proxysettings{'ENABLE_BLUE'} eq 'on'))
+ {
+ print FILE <<END
+if (
+ (isPlainHostName(host)) ||
+ (dnsDomainIs(host, ".$mainsettings{'DOMAINNAME'}")) ||
+ (isInNet(host, "10.0.0.0", "255.0.0.0")) ||
+ (isInNet(host, "172.16.0.0", "255.240.0.0")) ||
+ (isInNet(host, "169.254.0.0", "255.255.0.0")) ||
+ (isInNet(host, "192.168.0.0", "255.255.0.0"))
+ )
+ return "DIRECT";
+
+ else
+
+END
+;
+ if ($proxysettings{'ENABLE'} eq 'on')
+ {
+ print FILE <<END
+if (
+ (isInNet(myIpAddress(), "$netsettings{'GREEN_NETADDRESS'}", "$netsettings{'GREEN_NETMASK'}"))
+ )
+ return "PROXY $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
+END
+;
+ }
+ if (($proxysettings{'ENABLE'} eq 'on') && ($proxysettings{'ENABLE_BLUE'} eq 'on') && ($netsettings{'BLUE_DEV'}))
+ {
+ print FILE "\n else\n\n";
+ }
+ if (($netsettings{'BLUE_DEV'}) && ($proxysettings{'ENABLE_BLUE'} eq 'on'))
+ {
+ print FILE <<END
+if (
+ (isInNet(myIpAddress(), "$netsettings{'BLUE_NETADDRESS'}", "$netsettings{'BLUE_NETMASK'}"))
+ )
+ return "PROXY $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}";
+END
+;
+ }
+ }
+ print FILE "}\n";
+ close(FILE);
+}
+
+# -------------------------------------------------------------------
+
+sub writeconfig
+{
+ my $authrealm;
+ my $delaypools;
+
+ if ($proxysettings{'THROTTLING_GREEN_TOTAL'} +
+ $proxysettings{'THROTTLING_GREEN_HOST'} +
+ $proxysettings{'THROTTLING_BLUE_TOTAL'} +
+ $proxysettings{'THROTTLING_BLUE_HOST'} gt 0)
+ {
+ $delaypools = 1; } else { $delaypools = 0;
+ }
+
+ if ($proxysettings{'AUTH_REALM'} eq '')
+ {
+ $authrealm = "IPFire Advanced Proxy Server";
+ } else {
+ $authrealm = $proxysettings{'AUTH_REALM'};
+ }
+
+ $_ = $proxysettings{'UPSTREAM_PROXY'};
+ my ($remotehost, $remoteport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
+
+ if ($remoteport eq '') { $remoteport = 80; }
+
+ open(FILE, ">${General::swroot}/proxy/squid.conf");
+ flock(FILE, 2);
+ print FILE <<END
+shutdown_lifetime 5 seconds
+icp_port 0
+
+http_port $netsettings{'GREEN_ADDRESS'}:$proxysettings{'PROXY_PORT'}
+END
+ ;
+ if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
+ print FILE "http_port $netsettings{'BLUE_ADDRESS'}:$proxysettings{'PROXY_PORT'}\n";
+ }
+
+ print FILE <<END
+
+acl QUERY urlpath_regex cgi-bin \\?
+no_cache deny QUERY
+END
+ ;
+ if (!-z $acl_dst_nocache) {
+ print FILE "acl no_cache_domains dstdomain \"$acl_dst_nocache\"\n";
+ print FILE "no_cache deny no_cache_domains\n";
+ }
+
+ print FILE <<END
+
+cache_effective_user squid
+cache_effective_group squid
+
+pid_filename /var/run/squid.pid
+
+cache_mem $proxysettings{'CACHE_MEM'} MB
+cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DIRS'} 256
+
+error_directory /usr/lib/squid/errors/$proxysettings{'ERR_LANGUAGE'}
+
+END
+ ;
+
+ if ($proxysettings{'OFFLINE_MODE'} eq 'on') { print FILE "offline_mode on\n\n"; }
+
+ if ((!($proxysettings{'MEM_POLICY'} eq 'LRU')) || (!($proxysettings{'CACHE_POLICY'} eq 'LRU')))
+ {
+ if (!($proxysettings{'MEM_POLICY'} eq 'LRU'))
+ {
+ print FILE "memory_replacement_policy $proxysettings{'MEM_POLICY'}\n";
+ }
+ if (!($proxysettings{'CACHE_POLICY'} eq 'LRU'))
+ {
+ print FILE "cache_replacement_policy $proxysettings{'CACHE_POLICY'}\n";
+ }
+ print FILE "\n";
+ }
+
+ if ($proxysettings{'LOGGING'} eq 'on')
+ {
+ print FILE <<END
+cache_access_log /var/log/squid/access.log
+cache_log /var/log/squid/cache.log
+cache_store_log none
+END
+ ;
+ if ($proxysettings{'LOGUSERAGENT'} eq 'on') { print FILE "useragent_log \/var\/log\/squid\/user_agent.log\n"; }
+ if ($proxysettings{'LOGQUERY'} eq 'on') { print FILE "\nstrip_query_terms off\n"; }
+ } else {
+ print FILE <<END
+cache_access_log /dev/null
+cache_log /dev/null
+cache_store_log none
+END
+ ;}
+ print FILE <<END
+
+log_mime_hdrs off
+END
+ ;
+
+ if ($proxysettings{'FORWARD_IPADDRESS'} eq 'on')
+ {
+ print FILE "forwarded_for on\n\n";
+ } else {
+ print FILE "forwarded_for off\n\n";
+ }
+
+ if ((!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident')))
+ {
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ print FILE "auth_param basic program $libexecdir/ncsa_auth $userdb\n";
+ print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
+ print FILE "auth_param basic realm $authrealm\n";
+ print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
+ if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
+ }
+
+ if ($proxysettings{'AUTH_METHOD'} eq 'ldap')
+ {
+ print FILE "auth_param basic program $libexecdir/squid_ldap_auth -b \"$proxysettings{'LDAP_BASEDN'}\"";
+ if (!($proxysettings{'LDAP_BINDDN_USER'} eq '')) { print FILE " -D \"$proxysettings{'LDAP_BINDDN_USER'}\""; }
+ if (!($proxysettings{'LDAP_BINDDN_PASS'} eq '')) { print FILE " -w $proxysettings{'LDAP_BINDDN_PASS'}"; }
+ if ($proxysettings{'LDAP_TYPE'} eq 'ADS')
+ {
+ if ($proxysettings{'LDAP_GROUP'} eq '')
+ {
+ print FILE " -f \"(\&(objectClass=person)(sAMAccountName=\%s))\"";
+ } else {
+ print FILE " -f \"(\&(\&(objectClass=person)(sAMAccountName=\%s))(memberOf=$proxysettings{'LDAP_GROUP'}))\"";
+ }
+ print FILE " -u sAMAccountName -P";
+ }
+ if ($proxysettings{'LDAP_TYPE'} eq 'NDS')
+ {
+ if ($proxysettings{'LDAP_GROUP'} eq '')
+ {
+ print FILE " -f \"(\&(objectClass=person)(cn=\%s))\"";
+ } else {
+ print FILE " -f \"(\&(\&(objectClass=person)(cn=\%s))(groupMembership=$proxysettings{'LDAP_GROUP'}))\"";
+ }
+ print FILE " -u cn -P";
+ }
+ if (($proxysettings{'LDAP_TYPE'} eq 'V2') || ($proxysettings{'LDAP_TYPE'} eq 'V3'))
+ {
+ if ($proxysettings{'LDAP_GROUP'} eq '')
+ {
+ print FILE " -f \"(\&(objectClass=person)(uid=\%s))\"";
+ } else {
+ print FILE " -f \"(\&(\&(objectClass=person)(uid=\%s))(memberOf=$proxysettings{'LDAP_GROUP'}))\"";
+ }
+ if ($proxysettings{'LDAP_TYPE'} eq 'V2') { print FILE " -v 2"; }
+ if ($proxysettings{'LDAP_TYPE'} eq 'V3') { print FILE " -v 3"; }
+ print FILE " -u uid -P";
+ }
+ print FILE " $proxysettings{'LDAP_SERVER'}:$proxysettings{'LDAP_PORT'}\n";
+ print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
+ print FILE "auth_param basic realm $authrealm\n";
+ print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
+ if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
+ }
+
+ if ($proxysettings{'AUTH_METHOD'} eq 'ntlm')
+ {
+ if ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on')
+ {
+ print FILE "auth_param ntlm program $libexecdir/ntlm_auth $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_PDC'}";
+ if ($proxysettings{'NTLM_BDC'} eq '') { print FILE "\n"; } else { print FILE " $proxysettings{'NTLM_DOMAIN'}/$proxysettings{'NTLM_BDC'}\n"; }
+ print FILE "auth_param ntlm children $proxysettings{'AUTH_CHILDREN'}\n";
+ print FILE "auth_param ntlm max_challenge_reuses 0\n";
+ print FILE "auth_param ntlm max_challenge_lifetime 2 minutes\n";
+ if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
+ } else {
+ print FILE "auth_param basic program $libexecdir/msnt_auth\n";
+ print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
+ print FILE "auth_param basic realm $authrealm\n";
+ print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
+ if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
+
+ open(MSNTCONF, ">$ntlmdir/msntauth.conf");
+ flock(MSNTCONF,2);
+ print MSNTCONF "server $proxysettings{'NTLM_PDC'}";
+ if ($proxysettings{'NTLM_BDC'} eq '') { print MSNTCONF " $proxysettings{'NTLM_PDC'}"; } else { print MSNTCONF " $proxysettings{'NTLM_BDC'}"; }
+ print MSNTCONF " $proxysettings{'NTLM_DOMAIN'}\n";
+ if ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on')
+ {
+ if ($proxysettings{'NTLM_USER_ACL'} eq 'positive')
+ {
+ print MSNTCONF "allowusers $ntlmdir/msntauth.allowusers\n";
+ } else {
+ print MSNTCONF "denyusers $ntlmdir/msntauth.denyusers\n";
+ }
+ }
+ close(MSNTCONF);
+ }
+ }
+
+ if ($proxysettings{'AUTH_METHOD'} eq 'radius')
+ {
+ print FILE "auth_param basic program $libexecdir/squid_rad_auth -h $proxysettings{'RADIUS_SERVER'} -p $proxysettings{'RADIUS_PORT'} ";
+ if (!($proxysettings{'RADIUS_IDENTIFIER'} eq '')) { print FILE "-i $proxysettings{'RADIUS_IDENTIFIER'} "; }
+ print FILE "-w $proxysettings{'RADIUS_SECRET'}\n";
+ print FILE "auth_param basic children $proxysettings{'AUTH_CHILDREN'}\n";
+ print FILE "auth_param basic realm $authrealm\n";
+ print FILE "auth_param basic credentialsttl $proxysettings{'AUTH_CACHE_TTL'} minutes\n";
+ if (!($proxysettings{'AUTH_IPCACHE_TTL'} eq '0')) { print FILE "\nauthenticate_ip_ttl $proxysettings{'AUTH_IPCACHE_TTL'} minutes\n"; }
+ }
+
+ print FILE "\n";
+ print FILE "acl for_inetusers proxy_auth REQUIRED\n";
+ if (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on') && ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on'))
+ {
+ if ((!-z "$ntlmdir/msntauth.allowusers") && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
+ {
+ print FILE "acl for_acl_users proxy_auth \"$ntlmdir/msntauth.allowusers\"\n";
+ }
+ if ((!-z "$ntlmdir/msntauth.denyusers") && ($proxysettings{'NTLM_USER_ACL'} eq 'negative'))
+ {
+ print FILE "acl for_acl_users proxy_auth \"$ntlmdir/msntauth.denyusers\"\n";
+ }
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
+ {
+ if ((!-z "$raddir/radauth.allowusers") && ($proxysettings{'RADIUS_USER_ACL'} eq 'positive'))
+ {
+ print FILE "acl for_acl_users proxy_auth \"$raddir/radauth.allowusers\"\n";
+ }
+ if ((!-z "$raddir/radauth.denyusers") && ($proxysettings{'RADIUS_USER_ACL'} eq 'negative'))
+ {
+ print FILE "acl for_acl_users proxy_auth \"$raddir/radauth.denyusers\"\n";
+ }
+ }
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ print FILE "\n";
+ if (!-z $extgrp) { print FILE "acl for_extended_users proxy_auth \"$extgrp\"\n"; }
+ if (!-z $disgrp) { print FILE "acl for_disabled_users proxy_auth \"$disgrp\"\n"; }
+ }
+ if (!($proxysettings{'AUTH_MAX_USERIP'} eq '')) { print FILE "\nacl concurrent max_user_ip -s $proxysettings{'AUTH_MAX_USERIP'}\n"; }
+ print FILE "\n";
+
+ if (!-z $acl_dst_noauth) { print FILE "acl to_domains_without_auth dstdomain \"$acl_dst_noauth\"\n\n"; }
+ }
+
+ if ($proxysettings{'AUTH_METHOD'} eq 'ident')
+ {
+ if ($proxysettings{'IDENT_REQUIRED'} eq 'on')
+ {
+ print FILE "acl for_inetusers ident REQUIRED\n";
+ }
+ if ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on')
+ {
+ if ((!-z "$identdir/identauth.allowusers") && ($proxysettings{'IDENT_USER_ACL'} eq 'positive'))
+ {
+ print FILE "acl for_acl_users ident_regex -i \"$identdir/identauth.allowusers\"\n\n";
+ }
+ if ((!-z "$identdir/identauth.denyusers") && ($proxysettings{'IDENT_USER_ACL'} eq 'negative'))
+ {
+ print FILE "acl for_acl_users ident_regex -i \"$identdir/identauth.denyusers\"\n\n";
+ }
+ }
+ }
+
+ if (($delaypools) && (!-z $acl_dst_throttle)) { print FILE "acl for_throttled_urls url_regex -i \"$acl_dst_throttle\"\n\n"; }
+
+ if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE "acl with_allowed_useragents browser $browser_regexp\n\n"; }
+
+ print FILE "acl within_timeframe time ";
+ if ($proxysettings{'TIME_MON'} eq 'on') { print FILE "M"; }
+ if ($proxysettings{'TIME_TUE'} eq 'on') { print FILE "T"; }
+ if ($proxysettings{'TIME_WED'} eq 'on') { print FILE "W"; }
+ if ($proxysettings{'TIME_THU'} eq 'on') { print FILE "H"; }
+ if ($proxysettings{'TIME_FRI'} eq 'on') { print FILE "F"; }
+ if ($proxysettings{'TIME_SAT'} eq 'on') { print FILE "A"; }
+ if ($proxysettings{'TIME_SUN'} eq 'on') { print FILE "S"; }
+ print FILE " $proxysettings{'TIME_FROM_HOUR'}:";
+ print FILE "$proxysettings{'TIME_FROM_MINUTE'}-";
+ print FILE "$proxysettings{'TIME_TO_HOUR'}:";
+ print FILE "$proxysettings{'TIME_TO_MINUTE'}\n\n";
+
+ if ((!-z $mimetypes) && ($proxysettings{'ENABLE_MIME_FILTER'} eq 'on')) {
+ print FILE "acl blocked_mimetypes rep_mime_type \"$mimetypes\"\n\n";
+ }
+
+ print FILE <<END
+acl all src 0.0.0.0/0.0.0.0
+acl localhost src 127.0.0.1/255.255.255.255
+acl SSL_ports port 443 563
+acl Safe_ports port 80 # http
+acl Safe_ports port 21 # ftp
+acl Safe_ports port 443 563 # https, snews
+acl Safe_ports port 70 # gopher
+acl Safe_ports port 210 # wais
+acl Safe_ports port 1025-65535 # unregistered ports
+acl Safe_ports port 280 # http-mgmt
+acl Safe_ports port 488 # gss-http
+acl Safe_ports port 591 # filemaker
+acl Safe_ports port 777 # multiling http
+acl Safe_ports port 800 # Squids port (for icons)
+
+acl IPCop_http port 81
+acl IPCop_https port 445
+acl IPCop_ips dst $netsettings{'GREEN_ADDRESS'}
+acl IPCop_networks src "$acl_src_subnets"
+acl IPCop_green_network src $netsettings{'GREEN_NETADDRESS'}/$netsettings{'GREEN_NETMASK'}
+END
+ ;
+ if ($netsettings{'BLUE_DEV'}) { print FILE "acl IPCop_blue_network src $netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}\n"; }
+ if (!-z $acl_src_banned_ip) { print FILE "acl IPCop_banned_ips src \"$acl_src_banned_ip\"\n"; }
+ if (!-z $acl_src_banned_mac) { print FILE "acl IPCop_banned_mac arp \"$acl_src_banned_mac\"\n"; }
+ if (!-z $acl_src_unrestricted_ip) { print FILE "acl IPCop_unrestricted_ips src \"$acl_src_unrestricted_ip\"\n"; }
+ if (!-z $acl_src_unrestricted_mac) { print FILE "acl IPCop_unrestricted_mac arp \"$acl_src_unrestricted_mac\"\n"; }
+ print FILE <<END
+acl CONNECT method CONNECT
+END
+ ;
+
+ if ($proxysettings{'CLASSROOM_EXT'} eq 'on') {
+ print FILE <<END
+
+#Classroom extensions
+acl IPCop_no_access_ips src "$acl_src_noaccess_ip"
+acl IPCop_no_access_mac arp "$acl_src_noaccess_mac"
+END
+ ;
+ print FILE "deny_info ";
+ if (-e "/usr/lib/squid/errors/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED") {
+ print FILE "ERR_ACCESS_DISABLED";
+ } else { print FILE "ERR_ACCESS_DENIED"; }
+ print FILE " IPCop_no_access_ips\n";
+ print FILE "deny_info ";
+ if (-e "/usr/lib/squid/errors/$proxysettings{'ERR_LANGUAGE'}/ERR_ACCESS_DISABLED") {
+ print FILE "ERR_ACCESS_DISABLED";
+ } else { print FILE "ERR_ACCESS_DENIED"; }
+ print FILE " IPCop_no_access_mac\n";
+
+ print FILE <<END
+http_access deny IPCop_no_access_ips
+http_access deny IPCop_no_access_mac
+END
+ ;
+ }
+
+ #Insert acl file and replace __VAR__ with correct values
+ my $blue_net = ''; #BLUE empty by default
+ my $blue_ip = '';
+ if ($netsettings{'BLUE_DEV'} && $proxysettings{'ENABLE_BLUE'} eq 'on') {
+ $blue_net = "$netsettings{'BLUE_NETADDRESS'}/$netsettings{'BLUE_NETMASK'}";
+ $blue_ip = "$netsettings{'BLUE_ADDRESS'}";
+ }
+ if (!-z $acl_include)
+ {
+ open (ACL, "$acl_include");
+ print FILE "\n#Start of custom includes\n";
+ while (<ACL>) {
+ $_ =~ s/__GREEN_IP__/$netsettings{'GREEN_ADDRESS'}/;
+ $_ =~ s/__GREEN_NET__/$netsettings{'GREEN_NETADDRESS'}\/$netsettings{'GREEN_NETMASK'}/;
+ $_ =~ s/__BLUE_IP__/$blue_ip/;
+ $_ =~ s/__BLUE_NET__/$blue_net/;
+ print FILE $_;
+ }
+ print FILE "#End of custom includes\n";
+ close (ACL);
+ }
+ if ((!-z $extgrp) && ($proxysettings{'AUTH_METHOD'} eq 'ncsa') && ($proxysettings{'NCSA_BYPASS_REDIR'} eq 'on')) { print FILE "\nredirector_access deny for_extended_users\n"; }
+ print FILE <<END
+
+#Access to squid:
+#local machine, no restriction
+http_access allow localhost
+
+#GUI admin if local machine connects
+http_access allow IPCop_ips IPCop_networks IPCop_http
+http_access allow CONNECT IPCop_ips IPCop_networks IPCop_https
+
+#Deny not web services
+http_access deny !Safe_ports
+http_access deny CONNECT !SSL_ports
+
+END
+ ;
+
+if ($proxysettings{'AUTH_METHOD'} eq 'ident')
+{
+print FILE "#Set ident ACLs\n";
+if (!-z $identhosts)
+ {
+ print FILE "acl on_ident_aware_hosts src \"$identhosts\"\n";
+ print FILE "ident_lookup_access allow on_ident_aware_hosts\n";
+ print FILE "ident_lookup_access deny all\n";
+ } else {
+ print FILE "ident_lookup_access allow all\n";
+ }
+ print FILE "ident_timeout $proxysettings{'IDENT_TIMEOUT'} seconds\n\n";
+}
+
+if ($delaypools) {
+ print FILE "#Set download throttling\n";
+
+ if ($netsettings{'BLUE_DEV'})
+ {
+ print FILE "delay_pools 2\n";
+ } else {
+ print FILE "delay_pools 1\n";
+ }
+
+ print FILE "delay_class 1 3\n";
+ if ($netsettings{'BLUE_DEV'}) { print FILE "delay_class 2 3\n"; }
+
+ print FILE "delay_parameters 1 ";
+ if ($proxysettings{'THROTTLING_GREEN_TOTAL'} eq 'unlimited')
+ {
+ print FILE "-1/-1";
+ } else {
+ print FILE $proxysettings{'THROTTLING_GREEN_TOTAL'} * 125;
+ print FILE "/";
+ print FILE $proxysettings{'THROTTLING_GREEN_TOTAL'} * 250;
+ }
+
+ print FILE " -1/-1 ";
+ if ($proxysettings{'THROTTLING_GREEN_HOST'} eq 'unlimited')
+ {
+ print FILE "-1/-1";
+ } else {
+ print FILE $proxysettings{'THROTTLING_GREEN_HOST'} * 125;
+ print FILE "/";
+ print FILE $proxysettings{'THROTTLING_GREEN_HOST'} * 250;
+ }
+ print FILE "\n";
+
+ if ($netsettings{'BLUE_DEV'})
+ {
+ print FILE "delay_parameters 2 ";
+ if ($proxysettings{'THROTTLING_BLUE_TOTAL'} eq 'unlimited')
+ {
+ print FILE "-1/-1";
+ } else {
+ print FILE $proxysettings{'THROTTLING_BLUE_TOTAL'} * 125;
+ print FILE "/";
+ print FILE $proxysettings{'THROTTLING_BLUE_TOTAL'} * 250;
+ }
+ print FILE " -1/-1 ";
+ if ($proxysettings{'THROTTLING_BLUE_HOST'} eq 'unlimited')
+ {
+ print FILE "-1/-1";
+ } else {
+ print FILE $proxysettings{'THROTTLING_BLUE_HOST'} * 125;
+ print FILE "/";
+ print FILE $proxysettings{'THROTTLING_BLUE_HOST'} * 250;
+ }
+ print FILE "\n";
+ }
+
+ if (!-z $acl_src_unrestricted_ip) { print FILE "delay_access 1 deny IPCop_unrestricted_ips\n"; }
+ if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 1 deny IPCop_unrestricted_mac\n"; }
+ if (($proxysettings{'AUTH_METHOD'} eq 'ncsa') && (!-z $extgrp)) { print FILE "delay_access 1 deny for_extended_users\n"; }
+
+ if ($netsettings{'BLUE_DEV'})
+ {
+ print FILE "delay_access 1 allow IPCop_green_network";
+ if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
+ print FILE "\n";
+ print FILE "delay_access 1 deny all\n";
+ } else {
+ print FILE "delay_access 1 allow all";
+ if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
+ print FILE "\n";
+ }
+
+ if ($netsettings{'BLUE_DEV'})
+ {
+ if (!-z $acl_src_unrestricted_ip) { print FILE "delay_access 2 deny IPCop_unrestricted_ips\n"; }
+ if (!-z $acl_src_unrestricted_mac) { print FILE "delay_access 2 deny IPCop_unrestricted_mac\n"; }
+ if (($proxysettings{'AUTH_METHOD'} eq 'ncsa') && (!-z $extgrp)) { print FILE "delay_access 2 deny for_extended_users\n"; }
+ print FILE "delay_access 2 allow IPCop_blue_network";
+ if (!-z $acl_dst_throttle) { print FILE " for_throttled_urls"; }
+ print FILE "\n";
+ print FILE "delay_access 2 deny all\n";
+ }
+
+ print FILE "delay_initial_bucket_level 100%\n";
+ print FILE "\n";
+}
+ print FILE <<END
+#Set custom configured ACLs
+END
+ ;
+ if (!-z $acl_src_banned_ip) { print FILE "http_access deny IPCop_banned_ips\n"; }
+ if (!-z $acl_src_banned_mac) { print FILE "http_access deny IPCop_banned_mac\n"; }
+
+ if ((!-z $acl_dst_noauth) && (!($proxysettings{'AUTH_METHOD'} eq 'none')))
+ {
+ if (!-z $acl_src_unrestricted_ip)
+ {
+ print FILE "http_access allow IPCop_unrestricted_ips to_domains_without_auth\n";
+ }
+ if (!-z $acl_src_unrestricted_mac)
+ {
+ print FILE "http_access allow IPCop_unrestricted_mac to_domains_without_auth\n";
+ }
+ print FILE "http_access allow IPCop_networks";
+ if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
+ print FILE " !within_timeframe";
+ } else {
+ print FILE " within_timeframe"; }
+ if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
+ print FILE " to_domains_without_auth\n";
+ }
+
+ if (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on') && ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on'))
+ {
+ print FILE "http_access deny !for_inetusers";
+ if (!-z $identhosts) { print FILE " on_ident_aware_hosts"; }
+ print FILE "\n";
+ }
+
+ if (
+ ($proxysettings{'AUTH_METHOD'} eq 'ident') &&
+ ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on') &&
+ ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'IDENT_USER_ACL'} eq 'negative') &&
+ (!-z "$identdir/identauth.denyusers")
+ )
+ {
+ print FILE "http_access deny for_acl_users";
+ if (($proxysettings{'AUTH_METHOD'} eq 'ident') && (!-z "$identdir/hosts")) { print FILE " on_ident_aware_hosts"; }
+ print FILE "\n";
+ }
+
+ if (!-z $acl_src_unrestricted_ip)
+ {
+ print FILE "http_access allow IPCop_unrestricted_ips";
+ if ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on')
+ {
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ if (!-z $disgrp) { print FILE " !for_disabled_users"; } else { print FILE " for_inetusers"; }
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'ldap') || (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'off')) || ($proxysettings{'AUTH_METHOD'} eq 'radius'))
+ {
+ print FILE " for_inetusers";
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on'))
+ {
+ if ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on')
+ {
+ if (($proxysettings{'NTLM_USER_ACL'} eq 'positive') && (!-z "$ntlmdir/msntauth.allowusers"))
+ {
+ print FILE " for_acl_users";
+ }
+ if (($proxysettings{'NTLM_USER_ACL'} eq 'negative') && (!-z "$ntlmdir/msntauth.denyusers"))
+ {
+ print FILE " !for_acl_users";
+ }
+ } else { print FILE " for_inetusers"; }
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
+ {
+ if ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on')
+ {
+ if (($proxysettings{'RADIUS_USER_ACL'} eq 'positive') && (!-z "$raddir/radauth.allowusers"))
+ {
+ print FILE " for_acl_users";
+ }
+ if (($proxysettings{'RADIUS_USER_ACL'} eq 'negative') && (!-z "$raddir/radauth.denyusers"))
+ {
+ print FILE " !for_acl_users";
+ }
+ } else { print FILE " for_inetusers"; }
+ }
+ }
+ print FILE "\n";
+ }
+
+ if (!-z $acl_src_unrestricted_mac)
+ {
+ print FILE "http_access allow IPCop_unrestricted_mac";
+ if ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'on')
+ {
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ if (!-z $disgrp) { print FILE " !for_disabled_users"; } else { print FILE " for_inetusers"; }
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'ldap') || (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'off')) || ($proxysettings{'AUTH_METHOD'} eq 'radius'))
+ {
+ print FILE " for_inetusers";
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'ntlm') && ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on'))
+ {
+ if ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on')
+ {
+ if (($proxysettings{'NTLM_USER_ACL'} eq 'positive') && (!-z "$ntlmdir/msntauth.allowusers"))
+ {
+ print FILE " for_acl_users";
+ }
+ if (($proxysettings{'NTLM_USER_ACL'} eq 'negative') && (!-z "$ntlmdir/msntauth.denyusers"))
+ {
+ print FILE " !for_acl_users";
+ }
+ } else { print FILE " for_inetusers"; }
+ }
+ if (($proxysettings{'AUTH_METHOD'} eq 'radius') && ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on'))
+ {
+ if ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on')
+ {
+ if (($proxysettings{'RADIUS_USER_ACL'} eq 'positive') && (!-z "$raddir/radauth.allowusers"))
+ {
+ print FILE " for_acl_users";
+ }
+ if (($proxysettings{'RADIUS_USER_ACL'} eq 'negative') && (!-z "$raddir/radauth.denyusers"))
+ {
+ print FILE " !for_acl_users";
+ }
+ } else { print FILE " for_inetusers"; }
+ }
+ }
+ print FILE "\n";
+ }
+
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ if (!-z $disgrp) { print FILE "http_access deny for_disabled_users\n"; }
+ if (!-z $extgrp) { print FILE "http_access allow IPCop_networks for_extended_users\n"; }
+ }
+
+ if (
+ (
+ ($proxysettings{'AUTH_METHOD'} eq 'ntlm') &&
+ ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on') &&
+ ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'NTLM_USER_ACL'} eq 'negative') &&
+ (!-z "$ntlmdir/msntauth.denyusers")
+ )
+ ||
+ (
+ ($proxysettings{'AUTH_METHOD'} eq 'radius') &&
+ ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'RADIUS_USER_ACL'} eq 'negative') &&
+ (!-z "$raddir/radauth.denyusers")
+ )
+ ||
+ (
+ ($proxysettings{'AUTH_METHOD'} eq 'ident') &&
+ ($proxysettings{'AUTH_ALWAYS_REQUIRED'} eq 'off') &&
+ ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'IDENT_USER_ACL'} eq 'negative') &&
+ (!-z "$identdir/identauth.denyusers")
+ )
+ )
+ {
+ print FILE "http_access deny for_acl_users";
+ if (($proxysettings{'AUTH_METHOD'} eq 'ident') && (!-z "$identdir/hosts")) { print FILE " on_ident_aware_hosts"; }
+ print FILE "\n";
+ }
+
+ if (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on') && (!-z "$identhosts"))
+ {
+ print FILE "http_access allow";
+ if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
+ print FILE " !within_timeframe";
+ } else {
+ print FILE " within_timeframe"; }
+ if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
+ print FILE " !on_ident_aware_hosts\n";
+ }
+
+ print FILE "http_access allow IPCop_networks";
+ if (
+ (
+ ($proxysettings{'AUTH_METHOD'} eq 'ntlm') &&
+ ($proxysettings{'NTLM_ENABLE_INT_AUTH'} eq 'on') &&
+ ($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'NTLM_USER_ACL'} eq 'positive') &&
+ (!-z "$ntlmdir/msntauth.allowusers")
+ )
+ ||
+ (
+ ($proxysettings{'AUTH_METHOD'} eq 'radius') &&
+ ($proxysettings{'RADIUS_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'RADIUS_USER_ACL'} eq 'positive') &&
+ (!-z "$raddir/radauth.allowusers")
+ )
+ ||
+ (
+ ($proxysettings{'AUTH_METHOD'} eq 'ident') &&
+ ($proxysettings{'IDENT_REQUIRED'} eq 'on') &&
+ ($proxysettings{'IDENT_ENABLE_ACL'} eq 'on') &&
+ ($proxysettings{'IDENT_USER_ACL'} eq 'positive') &&
+ (!-z "$identdir/identauth.allowusers")
+ )
+ )
+ {
+ print FILE " for_acl_users";
+ } elsif (((!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident'))) ||
+ (($proxysettings{'AUTH_METHOD'} eq 'ident') && ($proxysettings{'IDENT_REQUIRED'} eq 'on'))) {
+ print FILE " for_inetusers";
+ }
+ if ((!($proxysettings{'AUTH_MAX_USERIP'} eq '')) && (!($proxysettings{'AUTH_METHOD'} eq 'none')) && (!($proxysettings{'AUTH_METHOD'} eq 'ident')))
+ {
+ print FILE " !concurrent";
+ }
+ if ($proxysettings{'TIME_ACCESS_MODE'} eq 'deny') {
+ print FILE " !within_timeframe";
+ } else {
+ print FILE " within_timeframe"; }
+ if ($proxysettings{'ENABLE_BROWSER_CHECK'} eq 'on') { print FILE " with_allowed_useragents"; }
+ print FILE "\n";
+
+ print FILE "http_access deny all\n\n";
+
+ if (($proxysettings{'FORWARD_IPADDRESS'} eq 'off') || ($proxysettings{'FORWARD_VIA'} eq 'off') ||
+ (!($proxysettings{'FAKE_USERAGENT'} eq '')) || (!($proxysettings{'FAKE_REFERER'} eq '')))
+ {
+ print FILE "#Strip HTTP Header\n";
+
+ if ($proxysettings{'FORWARD_IPADDRESS'} eq 'off')
+ {
+ print FILE "header_access X-Forwarded-For deny all\n";
+ }
+ if ($proxysettings{'FORWARD_VIA'} eq 'off')
+ {
+ print FILE "header_access Via deny all\n";
+ }
+ if (!($proxysettings{'FAKE_USERAGENT'} eq ''))
+ {
+ print FILE "header_access User-Agent deny all\n";
+ }
+ if (!($proxysettings{'FAKE_REFERER'} eq ''))
+ {
+ print FILE "header_access Referer deny all\n";
+ }
+
+ print FILE "\n";
+
+ if ((!($proxysettings{'FAKE_USERAGENT'} eq '')) || (!($proxysettings{'FAKE_REFERER'} eq '')))
+ {
+ if (!($proxysettings{'FAKE_USERAGENT'} eq ''))
+ {
+ print FILE "header_replace User-Agent $proxysettings{'FAKE_USERAGENT'}\n";
+ }
+ if (!($proxysettings{'FAKE_REFERER'} eq ''))
+ {
+ print FILE "header_replace Referer $proxysettings{'FAKE_REFERER'}\n";
+ }
+ print FILE "\n";
+ }
+ }
+
+ if ((!-z $mimetypes) && ($proxysettings{'ENABLE_MIME_FILTER'} eq 'on')) {
+ if (!-z $acl_src_unrestricted_ip) { print FILE "http_reply_access allow IPCop_unrestricted_ips\n"; }
+ if (!-z $acl_src_unrestricted_mac) { print FILE "http_reply_access allow IPCop_unrestricted_mac\n"; }
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ if (!-z $extgrp) { print FILE "http_reply_access allow for_extended_users\n"; }
+ }
+ print FILE "http_reply_access deny blocked_mimetypes\n";
+ print FILE "http_reply_access allow all\n\n";
+ }
+
+ print FILE <<END
+maximum_object_size $proxysettings{'MAX_SIZE'} KB
+minimum_object_size $proxysettings{'MIN_SIZE'} KB
+
+request_body_max_size $proxysettings{'MAX_OUTGOING_SIZE'} KB
+END
+ ;
+ $replybodymaxsize = 1024 * $proxysettings{'MAX_INCOMING_SIZE'};
+ if ($proxysettings{'MAX_INCOMING_SIZE'} > 0) {
+ if (!-z $acl_src_unrestricted_ip) { print FILE "reply_body_max_size 0 allow IPCop_unrestricted_ips\n"; }
+ if (!-z $acl_src_unrestricted_mac) { print FILE "reply_body_max_size 0 allow IPCop_unrestricted_mac\n"; }
+ if ($proxysettings{'AUTH_METHOD'} eq 'ncsa')
+ {
+ if (!-z $extgrp) { print FILE "reply_body_max_size 0 allow for_extended_users\n"; }
+ }
+ }
+ print FILE "reply_body_max_size $replybodymaxsize allow all\n\n";
+
+ print FILE "visible_hostname";
+ if ($proxysettings{'VISIBLE_HOSTNAME'} eq '')
+ {
+ print FILE " $mainsettings{'HOSTNAME'}.$mainsettings{'DOMAINNAME'}\n\n";
+ } else {
+ print FILE " $proxysettings{'VISIBLE_HOSTNAME'}\n\n";
+ }
+
+ if (!($proxysettings{'ADMIN_MAIL_ADDRESS'} eq '')) { print FILE "cache_mgr $proxysettings{'ADMIN_MAIL_ADDRESS'}\n\n"; }
+
+ # Write the parent proxy info, if needed.
+ if ($remotehost ne '')
+ {
+ # Enter authentication for the parent cache (format is login=user:password)
+ if ($proxy1 eq 'YES') {
+ print FILE <<END
+cache_peer $remotehost parent $remoteport 3130 login=$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'} default no-query
+
+END
+ ;
+ } else {
+ # Not using authentication with the parent cache
+ print FILE "cache_peer $remotehost parent $remoteport 3130 default no-query";
+ if ($proxysettings{'FORWARD_USERNAME'} eq 'on') { print FILE " login=*:password"; }
+ print FILE "\n";
+ }
+ print FILE "never_direct allow all\n\n";
+ }
+ if ($urlfilter_addon) {
+ if ($proxysettings{'ENABLE_FILTER'} eq 'on')
+ {
+ print FILE <<END
+redirect_program /usr/sbin/squidGuard
+redirect_children $filtersettings{'CHILDREN'}
+
+END
+ ;
+ }
+ }
+ if ($updacclrtr_addon) {
+ if ($proxysettings{'ENABLE_UPDACCEL'} eq 'on')
+ {
+ print FILE <<END
+redirect_program /usr/local/bin/updacclrtr
+redirect_children $updaccsettings{'ACCELERATORS'}
+
+END
+ ;
+ }
+ }
+ if (($proxysettings{'TRANSPARENT'} eq 'on') || ($proxysettings{'TRANSPARENT_BLUE'} eq 'on'))
+ {
+ print FILE <<END
+httpd_accel_host virtual
+httpd_accel_port 80
+httpd_accel_with_proxy on
+httpd_accel_uses_host_header on
+END
+ ;
+ }
+ close FILE;
+}
+
+# -------------------------------------------------------------------
+
+sub adduser
+{
+ my ($str_user, $str_pass, $str_group) = @_;
+ my @groupmembers=();
+
+ if ($str_pass eq 'lEaVeAlOnE')
+ {
+ open(FILE, "$userdb");
+ @groupmembers = <FILE>;
+ close(FILE);
+ foreach $line (@groupmembers) { if ($line =~ /^$str_user:/i) { $str_pass = substr($line,index($line,":")); } }
+ &deluser($str_user);
+ open(FILE, ">>$userdb");
+ flock FILE,2;
+ print FILE "$str_user$str_pass";
+ close(FILE);
+ } else {
+ &deluser($str_user);
+ system("/usr/bin/htpasswd -b $userdb $str_user $str_pass");
+ }
+
+ if ($str_group eq 'standard') { open(FILE, ">>$stdgrp");
+ } elsif ($str_group eq 'extended') { open(FILE, ">>$extgrp");
+ } elsif ($str_group eq 'disabled') { open(FILE, ">>$disgrp"); }
+ flock FILE, 2;
+ print FILE "$str_user\n";
+ close(FILE);
+
+ return;
+}
+
+# -------------------------------------------------------------------
+
+sub deluser
+{
+ my ($str_user) = @_;
+ my $groupfile='';
+ my @groupmembers=();
+ my @templist=();
+
+ foreach $groupfile ($stdgrp, $extgrp, $disgrp)
+ {
+ undef @templist;
+ open(FILE, "$groupfile");
+ @groupmembers = <FILE>;
+ close(FILE);
+ foreach $line (@groupmembers) { if (!($line =~ /^$str_user$/i)) { push(@templist, $line); } }
+ open(FILE, ">$groupfile");
+ flock FILE, 2;
+ print FILE @templist;
+ close(FILE);
+ }
+
+ undef @templist;
+ open(FILE, "$userdb");
+ @groupmembers = <FILE>;
+ close(FILE);
+ foreach $line (@groupmembers) { if (!($line =~ /^$str_user:/i)) { push(@templist, $line); } }
+ open(FILE, ">$userdb");
+ flock FILE, 2;
+ print FILE @templist;
+ close(FILE);
+
+ return;
+}