Geaendert:
[people/teissler/ipfire-2.x.git] / html / html / redirect.cgi
1 #!/usr/bin/perl
2
3 #
4 # $Id: redirect.cgi,v 0.3 2006/07/18 00:00:00 modyfy bye linuxadmin
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
40 <html>
41 <head>
42 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
43 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
44 <title>ACCESS MESSAGE</title>
45 </head>
46
47 END
48 ;
49
50 if (($filtersettings{'ENABLE_JPEG'} eq 'on') && (-e "/home/httpd/html/images/urlfilter/logo_ipfire.gif"))
51 {
52 print <<END
53 <body background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/logo_ipfire.gif" bgcolor="#FFFFFF">
54 END
55 ;
56 } else {
57 print <<END
58 <img src="http://$netsettings{'GREEN_ADDRESS'}:81//images/logo_ipfire.gif" ALT="IPFire-Logo">
59 <body bgcolor="#455B72">
60 END
61 ;
62 }
63
64 print <<END
65
66
67 <center>
68
69 <table width="80%" cellspacing="10" cellpadding="5" border="1">
70 <tr>
71 <td nowrap align="right" background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/bgcool.gif">
72 <font face="verdana, arial, sans serif" color="#CC000000" size="1">
73 <b> INFO: $category</b>
74 </font>
75 </td>
76 </tr>
77 <tr>
78 <td bgcolor="#F4F4F4" align="center">
79 <table width="100%" cellspacing="20" cellpadding="18" border="1">
80 <tr>
81 <td nowrap align="center" background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/bgcool.gif">
82 <font face="verdana, arial, sans serif" color="#CC000000" size="5">
83 <b>$msgtext1</b>
84 </font>
85 </td>
86 </tr>
87 <tr>
88 <td bgcolor="#E2E2E2" align="center">
89 <font face="verdana, arial, sans serif" color="#000000" size="4">
90 <b>$msgtext2</b>
91 </font>
92 <font face="verdana,arial,sans serif" color="#000000" size="2">
93 END
94 ;
95
96 if (!($url eq ""))
97 {
98 print <<END
99 <p>URL: <a href="$url">$url</a>
100 END
101 ;
102 }
103
104 if (!($ip eq ""))
105 {
106 print <<END
107 <p>Client IP address: <i>$ip</i>
108 END
109 ;
110 }
111
112 print <<END
113 <br><p>$msgtext3
114 </font>
115 </td>
116 </tr>
117 </td>
118 </tr>
119 </table>
120
121 <tr>
122 <td nowrap align="right" background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/bgcool.gif">
123 <font face="verdana,arial,sans serif" color="#656565" size="1">Web Filtering by
124 </font>
125 <a href="http://www.ipfire.eu" target="_blank"><b>
126 <font face="verdana,arial,sans serif" color="#656565" size="1">IPFire</b></a> and
127 <a href="http://www.squidguard.org" target="_blank"><b>
128 <font face="verdana,arial,sans serif" color="#656565" size="1">SquidGuard
129 </font></b></a>
130 </td>
131 </tr>
132
133 </table>
134
135 <img src="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/bg_cool_tux.jpg">
136 </center>
137
138 </body>
139
140 </html>
141 END
142 ;
143
144 sub readhash
145 {
146 my $filename = $_[0];
147 my $hash = $_[1];
148 my ($var, $val);
149
150 if (-e $filename)
151 {
152 open(FILE, $filename) or die "Unable to read file $filename";
153 while (<FILE>)
154 {
155 chop;
156 ($var, $val) = split /=/, $_, 2;
157 if ($var)
158 {
159 $val =~ s/^\'//g;
160 $val =~ s/\'$//g;
161
162 # Untaint variables read from hash
163 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
164 $val =~ /([\w\W]*)/; $val = $1;
165 $hash->{$var} = $val;
166 }
167 }
168 close FILE;
169 }
170 }