diff options
author | jim-p <jimp@pfsense.org> | 2015-08-25 14:41:42 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2015-08-25 14:41:42 -0400 |
commit | d2ecbddc79a9b67cae52fca6cd3b7bebd758b047 (patch) | |
tree | de3178137611050d9516f12255208847a1cfae85 /src/usr/local/captiveportal | |
parent | 5240564c054781330437c1767d61114d33bf7bb8 (diff) | |
download | pfsense-d2ecbddc79a9b67cae52fca6cd3b7bebd758b047.zip pfsense-d2ecbddc79a9b67cae52fca6cd3b7bebd758b047.tar.gz |
For captive portal, if a user reloads index.php of the portal while already logged in, show the logout page instead if it's custom.
Must be a custom logout page that does not include a redirect.
Diffstat (limited to 'src/usr/local/captiveportal')
-rw-r--r-- | src/usr/local/captiveportal/index.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/usr/local/captiveportal/index.php b/src/usr/local/captiveportal/index.php index d450233..b851e91 100644 --- a/src/usr/local/captiveportal/index.php +++ b/src/usr/local/captiveportal/index.php @@ -71,8 +71,25 @@ if (!$clientip) { return; } +$cpsession = captiveportal_isip_logged($clientip); $ourhostname = portal_hostname_from_client_ip($clientip); -if ($orig_host != $ourhostname) { +/* Automatically switching to the logout page requires a custom logout page to be present. */ +if ((!empty($cpsession)) && (! $_POST['logout_id']) && (!empty($cpcfg['page']['logouttext']))) { + /* if client already logged in so show logout page */ + $protocol = (isset($config['captiveportal'][$cpzone]['httpslogin'])) ? 'https://' : 'http://'; + $logouturl = "{$protocol}{$ourhostname}/"; + + $sessionid = $cpsession['sessionid']; + $attributes = array(); + if (!empty($cpsession['session_timeout'])) + $attributes['session_timeout'] = $cpsession['session_timeout']; + if (!empty($cpsession['session_terminate_time'])) + $attributes['session_terminate_time'] = $cpsession['session_terminate_time']; + + include("{$g['varetc_path']}/captiveportal-{$cpzone}-logout.html"); + ob_flush(); + return; +} else 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... */ $protocol = (isset($cpcfg['httpslogin'])) ? 'https://' : 'http://'; |