]>
git.ipfire.org Git - people/fbuehrle/ipfire-2.x.git/blob - html/html/captive/index.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2016 Alexander Marx alexander.marx@ipfire.org #
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 ###############################################################################
24 use CGI
::Carp
qw(fatalsToBrowser);
26 require '/var/ipfire/general-functions.pl';
28 my $url = "http://$ENV{'SERVER_NAME'}$ENV{'REQUEST_URI'}";
29 my $safe_url = uri_escape
($url);
30 my $settings="${General::swroot}/captive/settings";
31 my $ethernet="${General::swroot}/ethernet/settings";
40 &General
::readhash
("$settings", \
%settingshash) if(-f
$settings);
41 &General
::readhash
("$ethernet", \
%ethernethash) if(-f
$ethernet);
43 #Get Clients IP-Address
44 my $ip_address = $ENV{X_FORWARDED_FOR
} || $ENV{REMOTE_ADDR
} ||"";
46 if($settingshash{'ENABLE_GREEN'} eq "on" && $ethernethash{'GREEN_ADDRESS'} ne ''){
47 $green_ip=$ethernethash{'GREEN_ADDRESS'};
48 $green_mask=$ethernethash{'GREEN_NETMASK'};
50 if (&General
::IpInSubnet
($ip_address,$ethernethash{'GREEN_ADDRESS'},$ethernethash{'GREEN_NETMASK'})){
53 }elsif($settingshash{'ENABLE_BLUE'} eq "on" &&$ethernethash{'BLUE_ADDRESS'} ne '' ){
54 $blue_ip=$ethernethash{'BLUE_ADDRESS'};
55 $blue_mask=$ethernethash{'BLUE_NETMASK'};
57 if (&General
::IpInSubnet
($ip_address,$ethernethash{'BLUE_ADDRESS'},$ethernethash{'BLUE_NETMASK'})){
64 print "Status: 302 Moved Temporarily\n";
65 print "Location: http://$target:1013/cgi-bin/index.cgi?redirect=$safe_url\n";
66 print "Connection: close\n\n";