summaryrefslogtreecommitdiffstats
path: root/usr/local/www/services_captiveportal_vouchers.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-24 11:08:55 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-24 11:08:55 +0545
commit5fcc3079bb0f540f252477dbe26a09d0f0f712c6 (patch)
tree4939c846a2c3e53dc4ac701b7396ec0681b241f2 /usr/local/www/services_captiveportal_vouchers.php
parent88cbd0049b78bd731648be68c13e08161e5e943c (diff)
downloadpfsense-5fcc3079bb0f540f252477dbe26a09d0f0f712c6.zip
pfsense-5fcc3079bb0f540f252477dbe26a09d0f0f712c6.tar.gz
Code style www services captive portal
Diffstat (limited to 'usr/local/www/services_captiveportal_vouchers.php')
-rw-r--r--usr/local/www/services_captiveportal_vouchers.php489
1 files changed, 268 insertions, 221 deletions
diff --git a/usr/local/www/services_captiveportal_vouchers.php b/usr/local/www/services_captiveportal_vouchers.php
index 2f02802..82477b5 100644
--- a/usr/local/www/services_captiveportal_vouchers.php
+++ b/usr/local/www/services_captiveportal_vouchers.php
@@ -1,21 +1,21 @@
-<?php
+<?php
/*
services_captiveportal_vouchers.php
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
Copyright (C) 2007 Marcel Wiget <mwiget@mac.com>
- All rights reserved.
-
+ 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
@@ -39,8 +39,9 @@
##|*MATCH=services_captiveportal_vouchers.php*
##|-PRIV
-if ($_POST['postafterlogin'])
+if ($_POST['postafterlogin']) {
$nocsrf= true;
+}
require("guiconfig.inc");
require("functions.inc");
@@ -52,15 +53,16 @@ require_once("voucher.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/services_captiveportal_vouchers.php');
$cpzone = $_GET['zone'];
-if (isset($_POST['zone']))
- $cpzone = $_POST['zone'];
+if (isset($_POST['zone'])) {
+ $cpzone = $_POST['zone'];
+}
if (empty($cpzone)) {
- header("Location: services_captiveportal_zones.php");
- exit;
+ header("Location: services_captiveportal_zones.php");
+ exit;
}
-if($_REQUEST['generatekey']) {
+if ($_REQUEST['generatekey']) {
exec("/usr/bin/openssl genrsa 64 > /tmp/key64.private");
exec("/usr/bin/openssl rsa -pubout < /tmp/key64.private > /tmp/key64.public");
$privatekey = str_replace("\n", "\\n", file_get_contents("/tmp/key64.private"));
@@ -77,12 +79,14 @@ EOF;
exit;
}
-if (!is_array($config['captiveportal']))
- $config['captiveportal'] = array();
+if (!is_array($config['captiveportal'])) {
+ $config['captiveportal'] = array();
+}
$a_cp =& $config['captiveportal'];
-if (!is_array($config['voucher']))
+if (!is_array($config['voucher'])) {
$config['voucher'] = array();
+}
if (empty($a_cp[$cpzone])) {
log_error("Submission on captiveportal page with unknown zone parameter: " . htmlspecialchars($cpzone));
@@ -94,25 +98,33 @@ if (empty($a_cp[$cpzone])) {
$pgtitle = array(gettext("Services"), gettext("Captive portal"), gettext("Vouchers"), $a_cp[$cpzone]['zone']);
$shortcut_section = "captiveportal-vouchers";
-if (!is_array($config['voucher'][$cpzone]['roll']))
+if (!is_array($config['voucher'][$cpzone]['roll'])) {
$config['voucher'][$cpzone]['roll'] = array();
-if (!isset($config['voucher'][$cpzone]['charset']))
+}
+if (!isset($config['voucher'][$cpzone]['charset'])) {
$config['voucher'][$cpzone]['charset'] = '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
-if (!isset($config['voucher'][$cpzone]['rollbits']))
+}
+if (!isset($config['voucher'][$cpzone]['rollbits'])) {
$config['voucher'][$cpzone]['rollbits'] = 16;
-if (!isset($config['voucher'][$cpzone]['ticketbits']))
+}
+if (!isset($config['voucher'][$cpzone]['ticketbits'])) {
$config['voucher'][$cpzone]['ticketbits'] = 10;
-if (!isset($config['voucher'][$cpzone]['checksumbits']))
+}
+if (!isset($config['voucher'][$cpzone]['checksumbits'])) {
$config['voucher'][$cpzone]['checksumbits'] = 5;
-if (!isset($config['voucher'][$cpzone]['magic']))
+}
+if (!isset($config['voucher'][$cpzone]['magic'])) {
$config['voucher'][$cpzone]['magic'] = rand(); // anything slightly random will do
+}
if (!isset($config['voucher'][$cpzone]['exponent'])) {
while (true) {
- while (($exponent = rand()) % 30000 < 5000)
+ while (($exponent = rand()) % 30000 < 5000) {
continue;
+ }
$exponent = ($exponent * 2) + 1; // Make it odd number
- if ($exponent <= 65537)
+ if ($exponent <= 65537) {
break;
+ }
}
$config['voucher'][$cpzone]['exponent'] = $exponent;
unset($exponent);
@@ -131,31 +143,32 @@ if (!isset($config['voucher'][$cpzone]['publickey'])) {
}
// Check for invalid or expired vouchers
-if (!isset($config['voucher'][$cpzone]['descrmsgnoaccess']))
+if (!isset($config['voucher'][$cpzone]['descrmsgnoaccess'])) {
$config['voucher'][$cpzone]['descrmsgnoaccess'] = gettext("Voucher invalid");
-if (!isset($config['voucher'][$cpzone]['descrmsgexpired']))
+}
+if (!isset($config['voucher'][$cpzone]['descrmsgexpired'])) {
$config['voucher'][$cpzone]['descrmsgexpired'] = gettext("Voucher expired");
+}
$a_roll = &$config['voucher'][$cpzone]['roll'];
if ($_GET['act'] == "del") {
- $id = $_GET['id'];
- if ($a_roll[$id]) {
- $roll = $a_roll[$id]['number'];
+ $id = $_GET['id'];
+ if ($a_roll[$id]) {
+ $roll = $a_roll[$id]['number'];
$voucherlck = lock("voucher{$cpzone}");
unset($a_roll[$id]);
voucher_unlink_db($roll);
unlock($voucherlck);
write_config();
- }
+ }
header("Location: services_captiveportal_vouchers.php?zone={$cpzone}");
exit;
-}
-/* print all vouchers of the selected roll */
-else if ($_GET['act'] == "csv") {
+} else if ($_GET['act'] == "csv") {
+ /* print all vouchers of the selected roll */
$privkey = base64_decode($config['voucher'][$cpzone]['privatekey']);
- if (strstr($privkey,"BEGIN RSA PRIVATE KEY")) {
- $fd = fopen("{$g['varetc_path']}/voucher_{$cpzone}.private","w");
+ if (strstr($privkey, "BEGIN RSA PRIVATE KEY")) {
+ $fd = fopen("{$g['varetc_path']}/voucher_{$cpzone}.private", "w");
if (!$fd) {
$input_errors[] = gettext("Cannot write private key file") . ".\n";
} else {
@@ -169,11 +182,13 @@ else if ($_GET['act'] == "csv") {
$count = $a_voucher[$id]['count'];
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=vouchers_{$cpzone}_roll{$number}.csv");
- if (file_exists("{$g['varetc_path']}/voucher_{$cpzone}.cfg"))
+ if (file_exists("{$g['varetc_path']}/voucher_{$cpzone}.cfg")) {
system("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -p {$g['varetc_path']}/voucher_{$cpzone}.private $number $count");
+ }
@unlink("{$g['varetc_path']}/voucher_{$cpzone}.private");
- } else
+ } else {
header("Location: services_captiveportal_vouchers.php?zone={$cpzone}");
+ }
exit;
}
} else {
@@ -210,48 +225,59 @@ if ($_POST) {
/* input validation */
if ($_POST['enable'] == "yes") {
- if (!$_POST['vouchersyncusername']) {
+ if (!$_POST['vouchersyncusername']) {
$reqdfields = explode(" ", "charset rollbits ticketbits checksumbits publickey magic");
- $reqdfieldsn = array(gettext("charset"),gettext("rollbits"),gettext("ticketbits"),gettext("checksumbits"),gettext("publickey"),gettext("magic"));
+ $reqdfieldsn = array(gettext("charset"), gettext("rollbits"), gettext("ticketbits"), gettext("checksumbits"), gettext("publickey"), gettext("magic"));
} else {
$reqdfields = explode(" ", "vouchersyncdbip vouchersyncport vouchersyncpass vouchersyncusername");
- $reqdfieldsn = array(gettext("Synchronize Voucher Database IP"),gettext("Sync port"),gettext("Sync password"),gettext("Sync username"));
+ $reqdfieldsn = array(gettext("Synchronize Voucher Database IP"), gettext("Sync port"), gettext("Sync password"), gettext("Sync username"));
}
-
+
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
}
-
- if (!$_POST['vouchersyncusername']) {
+
+ if (!$_POST['vouchersyncusername']) {
// Check for form errors
- if ($_POST['charset'] && (strlen($_POST['charset'] < 2)))
+ if ($_POST['charset'] && (strlen($_POST['charset'] < 2))) {
$input_errors[] = gettext("Need at least 2 characters to create vouchers.");
- if ($_POST['charset'] && (strpos($_POST['charset'],"\"")>0))
+ }
+ if ($_POST['charset'] && (strpos($_POST['charset'], "\"")>0)) {
$input_errors[] = gettext("Double quotes aren't allowed.");
- if ($_POST['charset'] && (strpos($_POST['charset'],",")>0))
+ }
+ 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)))
+ }
+ 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)))
+ }
+ 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)))
+ }
+ 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['publickey'] && (!strstr($_POST['publickey'],"BEGIN PUBLIC KEY")))
+ }
+ 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")))
+ }
+ if ($_POST['privatekey'] && (!strstr($_POST['privatekey'], "BEGIN RSA PRIVATE KEY"))) {
$input_errors[] = gettext("This doesn't look like an RSA Private key.");
- if ($_POST['vouchersyncdbip'] && (is_ipaddr_configured($_POST['vouchersyncdbip'])))
+ }
+ if ($_POST['vouchersyncdbip'] && (is_ipaddr_configured($_POST['vouchersyncdbip']))) {
$input_errors[] = gettext("You cannot sync the voucher database to this host (itself).");
+ }
}
if (!$input_errors) {
- if (empty($config['voucher'][$cpzone]))
- $newvoucher = array();
- else
- $newvoucher = $config['voucher'][$cpzone];
- if ($_POST['enable'] == "yes")
+ if (empty($config['voucher'][$cpzone])) {
+ $newvoucher = array();
+ } else {
+ $newvoucher = $config['voucher'][$cpzone];
+ }
+ if ($_POST['enable'] == "yes") {
$newvoucher['enable'] = true;
- else
+ } else {
unset($newvoucher['enable']);
+ }
if (empty($_POST['vouchersyncusername'])) {
unset($newvoucher['vouchersyncdbip']);
unset($newvoucher['vouchersyncport']);
@@ -275,19 +301,21 @@ if ($_POST) {
$newvoucher['vouchersyncport'] = $_POST['vouchersyncport'];
$newvoucher['vouchersyncusername'] = $_POST['vouchersyncusername'];
$newvoucher['vouchersyncpass'] = $_POST['vouchersyncpass'];
- if($newvoucher['vouchersyncpass'] && $newvoucher['vouchersyncusername'] &&
- $newvoucher['vouchersyncport'] && $newvoucher['vouchersyncdbip']) {
+ if ($newvoucher['vouchersyncpass'] && $newvoucher['vouchersyncusername'] &&
+ $newvoucher['vouchersyncport'] && $newvoucher['vouchersyncdbip']) {
// Synchronize the voucher DB from the master node
require_once("xmlrpc.inc");
$protocol = "http";
if (is_array($config['system']) && is_array($config['system']['webgui']) && !empty($config['system']['webgui']['protocol']) &&
- $config['system']['webgui']['protocol'] == "https")
+ $config['system']['webgui']['protocol'] == "https") {
$protocol = "https";
- if ($protocol == "https" || $newvoucher['vouchersyncport'] == "443")
+ }
+ if ($protocol == "https" || $newvoucher['vouchersyncport'] == "443") {
$url = "https://{$newvoucher['vouchersyncdbip']}";
- else
+ } else {
$url = "http://{$newvoucher['vouchersyncdbip']}";
+ }
$execcmd = <<<EOF
\$toreturn = array();
@@ -307,12 +335,12 @@ EOF;
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
$cli->setCredentials($newvoucher['vouchersyncusername'], $newvoucher['vouchersyncpass']);
$resp = $cli->send($msg, "250");
- if(!is_object($resp)) {
+ if (!is_object($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()) {
+ } 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();
@@ -324,31 +352,42 @@ EOF;
}
if (!$input_errors) {
$toreturn = XML_RPC_Decode($resp->value());
- if(!is_array($toreturn)) {
- if($toreturn == "Authentication failed")
+ if (!is_array($toreturn)) {
+ if ($toreturn == "Authentication failed") {
$input_errors[] = "Could not synchronize the voucher database: Authentication Failed.";
- } else {
+ }
+ } else {
// If we received back the voucher roll and other information then store it.
- if($toreturn['voucher']['roll'])
+ if ($toreturn['voucher']['roll']) {
$newvoucher['roll'] = $toreturn['voucher']['roll'];
- if($toreturn['voucher']['rollbits'])
+ }
+ if ($toreturn['voucher']['rollbits']) {
$newvoucher['rollbits'] = $toreturn['voucher']['rollbits'];
- if($toreturn['voucher']['ticketbits'])
+ }
+ if ($toreturn['voucher']['ticketbits']) {
$newvoucher['ticketbits'] = $toreturn['voucher']['ticketbits'];
- if($toreturn['voucher']['checksumbits'])
+ }
+ if ($toreturn['voucher']['checksumbits']) {
$newvoucher['checksumbits'] = $toreturn['voucher']['checksumbits'];
- if($toreturn['voucher']['magic'])
+ }
+ if ($toreturn['voucher']['magic']) {
$newvoucher['magic'] = $toreturn['voucher']['magic'];
- if($toreturn['voucher']['exponent'])
+ }
+ if ($toreturn['voucher']['exponent']) {
$newvoucher['exponent'] = $toreturn['voucher']['exponent'];
- if($toreturn['voucher']['publickey'])
+ }
+ if ($toreturn['voucher']['publickey']) {
$newvoucher['publickey'] = $toreturn['voucher']['publickey'];
- if($toreturn['voucher']['privatekey'])
+ }
+ if ($toreturn['voucher']['privatekey']) {
$newvoucher['privatekey'] = $toreturn['voucher']['privatekey'];
- if($toreturn['voucher']['descrmsgnoaccess'])
+ }
+ if ($toreturn['voucher']['descrmsgnoaccess']) {
$newvoucher['descrmsgnoaccess'] = $toreturn['voucher']['descrmsgnoaccess'];
- if($toreturn['voucher']['descrmsgexpired'])
+ }
+ if ($toreturn['voucher']['descrmsgexpired']) {
$newvoucher['descrmsgexpired'] = $toreturn['voucher']['descrmsgexpired'];
+ }
$savemsg = gettext("Voucher database has been synchronized from {$url}:{$port}");
$config['voucher'][$cpzone] = $newvoucher;
@@ -374,10 +413,10 @@ function generatenewkey() {
jQuery('#privatekey').val('One moment please...');
jQuery.ajax("services_captiveportal_vouchers.php?zone=<?php echo($cpzone); ?>&generatekey=true", {
type: 'get',
- success: function(data) {
+ success: function(data) {
eval(data);
}
- });
+ });
}
function before_save() {
document.iform.charset.disabled = false;
@@ -389,13 +428,14 @@ function before_save() {
document.iform.privatekey.disabled = false;
document.iform.msgnoaccess.disabled = false;
document.iform.msgexpired.disabled = false;
- for(var x=0; x < <?php echo count($a_roll); ?>; x++)
+ for (var x=0; x < <?php echo count($a_roll); ?>; x++) {
jQuery('#addeditdelete' + x).show();
+ }
jQuery('#addnewroll').show();
}
function enable_change(enable_change) {
var endis;
- endis = !(document.iform.enable.checked || enable_change);
+ endis = !(document.iform.enable.checked || enable_change);
document.iform.charset.disabled = endis;
document.iform.rollbits.disabled = endis;
document.iform.ticketbits.disabled = endis;
@@ -409,7 +449,7 @@ function enable_change(enable_change) {
document.iform.vouchersyncport.disabled = endis;
document.iform.vouchersyncpass.disabled = endis;
document.iform.vouchersyncusername.disabled = endis;
- if(document.iform.vouchersyncusername.value != "") {
+ if (document.iform.vouchersyncusername.value != "") {
document.iform.charset.disabled = true;
document.iform.rollbits.disabled = true;
document.iform.ticketbits.disabled = true;
@@ -419,12 +459,14 @@ function enable_change(enable_change) {
document.iform.privatekey.disabled = true;
document.iform.msgnoaccess.disabled = true;
document.iform.msgexpired.disabled = true;
- for(var x=0; x < <?php echo count($a_roll); ?>; x++)
+ for (var x=0; x < <?php echo count($a_roll); ?>; x++) {
jQuery('#addeditdelete' + x).hide();
+ }
jQuery('#addnewroll').hide();
} else {
- for(var x=0; x < <?php echo count($a_roll); ?>; x++)
+ for (var x=0; x < <?php echo count($a_roll); ?>; x++) {
jQuery('#addeditdelete' + x).show();
+ }
jQuery('#addnewroll').show();
}
}
@@ -439,7 +481,7 @@ function enable_change(enable_change) {
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
<tr>
<td class="tabnavtbl">
-<?php
+<?php
$tab_array = array();
$tab_array[] = array(gettext("Captive portal(s)"), false, "services_captiveportal.php?zone={$cpzone}");
$tab_array[] = array(gettext("MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
@@ -448,13 +490,13 @@ function enable_change(enable_change) {
$tab_array[] = array(gettext("Vouchers"), true, "services_captiveportal_vouchers.php?zone={$cpzone}");
$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
display_top_tabs($tab_array, true);
-?>
+?>
</td>
</tr>
<tr>
<td class="tabcont">
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="checkbox pane">
- <tr>
+ <tr>
<td width="22%" valign="top" class="vtable">&nbsp;</td>
<td width="78%" class="vtable">
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
@@ -464,9 +506,10 @@ function enable_change(enable_change) {
<tr>
<td valign="top" class="vncell">
<?=gettext("Voucher Rolls"); ?>
- <?php
- if($pconfig['vouchersyncdbip'])
+ <?php
+ if ($pconfig['vouchersyncdbip']) {
echo "<br />(Synchronized from {$pconfig['vouchersyncdbip']})";
+ }
?>
</td>
<td class="vtable">
@@ -478,9 +521,9 @@ function enable_change(enable_change) {
<td width="35%" class="listhdr"><?=gettext("Comment"); ?></td>
<td width="15%" class="list"></td>
</tr>
- <?php $i = 0; foreach($a_roll as $rollent): ?>
- <tr>
- <td class="listlr">
+ <?php $i = 0; foreach ($a_roll as $rollent): ?>
+ <tr>
+ <td class="listlr">
<?=htmlspecialchars($rollent['number']); ?>&nbsp;
</td>
<td class="listr">
@@ -492,26 +535,27 @@ function enable_change(enable_change) {
<td class="listr">
<?=htmlspecialchars($rollent['descr']); ?>&nbsp;
</td>
- <td valign="middle" class="list nowrap">
+ <td valign="middle" class="list nowrap">
<div id='addeditdelete<?=$i?>'>
- <?php if ($pconfig['enable']): ?>
+ <?php if ($pconfig['enable']): ?>
<a href="services_captiveportal_vouchers_edit.php?zone=<?=$cpzone;?>&amp;id=<?=$i; ?>"><img src="/themes/<?=$g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit voucher"); ?>" width="17" height="17" border="0" alt="<?=gettext("edit voucher"); ?>" /></a>
<a href="services_captiveportal_vouchers.php?zone=<?=$cpzone;?>&amp;act=del&amp;id=<?=$i; ?>" onclick="return confirm('<?=gettext("Do you really want to delete this voucher? This makes all vouchers from this roll invalid"); ?>')"><img src="/themes/<?=$g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete vouchers"); ?>" width="17" height="17" border="0" alt="<?=gettext("delete vouchers"); ?>" /></a>
<a href="services_captiveportal_vouchers.php?zone=<?=$cpzone;?>&amp;act=csv&amp;id=<?=$i; ?>"><img src="/themes/<?=$g['theme']; ?>/images/icons/icon_log_s.gif" title="<?=gettext("generate vouchers for this roll to CSV file"); ?>" width="11" height="15" border="0" alt="<?=gettext("generate vouchers for this roll to CSV file"); ?>" /></a>
- <?php endif;?>
+ <?php endif;?>
</div>
</td>
</tr>
<?php $i++; endforeach; ?>
- <tr>
+ <tr>
<td class="list" colspan="4"></td>
<?php
- if ($pconfig['enable'])
+ if ($pconfig['enable']) {
echo "<td class=\"list\"><div id='addnewroll'> <a href=\"services_captiveportal_vouchers_edit.php?zone={$cpzone}\"><img src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" title=\"" . gettext("add voucher") . "\" width=\"17\" height=\"17\" border=\"0\" alt=\"" . gettext("add voucher") . "\" /></a></div></td>";
+ }
?>
</tr>
- </table>
- <?php if ($pconfig['enable']): ?>
+ </table>
+ <?php if ($pconfig['enable']): ?>
<?=gettext("Create, generate and activate Rolls with Vouchers that allow access through the " .
"captive portal for the configured time. Once a voucher is activated, " .
"its clock is started and runs uninterrupted until it expires. During that " .
@@ -520,128 +564,131 @@ function enable_change(enable_change) {
<?php else: ?>
<?=gettext("Enable Voucher support first using the checkbox above and hit Save at the bottom."); ?>
<?php endif;?>
- </td>
- </tr>
- <tr>
- <td valign="top" class="vncellreq">
- <?=gettext("Voucher public key"); ?>
- </td>
- <td class="vtable">
- <textarea name="publickey" cols="65" rows="4" id="publickey" class="formpre"><?=htmlspecialchars($pconfig['publickey']);?></textarea>
- <br />
- <?=gettext("Paste an RSA public key (64 Bit or smaller) in PEM format here. This key is used to decrypt vouchers."); ?> <a href='#' onclick='generatenewkey();'><?=gettext('Generate');?></a> <?=gettext('new key');?>.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell"><?=gettext("Voucher private key"); ?></td>
- <td class="vtable">
- <textarea name="privatekey" cols="65" rows="5" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea>
- <br />
- <?=gettext("Paste an RSA private key (64 Bit or smaller) in PEM format here. This key is only used to generate encrypted vouchers and doesn't need to be available if the vouchers have been generated offline."); ?> <a href='#' onclick='generatenewkey();'> <?=gettext('Generate');?></a> <?=gettext('new key');?>.</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Character set"); ?></td>
- <td width="78%" class="vtable">
- <input name="charset" type="text" class="formfld" id="charset" size="80" value="<?=htmlspecialchars($pconfig['charset']);?>" />
- <br />
- <?=gettext("Tickets are generated with the specified character set. It should contain printable characters (numbers, lower case and upper case letters) that are hard to confuse with others. Avoid e.g. 0/O and l/1."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"># <?=gettext("of Roll Bits"); ?></td>
- <td width="78%" class="vtable">
- <input name="rollbits" type="text" class="formfld" id="rollbits" size="2" value="<?=htmlspecialchars($pconfig['rollbits']);?>" />
- <br />
- <?=gettext("Reserves a range in each voucher to store the Roll # it belongs to. Allowed range: 1..31. Sum of Roll+Ticket+Checksum bits must be one Bit less than the RSA key size."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"># <?=gettext("of Ticket Bits"); ?></td>
- <td width="78%" class="vtable">
- <input name="ticketbits" type="text" class="formfld" id="ticketbits" size="2" value="<?=htmlspecialchars($pconfig['ticketbits']);?>" />
- <br />
- <?=gettext("Reserves a range in each voucher to store the Ticket# it belongs to. Allowed range: 1..16. Using 16 bits allows a roll to have up to 65535 vouchers. A bit array, stored in RAM and in the config, is used to mark if a voucher has been used. A bit array for 65535 vouchers requires 8 KB of storage."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"># <?=gettext("of Checksum Bits"); ?></td>
- <td width="78%" class="vtable">
- <input name="checksumbits" type="text" class="formfld" id="checksumbits" size="2" value="<?=htmlspecialchars($pconfig['checksumbits']);?>" />
- <br />
- <?=gettext("Reserves a range in each voucher to store a simple checksum over Roll # and Ticket#. Allowed range is 0..31."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Magic Number"); ?></td>
- <td width="78%" class="vtable">
- <input name="magic" type="text" class="formfld" id="magic" size="20" value="<?=htmlspecialchars($pconfig['magic']);?>" />
- <br />
- <?=gettext("Magic number stored in every voucher. Verified during voucher check. Size depends on how many bits are left by Roll+Ticket+Checksum bits. If all bits are used, no magic number will be used and checked."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Invalid Voucher Message"); ?></td>
- <td width="78%" class="vtable">
- <input name="msgnoaccess" type="text" class="formfld" id="msgnoaccess" size="80" value="<?=htmlspecialchars($pconfig['msgnoaccess']);?>" />
- <br /><?=gettext("Error message displayed for invalid vouchers on captive portal error page"); ?> ($PORTAL_MESSAGE$).
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Expired Voucher Message"); ?></td>
- <td width="78%" class="vtable">
- <input name="msgexpired" type="text" class="formfld" id="msgexpired" size="80" value="<?=htmlspecialchars($pconfig['msgexpired']);?>" />
- <br /><?=gettext("Error message displayed for expired vouchers on captive portal error page"); ?> ($PORTAL_MESSAGE$).
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- &nbsp;
- </td>
- </tr>
- <tr>
- <td colspan="2" valign="top" class="listtopic"><?=gettext("Voucher database synchronization"); ?></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Synchronize Voucher Database IP"); ?></td>
- <td width="78%" class="vtable">
- <input name="vouchersyncdbip" type="text" class="formfld" id="vouchersyncdbip" size="17" value="<?=htmlspecialchars($pconfig['vouchersyncdbip']);?>" />
- <br /><?=gettext("IP address of master nodes webConfigurator to synchronize voucher database and used vouchers from."); ?>
- <br /><?=gettext("NOTE: this should be setup on the slave nodes and not the primary node!"); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Voucher sync port"); ?></td>
- <td width="78%" class="vtable">
- <input name="vouchersyncport" type="text" class="formfld" id="vouchersyncport" size="7" value="<?=htmlspecialchars($pconfig['vouchersyncport']);?>" />
- <br /><?=gettext("This is the port of the master voucher nodes webConfigurator. Example: 443"); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Voucher sync username"); ?></td>
- <td width="78%" class="vtable">
- <input name="vouchersyncusername" type="text" class="formfld" id="vouchersyncusername" size="25" value="<?=htmlspecialchars($pconfig['vouchersyncusername']);?>" autocomplete="off" />
- <br /><?=gettext("This is the username of the master voucher nodes webConfigurator."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Voucher sync password"); ?></td>
- <td width="78%" class="vtable">
- <input name="vouchersyncpass" type="password" class="formfld" id="vouchersyncpass" size="25" value="<?=htmlspecialchars($pconfig['vouchersyncpass']);?>" autocomplete="off" />
- <br /><?=gettext("This is the password of the master voucher nodes webConfigurator."); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input type="hidden" name="zone" id="zone" value="<?=htmlspecialchars($cpzone);?>" />
- <input type="hidden" name="exponent" id="exponent" value="<?=$pconfig['exponent'];?>" />
- <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true); before_save();" />
- <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
- </td>
- </tr>
- <tr>
- <td colspan="2" class="list"><p class="vexpl">
- <span class="red"><strong> <?=gettext("Note:"); ?><br /> </strong></span>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncellreq">
+ <?=gettext("Voucher public key"); ?>
+ </td>
+ <td class="vtable">
+ <textarea name="publickey" cols="65" rows="4" id="publickey" class="formpre"><?=htmlspecialchars($pconfig['publickey']);?></textarea>
+ <br />
+ <?=gettext("Paste an RSA public key (64 Bit or smaller) in PEM format here. This key is used to decrypt vouchers."); ?> <a href='#' onclick='generatenewkey();'><?=gettext('Generate');?></a> <?=gettext('new key');?>.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell"><?=gettext("Voucher private key"); ?></td>
+ <td class="vtable">
+ <textarea name="privatekey" cols="65" rows="5" id="privatekey" class="formpre"><?=htmlspecialchars($pconfig['privatekey']);?></textarea>
+ <br />
+ <?=gettext("Paste an RSA private key (64 Bit or smaller) in PEM format here. This key is only used to generate encrypted vouchers and doesn't need to be available if the vouchers have been generated offline."); ?> <a href='#' onclick='generatenewkey();'> <?=gettext('Generate');?></a> <?=gettext('new key');?>.
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Character set"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="charset" type="text" class="formfld" id="charset" size="80" value="<?=htmlspecialchars($pconfig['charset']);?>" />
+ <br />
+ <?=gettext("Tickets are generated with the specified character set. It should contain printable characters (numbers, lower case and upper case letters) that are hard to confuse with others. Avoid e.g. 0/O and l/1."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"># <?=gettext("of Roll Bits"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="rollbits" type="text" class="formfld" id="rollbits" size="2" value="<?=htmlspecialchars($pconfig['rollbits']);?>" />
+ <br />
+ <?=gettext("Reserves a range in each voucher to store the Roll # it belongs to. Allowed range: 1..31. Sum of Roll+Ticket+Checksum bits must be one Bit less than the RSA key size."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"># <?=gettext("of Ticket Bits"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="ticketbits" type="text" class="formfld" id="ticketbits" size="2" value="<?=htmlspecialchars($pconfig['ticketbits']);?>" />
+ <br />
+ <?=gettext("Reserves a range in each voucher to store the Ticket# it belongs to. Allowed range: 1..16. Using 16 bits allows a roll to have up to 65535 vouchers. A bit array, stored in RAM and in the config, is used to mark if a voucher has been used. A bit array for 65535 vouchers requires 8 KB of storage."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"># <?=gettext("of Checksum Bits"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="checksumbits" type="text" class="formfld" id="checksumbits" size="2" value="<?=htmlspecialchars($pconfig['checksumbits']);?>" />
+ <br />
+ <?=gettext("Reserves a range in each voucher to store a simple checksum over Roll # and Ticket#. Allowed range is 0..31."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Magic Number"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="magic" type="text" class="formfld" id="magic" size="20" value="<?=htmlspecialchars($pconfig['magic']);?>" />
+ <br />
+ <?=gettext("Magic number stored in every voucher. Verified during voucher check. Size depends on how many bits are left by Roll+Ticket+Checksum bits. If all bits are used, no magic number will be used and checked."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Invalid Voucher Message"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="msgnoaccess" type="text" class="formfld" id="msgnoaccess" size="80" value="<?=htmlspecialchars($pconfig['msgnoaccess']);?>" />
+ <br /><?=gettext("Error message displayed for invalid vouchers on captive portal error page"); ?> ($PORTAL_MESSAGE$).
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Expired Voucher Message"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="msgexpired" type="text" class="formfld" id="msgexpired" size="80" value="<?=htmlspecialchars($pconfig['msgexpired']);?>" />
+ <br /><?=gettext("Error message displayed for expired vouchers on captive portal error page"); ?> ($PORTAL_MESSAGE$).
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ &nbsp;
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Voucher database synchronization"); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Synchronize Voucher Database IP"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="vouchersyncdbip" type="text" class="formfld" id="vouchersyncdbip" size="17" value="<?=htmlspecialchars($pconfig['vouchersyncdbip']);?>" />
+ <br /><?=gettext("IP address of master nodes webConfigurator to synchronize voucher database and used vouchers from."); ?>
+ <br /><?=gettext("NOTE: this should be setup on the slave nodes and not the primary node!"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Voucher sync port"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="vouchersyncport" type="text" class="formfld" id="vouchersyncport" size="7" value="<?=htmlspecialchars($pconfig['vouchersyncport']);?>" />
+ <br /><?=gettext("This is the port of the master voucher nodes webConfigurator. Example: 443"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Voucher sync username"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="vouchersyncusername" type="text" class="formfld" id="vouchersyncusername" size="25" value="<?=htmlspecialchars($pconfig['vouchersyncusername']);?>" autocomplete="off" />
+ <br /><?=gettext("This is the username of the master voucher nodes webConfigurator."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Voucher sync password"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="vouchersyncpass" type="password" class="formfld" id="vouchersyncpass" size="25" value="<?=htmlspecialchars($pconfig['vouchersyncpass']);?>" autocomplete="off" />
+ <br /><?=gettext("This is the password of the master voucher nodes webConfigurator."); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input type="hidden" name="zone" id="zone" value="<?=htmlspecialchars($cpzone);?>" />
+ <input type="hidden" name="exponent" id="exponent" value="<?=$pconfig['exponent'];?>" />
+ <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true); before_save();" />
+ <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="list">
+ <p class="vexpl">
+ <span class="red"><strong> <?=gettext("Note:"); ?><br /> </strong></span>
<?=gettext("Changing any Voucher parameter (apart from managing the list of Rolls) on this page will render existing vouchers useless if they were generated with different settings."); ?>
<br />
<?=gettext("Specifying the Voucher Database Synchronization options will not record any other value from the other options. They will be retrieved/synced from the master."); ?>
OpenPOWER on IntegriCloud