Fix dahdi firmware download.
[people/pmueller/ipfire-2.x.git] / html / html / redirect.cgi
CommitLineData
10e4f239 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
10e4f239
MT
21
22use CGI qw(param);
23
24$swroot="/var/ipfire";
25
26my %netsettings;
27my %filtersettings;
28
29&readhash("$swroot/ethernet/settings", \%netsettings);
30&readhash("$swroot/urlfilter/settings", \%filtersettings);
31
32$category=param("category");
33$url=param("url");
34$ip=param("ip");
35
10e4f239
MT
36if ($filtersettings{'MSG_TEXT_1'} eq '') {
37 $msgtext1 = "A C C E S S &nbsp;&nbsp; D E N I E D";
38} else { $msgtext1 = $filtersettings{'MSG_TEXT_1'}; }
39if ($filtersettings{'MSG_TEXT_2'} eq '') {
40 $msgtext2 = "Access to the requested page has been denied";
41} else { $msgtext2 = $filtersettings{'MSG_TEXT_2'}; }
42if ($filtersettings{'MSG_TEXT_3'} eq '') {
43 $msgtext3 = "Please contact the Network Administrator if you think there has been an error";
44} else { $msgtext3 = $filtersettings{'MSG_TEXT_3'}; }
45
46if ($category eq '') { $category = '&nbsp;'; } else { $category = '['.$category.']'; }
47
48print "Pragma: no-cache\n";
49print "Cache-control: no-cache\n";
50print "Connection: close\n";
51print "Content-type: text/html\n\n";
52
53print <<END
40a4ea4c 54
10e4f239
MT
55<html>
56<head>
40a4ea4c 57<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
10e4f239 58<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
40a4ea4c 59<title>ACCESS MESSAGE</title>
10e4f239
MT
60</head>
61
5e773594
MT
62<body>
63<table width="100%" height='100%' border="0">
64<tr>
f1baee3e 65 <td colspan='3' width='100%' height='130' align="center" background="http://$netsettings{'GREEN_ADDRESS'}:81/images/background.gif">
5e773594
MT
66<tr> <td width='10%'><td align='center' bgcolor='#CC000000' width='80%'><font face="verdana, arial, sans serif" color="#FFFFFF" size="5">
67 <b>$msgtext1</b>
68 </font>
69 <td width='10%'>
10e4f239
MT
70END
71;
72
5e773594 73if (!($category eq ""))
10e4f239 74{
5e773594
MT
75 print <<END
76 <tr> <td colspan='3' align='center'>
77 <font face="verdana, arial, sans serif" color="#CC000000" size="1">
78 <b>$category</b>
79 </font>
10e4f239
MT
80END
81;
82}
10e4f239 83print <<END
10e4f239 84<tr>
5e773594
MT
85 <td colspan='3' 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">
10e4f239
MT
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>
10e4f239
MT
112
113<tr>
5e773594 114 <td colspan='3' height='60%' valign="bottom" align="right">
40a4ea4c 115 <font face="verdana,arial,sans serif" color="#656565" size="1">Web Filtering by
10e4f239 116 </font>
ed828642 117 <a href="http://www.ipfire.org" target="_blank"><b>
5e773594
MT
118 <font face="verdana,arial,sans serif" color="#656565" size="1">IPFire</b></a>
119 </font>
10e4f239
MT
120
121</table>
10e4f239
MT
122</body>
123
124</html>
125END
126;
127
128sub readhash
129{
130 my $filename = $_[0];
131 my $hash = $_[1];
132 my ($var, $val);
133
134 if (-e $filename)
135 {
136 open(FILE, $filename) or die "Unable to read file $filename";
137 while (<FILE>)
138 {
139 chop;
140 ($var, $val) = split /=/, $_, 2;
141 if ($var)
142 {
143 $val =~ s/^\'//g;
144 $val =~ s/\'$//g;
145
146 # Untaint variables read from hash
147 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
148 $val =~ /([\w\W]*)/; $val = $1;
149 $hash->{$var} = $val;
150 }
151 }
152 close FILE;
153 }
154}