. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* pfSense_MODULE: captiveportal */ ##|+PRIV ##|*IDENT=page-services-captiveportal ##|*NAME=Services: Captive portal page ##|*DESCR=Allow access to the 'Services: Captive portal' page. ##|*MATCH=services_captiveportal.php* ##|-PRIV $statusurl = "status_captiveportal.php"; $logurl = "diag_logs_auth.php"; require("guiconfig.inc"); require("functions.inc"); require("filter.inc"); require("shaper.inc"); require("captiveportal.inc"); $pgtitle = array(gettext("Services"),gettext("Captive portal")); if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); $config['captiveportal']['page'] = array(); $config['captiveportal']['timeout'] = 60; } if ($_GET['act'] == "viewhtml") { echo base64_decode($config['captiveportal']['page']['htmltext']); exit; } else if ($_GET['act'] == "viewerrhtml") { echo base64_decode($config['captiveportal']['page']['errtext']); exit; } else if ($_GET['act'] == "viewlogouthtml") { echo base64_decode($config['captiveportal']['page']['logouttext']); exit; } $pconfig['cinterface'] = $config['captiveportal']['interface']; $pconfig['maxproc'] = $config['captiveportal']['maxproc']; $pconfig['maxprocperip'] = $config['captiveportal']['maxprocperip']; $pconfig['timeout'] = $config['captiveportal']['timeout']; $pconfig['idletimeout'] = $config['captiveportal']['idletimeout']; $pconfig['freelogins_count'] = $config['captiveportal']['freelogins_count']; $pconfig['freelogins_resettimeout'] = $config['captiveportal']['freelogins_resettimeout']; $pconfig['freelogins_updatetimeouts'] = isset($config['captiveportal']['freelogins_updatetimeouts']); $pconfig['enable'] = isset($config['captiveportal']['enable']); $pconfig['auth_method'] = $config['captiveportal']['auth_method']; $pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']); $pconfig['radmac_enable'] = isset($config['captiveportal']['radmac_enable']); $pconfig['radmac_secret'] = $config['captiveportal']['radmac_secret']; $pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']); $pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct']; $pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']); $pconfig['httpsname'] = $config['captiveportal']['httpsname']; $pconfig['preauthurl'] = strtolower($config['captiveportal']['preauthurl']); $pconfig['cert'] = base64_decode($config['captiveportal']['certificate']); $pconfig['cacert'] = base64_decode($config['captiveportal']['cacertificate']); $pconfig['key'] = base64_decode($config['captiveportal']['private-key']); $pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']); $pconfig['peruserbw'] = isset($config['captiveportal']['peruserbw']); $pconfig['bwdefaultdn'] = $config['captiveportal']['bwdefaultdn']; $pconfig['bwdefaultup'] = $config['captiveportal']['bwdefaultup']; $pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']); $pconfig['noconcurrentlogins'] = isset($config['captiveportal']['noconcurrentlogins']); $pconfig['redirurl'] = $config['captiveportal']['redirurl']; $pconfig['radiusip'] = $config['captiveportal']['radiusip']; $pconfig['radiusip2'] = $config['captiveportal']['radiusip2']; $pconfig['radiusport'] = $config['captiveportal']['radiusport']; $pconfig['radiusport2'] = $config['captiveportal']['radiusport2']; $pconfig['radiusacctport'] = $config['captiveportal']['radiusacctport']; $pconfig['radiuskey'] = $config['captiveportal']['radiuskey']; $pconfig['radiuskey2'] = $config['captiveportal']['radiuskey2']; $pconfig['radiusvendor'] = $config['captiveportal']['radiusvendor']; $pconfig['radiussession_timeout'] = isset($config['captiveportal']['radiussession_timeout']); $pconfig['radiussrcip_attribute'] = $config['captiveportal']['radiussrcip_attribute']; $pconfig['passthrumacadd'] = isset($config['captiveportal']['passthrumacadd']); $pconfig['passthrumacaddusername'] = isset($config['captiveportal']['passthrumacaddusername']); $pconfig['radmac_format'] = $config['captiveportal']['radmac_format']; if ($_POST) { unset($input_errors); $pconfig = $_POST; /* input validation */ if ($_POST['enable']) { $reqdfields = explode(" ", "cinterface"); $reqdfieldsn = array(gettext("Interface")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); /* make sure no interfaces are bridged */ if (is_array($_POST['cinterface'])) foreach ($pconfig['cinterface'] as $cpbrif) if (link_interface_to_bridge($cpbrif)) $input_errors[] = sprintf(gettext("The captive portal cannot be used on interface %s since it is part of a bridge."), $cpbrif); if ($_POST['httpslogin_enable']) { if (!$_POST['cert'] || !$_POST['key']) { $input_errors[] = gettext("Certificate and key must be specified for HTTPS login."); } else { if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE")) $input_errors[] = gettext("This certificate does not appear to be valid."); if (!strstr($_POST['cacert'], "BEGIN CERTIFICATE") || !strstr($_POST['cacert'], "END CERTIFICATE")) $input_errors[] = gettext("This intermmediate certificate does not appear to be valid."); if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY")) $input_errors[] = gettext("This key does not appear to be valid."); } if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) { $input_errors[] = gettext("The HTTPS server name must be specified for HTTPS login."); } } } if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) { $input_errors[] = gettext("The timeout must be at least 1 minute."); } if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) { $input_errors[] = gettext("The idle timeout must be at least 1 minute."); } if ($_POST['freelogins_count'] && (!is_numeric($_POST['freelogins_count']))) { $input_errors[] = gettext("The pass-through credit count must be a number or left blank."); } else if ($_POST['freelogins_count'] && is_numeric($_POST['freelogins_count']) && ($_POST['freelogins_count'] >= 1)) { if (empty($_POST['freelogins_resettimeout']) || !is_numeric($_POST['freelogins_resettimeout']) || ($_POST['freelogins_resettimeout'] <= 0)) { $input_errors[] = gettext("The waiting period to restore pass-through credits must be above 0 hours."); } } if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) { $input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip']); } if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) { $input_errors[] = sprintf(gettext("A valid IP address must be specified. [%s]"), $_POST['radiusip2']); } if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport']); } if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusport2']); } if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) { $input_errors[] = sprintf(gettext("A valid port number must be specified. [%s]"), $_POST['radiusacctport']); } if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) { $input_errors[] = gettext("The total maximum number of concurrent connections must be between 4 and 100."); } $mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16; if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) { $input_errors[] = gettext("The maximum number of concurrent connections per client IP address may not be larger than the global maximum."); } if (!$input_errors) { if (is_array($_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']; $config['captiveportal']['idletimeout'] = $_POST['idletimeout']; $config['captiveportal']['freelogins_count'] = $_POST['freelogins_count']; $config['captiveportal']['freelogins_resettimeout'] = $_POST['freelogins_resettimeout']; $config['captiveportal']['freelogins_updatetimeouts'] = $_POST['freelogins_updatetimeouts'] ? true : false; $config['captiveportal']['enable'] = $_POST['enable'] ? true : false; $config['captiveportal']['auth_method'] = $_POST['auth_method']; $config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false; $config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false; $config['captiveportal']['radmac_enable'] = $_POST['radmac_enable'] ? true : false; $config['captiveportal']['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false; $config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct']; $config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false; $config['captiveportal']['httpsname'] = $_POST['httpsname']; $config['captiveportal']['preauthurl'] = $_POST['preauthurl']; $config['captiveportal']['peruserbw'] = $_POST['peruserbw'] ? true : false; $config['captiveportal']['bwdefaultdn'] = $_POST['bwdefaultdn']; $config['captiveportal']['bwdefaultup'] = $_POST['bwdefaultup']; $config['captiveportal']['certificate'] = base64_encode($_POST['cert']); $config['captiveportal']['cacertificate'] = base64_encode($_POST['cacert']); $config['captiveportal']['private-key'] = base64_encode($_POST['key']); $config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false; $config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false; $config['captiveportal']['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false; $config['captiveportal']['redirurl'] = $_POST['redirurl']; $config['captiveportal']['radiusip'] = $_POST['radiusip']; $config['captiveportal']['radiusip2'] = $_POST['radiusip2']; $config['captiveportal']['radiusport'] = $_POST['radiusport']; $config['captiveportal']['radiusport2'] = $_POST['radiusport2']; $config['captiveportal']['radiusacctport'] = $_POST['radiusacctport']; $config['captiveportal']['radiuskey'] = $_POST['radiuskey']; $config['captiveportal']['radiuskey2'] = $_POST['radiuskey2']; $config['captiveportal']['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false; $config['captiveportal']['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false; $config['captiveportal']['radiussrcip_attribute'] = $_POST['radiussrcip_attribute']; $config['captiveportal']['passthrumacadd'] = $_POST['passthrumacadd'] ? true : false; $config['captiveportal']['passthrumacaddusername'] = $_POST['passthrumacaddusername'] ? true : false; $config['captiveportal']['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false; /* file upload? */ if (is_uploaded_file($_FILES['htmlfile']['tmp_name'])) $config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name'])); if (is_uploaded_file($_FILES['errfile']['tmp_name'])) $config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name'])); if (is_uploaded_file($_FILES['logoutfile']['tmp_name'])) $config['captiveportal']['page']['logouttext'] = base64_encode(file_get_contents($_FILES['logoutfile']['tmp_name'])); write_config(); $retval = 0; $retval = captiveportal_configure(); $savemsg = get_std_save_message($retval); if (is_array($_POST['cinterface'])) $pconfig['cinterface'] = implode(",", $_POST['cinterface']); filter_configure(); } } include("head.inc"); ?>
  onClick="enable_change(false)">





>
>


>
>
>


>
>


>
>
>
   


  

  
  >

  >
>
>
>
  >

>



00:11:22:33:44:55
001122-334455
00-11-22-33-44-55
0011.2233.4455
001122334455
>









<form method="post" action="$PORTAL_ACTION$">
   <input name="auth_user" type="text">
   <input name="auth_pass" type="password">
   <input name="auth_voucher" type="text">
   <input name="redirurl" type="hidden" value="$PORTAL_REDIRURL$">
   <input name="accept" type="submit" value="Continue">
</form>





"$PORTAL_MESSAGE$",





  " onClick="enable_change(true)">