diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-05-21 21:44:38 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-05-21 21:44:58 +0000 |
commit | f8b1131038f1a8ced102c79ed6c72ef9dc05e6f1 (patch) | |
tree | af5965311271a555f903685cbb586a40aed64ff9 /usr/local | |
parent | 868a5b990ab32dbea625c254a6daa264086fd08b (diff) | |
download | pfsense-f8b1131038f1a8ced102c79ed6c72ef9dc05e6f1.zip pfsense-f8b1131038f1a8ced102c79ed6c72ef9dc05e6f1.tar.gz |
Make CP multi-interface capable.
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/captiveportal/index.php | 31 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal.php | 10 |
2 files changed, 30 insertions, 11 deletions
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php index eab9763..3771bf9 100755 --- a/usr/local/captiveportal/index.php +++ b/usr/local/captiveportal/index.php @@ -49,8 +49,13 @@ if (!$clientip) { if (isset($config['captiveportal']['httpslogin'])) $ourhostname = $config['captiveportal']['httpsname'] . ":8001"; -else - $ourhostname = get_interface_ip($config['captiveportal']['interface']) . ":8000"; +else { + $ifip = portal_ip_from_client_ip($clientip); + if (!$ifip) + $ourhostname = $config['system']['hostname'] . ":8000"; + else + $ourhostname = "{$ifip}:8000"; +} if ($orig_host != $ourhostname) { /* the client thinks it's connected to the desired web server, but instead @@ -84,7 +89,7 @@ if (!$clientmac && $macfilter) { /* find out if we need RADIUS + RADIUSMAC or not */ if (file_exists("{$g['vardb_path']}/captiveportal_radius.db")) { $radius_enable = TRUE; - if ($radius_enable && isset($config['captiveportal']['radmac_enable'])) + if (isset($config['captiveportal']['radmac_enable'])) $radmac_enable = TRUE; } @@ -167,8 +172,14 @@ function portal_reply_page($redirurl, $type = null, $message = null, $clientmac /* substitute other variables */ if (isset($config['captiveportal']['httpslogin'])) $htmltext = str_replace("\$PORTAL_ACTION\$", "https://{$config['captiveportal']['httpsname']}:8001/", $htmltext); - else - $htmltext = str_replace("\$PORTAL_ACTION\$", "http://" . get_interface_ip($config['captiveportal']['interface']) . ":8000/", $htmltext); + else { + $ifip = portal_ip_from_client_ip($clientip); + if (!$ifip) + $ourhostname = $config['system']['hostname'] . ":8000"; + else + $ourhostname = "{$ifip}:8000"; + $htmltext = str_replace("\$PORTAL_ACTION\$", "http://{$ourhostname}/", $htmltext); + } $htmltext = str_replace("\$PORTAL_REDIRURL\$", htmlspecialchars($redirurl), $htmltext); $htmltext = str_replace("\$PORTAL_MESSAGE\$", htmlspecialchars($message), $htmltext); @@ -320,8 +331,14 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut if (isset($config['captiveportal']['httpslogin'])) $logouturl = "https://{$config['captiveportal']['httpsname']}:8001/"; - else - $logouturl = "http://" . get_interface_ip($config['captiveportal']['interface']) . ":8000/"; + else { + $ifip = portal_ip_from_client_ip($clientip); + if (!$ifip) + $ourhostname = $config['system']['hostname'] . ":8000"; + else + $ourhostname = "{$ifip}:8000"; + $logouturl = "http://{$ourhostname}/"; + } echo <<<EOD <HTML> diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php index 7d5a73d..bc07fb2 100755 --- a/usr/local/www/services_captiveportal.php +++ b/usr/local/www/services_captiveportal.php @@ -149,7 +149,7 @@ if ($_POST) { } if (!$input_errors) { - $config['captiveportal']['interface'] = $_POST['cinterface']; + $config['captiveportal']['interface'] = implode(",", $_POST['cinterface']); $config['captiveportal']['maxproc'] = $_POST['maxproc']; $config['captiveportal']['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false; $config['captiveportal']['timeout'] = $_POST['timeout']; @@ -194,6 +194,8 @@ if ($_POST) { $retval = captiveportal_configure(); $savemsg = get_std_save_message($retval); + + $pconfig['cinterface'] = implode(",", $_POST['cinterface']); } } include("head.inc"); @@ -276,16 +278,16 @@ function enable_change(enable_change) { <tr> <td width="22%" valign="top" class="vncellreq">Interface</td> <td width="78%" class="vtable"> - <select name="cinterface" class="formselect" id="cinterface"> + <select name="cinterface[]" multiple="true" size="3" class="formselect" id="cinterface"> <?php $interfaces = get_configured_interface_with_descr(); foreach ($interfaces as $iface => $ifacename): ?> - <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>> + <option value="<?=$iface;?>" <?php if (stristr($pconfig['cinterface'], $iface)) echo "selected"; ?>> <?=htmlspecialchars($ifacename);?> </option> <?php endforeach; ?> </select> <br> - <span class="vexpl">Choose which interface to run the captive portal on.</span></td> + <span class="vexpl">Choose which interface(s) to run the captive portal on.</span></td> </tr> <tr> <td valign="top" class="vncell">Maximum concurrent connections</td> |