Merge remote branch 'mainline/master' into inc

Conflicts:
	etc/inc/captiveportal.inc
This commit is contained in:
Renato Botelho 2010-08-30 19:36:59 -03:00
commit 5e56c56dba
15 changed files with 811 additions and 328 deletions

View File

@ -50,54 +50,85 @@ require_once("filter.inc");
require_once("radius.inc");
require_once("voucher.inc");
function captiveportal_configure() {
function get_default_captive_portal_html() {
global $config, $g;
$captiveportallck = lock('captiveportal');
if (isset($config['captiveportal']['enable'])) {
if ($g['booting'])
echo gettext("Starting captive portal... ");
/* kill any running mini_httpd */
killbypid("{$g['varrun_path']}/lighty-CaptivePortal.pid");
killbypid("{$g['varrun_path']}/lighty-CaptivePortal-SSL.pid");
/* remove old information */
unlink_if_exists("{$g['vardb_path']}/captiveportal.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_mac.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_ip.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_radius.db");
/* setup new database in case someone tries to access the status -> captive portal page */
touch("{$g['vardb_path']}/captiveportal.db");
/* kill any running minicron */
killbypid("{$g['varrun_path']}/minicron.pid");
/* init ipfw rules */
captiveportal_init_rules(true);
/* stop accounting on all clients */
captiveportal_radius_stop_all(true);
/* initialize minicron interval value */
$croninterval = $config['captiveportal']['croninterval'] ? $config['captiveportal']['croninterval'] : 60;
/* double check if the $croninterval is numeric and at least 10 seconds. If not we set it to 60 to avoid problems */
if ((!is_numeric($croninterval)) || ($croninterval < 10)) { $croninterval = 60; }
/* write portal page */
if ($config['captiveportal']['page']['htmltext'])
$htmltext = base64_decode($config['captiveportal']['page']['htmltext']);
else {
/* example/template page */
// Detect if vouchers are being used and default to the voucher page
if($config['voucher']) {
$htmltext = <<<EOD
<html>
<body>
<form method="post" action="$PORTAL_ACTION$">
<input name="redirurl" type="hidden" value="$PORTAL_REDIRURL$">
<form method="post" action="\$PORTAL_ACTION\$">
<center>
<table cellpadding="6" cellspacing="0" width="550" height="380" style="border:1px solid #000000">
<tr height="10" bgcolor="#990000">
<td style="border-bottom:1px solid #000000">
<font color='white'>
<b>
Guest Voucher code required to continue
</b>
</font>
</td>
</tr>
<tr>
<td>
<div id="mainlevel">
<center>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td>
<center>
<div id="mainarea">
<center>
<table width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td>
<div id="maindivarea">
<center>
<div id='statusbox'>
<font color='red' face='arial' size='+1'>
<b>
\$PORTAL_MESSAGE\$
</b>
</font>
</div>
<p/>
<div id='loginbox'>
Enter Voucher Code:
<input name="auth_voucher" type="text" style="border:1px dashed;" size="22">
<input name="redirurl" type="hidden" value="\$PORTAL_REDIRURL\$">
<input name="accept" type="submit" value="Continue">
</div>
</center>
</div>
</td>
</tr>
</table>
</center>
</div>
</center>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
EOD;
return $htmltext;
}
// Vouchers are not found, return the normal user/pass auth page
$htmltext = <<<EOD
<html>
<body>
<form method="post" action="\$PORTAL_ACTION\$">
<input name="redirurl" type="hidden" value="\$PORTAL_REDIRURL\$">
<center>
<table cellpadding="6" cellspacing="0" width="550" height="380" style="border:1px solid #000000">
<tr height="10" bgcolor="#990000">
@ -127,7 +158,7 @@ function captiveportal_configure() {
<div id='statusbox'>
<font color='red' face='arial' size='+1'>
<b>
$PORTAL_MESSAGE$
\$PORTAL_MESSAGE\$
</b>
</font>
</div>
@ -167,9 +198,55 @@ function captiveportal_configure() {
</body>
</html>
EOD;
return $htmltext;
}
function captiveportal_configure() {
global $config, $g;
$captiveportallck = lock('captiveportal');
if (isset($config['captiveportal']['enable'])) {
if ($g['booting'])
echo "Starting captive portal... ";
/* kill any running mini_httpd */
killbypid("{$g['varrun_path']}/lighty-CaptivePortal.pid");
killbypid("{$g['varrun_path']}/lighty-CaptivePortal-SSL.pid");
/* remove old information */
unlink_if_exists("{$g['vardb_path']}/captiveportal.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_mac.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_ip.db");
unlink_if_exists("{$g['vardb_path']}/captiveportal_radius.db");
/* setup new database in case someone tries to access the status -> captive portal page */
touch("{$g['vardb_path']}/captiveportal.db");
/* kill any running minicron */
killbypid("{$g['varrun_path']}/minicron.pid");
/* init ipfw rules */
captiveportal_init_rules(true);
/* stop accounting on all clients */
captiveportal_radius_stop_all(true);
/* initialize minicron interval value */
$croninterval = $config['captiveportal']['croninterval'] ? $config['captiveportal']['croninterval'] : 60;
/* double check if the $croninterval is numeric and at least 10 seconds. If not we set it to 60 to avoid problems */
if ((!is_numeric($croninterval)) || ($croninterval < 10)) { $croninterval = 60; }
/* write portal page */
if ($config['captiveportal']['page']['htmltext'])
$htmltext = base64_decode($config['captiveportal']['page']['htmltext']);
else {
/* example/template page */
$htmltext = get_default_captive_portal_html();
}
$fd = @fopen("{$g['varetc_path']}/captiveportal.html", "w");
@ -194,8 +271,8 @@ EOD;
$errtext = <<<EOD
<html>
<body>
<form method="post" action="$PORTAL_ACTION$">
<input name="redirurl" type="hidden" value="$PORTAL_REDIRURL$">
<form method="post" action="\$PORTAL_ACTION\$">
<input name="redirurl" type="hidden" value="\$PORTAL_REDIRURL\$">
<center>
<table cellpadding="6" cellspacing="0" width="550" height="380" style="border:1px solid #000000">
<tr height="10" bgcolor="#990000">
@ -225,7 +302,7 @@ EOD;
<div id='statusbox'>
<font color='red' face='arial' size='+1'>
<b>
$PORTAL_MESSAGE$
\$PORTAL_MESSAGE\$
</b>
</font>
</div>

View File

@ -2313,7 +2313,7 @@ function find_dhclient_process($interface) {
return $pid;
}
function interface_configure($interface = "wan", $reloadall = false) {
function interface_configure($interface = "wan", $reloadall = false, $linkupevent = false) {
global $config, $g;
global $interface_sn_arr_cache, $interface_ip_arr_cache;
@ -2482,10 +2482,12 @@ function interface_configure($interface = "wan", $reloadall = false) {
if (!empty($gif))
interface_gif_configure($gif);
unset($bridgetmp);
$bridgetmp = link_interface_to_bridge($interface);
if (!empty($bridgetmp))
interface_bridge_add_member($bridgetmp, $realif);
if ($linkupevent == false) {
unset($bridgetmp);
$bridgetmp = link_interface_to_bridge($interface);
if (!empty($bridgetmp))
interface_bridge_add_member($bridgetmp, $realif);
}
link_interface_to_vips($interface, "update");

View File

@ -136,12 +136,24 @@ function voucher_auth($voucher_received, $test = 0) {
// the user wouldn't know that he used at least one invalid voucher.
if ($error) {
unlock($voucherlck);
unlock($voucherlck);
if ($total_minutes > 0) // probably not needed, but want to make sure
$total_minutes = 0; // we only report -1 (expired) or 0 (no access)
return $total_minutes; // well, at least one voucher had errors. Say NO ACCESS
}
// XMLRPC Call over to the master Voucher node
$a_voucher = &$config['voucher'];
if($a_voucher['vouchersyncdbip']) {
$syncip = $a_voucher['vouchersyncdbip'];
$syncport = $a_voucher['vouchersyncport'];
$syncpass = $a_voucher['vouchersyncpass'];
$syncpass = $a_voucher['vouchersyncusername'];
$remote_time_used = sync_used_voucher($voucher_received, $syncip, $syncport, $syncpass, $vouchersyncusername);
if($remote_time_used['timeleft'] < 1)
$total_minutes = $remote_time_used['timeleft'];
}
// All given vouchers were valid and this isn't simply a test.
// Write back the used DB's
@ -179,6 +191,54 @@ function voucher_auth($voucher_received, $test = 0) {
return $total_minutes;
}
function sync_used_voucher($voucher_received, $syncip, $port, $password, $username) {
require_once("xmlrpc.inc");
if($port == "443")
$url = "https://{$syncip}:{$port}";
else
$url = "http://{$syncip}:{$port}";
/* Construct code that is run on remote machine */
$method = 'pfsense.exec_php';
$execcmd = <<<EOF
require_once('/etc/inc/voucher.inc');
\$timeleft = voucher_auth($voucher_received);
\$toreturn = array();
\$toreturn['timeleft'] = \$timeleft;
EOF;
/* assemble xmlrpc payload */
$params = array(
XML_RPC_encode($password),
XML_RPC_encode($execcmd)
);
log_error("voucher XMLRPC sync data {$url}:{$port}.");
$msg = new XML_RPC_Message($method, $params);
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
$cli->setCredentials('admin', $password);
$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", "");
return array("timeleft" => "0");
} 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", "");
return array("timeleft" => "0");
} else {
log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
}
$timeleft = XML_RPC_Decode($resp->value());
//print_r($timeleft);
return $timeleft;
}
function voucher_configure() {
global $config, $g;

View File

@ -36,7 +36,7 @@ function listtags() {
* I know it's a pain, but it's a pain to find stuff too if it's not
*/
$ret = explode(" ",
"alias aliasurl allowedip authserver bridged ca cacert cert clone config ".
"alias aliasurl allowedip authserver bridged ca cacert cert crl clone config ".
"container columnitem build_port_path depends_on_package disk dnsserver dnsupdate ".
"domainoverrides dyndns earlyshellcmd element encryption-algorithm-option ".
"field fieldname hash-algorithm-option gateway_item gateway_group gif gre ".

View File

@ -40,7 +40,7 @@ function listtags() {
* I know it's a pain, but it's a pain to find stuff too if it's not
*/
$ret = explode(" ",
"alias aliasurl allowedip authserver bridged ca cacert cert clone config ".
"alias aliasurl allowedip authserver bridged ca cacert cert crl clone config ".
"container columnitem depends_on_package disk dnsserver dnsupdate ".
"domainoverrides dyndns earlyshellcmd element encryption-algorithm-option ".
"field fieldname hash-algorithm-option gateway_item gateway_group gif gre ".

View File

@ -40,7 +40,7 @@ function handle_argument_group($iface, $argument2) {
global $config;
$ipaddr = $config['interfaces'][$iface]['ipaddr'];
if (is_ipaddr($ipaddr)) {
if (is_ipaddr($ipaddr) || empty($ipaddr)) {
log_error("Hotplug event detected for {$iface} but ignoring since interface is configured with static IP ({$ipaddr})");
$iface = get_real_interface($iface);
exec("/usr/sbin/arp -d -i {$iface} -a");
@ -56,7 +56,8 @@ function handle_argument_group($iface, $argument2) {
$riface = get_real_interface($iface);
exec("/usr/sbin/arp -d -i {$riface} -a");
log_error("HOTPLUG: Configuring interface {$iface}");
interface_configure($iface);
// Do not try to readd to bridge otherwise em(4) has problems
interface_configure($iface, false, true);
break;
case "up":
log_error("DEVD Ethernet attached event for {$iface}");

View File

@ -25,6 +25,13 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
if [ -f /usr/local/etc/php.ini ]; then
rm /usr/local/etc/php.ini
fi
if [ -f /usr/local/lib/php.ini ]; then
rm /usr/local/lib/php.ini
fi
# Set our operating platform
PLATFORM=`cat /etc/platform`
EXTENSIONSDIR="/usr/local/lib/php/20060613/"

142
usr/local/www/base64.js Normal file
View File

@ -0,0 +1,142 @@
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
* http://www.webtoolkit.info/licence
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}

View File

@ -14,5 +14,5 @@
</div> <!-- Wrapper Div -->
<?php outputJavaScriptFileInline("themes/{$g['theme']}/bottom-loader.js"); ?>
<?php outputJavaScriptFileInline("/usr/local/www/themes/{$g['theme']}/bottom-loader.js"); ?>

View File

@ -854,7 +854,7 @@ include("head.inc");
</tr>
</table>
<br />
<span class="vexpl"><?=gettext("Specify the source port or port range for this rule."); ?> <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be"); ?> &quot;<?=gettext("any"); ?>&quot;).</b>")."<br />".<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("\"to\""); ?></em> <?=gettext("field empty if you only want to filter a single port.");?></span><br/>
<span class="vexpl"><?=gettext("Specify the source port or port range for this rule."); ?> <b><?=gettext("This is usually"); ?> <em><?=gettext("random"); ?></em> <?=gettext("and almost never equal to the destination port range (and should usually be"); ?> &quot;<?=gettext("any"); ?>&quot;</b>).<br />.<?=gettext("Hint: you can leave the"); ?> <em><?=gettext("\"to\""); ?></em> <?=gettext("field empty if you only want to filter a single port.");?></span><br/>
</td>
</tr>
<tr>

View File

@ -52,7 +52,7 @@ function ppp_inuse($num) {
global $config, $g, $a_ppps;
$iflist = get_configured_interface_list(false, true);
foreach ($iflist as $if) {
if (isset($config['interfaces'][$if]['ptpid']) && $config['interfaces'][$if]['ptpid'] == $a_ppps[$num]['ptpid'])
if ($config['interfaces'][$if]['if'] == $a_ppps[$num]['if'])
return true;
}
return false;

View File

@ -46,98 +46,103 @@ 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 <<<EOF
\$('publickey').value = '{$publickey}';
\$('privatekey').value = '{$privatekey}';
alert('{$alertmessage}');
new Effect.Highlight('publickey');
new Effect.Highlight('privatekey');
EOF;
exit;
}
$pgtitle = array(gettext("Services"), gettext("Captive portal"), gettext("Vouchers"));
if (!is_array($config['voucher'])) {
$config['voucher'] = array();
}
if (!is_array($config['voucher']))
$config['voucher'] = array();
if (!is_array($config['voucher']['roll']))
$config['voucher']['roll'] = array();
if (!isset($config['voucher']['charset']))
$config['voucher']['charset'] = '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
if (!isset($config['voucher']['rollbits']))
$config['voucher']['rollbits'] = 16;
if (!isset($config['voucher']['ticketbits']))
$config['voucher']['ticketbits'] = 10;
if (!isset($config['voucher']['saveinterval']))
$config['voucher']['saveinterval'] = 300;
if (!isset($config['voucher']['checksumbits']))
$config['voucher']['checksumbits'] = 5;
if (!isset($config['voucher']['magic']))
$config['voucher']['magic'] = rand(); // anything slightly random will do
if (!is_array($config['voucher']['roll'])) {
$config['voucher']['roll'] = array();
}
if (!isset($config['voucher']['charset'])) {
$config['voucher']['charset'] = '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
}
if (!isset($config['voucher']['rollbits'])) {
$config['voucher']['rollbits'] = 16;
}
if (!isset($config['voucher']['ticketbits'])) {
$config['voucher']['ticketbits'] = 10;
}
if (!isset($config['voucher']['saveinterval'])) {
$config['voucher']['saveinterval'] = 300;
}
if (!isset($config['voucher']['checksumbits'])) {
$config['voucher']['checksumbits'] = 5;
}
if (!isset($config['voucher']['magic'])) {
$config['voucher']['magic'] = rand(); // anything slightly random will do
}
if (!isset($config['voucher']['publickey'])) {
/* generate a random 64 bit RSA key pair using the voucher binary */
$fd = popen("/usr/local/bin/voucher -g 64", "r");
if ($fd !== false) {
$output = fread($fd, 16384);
pclose($fd);
pclose($fd);
list($privkey, $pubkey) = explode("\0", $output);
$config['voucher']['publickey'] = base64_encode($pubkey);
$config['voucher']['privatekey'] = base64_encode($privkey);
$config['voucher']['publickey'] = base64_encode($pubkey);
$config['voucher']['privatekey'] = base64_encode($privkey);
}
}
if (!isset($config['voucher']['msgnoaccess'])) {
$config['voucher']['msgnoaccess'] = gettext("Voucher invalid");
}
if (!isset($config['voucher']['msgexpired'])) {
$config['voucher']['msgexpired'] = gettext("Voucher expired");
}
// Check for invalid or expired vouchers
if (!isset($config['voucher']['msgnoaccess']))
$config['voucher']['msgnoaccess'] = gettext("Voucher invalid");
if (!isset($config['voucher']['msgexpired']))
$config['voucher']['msgexpired'] = gettext("Voucher expired");
$a_roll = &$config['voucher']['roll'];
if ($_GET['act'] == "del") {
$id = $_GET['id'];
if ($a_roll[$id]) {
$roll = $a_roll[$id]['number'];
$voucherlck = lock('voucher');
unset($a_roll[$id]);
voucher_unlink_db($roll);
unlock($voucherlck);
write_config();
header("Location: services_captiveportal_vouchers.php");
exit;
$roll = $a_roll[$id]['number'];
$voucherlck = lock('voucher');
unset($a_roll[$id]);
voucher_unlink_db($roll);
unlock($voucherlck);
write_config();
header("Location: services_captiveportal_vouchers.php");
exit;
}
}
/* print all vouchers of the selected roll */
if ($_GET['act'] == "csv") {
$privkey = base64_decode($config['voucher']['privatekey']);
if (strstr($privkey,"BEGIN RSA PRIVATE KEY")) {
$fd = fopen("{$g['varetc_path']}/voucher.private","w");
if (!$fd) {
$input_errors[] = gettext("Cannot write private key file") . ".\n";
} else {
chmod("{$g['varetc_path']}/voucher.private", 0600);
fwrite($fd, $privkey);
fclose($fd);
$a_voucher = &$config['voucher']['roll'];
$id = $_GET['id'];
if (isset($id) && $a_voucher[$id]) {
$number = $a_voucher[$id]['number'];
$count = $a_voucher[$id]['count'];
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=vouchers_roll$number.csv");
system("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher.cfg -p {$g['varetc_path']}/voucher.private $number $count");
unlink("{$g['varetc_path']}/voucher.private");
exit;
}
}
} else {
$input_errors[] = gettext("Need private RSA key to print vouchers") . "\n";
}
$privkey = base64_decode($config['voucher']['privatekey']);
if (strstr($privkey,"BEGIN RSA PRIVATE KEY")) {
$fd = fopen("{$g['varetc_path']}/voucher.private","w");
if (!$fd) {
$input_errors[] = gettext("Cannot write private key file") . ".\n";
} else {
chmod("{$g['varetc_path']}/voucher.private", 0600);
fwrite($fd, $privkey);
fclose($fd);
$a_voucher = &$config['voucher']['roll'];
$id = $_GET['id'];
if (isset($id) && $a_voucher[$id]) {
$number = $a_voucher[$id]['number'];
$count = $a_voucher[$id]['count'];
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=vouchers_roll$number.csv");
system("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher.cfg -p {$g['varetc_path']}/voucher.private $number $count");
unlink("{$g['varetc_path']}/voucher.private");
exit;
}
}
} else {
$input_errors[] = gettext("Need private RSA key to print vouchers") . "\n";
}
}
$pconfig['enable'] = isset($config['voucher']['enable']);
@ -151,6 +156,10 @@ $pconfig['publickey'] = base64_decode($config['voucher']['publickey']);
$pconfig['privatekey'] = base64_decode($config['voucher']['privatekey']);
$pconfig['msgnoaccess'] = $config['voucher']['msgnoaccess'];
$pconfig['msgexpired'] = $config['voucher']['msgexpired'];
$pconfig['vouchersyncdbip'] = $config['voucher']['vouchersyncdbip'];
$pconfig['vouchersyncport'] = $config['voucher']['vouchersyncport'];
$pconfig['vouchersyncpass'] = $config['voucher']['vouchersyncpass'];
$pconfig['vouchersyncusername'] = $config['voucher']['vouchersyncusername'];
if ($_POST) {
@ -165,52 +174,126 @@ if ($_POST) {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
}
if ($_POST['charset'] && (strlen($_POST['charset'] < 2))) {
// Check for form errors
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['saveinterval'] && (!is_numeric($_POST['saveinterval']) || ($_POST['saveinterval'] < 1))) {
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"))) {
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 (!$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'];
write_config();
voucher_configure();
if (isset($config['voucher']['enable']) && !isset($config['captiveportal']['enable'])) {
$savemsg = gettext("Don't forget to configure and enable Captive Portal.");
}
$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 = <<<EOF
\$toreturn['voucher']['roll'] = \$config['voucher']['roll'];
\$toreturn['voucher']['charset'] = \$config['voucher']['charset'];
\$toreturn['voucher']['rollbits'] = \$config['voucher']['rollbits'];
\$toreturn['voucher']['ticketbits'] = \$config['voucher']['ticketbits'];
\$toreturn['voucher']['saveinterval'] = \$config['voucher']['saveinterval'];
\$toreturn['voucher']['checksumbits'] = \$config['voucher']['checksumbits'];
\$toreturn['voucher']['magic'] = \$config['voucher']['magic'];
\$toreturn['voucher']['publickey'] = \$config['voucher']['publickey'];
\$toreturn['voucher']['privatekey'] = \$config['voucher']['privatekey'];
\$toreturn['voucher']['msgnoaccess'] = \$config['voucher']['msgnoaccess'];
\$toreturn['voucher']['msgexpired'] = \$config['voucher']['msgexpired'];
EOF;
/* assemble xmlrpc payload */
$params = array(
XML_RPC_encode($config['voucher']['vouchersyncpass']),
XML_RPC_encode($execcmd)
);
log_error("voucher XMLRPC sync data {$url}:{$port}.");
$msg = new XML_RPC_Message('pfsense.exec_php', $params);
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $config['voucher']['vouchersyncport']);
$cli->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 .= "<br/>";
if (isset($config['voucher']['enable']) && !isset($config['captiveportal']['enable']))
$savemsg .= gettext("Don't forget to configure and enable Captive Portal.");
}
}
include("head.inc");
@ -218,10 +301,34 @@ include("head.inc");
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
<!--
function generatenewkey() {
$('publickey').value = 'One moment please...';
$('privatekey').value = 'One moment please...';
new Ajax.Request("services_captiveportal_vouchers.php?generatekey=true", {
method: 'get',
onSuccess: function(transport) {
eval(transport.responseText);
}
});
}
function before_save() {
document.iform.charset.disabled = false;
document.iform.rollbits.disabled = false;
document.iform.ticketbits.disabled = false;
document.iform.saveinterval.disabled = false;
document.iform.checksumbits.disabled = false;
document.iform.magic.disabled = false;
document.iform.publickey.disabled = false;
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++)
$('addeditdelete' + x).show();
$('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;
@ -232,6 +339,29 @@ function enable_change(enable_change) {
document.iform.privatekey.disabled = endis;
document.iform.msgnoaccess.disabled = endis;
document.iform.msgexpired.disabled = endis;
document.iform.vouchersyncdbip.disabled = endis;
document.iform.vouchersyncport.disabled = endis;
document.iform.vouchersyncpass.disabled = endis;
document.iform.vouchersyncusername.disabled = endis;
if(document.iform.vouchersyncusername.value != "") {
document.iform.charset.disabled = true;
document.iform.rollbits.disabled = true;
document.iform.ticketbits.disabled = true;
document.iform.saveinterval.disabled = true;
document.iform.checksumbits.disabled = true;
document.iform.magic.disabled = true;
document.iform.publickey.disabled = true;
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++)
$('addeditdelete' + x).hide();
$('addnewroll').hide();
} else {
for(var x=0; x < <?php echo count($a_roll); ?>; x++)
$('addeditdelete' + x).show();
$('addnewroll').show();
}
}
//-->
</script>
@ -239,167 +369,225 @@ function enable_change(enable_change) {
<?php if ($savemsg) print_info_box($savemsg); ?>
<form action="services_captiveportal_vouchers.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane">
<tr><td class="tabnavtbl">
<ul id="tabnav">
<tr>
<td class="tabnavtbl">
<ul id="tabnav">
<?php
$tab_array = array();
$tab_array[] = array(gettext("Captive portal"), false, "services_captiveportal.php");
$tab_array[] = array(gettext("Pass-through MAC"), false, "services_captiveportal_mac.php");
$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php");
$tab_array[] = array(gettext("Vouchers"), true, "services_captiveportal_vouchers.php");
$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php");
display_top_tabs($tab_array);
$tab_array[] = array(gettext("Captive portal"), false, "services_captiveportal.php");
$tab_array[] = array(gettext("Pass-through MAC"), false, "services_captiveportal_mac.php");
$tab_array[] = array(gettext("Allowed IP addresses"), false, "services_captiveportal_ip.php");
$tab_array[] = array(gettext("Vouchers"), true, "services_captiveportal_vouchers.php");
$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php");
display_top_tabs($tab_array);
?>
</ul>
</td></tr>
<tr>
<td class="tabcont">
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="checkbox pane">
<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"; ?> onClick="enable_change(false)">
<strong><?=gettext("Enable Vouchers"); ?></strong></td>
</ul>
</td>
</tr>
<tr>
<td valign="top" class="vncell"><?=gettext("Voucher Rolls"); ?></td>
<td class="vtable">
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="content pane">
<tr>
<td width="10%" class="listhdrr"><?=gettext("Roll"); ?>#</td>
<td width="20%" class="listhdrr"><?=gettext("Minutes/Ticket"); ?></td>
<td width="20%" class="listhdrr"># <?=gettext("of Tickets"); ?></td>
<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">
<?=htmlspecialchars($rollent['number']); ?>&nbsp;
</td>
<td class="listr">
<?=htmlspecialchars($rollent['minutes']);?>&nbsp;
</td>
<td class="listr">
<?=htmlspecialchars($rollent['count']);?>&nbsp;
</td>
<td class="listr">
<?=htmlspecialchars($rollent['comment']); ?>&nbsp;
</td>
<td valign="middle" nowrap class="list">
<?php if ($pconfig['enable']): ?>
<a href="services_captiveportal_vouchers_edit.php?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?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?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;?>
</td>
</tr>
<?php $i++; endforeach; ?>
<tr>
<td class="list" colspan="4"></td>
<?php
if ($pconfig['enable']) {
echo "<td class=\"list\"> <a href=\"services_captiveportal_vouchers_edit.php\"><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></td>";
}
?>
</tr>
</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 " .
"time, the voucher can be re-used from the same or a different computer. If the voucher " .
"is used again from another computer, the previous session is stopped."); ?>
<?php else: ?>
<?=gettext("Enable Voucher support first using the checkbox above and hit Save at the bottom."); ?></td>
<?php endif;?>
<td class="tabcont">
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="checkbox pane">
<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"; ?> onClick="enable_change(false)">
<strong><?=gettext("Enable Vouchers"); ?></strong>
</td>
</tr>
<tr>
<td valign="top" class="vncell">
<?=gettext("Voucher Rolls"); ?>
<?php
if($pconfig['vouchersyncdbip'])
echo "<br/>(Synchronized from {$pconfig['vouchersyncdbip']})";
?>
</td>
<td class="vtable">
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="content pane">
<tr>
<td width="10%" class="listhdrr"><?=gettext("Roll"); ?> #</td>
<td width="20%" class="listhdrr"><?=gettext("Minutes/Ticket"); ?></td>
<td width="20%" class="listhdrr"># <?=gettext("of Tickets"); ?></td>
<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">
<?=htmlspecialchars($rollent['number']); ?>&nbsp;
</td>
<td class="listr">
<?=htmlspecialchars($rollent['minutes']);?>&nbsp;
</td>
<td class="listr">
<?=htmlspecialchars($rollent['count']);?>&nbsp;
</td>
<td class="listr">
<?=htmlspecialchars($rollent['comment']); ?>&nbsp;
</td>
<td valign="middle" nowrap class="list">
<div id='addeditdelete<?=$i?>'>
<?php if ($pconfig['enable']): ?>
<a href="services_captiveportal_vouchers_edit.php?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?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?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;?>
</div>
</td>
</tr>
<?php $i++; endforeach; ?>
<tr>
<td class="list" colspan="4"></td>
<?php
if ($pconfig['enable'])
echo "<td class=\"list\"><div id='addnewroll'> <a href=\"services_captiveportal_vouchers_edit.php\"><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']): ?>
<?=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 " .
"time, the voucher can be re-used from the same or a different computer. If the voucher " .
"is used again from another computer, the previous session is stopped."); ?>
<?php else: ?>
<?=gettext("Enable Voucher support first using the checkbox above and hit Save at the bottom."); ?></td>
<?php endif;?>
</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>
</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("Save Interval"); ?></td>
<td width="78%" class="vtable">
<input name="saveinterval" type="text" class="formfld" id="saveinterval" size="4" value="<?=htmlspecialchars($pconfig['saveinterval']);?>">
<?=gettext("Minutes"); ?><br>
<?=gettext("The list of active and used vouchers can be stored in the system's configuration file once every x minutes to survive power outages. No save is done if no new vouchers have been activated. Enter 0 to never write runtime state to XML config."); ?>
</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."); ?>
</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']);?>">
<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']);?>">
<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 name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onClick="enable_change(true); before_save();">
<input type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()">
</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."); ?>
</p>
</td>
</tr>
</table>
</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."); ?></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."); ?></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("Save Interval"); ?></td>
<td width="78%" class="vtable">
<input name="saveinterval" type="text" class="formfld" id="saveinterval" size="4" value="<?=htmlspecialchars($pconfig['saveinterval']);?>">
<?=gettext("Minutes"); ?><br>
<?=gettext("The list of active and used vouchers can be stored in the system's configuration file once every x minutes to survive power outages. No save is done if no new vouchers have been activated. Enter 0 to never write runtime state to XML config."); ?></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%">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onClick="enable_change(true)">
</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."); ?>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</table>
</form>
<script type="text/javascript">
<!--

View File

@ -253,9 +253,10 @@ if ($_POST) {
}
$noip = false;
foreach ($a_maps as $map)
if (empty($map['ipaddr']))
$noip = true;
if(is_array($a_maps))
foreach ($a_maps as $map)
if (empty($map['ipaddr']))
$noip = true;
if ($_POST['staticarp'] && $noip)
$input_errors[] = "Cannot enable static ARP when you have static map entries without IP addresses. Ensure all static maps have IP addresses and try again.";

View File

@ -189,6 +189,8 @@ if ($_POST) {
conf_mount_rw();
setup_serial_port();
// Restart dnsmasq in case dns rebinding toggled
services_dnsmasq_configure();
conf_mount_ro();
}
}

View File

@ -179,6 +179,9 @@ if ($_POST) {
}
}
if (empty($pconfig['authmode']) && (($pconfig['mode'] == "server_user") || ($pconfig['mode'] == "server_tls_user")))
$input_errors[] = gettext("You must select a Backend for Authentication if the server mode requires User Auth.");
/* input validation */
if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
$input_errors[] = $result;