]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/webaccess.cgi
4 # $Id: webaccess.cgi,v 2.0 2006/01/11 00:00:00 marco.s Exp $
9 my $swroot = "/var/ipfire";
10 my $apdir = "$swroot/proxy/advanced";
11 my $group_def_file = "$apdir/cre/classrooms";
12 my $svhosts_file = "$apdir/cre/supervisors";
13 my $acl_src_noaccess_ips = "$apdir/acls/src_noaccess_ip.acl";
14 my $acl_src_noaccess_mac = "$apdir/acls/src_noaccess_mac.acl";
16 my $banner = "A D V A N C E D P R O X Y - W E B A C C E S S M A N A G E R";
25 ### Initialize environment
26 &readhash
("${swroot}/main/settings", \
%mainsettings);
27 &readhash
("${swroot}/proxy/advanced/settings", \
%proxysettings);
28 $language = $mainsettings{'LANGUAGE'};
30 ### Initialize language
31 if ($language =~ /^(\w+)$/) {$language = $1;}
33 # Uncomment this to force a certain language:
36 require "${swroot}/langs/en.pl";
37 require "${swroot}/langs/${language}.pl";
39 &getcgihash
(\
%cgiparams);
46 if ($cgiparams{$_} eq $tr{'advproxy mode deny'}) { $acl{$_}='on'; }
47 if ($cgiparams{$_} eq $tr{'advproxy mode allow'}) { $acl{$_}='off'; }
54 if ((-e
$svhosts_file) && (!-z
$svhosts_file))
56 open (FILE
, $svhosts_file);
60 if ($ENV{'REMOTE_ADDR'} eq $_) { $is_supervisor=1; }
64 } else { $is_supervisor=1; }
66 if (($cgiparams{'ACTION'} eq 'submit') && ($is_supervisor))
68 if ( ($cgiparams{'PASSWORD'} eq $proxysettings{'SUPERVISOR_PASSWORD'}) && (!($proxysettings{'SUPERVISOR_PASSWORD'} eq '')) ||
69 ((defined($proxysettings{'SUPERVISOR_PASSWORD'})) && ($proxysettings{'SUPERVISOR_PASSWORD'} eq '')))
72 system("/usr/local/bin/squidctrl restart >/dev/null 2>&1");
80 # -------------------------------------------------------------------
84 Cache-control: no-cache
86 Content-type: text/html
88 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
91 <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
92 <title>Advanced Proxy - Web Access Manager</title>
93 <style type='text/css'>
94 a:link { text-decoration:none; font-family:verdana,arial,helvetica; font-weight:bold; color:#ffffff; }
95 a:visited { text-decoration:none; font-family:verdana,arial,helvetica; font-weight:bold; color:#ffffff; }
96 a:hover { text-decoration:none; font-family:verdana,arial,helvetica; font-weight:bold; color:#000000; }
97 a:active { text-decoration:none; font-family:verdana,arial,helvetica; font-weight:bold; color:#000000; }
98 a:focus { text-decoration:none; font-family:verdana,arial,helvetica; font-weight:bold; color:#ffffff; }
101 <body bgcolor='#FFFFFF'>
105 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
107 <table width='720' cellspacing='10' cellpadding='5' border='0'>
110 <td bgcolor='#C0C0C0' height='20'></td>
114 <td bgcolor='#F4F4F4' align='center'>
115 <table width='100%' cellspacing='10' cellpadding='10' border='0'>
118 <td nowrap bgcolor='#FFFFFF' align='center'>
119 <font face='verdana,arial,helvetica' color='#000000' size='3'>$banner</font>
125 if ($proxysettings{'CLASSROOM_EXT'} eq 'on')
132 <table width='70%' cellspacing='2' cellpadding='2' border='0' align='center'>
133 <tr><td><input type='hidden' name='ACTION' value='submit'></td></tr>
137 if (($is_supervisor) && ((defined($proxysettings{'SUPERVISOR_PASSWORD'})) && (!($proxysettings{'SUPERVISOR_PASSWORD'} eq ''))))
141 <font face='verdana,arial,helvetica' color='#000000' size='2'>$tr{'advproxy supervisor password'}:</font>
143 <td align='center'><input type='password' name='PASSWORD' size='15'></td>
159 print"<table width='65%' cellspacing='2' cellpadding='2' border='0' align='center' rules='groups'>";
161 print"<table width='50%' cellspacing='2' cellpadding='6' border='0' align='center' rules='groups'>";
164 if ((defined($acl{$_})) && ($acl{$_} eq 'on'))
166 print " <td bgcolor='#D00000' align='center'><font face='verdana,arial,helvetica' color='#FFFFFF' size='2'>$_</font>";
167 } else { print " <td bgcolor='#00A000' align='center'><font face='verdana,arial,helvetica' color='#FFFFFF' size='2'>$_</font>"; }
170 if ((defined($acl{$_})) && ($acl{$_} eq 'on'))
172 print "</td><td width='120' align='center'>";
173 print "<input type='submit' name='$_' value=' $tr{'advproxy mode allow'} '>";
174 print "</td><td width='16' bgcolor='#D00000'> </td>\n";
176 print "</td><td width='120' align='center'>";
177 print "<input type='submit' name='$_' value=' $tr{'advproxy mode deny'} '>";
178 print "</td><td width='16' bgcolor='#00A000'> </td>\n";
183 print"<table width='65%' cellspacing='2' cellpadding='2' border='0' align='center'>";
184 print "<tr><td></td></tr>\n";
195 print " <td align='center'>\n";
196 print " <font face='verdana,arial,helvetica' color='#000000' size='2'>$tr{'advproxy no cre groups'}</font>\n";
202 print " <td align='center'>\n";
203 print " <font face='verdana,arial,helvetica' color='#000000' size='2'>$tr{'advproxy cre disabled'}</font>\n";
216 <td bgcolor='#C0C0C0' align='right'>
217 <font face='verdana,arial,helvetica' color='#FFFFFF' size='1'>
218 <a href='http://www.advproxy.net' target='_blank'>Advanced Proxy</a> running on
219 <a href='http://www.ipcop.org' target='_blank'>IPCop</a>
236 # -------------------------------------------------------------------
240 my $filename = $_[0];
246 open(FILE
, $filename) or die "Unable to read file $filename";
250 ($var, $val) = split /=/, $_, 2;
256 # Untaint variables read from hash
257 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
258 $val =~ /([\w\W]*)/; $val = $1;
259 $hash->{$var} = $val;
266 # -------------------------------------------------------------------
270 my ($hash, $params) = @_;
271 my $cgi = CGI
->new ();
272 return if ($ENV{'REQUEST_METHOD'} ne 'POST');
273 if (!$params->{'wantfile'}) {
274 $CGI::DISABLE_UPLOADS
= 1;
275 $CGI::POST_MAX
= 512 * 1024;
277 $CGI::POST_MAX
= 10 * 1024 * 1024;
280 $cgi->referer() =~ m/^https?\:\/\
/([^\/]+)/;
282 $cgi->url() =~ m/^https?\:\/\
/([^\/]+)/;
284 return if ($referer ne $servername);
286 ### Modified for getting multi-vars, split by |
287 %temp = $cgi->Vars();
288 foreach my $key (keys %temp) {
289 $hash->{$key} = $temp{$key};
290 $hash->{$key} =~ s/\0/|/g;
291 $hash->{$key} =~ s/^\s*(.*?)\s*$/$1/;
294 if (($params->{'wantfile'})&&($params->{'filevar'})) {
295 $hash->{$params->{'filevar'}} = $cgi->upload
296 ($params->{'filevar'});
301 # -------------------------------------------------------------------
306 open (FILE
,"$acl_src_noaccess_ips");
307 my @aclgroups = <FILE
>;
320 # -------------------------------------------------------------------
326 open (FILE
,"$group_def_file");
327 @group_defs = <FILE
>;
331 foreach (@group_defs)
334 if (/^\s*\[.*\]\s*$/)
337 $grpstr =~ s/^\s*\[\s*//;
338 $grpstr =~ s/\s*\]\s*$//;
339 push(@groups,$grpstr);
344 # -------------------------------------------------------------------
350 open (FILE_IPS
,">$acl_src_noaccess_ips");
351 open (FILE_MAC
,">$acl_src_noaccess_mac");
354 foreach (@group_defs)
356 if (/^\s*\[.*\]\s*$/)
360 if ((defined($acl{$_})) && ($acl{$_} eq 'on'))
362 print FILE_IPS
"# $_\n";
363 print FILE_MAC
"# $_\n";
365 } else { $is_blocked=0; }
366 } elsif (($is_blocked) && ($_))
368 s/^\s+//g; s/\s+$//g;
369 /^[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}$/i ?
print FILE_MAC
"$_\n" : print FILE_IPS
"$_\n";
377 # -------------------------------------------------------------------