HinzugefĆ¼gt:
[ipfire-2.x.git] / html / cgi-bin / redirect.cgi
CommitLineData
10e4f239
MT
1#!/usr/bin/perl
2
3#
4# $Id: redirect.cgi,v 0.1 2004/09/26 00:00:00 marco Exp $
5#
6
7use CGI qw(param);
8
9$swroot="/var/ipfire";
10
11my %netsettings;
12my %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
21if ($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'}; }
24if ($filtersettings{'MSG_TEXT_2'} eq '') {
25 $msgtext2 = "Access to the requested page has been denied";
26} else { $msgtext2 = $filtersettings{'MSG_TEXT_2'}; }
27if ($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
31if ($category eq '') { $category = ' '; } else { $category = '['.$category.']'; }
32
33print "Pragma: no-cache\n";
34print "Cache-control: no-cache\n";
35print "Connection: close\n";
36print "Content-type: text/html\n\n";
37
38print <<END
39<html>
40<head>
41<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
42<title></title>
43</head>
44
45END
46;
47
48if (($filtersettings{'ENABLE_JPEG'} eq 'on') && (-e "/home/httpd/html/images/urlfilter/background.jpg"))
49{
50print <<END
51<body background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/background.jpg" bgcolor="#FFFFFF">
52END
53;
54} else {
55print <<END
56<body bgcolor="#FFFFFF">
57END
58;
59}
60
61print <<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">
90END
91;
92
93if (!($url eq ""))
94{
95print <<END
96 <p>URL: <a href="$url">$url</a>
97END
98;
99}
100
101if (!($ip eq ""))
102{
103print <<END
104 <p>Client IP address: <i>$ip</i>
105END
106;
107}
108
109print <<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>
137END
138;
139
140sub 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}
167#!/usr/bin/perl
168
169#
170# $Id: redirect.cgi,v 0.1 2004/09/26 00:00:00 marco Exp $
171#
172
173use CGI qw(param);
174
175$swroot="/var/ipfire";
176
177my %netsettings;
178my %filtersettings;
179
180&readhash("$swroot/ethernet/settings", \%netsettings);
181&readhash("$swroot/urlfilter/settings", \%filtersettings);
182
183$category=param("category");
184$url=param("url");
185$ip=param("ip");
186
187if ($filtersettings{'MSG_TEXT_1'} eq '') {
188 $msgtext1 = "A C C E S S &nbsp;&nbsp; D E N I E D";
189} else { $msgtext1 = $filtersettings{'MSG_TEXT_1'}; }
190if ($filtersettings{'MSG_TEXT_2'} eq '') {
191 $msgtext2 = "Access to the requested page has been denied";
192} else { $msgtext2 = $filtersettings{'MSG_TEXT_2'}; }
193if ($filtersettings{'MSG_TEXT_3'} eq '') {
194 $msgtext3 = "Please contact the Network Administrator if you think there has been an error";
195} else { $msgtext3 = $filtersettings{'MSG_TEXT_3'}; }
196
197if ($category eq '') { $category = '&nbsp;'; } else { $category = '['.$category.']'; }
198
199print "Pragma: no-cache\n";
200print "Cache-control: no-cache\n";
201print "Connection: close\n";
202print "Content-type: text/html\n\n";
203
204print <<END
205<html>
206<head>
207<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
208<title></title>
209</head>
210
211END
212;
213
214if (($filtersettings{'ENABLE_JPEG'} eq 'on') && (-e "/home/httpd/html/images/urlfilter/background.jpg"))
215{
216print <<END
217<body background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/background.jpg" bgcolor="#FFFFFF">
218END
219;
220} else {
221print <<END
222<body bgcolor="#FFFFFF">
223END
224;
225}
226
227print <<END
228
229<center>
230
231<table width="80%" cellspacing="10" cellpadding="5" border="0">
232
233<tr>
234 <td bgcolor="#C0C0C0" align="right">
235 <font face="verdana, arial, sans serif" color="#000000" size="1">
236 <b>$category</b>
237 </font>
238 </td>
239</tr>
240<tr>
241 <td bgcolor="#F4F4F4" align="center">
242 <table width="100%" cellspacing="20" cellpadding="20" border="0">
243 <tr>
244 <td nowrap bgcolor="#FF0000" align="center">
245 <font face="verdana, arial, sans serif" color="#FFFFFF" size="6">
246 <b>$msgtext1</b>
247 </font>
248 </td>
249 </tr>
250 <tr>
251 <td bgcolor="#E2E2E2" align="center">
252 <font face="verdana, arial, sans serif" color="#000000" size="4">
253 <b>$msgtext2</b>
254 </font>
255 <font face="verdana,arial,sans serif" color="#000000" size="2">
256END
257;
258
259if (!($url eq ""))
260{
261print <<END
262 <p>URL: <a href="$url">$url</a>
263END
264;
265}
266
267if (!($ip eq ""))
268{
269print <<END
270 <p>Client IP address: <i>$ip</i>
271END
272;
273}
274
275print <<END
276 <br><p>$msgtext3
277 </font>
278 </td>
279 </tr>
280 </td>
281</tr>
282</table>
283
284<tr>
285 <td bgcolor="#C0C0C0" align="right">
286 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">Web Filtering by
287 </font>
288 <a href="http://www.ipcop.org" target="_blank"><b>
289 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">IPCop</b></a> and
290 <a href="http://www.squidguard.org" target="_blank"><b>
291 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">SquidGuard
292 </font></b></a>
293 </td>
294</tr>
295
296</table>
297
298</center>
299
300</body>
301
302</html>
303END
304;
305
306sub readhash
307{
308 my $filename = $_[0];
309 my $hash = $_[1];
310 my ($var, $val);
311
312 if (-e $filename)
313 {
314 open(FILE, $filename) or die "Unable to read file $filename";
315 while (<FILE>)
316 {
317 chop;
318 ($var, $val) = split /=/, $_, 2;
319 if ($var)
320 {
321 $val =~ s/^\'//g;
322 $val =~ s/\'$//g;
323
324 # Untaint variables read from hash
325 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
326 $val =~ /([\w\W]*)/; $val = $1;
327 $hash->{$var} = $val;
328 }
329 }
330 close FILE;
331 }
332}
333#!/usr/bin/perl
334
335#
336# $Id: redirect.cgi,v 0.1 2004/09/26 00:00:00 marco Exp $
337#
338
339use CGI qw(param);
340
341$swroot="/var/ipfire";
342
343my %netsettings;
344my %filtersettings;
345
346&readhash("$swroot/ethernet/settings", \%netsettings);
347&readhash("$swroot/urlfilter/settings", \%filtersettings);
348
349$category=param("category");
350$url=param("url");
351$ip=param("ip");
352
353if ($filtersettings{'MSG_TEXT_1'} eq '') {
354 $msgtext1 = "A C C E S S &nbsp;&nbsp; D E N I E D";
355} else { $msgtext1 = $filtersettings{'MSG_TEXT_1'}; }
356if ($filtersettings{'MSG_TEXT_2'} eq '') {
357 $msgtext2 = "Access to the requested page has been denied";
358} else { $msgtext2 = $filtersettings{'MSG_TEXT_2'}; }
359if ($filtersettings{'MSG_TEXT_3'} eq '') {
360 $msgtext3 = "Please contact the Network Administrator if you think there has been an error";
361} else { $msgtext3 = $filtersettings{'MSG_TEXT_3'}; }
362
363if ($category eq '') { $category = '&nbsp;'; } else { $category = '['.$category.']'; }
364
365print "Pragma: no-cache\n";
366print "Cache-control: no-cache\n";
367print "Connection: close\n";
368print "Content-type: text/html\n\n";
369
370print <<END
371<html>
372<head>
373<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
374<title></title>
375</head>
376
377END
378;
379
380if (($filtersettings{'ENABLE_JPEG'} eq 'on') && (-e "/home/httpd/html/images/urlfilter/background.jpg"))
381{
382print <<END
383<body background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/background.jpg" bgcolor="#FFFFFF">
384END
385;
386} else {
387print <<END
388<body bgcolor="#FFFFFF">
389END
390;
391}
392
393print <<END
394
395<center>
396
397<table width="80%" cellspacing="10" cellpadding="5" border="0">
398
399<tr>
400 <td bgcolor="#C0C0C0" align="right">
401 <font face="verdana, arial, sans serif" color="#000000" size="1">
402 <b>$category</b>
403 </font>
404 </td>
405</tr>
406<tr>
407 <td bgcolor="#F4F4F4" align="center">
408 <table width="100%" cellspacing="20" cellpadding="20" border="0">
409 <tr>
410 <td nowrap bgcolor="#FF0000" align="center">
411 <font face="verdana, arial, sans serif" color="#FFFFFF" size="6">
412 <b>$msgtext1</b>
413 </font>
414 </td>
415 </tr>
416 <tr>
417 <td bgcolor="#E2E2E2" align="center">
418 <font face="verdana, arial, sans serif" color="#000000" size="4">
419 <b>$msgtext2</b>
420 </font>
421 <font face="verdana,arial,sans serif" color="#000000" size="2">
422END
423;
424
425if (!($url eq ""))
426{
427print <<END
428 <p>URL: <a href="$url">$url</a>
429END
430;
431}
432
433if (!($ip eq ""))
434{
435print <<END
436 <p>Client IP address: <i>$ip</i>
437END
438;
439}
440
441print <<END
442 <br><p>$msgtext3
443 </font>
444 </td>
445 </tr>
446 </td>
447</tr>
448</table>
449
450<tr>
451 <td bgcolor="#C0C0C0" align="right">
452 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">Web Filtering by
453 </font>
454 <a href="http://www.ipcop.org" target="_blank"><b>
455 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">IPCop</b></a> and
456 <a href="http://www.squidguard.org" target="_blank"><b>
457 <font face="verdana,arial,sans serif" color="#FFFFFF" size="1">SquidGuard
458 </font></b></a>
459 </td>
460</tr>
461
462</table>
463
464</center>
465
466</body>
467
468</html>
469END
470;
471
472sub readhash
473{
474 my $filename = $_[0];
475 my $hash = $_[1];
476 my ($var, $val);
477
478 if (-e $filename)
479 {
480 open(FILE, $filename) or die "Unable to read file $filename";
481 while (<FILE>)
482 {
483 chop;
484 ($var, $val) = split /=/, $_, 2;
485 if ($var)
486 {
487 $val =~ s/^\'//g;
488 $val =~ s/\'$//g;
489
490 # Untaint variables read from hash
491 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
492 $val =~ /([\w\W]*)/; $val = $1;
493 $hash->{$var} = $val;
494 }
495 }
496 close FILE;
497 }
498}