GeƤndert:
[ipfire-2.x.git] / html / html / redirect.cgi
1 #!/usr/bin/perl
2
3 #
4 # $Id: redirect.cgi,v 0.1 2004/09/26 00:00:00 marco Exp $
5 #
6
7 use CGI qw(param);
8
9 $swroot="/var/ipfire";
10
11 my %netsettings;
12 my %filtersettings;
13
14 &readhash("$swroot/ethernet/settings", \%netsettings);
15 &readhash("$swroot/urlfilter/settings", \%filtersettings);
16
17 $category=param("category");
18 $url=param("url");
19 $ip=param("ip");
20
21 if ($filtersettings{'MSG_TEXT_1'} eq '') {
22 $msgtext1 = "A C C E S S    D E N I E D";
23 } else { $msgtext1 = $filtersettings{'MSG_TEXT_1'}; }
24 if ($filtersettings{'MSG_TEXT_2'} eq '') {
25 $msgtext2 = "Access to the requested page has been denied";
26 } else { $msgtext2 = $filtersettings{'MSG_TEXT_2'}; }
27 if ($filtersettings{'MSG_TEXT_3'} eq '') {
28 $msgtext3 = "Please contact the Network Administrator if you think there has been an error";
29 } else { $msgtext3 = $filtersettings{'MSG_TEXT_3'}; }
30
31 if ($category eq '') { $category = ' '; } else { $category = '['.$category.']'; }
32
33 print "Pragma: no-cache\n";
34 print "Cache-control: no-cache\n";
35 print "Connection: close\n";
36 print "Content-type: text/html\n\n";
37
38 print <<END
39 <html>
40 <head>
41 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
42 <title></title>
43 </head>
44
45 END
46 ;
47
48 if (($filtersettings{'ENABLE_JPEG'} eq 'on') && (-e "/home/httpd/html/images/urlfilter/background.jpg"))
49 {
50 print <<END
51 <body background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/background.jpg" bgcolor="#FFFFFF">
52 END
53 ;
54 } else {
55 print <<END
56 <body bgcolor="#FFFFFF">
57 END
58 ;
59 }
60
61 print <<END
62
63 <center>
64
65 <table width="80%" cellspacing="10" cellpadding="5" border="0">
66
67 <tr>
68 <td bgcolor="#C0C0C0" align="right">
69 <font face="verdana, arial, sans serif" color="#000000" size="1">
70 <b>$category</b>
71 </font>
72 </td>
73 </tr>
74 <tr>
75 <td bgcolor="#F4F4F4" align="center">
76 <table width="100%" cellspacing="20" cellpadding="20" border="0">
77 <tr>
78 <td nowrap bgcolor="#FF0000" align="center">
79 <font face="verdana, arial, sans serif" color="#FFFFFF" size="6">
80 <b>$msgtext1</b>
81 </font>
82 </td>
83 </tr>
84 <tr>
85 <td bgcolor="#E2E2E2" 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 </td>
113 </tr>
114 </td>
115 </tr>
116 </table>
117
118 <tr>
119 <td bgcolor="#C0C0C0" align="right">
120 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">Web Filtering by
121 </font>
122 <a href="http://www.ipcop.org" target="_blank"><b>
123 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">IPCop</b></a> and
124 <a href="http://www.squidguard.org" target="_blank"><b>
125 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">SquidGuard
126 </font></b></a>
127 </td>
128 </tr>
129
130 </table>
131
132 </center>
133
134 </body>
135
136 </html>
137 END
138 ;
139
140 sub readhash
141 {
142 my $filename = $_[0];
143 my $hash = $_[1];
144 my ($var, $val);
145
146 if (-e $filename)
147 {
148 open(FILE, $filename) or die "Unable to read file $filename";
149 while (<FILE>)
150 {
151 chop;
152 ($var, $val) = split /=/, $_, 2;
153 if ($var)
154 {
155 $val =~ s/^\'//g;
156 $val =~ s/\'$//g;
157
158 # Untaint variables read from hash
159 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
160 $val =~ /([\w\W]*)/; $val = $1;
161 $hash->{$var} = $val;
162 }
163 }
164 close FILE;
165 }
166 }