diff options
author | bcyrill <cyrill@bannwart.info> | 2013-01-15 23:26:25 +0100 |
---|---|---|
committer | bcyrill <cyrill@bannwart.info> | 2013-01-15 23:26:25 +0100 |
commit | de132ae3ac9ae89e9c18113b879273d5eb3bf2b8 (patch) | |
tree | ecf3d485f70143adec269dc12f75548e3202e922 /usr | |
parent | a74260cb3f4811212d6fb4d5ebc0b231bdfa52a6 (diff) | |
download | pfsense-de132ae3ac9ae89e9c18113b879273d5eb3bf2b8.zip pfsense-de132ae3ac9ae89e9c18113b879273d5eb3bf2b8.tar.gz |
Add portal_hostname_from_client_ip function
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/captiveportal/index.php | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php index 2782cdf..29bf068 100755 --- a/usr/local/captiveportal/index.php +++ b/usr/local/captiveportal/index.php @@ -61,35 +61,17 @@ if (!$clientip) { return; } -$listenporthttps = $cpcfg['listenporthttps'] ? $cpcfg['listenporthttps'] : ($cpcfg['zoneid'] + 1); -$listenporthttp = $cpcfg['listenporthttp'] ? $cpcfg['listenporthttp'] : $cpcfg['zoneid']; - -if (isset($cpcfg['httpslogin'])) - $ourhostname = $cpcfg['httpsname'] . ":" . $listenporthttps; -else { - $ifip = portal_ip_from_client_ip($clientip); - if (!$ifip) { - $ourhostname = "{$config['system']['hostname']}.{$config['system']['domain']}:{$listenporthttp}"; - } else { - if (is_ipaddrv6($ifip)) - $ourhostname = "[{$ifip}]:{$listenporthttp}"; - else - $ourhostname = "{$ifip}:{$listenporthttp}"; - } -} - +$ourhostname = portal_hostname_from_client_ip($clientip); if ($orig_host != $ourhostname) { - /* the client thinks it's connected to the desired web server, but instead - it's connected to us. Issue a redirect... */ + /* the client thinks it's connected to the desired web server, but instead + it's connected to us. Issue a redirect... */ + $protocol = (isset($cpcfg['httpslogin'])) ? 'https://' : 'http://'; + header("Location: {$protocol}{$ourhostname}/index.php?zone={$cpzone}&redirurl=" . urlencode("http://{$orig_host}/{$orig_request}")); - if (isset($cpcfg['httpslogin'])) - header("Location: https://{$ourhostname}/index.php?zone={$cpzone}&redirurl=" . urlencode("http://{$orig_host}/{$orig_request}")); - else - header("Location: http://{$ourhostname}/index.php?zone={$cpzone}&redirurl=" . urlencode("http://{$orig_host}/{$orig_request}")); - - ob_flush(); - return; + ob_flush(); + return; } + if (!empty($cpcfg['redirurl'])) $redirurl = $cpcfg['redirurl']; else if (preg_match("/redirurl=(.*)/", $orig_request, $matches)) |