MONSTER-REVISION!
[ipfire-2.x.git] / html / html / redirect.cgi
1 #!/usr/bin/perl
2
3 #
4 # redirect.cgi - By IPFire-Team (C)
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 <body>
48 <table width="100%" height='100%' border="0">
49 <tr>
50                 <td colspan='3' width='100%' height='130' align="center" background="http://$netsettings{'GREEN_ADDRESS'}:81/images/background.gif">
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%'>
55 END
56 ;
57
58 if (!($category eq ""))
59 {
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>
65 END
66 ;
67 }
68 print <<END
69 <tr>
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">
75 END
76 ;
77
78 if (!($url eq ""))
79 {
80 print <<END
81                                         <p>URL: <a href="$url">$url</a>
82 END
83 ;
84 }
85
86 if (!($ip eq ""))
87 {
88 print <<END
89                                         <p>Client IP address: <i>$ip</i>
90 END
91 ;
92 }
93
94 print <<END
95                                         <br><p>$msgtext3
96                                         </font>
97
98 <tr>
99         <td colspan='3' height='60%' valign="bottom" align="right">
100                 <font face="verdana,arial,sans serif" color="#656565" size="1">Web Filtering by
101                 </font>
102                 <a href="http://www.ipfire.eu" target="_blank"><b>
103                 <font face="verdana,arial,sans serif" color="#656565" size="1">IPFire</b></a>
104                 </font>
105
106 </table>
107 </body>
108
109 </html>
110 END
111 ;
112
113 sub 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 }