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_BUILDER_BINARIES: /usr/local/bin/voucher pfSense_MODULE: captiveportal */ ##|+PRIV ##|*IDENT=page-services-captiveportal-vouchers ##|*NAME=Services: Captive portal Vouchers page ##|*DESCR=Allow access to the 'Services: Captive portal Vouchers' page. ##|*MATCH=services_captiveportal_vouchers.php* ##|-PRIV $statusurl = "status_captiveportal_vouchers.php"; $logurl = "diag_logs_auth.php"; require("guiconfig.inc"); require("functions.inc"); require("filter.inc"); require("shaper.inc"); require("captiveportal.inc"); require_once("voucher.inc"); if($_REQUEST['generatekey']) { exec("openssl genrsa 64 > /tmp/key64.private"); exec("openssl rsa -pubout < /tmp/key64.private > /tmp/key64.public"); $privatekey = str_replace("\n", "\\n", file_get_contents("/tmp/key64.private")); $publickey = str_replace("\n", "\\n", file_get_contents("/tmp/key64.public")); exec("rm /tmp/key64.private /tmp/key64.public"); $alertmessage = gettext("You will need to recreate any existing Voucher Rolls due to the public and private key changes. Click cancel if you do not wish to recreate the vouchers."); echo <<0)) $input_errors[] = gettext("Double quotes aren't allowed."); if ($_POST['charset'] && (strpos($_POST['charset'],",")>0)) $input_errors[] = "',' " . gettext("aren't allowed."); if ($_POST['rollbits'] && (!is_numeric($_POST['rollbits']) || ($_POST['rollbits'] < 1) || ($_POST['rollbits'] > 31))) $input_errors[] = gettext("# of Bits to store Roll Id needs to be between 1..31."); if ($_POST['ticketbits'] && (!is_numeric($_POST['ticketbits']) || ($_POST['ticketbits'] < 1) || ($_POST['ticketbits'] > 16))) $input_errors[] = gettext("# of Bits to store Ticket Id needs to be between 1..16."); if ($_POST['checksumbits'] && (!is_numeric($_POST['checksumbits']) || ($_POST['checksumbits'] < 1) || ($_POST['checksumbits'] > 31))) $input_errors[] = gettext("# of Bits to store checksum needs to be between 1..31."); if ($_POST['saveinterval'] && (!is_numeric($_POST['saveinterval']) || ($_POST['saveinterval'] < 1))) $input_errors[] = gettext("Save interval in minutes cant be negative."); if ($_POST['publickey'] && (!strstr($_POST['publickey'],"BEGIN PUBLIC KEY"))) $input_errors[] = gettext("This doesn't look like an RSA Public key."); if ($_POST['privatekey'] && (!strstr($_POST['privatekey'],"BEGIN RSA PRIVATE KEY"))) $input_errors[] = gettext("This doesn't look like an RSA Private key."); if (!$input_errors) { $config['voucher']['enable'] = $_POST['enable'] ? true : false; $config['voucher']['charset'] = $_POST['charset']; $config['voucher']['rollbits'] = $_POST['rollbits']; $config['voucher']['ticketbits'] = $_POST['ticketbits']; $config['voucher']['checksumbits'] = $_POST['checksumbits']; $config['voucher']['magic'] = $_POST['magic']; $config['voucher']['saveinterval'] = $_POST['saveinterval']; $config['voucher']['publickey'] = base64_encode($_POST['publickey']); $config['voucher']['privatekey'] = base64_encode($_POST['privatekey']); $config['voucher']['msgnoaccess'] = $_POST['msgnoaccess']; $config['voucher']['msgexpired'] = $_POST['msgexpired']; $config['voucher']['vouchersyncdbip'] = $_POST['vouchersyncdbip']; $config['voucher']['vouchersyncport'] = $_POST['vouchersyncport']; $config['voucher']['vouchersyncusername'] = $_POST['vouchersyncusername']; $config['voucher']['vouchersyncpass'] = $_POST['vouchersyncpass']; if($config['voucher']['vouchersyncpass'] && $config['voucher']['vouchersyncusername'] && $config['voucher']['vouchersyncport'] && $config['voucher']['vouchersyncdbip']) { // Synchronize the voucher DB from the master node require_once("xmlrpc.inc"); if($config['voucher']['vouchersyncport'] == "443") $url = "https://{$config['voucher']['vouchersyncdbip']}:{$config['voucher']['vouchersyncport']}"; else $url = "http://{$config['voucher']['vouchersyncdbip']}:{$config['voucher']['vouchersyncport']}"; $execcmd = <<setCredentials($config['voucher']['vouchersyncusername'], $config['voucher']['vouchersyncpass']); $resp = $cli->send($msg, "250"); if(!$resp) { $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); $input_errors[] = $error; } elseif($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, "250"); $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); $input_errors[] = $error; } else { log_error("The Captive Portal voucher database has been synchronized with {$url}:{$port} (pfsense.exec_php)."); } $toreturn = XML_RPC_Decode($resp->value()); if(!is_array($toreturn)) { if($toreturn == "Authentication failed") $input_errors[] = "Could not synchronize the voucher database: Authentication Failed."; } else { // If we received back the voucher roll and other information then store it. if($toreturn['voucher']['roll']) $config['voucher']['roll'] = $toreturn['voucher']['roll']; if($toreturn['voucher']['rollbits']) $config['voucher']['rollbits'] = $toreturn['voucher']['rollbits']; if($toreturn['voucher']['ticketbits']) $config['voucher']['ticketbits'] = $toreturn['voucher']['ticketbits']; if($toreturn['voucher']['saveinterval']) $config['voucher']['saveinterval'] = $toreturn['voucher']['saveinterval']; if($toreturn['voucher']['checksumbits']) $config['voucher']['checksumbits'] = $toreturn['voucher']['checksumbits']; if($toreturn['voucher']['magic']) $config['voucher']['magic'] = $toreturn['voucher']['magic']; if($toreturn['voucher']['publickey']) $config['voucher']['publickey'] = $toreturn['voucher']['publickey']; if($toreturn['voucher']['privatekey']) $config['voucher']['privatekey'] = $toreturn['voucher']['privatekey']; if($toreturn['voucher']['msgnoaccess']) $config['voucher']['msgnoaccess'] = $toreturn['voucher']['msgnoaccess']; if($toreturn['voucher']['msgexpired']) $config['voucher']['msgexpired'] = $toreturn['voucher']['msgexpired']; if($toreturn['voucher']['msgnoaccess']) $config['voucher']['msgnoaccess'] = $toreturn['voucher']['msgnoaccess']; $savemsg = gettext("Voucher database has been synchronized from {$url}"); } } write_config(); voucher_configure(); if($savemsg && isset($config['voucher']['enable']) && !isset($config['captiveportal']['enable'])) $savemsg .= "
"; if (isset($config['voucher']['enable']) && !isset($config['captiveportal']['enable'])) $savemsg .= gettext("Don't forget to configure and enable Captive Portal."); } } include("head.inc"); ?>
  onClick="enable_change(false)">
(Synchronized from {$pconfig['vouchersyncdbip']})"; ?>
\""
"; ?>
# #
       

.

.

#
#
#



($PORTAL_MESSAGE$).

($PORTAL_MESSAGE$).
   




  " onClick="enable_change(true); before_save();"> " onclick="history.back()">