]>
git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - html/html/redirect.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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. #
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. #
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/>. #
20 ###############################################################################
26 my $swroot="/var/ipfire";
27 my $templateroot = "/srv/web/ipfire/html/redirect-templates";
32 &readhash
("$swroot/ethernet/settings", \
%netsettings);
33 &readhash
("$swroot/urlfilter/settings", \
%filtersettings);
35 # Read the template file.
36 my $template = $filtersettings{'REDIRECT_TEMPLATE'};
37 if (($template eq '') || (! -e
"$templateroot/$template")) {
40 my $tmpl = HTML
::Template
->new(
41 filename
=> "$templateroot/$template/template.html",
42 die_on_bad_params
=> 0
45 # Address where to load more resources from.
46 $tmpl->param(ADDRESS
=> "http://$netsettings{'GREEN_ADDRESS'}:81");
49 my $msgtext1 = $filtersettings{'MSG_TEXT_1'};
50 if ($msgtext1 eq '') {
51 $msgtext1 = "A C C E S S D E N I E D";
53 $tmpl->param(MSG_TEXT_1
=> $msgtext1);
56 my $msgtext2 = $filtersettings{'MSG_TEXT_2'};
57 if ($msgtext2 eq '') {
58 $msgtext2 = "Access to the requested page has been denied";
60 $tmpl->param(MSG_TEXT_2
=> $msgtext2);
63 my $msgtext3 = $filtersettings{'MSG_TEXT_3'};
64 if ($msgtext3 eq '') {
65 $msgtext3 = "Please contact the Network Administrator if you think there has been an error";
67 $tmpl->param(MSG_TEXT_3
=> $msgtext3);
70 my $category = CGI
::param
("category");
71 $tmpl->param(CATEGORY
=> &escape
($category));
74 my $url = CGI
::param
("url");
75 $tmpl->param(URL
=> &escape
($url));
78 my $ip_address = CGI
::param
("ip");
79 $tmpl->param(IP_ADDRESS
=> &escape
($ip_address));
82 print "Pragma: no-cache\n";
83 print "Cache-control: no-cache\n";
84 print "Connection: close\n";
85 print "Content-type: text/html\n\n";
90 return HTML
::Entities
::encode_entities
($s);
99 open(FILE
, $filename) or die "Unable to read file $filename";
102 ($var, $val) = split /=/, $_, 2;
107 # Untaint variables read from hash
108 $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
109 $val =~ /([\w\W]*)/; $val = $1;
110 $hash->{$var} = $val;