]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/html/redirect.cgi
proxylog.dat: Escape usernames.
[people/teissler/ipfire-2.x.git] / html / html / redirect.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use CGI qw(param);
23
24 $swroot="/var/ipfire";
25
26 my %netsettings;
27 my %filtersettings;
28
29 &readhash("$swroot/ethernet/settings", \%netsettings);
30 &readhash("$swroot/urlfilter/settings", \%filtersettings);
31
32 $category=param("category");
33 $url=param("url");
34 $ip=param("ip");
35
36 if ($filtersettings{'MSG_TEXT_1'} eq '') {
37 $msgtext1 = "A C C E S S &nbsp;&nbsp; D E N I E D";
38 } else { $msgtext1 = $filtersettings{'MSG_TEXT_1'}; }
39 if ($filtersettings{'MSG_TEXT_2'} eq '') {
40 $msgtext2 = "Access to the requested page has been denied";
41 } else { $msgtext2 = $filtersettings{'MSG_TEXT_2'}; }
42 if ($filtersettings{'MSG_TEXT_3'} eq '') {
43 $msgtext3 = "Please contact the Network Administrator if you think there has been an error";
44 } else { $msgtext3 = $filtersettings{'MSG_TEXT_3'}; }
45
46 if ($category eq '') { $category = '&nbsp;'; } else { $category = '['.$category.']'; }
47
48 print "Pragma: no-cache\n";
49 print "Cache-control: no-cache\n";
50 print "Connection: close\n";
51 print "Content-type: text/html\n\n";
52
53 print <<END
54
55 <html>
56 <head>
57 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
58 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
59 <title>ACCESS MESSAGE</title>
60 </head>
61
62 <body>
63 <table width="100%" height='100%' border="0">
64 <tr>
65 <td colspan='3' width='100%' height='130' align="center" background="http://$netsettings{'GREEN_ADDRESS'}:81/images/background.gif">
66 <tr> <td width='10%'><td align='center' bgcolor='#CC000000' width='80%'><font face="verdana, arial, sans serif" color="#FFFFFF" size="5">
67 <b>$msgtext1</b>
68 </font>
69 <td width='10%'>
70 END
71 ;
72
73 if (!($category eq ""))
74 {
75 print <<END
76 <tr> <td colspan='3' align='center'>
77 <font face="verdana, arial, sans serif" color="#CC000000" size="1">
78 <b>$category</b>
79 </font>
80 END
81 ;
82 }
83 print <<END
84 <tr>
85 <td colspan='3' align="center">
86 <font face="verdana, arial, sans serif" color="#000000" size="4">
87 <b>$msgtext2</b>
88 </font>
89 <font face="verdana,arial,sans serif" color="#000000" size="2">
90 END
91 ;
92
93 if (!($url eq ""))
94 {
95 print <<END
96 <p>URL: <a href="$url">$url</a>
97 END
98 ;
99 }
100
101 if (!($ip eq ""))
102 {
103 print <<END
104 <p>Client IP address: <i>$ip</i>
105 END
106 ;
107 }
108
109 print <<END
110 <br><p>$msgtext3
111 </font>
112
113 <tr>
114 <td colspan='3' height='60%' valign="bottom" align="right">
115 <font face="verdana,arial,sans serif" color="#656565" size="1">Web Filtering by
116 </font>
117 <a href="http://www.ipfire.org" target="_blank"><b>
118 <font face="verdana,arial,sans serif" color="#656565" size="1">IPFire</b></a>
119 </font>
120
121 </table>
122 </body>
123
124 </html>
125 END
126 ;
127
128 sub readhash
129 {
130 my $filename = $_[0];
131 my $hash = $_[1];
132 my ($var, $val);
133
134 if (-e $filename)
135 {
136 open(FILE, $filename) or die "Unable to read file $filename";
137 while (<FILE>)
138 {
139 chop;
140 ($var, $val) = split /=/, $_, 2;
141 if ($var)
142 {
143 $val =~ s/^\'//g;
144 $val =~ s/\'$//g;
145
146 # Untaint variables read from hash
147 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
148 $val =~ /([\w\W]*)/; $val = $1;
149 $hash->{$var} = $val;
150 }
151 }
152 close FILE;
153 }
154 }