Direkt ein Fix fuer eben genannte Sachen...
[ipfire-2.x.git] / html / html / redirect.cgi
CommitLineData
10e4f239
MT
1#!/usr/bin/perl
2
3#
20e891c6 4# $Id: redirect.cgi,v 0.3 2006/07/18 00:00:00 modyfy bye linuxadmin
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
47END
48;
49
20e891c6 50if (($filtersettings{'ENABLE_JPEG'} eq 'on') && (-e "/home/httpd/html/images/urlfilter/logo_ipfire.gif"))
10e4f239
MT
51{
52print <<END
20e891c6 53<body background="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/logo_ipfire.gif" bgcolor="#FFFFFF">
10e4f239
MT
54END
55;
56} else {
57print <<END
40a4ea4c
MT
58<img src="http://$netsettings{'GREEN_ADDRESS'}:81//images/logo_ipfire.gif" ALT="IPFire-Logo">
59<body bgcolor="#455B72">
10e4f239
MT
60END
61;
62}
63
64print <<END
65
10e4f239 66
40a4ea4c 67<center>
10e4f239 68
40a4ea4c 69<table width="80%" cellspacing="10" cellpadding="5" border="1">
10e4f239 70<tr>
40a4ea4c
MT
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>
10e4f239
MT
74 </font>
75 </td>
76</tr>
77<tr>
78 <td bgcolor="#F4F4F4" align="center">
40a4ea4c 79 <table width="100%" cellspacing="20" cellpadding="18" border="1">
10e4f239 80 <tr>
40a4ea4c
MT
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">
10e4f239
MT
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">
93END
94;
95
96if (!($url eq ""))
97{
98print <<END
99 <p>URL: <a href="$url">$url</a>
100END
101;
102}
103
104if (!($ip eq ""))
105{
106print <<END
107 <p>Client IP address: <i>$ip</i>
108END
109;
110}
111
112print <<END
113 <br><p>$msgtext3
114 </font>
115 </td>
116 </tr>
117 </td>
118</tr>
119</table>
120
121<tr>
40a4ea4c
MT
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
10e4f239 124 </font>
40a4ea4c
MT
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
10e4f239 127 <a href="http://www.squidguard.org" target="_blank"><b>
40a4ea4c 128 <font face="verdana,arial,sans serif" color="#656565" size="1">SquidGuard
10e4f239
MT
129 </font></b></a>
130 </td>
131</tr>
132
133</table>
134
40a4ea4c 135<img src="http://$netsettings{'GREEN_ADDRESS'}:81//images/urlfilter/bg_cool_tux.jpg">
10e4f239
MT
136</center>
137
138</body>
139
140</html>
141END
142;
143
144sub 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}