MONSTER-REVISION!
[ipfire-2.x.git] / html / html / redirect.cgi
CommitLineData
10e4f239
MT
1#!/usr/bin/perl
2
3#
f1baee3e 4# redirect.cgi - By IPFire-Team (C)
10e4f239
MT
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
40a4ea4c 39
10e4f239
MT
40<html>
41<head>
40a4ea4c 42<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
10e4f239 43<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
40a4ea4c 44<title>ACCESS MESSAGE</title>
10e4f239
MT
45</head>
46
5e773594
MT
47<body>
48<table width="100%" height='100%' border="0">
49<tr>
f1baee3e 50 <td colspan='3' width='100%' height='130' align="center" background="http://$netsettings{'GREEN_ADDRESS'}:81/images/background.gif">
5e773594
MT
51<tr> <td width='10%'><td align='center' bgcolor='#CC000000' width='80%'><font face="verdana, arial, sans serif" color="#FFFFFF" size="5">
52 <b>$msgtext1</b>
53 </font>
54 <td width='10%'>
10e4f239
MT
55END
56;
57
5e773594 58if (!($category eq ""))
10e4f239 59{
5e773594
MT
60 print <<END
61 <tr> <td colspan='3' align='center'>
62 <font face="verdana, arial, sans serif" color="#CC000000" size="1">
63 <b>$category</b>
64 </font>
10e4f239
MT
65END
66;
67}
10e4f239 68print <<END
10e4f239 69<tr>
5e773594
MT
70 <td colspan='3' align="center">
71 <font face="verdana, arial, sans serif" color="#000000" size="4">
72 <b>$msgtext2</b>
73 </font>
74 <font face="verdana,arial,sans serif" color="#000000" size="2">
10e4f239
MT
75END
76;
77
78if (!($url eq ""))
79{
80print <<END
81 <p>URL: <a href="$url">$url</a>
82END
83;
84}
85
86if (!($ip eq ""))
87{
88print <<END
89 <p>Client IP address: <i>$ip</i>
90END
91;
92}
93
94print <<END
95 <br><p>$msgtext3
96 </font>
10e4f239
MT
97
98<tr>
5e773594 99 <td colspan='3' height='60%' valign="bottom" align="right">
40a4ea4c 100 <font face="verdana,arial,sans serif" color="#656565" size="1">Web Filtering by
10e4f239 101 </font>
40a4ea4c 102 <a href="http://www.ipfire.eu" target="_blank"><b>
5e773594
MT
103 <font face="verdana,arial,sans serif" color="#656565" size="1">IPFire</b></a>
104 </font>
10e4f239
MT
105
106</table>
10e4f239
MT
107</body>
108
109</html>
110END
111;
112
113sub readhash
114{
115 my $filename = $_[0];
116 my $hash = $_[1];
117 my ($var, $val);
118
119 if (-e $filename)
120 {
121 open(FILE, $filename) or die "Unable to read file $filename";
122 while (<FILE>)
123 {
124 chop;
125 ($var, $val) = split /=/, $_, 2;
126 if ($var)
127 {
128 $val =~ s/^\'//g;
129 $val =~ s/\'$//g;
130
131 # Untaint variables read from hash
132 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
133 $val =~ /([\w\W]*)/; $val = $1;
134 $hash->{$var} = $val;
135 }
136 }
137 close FILE;
138 }
139}