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