GeƤndert:
[ipfire-2.x.git] / html / html / 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
10e4f239
MT
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}