Commit 15c0ce09 authored by Franco Fichtner's avatar Franco Fichtner

inc: apply last batch of whitespace cleanups

Also reapply a few after recent merge/rebase action in the CP.
parent 1a3cfae0
...@@ -264,9 +264,9 @@ function get_default_captive_portal_html() { ...@@ -264,9 +264,9 @@ function get_default_captive_portal_html() {
global $config, $g, $cpzone; global $config, $g, $cpzone;
$htmltext = <<<EOD $htmltext = <<<EOD
<html> <html>
<body> <body>
<form method="post" action="\$PORTAL_ACTION\$"> <form method="post" action="\$PORTAL_ACTION\$">
<input name="redirurl" type="hidden" value="\$PORTAL_REDIRURL\$"> <input name="redirurl" type="hidden" value="\$PORTAL_REDIRURL\$">
<input name="zone" type="hidden" value="\$PORTAL_ZONE\$"> <input name="zone" type="hidden" value="\$PORTAL_ZONE\$">
<center> <center>
...@@ -347,7 +347,7 @@ EOD; ...@@ -347,7 +347,7 @@ EOD;
</table> </table>
</center> </center>
</form> </form>
</body> </body>
</html> </html>
EOD; EOD;
...@@ -658,7 +658,7 @@ function captiveportal_init_webgui_zone($cpcfg) { ...@@ -658,7 +658,7 @@ function captiveportal_init_webgui_zone($cpcfg) {
} }
/* /*
* Remove clients that have been around for longer than the specified amount of time * Remove clients that have been around for longer than the specified amount of time
* db file structure: * db file structure:
* timestamp,ipfw_rule_no,clientip,clientmac,username,sessionid,password,session_timeout,idle_timeout,session_terminate_time,interim_interval * timestamp,ipfw_rule_no,clientip,clientmac,username,sessionid,password,session_timeout,idle_timeout,session_terminate_time,interim_interval
...@@ -680,7 +680,7 @@ function captiveportal_prune_old() { ...@@ -680,7 +680,7 @@ function captiveportal_prune_old() {
}else{ }else{
// cleanup sessions if radius accounting is enable // cleanup sessions if radius accounting is enable
// TODO: this code needs a rewrite, probably the easiest thing todo is update the zone administration and run // TODO: this code needs a rewrite, probably the easiest thing todo is update the zone administration and run
// the normal cleanup (portal_cleanup_sessions) to detach both processes // the normal cleanup (portal_cleanup_sessions) to detach both processes
// //
$vcpcfg = $config['voucher'][$cpzone]; $vcpcfg = $config['voucher'][$cpzone];
......
<?php <?php
/****h* pfSense/config
* NAME
* config.inc - Functions to manipulate config.xml
* DESCRIPTION
* This include contains various config.xml specific functions.
* HISTORY
* $Id$
******
config.console.inc
Copyright (C) 2004-2010 Scott Ullrich
All rights reserved.
originally part of m0n0wall (http://m0n0.ch/wall) /*
Copyright (C) 2004-2010 Scott Ullrich
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved. All rights reserved.
...@@ -36,18 +25,17 @@ ...@@ -36,18 +25,17 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 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 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
pfSense_BUILDER_BINARIES: /sbin/mount /sbin/umount /sbin/halt /sbin/fsck
pfSense_MODULE: config
*/ */
function set_networking_interfaces_ports() { function set_networking_interfaces_ports()
{
global $noreboot; global $noreboot;
global $config; global $config;
global $g; global $g;
global $fp; global $fp;
$yes_no_prompt = '[y|n]? ';
$fp = fopen('php://stdin', 'r'); $fp = fopen('php://stdin', 'r');
$memory = get_memory(); $memory = get_memory();
...@@ -66,7 +54,7 @@ function set_networking_interfaces_ports() { ...@@ -66,7 +54,7 @@ function set_networking_interfaces_ports() {
$iflist = get_interface_list(); $iflist = get_interface_list();
/* Function flow is based on $key and $auto_assign or the lack thereof */ /* Function flow is based on $key and $auto_assign or the lack thereof */
$key = null; $key = null;
/* Only present auto interface option if running from LiveCD and interface mismatch*/ /* Only present auto interface option if running from LiveCD and interface mismatch*/
...@@ -92,21 +80,21 @@ EOD; ...@@ -92,21 +80,21 @@ EOD;
if ($auto_assign) { if ($auto_assign) {
echo <<<EOD echo <<<EOD
!!! LiveCD Detected: Auto Interface Option !!!! !!! LiveCD Detected: Auto Interface Option !!!!
BEGIN MANUAL CONFIGURATION OR WE WILL PROCEED WITH AUTO CONFIGURATION. BEGIN MANUAL CONFIGURATION OR WE WILL PROCEED WITH AUTO CONFIGURATION.
EOD; EOD;
} }
echo <<<EOD echo <<<EOD
Do you want to set up VLANs first? Do you want to set up VLANs first?
If you are not going to use VLANs, or only for optional interfaces, you should If you are not going to use VLANs, or only for optional interfaces, you should
say no here and use the webConfigurator to configure VLANs later, if required. say no here and use the webConfigurator to configure VLANs later, if required.
Do you want to set up VLANs now [y|n]? Do you want to set up VLANs now ${yes_no_prompt}
EOD; EOD;
if ($auto_assign) { if ($auto_assign) {
...@@ -132,16 +120,16 @@ now is the time to do so. ...@@ -132,16 +120,16 @@ now is the time to do so.
We'll keep trying until you do. We'll keep trying until you do.
Searching for active interfaces... Searching for active interfaces...
EOD; EOD;
unset($wanif, $lanif); unset($wanif, $lanif);
$media_iflist = $plugged_in = array(); $media_iflist = $plugged_in = array();
$media_iflist = get_interface_list("media"); $media_iflist = get_interface_list("media");
foreach ($media_iflist as $iface => $ifa) { foreach ($media_iflist as $iface => $ifa) {
if ($ifa['up']) if ($ifa['up'])
$plugged_in[] = $iface; $plugged_in[] = $iface;
} }
$lanif = array_shift($plugged_in); $lanif = array_shift($plugged_in);
...@@ -158,11 +146,11 @@ EOD; ...@@ -158,11 +146,11 @@ EOD;
echo <<<EOD echo <<<EOD
Assigned WAN to : $wanif Assigned WAN to : ${wanif}
Assigned LAN to : $lanif Assigned LAN to : ${lanif}
If you don't like this assignment, If you don't like this assignment,
press any key to go back to manual configuration. press any key to go back to manual configuration.
EOD; EOD;
$key = timeout(20); $key = timeout(20);
...@@ -170,33 +158,33 @@ EOD; ...@@ -170,33 +158,33 @@ EOD;
return; return;
} while (!isset($wanif)); } while (!isset($wanif));
$config['system']['enablesshd'] = 'enabled'; $config['system']['enablesshd'] = 'enabled';
$key = 'y'; $key = 'y';
} else { //Manually assign interfaces } else { //Manually assign interfaces
if (in_array($key, array('y', 'Y'))) if (in_array($key, array('y', 'Y')))
vlan_setup(); vlan_setup();
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
echo "\n\n" . gettext("VLAN interfaces:") . "\n\n"; echo "\n\n" . gettext("VLAN interfaces:") . "\n\n";
foreach ($config['vlans']['vlan'] as $vlan) { foreach ($config['vlans']['vlan'] as $vlan) {
echo sprintf("% -16s%s\n", "{$vlan['if']}_vlan{$vlan['tag']}", echo sprintf("% -16s%s\n", "{$vlan['if']}_vlan{$vlan['tag']}",
"VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}"); "VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}");
$iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array(); $iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array();
} }
} }
echo <<<EOD echo <<<EOD
If you do not know the names of your interfaces, you may choose to use If you do not know the names of your interfaces, you may choose to use
auto-detection. In that case, disconnect all interfaces now before auto-detection. In that case, disconnect all interfaces now before
hitting 'a' to initiate auto detection. hitting 'a' to initiate auto detection.
EOD; EOD;
do { do {
echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection:") . " "; echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection:") . " ";
$wanif = chop(fgets($fp)); $wanif = chop(fgets($fp));
...@@ -211,22 +199,22 @@ EOD; ...@@ -211,22 +199,22 @@ EOD;
continue; continue;
} }
} while (!$wanif); } while (!$wanif);
do { do {
printf(gettext("%sEnter the LAN interface name or 'a' for auto-detection %s" . printf(gettext("%sEnter the LAN interface name or 'a' for auto-detection %s" .
"NOTE: this enables full Firewalling/NAT mode.%s" . "NOTE: this enables full Firewalling/NAT mode.%s" .
"(or nothing if finished):%s"), "\n", "\n", "\n", " "); "(or nothing if finished):%s"), "\n", "\n", "\n", " ");
$lanif = chop(fgets($fp)); $lanif = chop(fgets($fp));
if($lanif == "exit") { if($lanif == "exit") {
exit; exit;
} }
if($lanif == "") { if($lanif == "") {
break; break;
} }
if ($lanif === "a") if ($lanif === "a")
$lanif = autodetect_interface("LAN", $fp); $lanif = autodetect_interface("LAN", $fp);
else if (!array_key_exists($lanif, $iflist)) { else if (!array_key_exists($lanif, $iflist)) {
...@@ -235,11 +223,11 @@ EOD; ...@@ -235,11 +223,11 @@ EOD;
continue; continue;
} }
} while (!$lanif); } while (!$lanif);
/* optional interfaces */ /* optional interfaces */
$i = 0; $i = 0;
$optif = array(); $optif = array();
if($lanif <> "") { if($lanif <> "") {
while (1) { while (1) {
if ($optif[$i]) if ($optif[$i])
...@@ -248,12 +236,12 @@ EOD; ...@@ -248,12 +236,12 @@ EOD;
if($config['interfaces']['opt' . $io]['descr']) if($config['interfaces']['opt' . $io]['descr'])
printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']); printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']);
printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" . printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" .
"(or nothing if finished):%s"), "\n", $io, "\n", " "); "(or nothing if finished):%s"), "\n", $io, "\n", " ");
$optif[$i] = chop(fgets($fp)); $optif[$i] = chop(fgets($fp));
if ($optif[$i]) { if ($optif[$i]) {
if ($optif[$i] === "a") { if ($optif[$i] === "a") {
$ad = autodetect_interface(gettext("Optional") . " " . $io, $fp); $ad = autodetect_interface(gettext("Optional") . " " . $io, $fp);
...@@ -272,38 +260,38 @@ EOD; ...@@ -272,38 +260,38 @@ EOD;
} }
} }
} }
/* check for double assignments */ /* check for double assignments */
$ifarr = array_merge(array($lanif, $wanif), $optif); $ifarr = array_merge(array($lanif, $wanif), $optif);
for ($i = 0; $i < (count($ifarr)-1); $i++) { for ($i = 0; $i < (count($ifarr)-1); $i++) {
for ($j = ($i+1); $j < count($ifarr); $j++) { for ($j = ($i+1); $j < count($ifarr); $j++) {
if ($ifarr[$i] == $ifarr[$j]) { if ($ifarr[$i] == $ifarr[$j]) {
echo <<<EOD echo <<<EOD
Error: you cannot assign the same interface name twice! Error: you cannot assign the same interface name twice!
EOD; EOD;
fclose($fp); fclose($fp);
return; return;
} }
} }
} }
echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n"; echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n";
echo "WAN -> " . $wanif . "\n"; echo "WAN -> " . $wanif . "\n";
if ($lanif != "") if ($lanif != "")
echo "LAN -> " . $lanif . "\n"; echo "LAN -> " . $lanif . "\n";
for ($i = 0; $i < count($optif); $i++) { for ($i = 0; $i < count($optif); $i++) {
echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n"; echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n";
} }
echo <<<EOD echo <<<EOD
Do you want to proceed [y|n]? Do you want to proceed ${yes_no_prompt}
EOD; EOD;
$key = chop(fgets($fp)); $key = chop(fgets($fp));
} }
if (in_array($key, array('y', 'Y'))) { if (in_array($key, array('y', 'Y'))) {
...@@ -319,7 +307,7 @@ echo <<<EODD ...@@ -319,7 +307,7 @@ echo <<<EODD
You have chosen to remove the LAN interface. You have chosen to remove the LAN interface.
Would you like to remove the LAN IP address and Would you like to remove the LAN IP address and
unload the interface now? [y|n]? unload the interface now ${yes_no_prompt}
EODD; EODD;
if (strcasecmp(chop(fgets($fp)), "y") == 0) { if (strcasecmp(chop(fgets($fp)), "y") == 0) {
...@@ -339,7 +327,7 @@ EODD; ...@@ -339,7 +327,7 @@ EODD;
if(isset($config['ezshaper'])) if(isset($config['ezshaper']))
unset($config['ezshaper']); unset($config['ezshaper']);
if(isset($config['nat'])) if(isset($config['nat']))
unset($config['nat']); unset($config['nat']);
} else { } else {
if(isset($config['interfaces']['lan']['if'])) if(isset($config['interfaces']['lan']['if']))
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete"); mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
...@@ -356,7 +344,7 @@ EODD; ...@@ -356,7 +344,7 @@ EODD;
if(isset($config['ezshaper'])) if(isset($config['ezshaper']))
unset($config['ezshaper']); unset($config['ezshaper']);
if(isset($config['nat'])) if(isset($config['nat']))
unset($config['nat']); unset($config['nat']);
} }
if (preg_match($g['wireless_regex'], $lanif)) { if (preg_match($g['wireless_regex'], $lanif)) {
if (is_array($config['interfaces']['lan']) && if (is_array($config['interfaces']['lan']) &&
...@@ -424,8 +412,9 @@ EODD; ...@@ -424,8 +412,9 @@ EODD;
} }
} }
function autodetect_interface($ifname, $fp) { function autodetect_interface($ifname, $fp)
$iflist_prev = get_interface_list("media"); {
$iflist_prev = get_interface_list('media');
echo <<<EOD echo <<<EOD
Connect the {$ifname} interface now and make sure that the link is up. Connect the {$ifname} interface now and make sure that the link is up.
...@@ -447,16 +436,11 @@ EOD; ...@@ -447,16 +436,11 @@ EOD;
return null; return null;
} }
function interfaces_setup() { function vlan_setup()
{
global $iflist, $config, $g, $fp; global $iflist, $config, $g, $fp;
$iflist = get_interface_list(); $yes_no_prompt = '[y|n]? ';
}
function vlan_setup() {
global $iflist, $config, $g, $fp;
$iflist = get_interface_list(); $iflist = get_interface_list();
...@@ -466,7 +450,7 @@ function vlan_setup() { ...@@ -466,7 +450,7 @@ function vlan_setup() {
WARNING: all existing VLANs will be cleared if you proceed! WARNING: all existing VLANs will be cleared if you proceed!
Do you want to proceed [y|n]? Do you want to proceed ${yes_no_prompt}
EOD; EOD;
if (strcasecmp(chop(fgets($fp)), "y") != 0) if (strcasecmp(chop(fgets($fp)), "y") != 0)
...@@ -520,10 +504,8 @@ EOD; ...@@ -520,10 +504,8 @@ EOD;
printf(gettext("%sInvalid VLAN tag '%s'%s"), "\n", $vlan['tag'], "\n"); printf(gettext("%sInvalid VLAN tag '%s'%s"), "\n", $vlan['tag'], "\n");
continue; continue;
} }
$config['vlans']['vlan'][] = $vlan; $config['vlans']['vlan'][] = $vlan;
$vlanif++; $vlanif++;
} }
} }
?>
...@@ -4,17 +4,17 @@ ...@@ -4,17 +4,17 @@
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com> Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2007 Marcel Wiget <mwiget@mac.com> 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 Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, 1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
...@@ -243,7 +243,7 @@ function voucher_expire($voucher_received) { ...@@ -243,7 +243,7 @@ function voucher_expire($voucher_received) {
} }
// split into an array. Useful for multiple vouchers given // split into an array. Useful for multiple vouchers given
$a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received); $a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received);
$active_dirty = false; $active_dirty = false;
// go through all received vouchers, check their valid and extract // go through all received vouchers, check their valid and extract
...@@ -257,9 +257,9 @@ function voucher_expire($voucher_received) { ...@@ -257,9 +257,9 @@ function voucher_expire($voucher_received) {
$_gb = exec("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -k {$g['varetc_path']}/voucher_{$cpzone}.public -- $v", $output); $_gb = exec("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -k {$g['varetc_path']}/voucher_{$cpzone}.public -- $v", $output);
list($status, $roll, $nr) = explode(" ", $output[0]); list($status, $roll, $nr) = explode(" ", $output[0]);
if ($status == "OK") { if ($status == "OK") {
// check if we have this ticket on a registered roll for this ticket // check if we have this ticket on a registered roll for this ticket
if ($tickets_per_roll[$roll] && ($nr <= $tickets_per_roll[$roll])) { if ($tickets_per_roll[$roll] && ($nr <= $tickets_per_roll[$roll])) {
// voucher is from a registered roll. // voucher is from a registered roll.
if (!isset($active_vouchers[$roll])) if (!isset($active_vouchers[$roll]))
$active_vouchers[$roll] = voucher_read_active_db($roll); $active_vouchers[$roll] = voucher_read_active_db($roll);
// valid voucher. Store roll# and ticket# // valid voucher. Store roll# and ticket#
...@@ -321,7 +321,7 @@ function voucher_expire($voucher_received) { ...@@ -321,7 +321,7 @@ function voucher_expire($voucher_received) {
return true; return true;
} }
/* /*
* Authenticate a voucher and return the remaining time credit in minutes * Authenticate a voucher and return the remaining time credit in minutes
* if $test is set, don't mark the voucher as used nor add it to the list * if $test is set, don't mark the voucher as used nor add it to the list
* of active vouchers * of active vouchers
...@@ -356,7 +356,7 @@ function voucher_auth($voucher_received, $test = 0) { ...@@ -356,7 +356,7 @@ function voucher_auth($voucher_received, $test = 0) {
} }
// split into an array. Useful for multiple vouchers given // split into an array. Useful for multiple vouchers given
$a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received); $a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received);
$error = 0; $error = 0;
$test_result = array(); // used to display for voucher test option in GUI $test_result = array(); // used to display for voucher test option in GUI
$total_minutes = 0; $total_minutes = 0;
...@@ -378,9 +378,9 @@ function voucher_auth($voucher_received, $test = 0) { ...@@ -378,9 +378,9 @@ function voucher_auth($voucher_received, $test = 0) {
$first_voucher = $voucher; $first_voucher = $voucher;
$first_voucher_roll = $roll; $first_voucher_roll = $roll;
} }
// check if we have this ticket on a registered roll for this ticket // check if we have this ticket on a registered roll for this ticket
if ($tickets_per_roll[$roll] && ($nr <= $tickets_per_roll[$roll])) { if ($tickets_per_roll[$roll] && ($nr <= $tickets_per_roll[$roll])) {
// voucher is from a registered roll. // voucher is from a registered roll.
if (!isset($active_vouchers[$roll])) if (!isset($active_vouchers[$roll]))
$active_vouchers[$roll] = voucher_read_active_db($roll); $active_vouchers[$roll] = voucher_read_active_db($roll);
// valid voucher. Store roll# and ticket# // valid voucher. Store roll# and ticket#
...@@ -448,7 +448,7 @@ function voucher_auth($voucher_received, $test = 0) { ...@@ -448,7 +448,7 @@ function voucher_auth($voucher_received, $test = 0) {
if (!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) { if (!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) {
if (!is_null($remote_time_used)) if (!is_null($remote_time_used))
$total_minutes = $remote_time_used; $total_minutes = $remote_time_used;
else if ($remote_time_used < $total_minutes) else if ($remote_time_used < $total_minutes)
$total_minutes -= $remote_time_used; $total_minutes -= $remote_time_used;
} }
...@@ -572,7 +572,7 @@ function voucher_configure_zone($sync = false) { ...@@ -572,7 +572,7 @@ function voucher_configure_zone($sync = false) {
return 0; return 0;
} }
/* write bitstring of used vouchers to ramdisk. /* write bitstring of used vouchers to ramdisk.
* Bitstring must already be base64_encoded! * Bitstring must already be base64_encoded!
*/ */
function voucher_write_used_db($roll, $vdb) { function voucher_write_used_db($roll, $vdb) {
...@@ -587,7 +587,7 @@ function voucher_write_used_db($roll, $vdb) { ...@@ -587,7 +587,7 @@ function voucher_write_used_db($roll, $vdb) {
} }
/* return assoc array of active vouchers with activation timestamp /* return assoc array of active vouchers with activation timestamp
* voucher is index. * voucher is index.
*/ */
function voucher_read_active_db($roll) { function voucher_read_active_db($roll) {
global $g, $cpzone; global $g, $cpzone;
...@@ -642,7 +642,7 @@ function voucher_used_count($roll) { ...@@ -642,7 +642,7 @@ function voucher_used_count($roll) {
$max = strlen($bitstring) * 8; $max = strlen($bitstring) * 8;
$used = 0; $used = 0;
for ($i = 1; $i <= $max; $i++) { for ($i = 1; $i <= $max; $i++) {
// check if ticket already used or not. // check if ticket already used or not.
$pos = $i >> 3; // divide by 8 -> octet $pos = $i >> 3; // divide by 8 -> octet
$mask = 1 << ($i % 8); // mask to test bit in octet $mask = 1 << ($i % 8); // mask to test bit in octet
if (ord($bitstring[$pos]) & $mask) if (ord($bitstring[$pos]) & $mask)
...@@ -701,7 +701,7 @@ function voucher_save_db_to_config() { ...@@ -701,7 +701,7 @@ function voucher_save_db_to_config() {
function voucher_save_db_to_config_zone() { function voucher_save_db_to_config_zone() {
global $config, $g, $cpzone; global $config, $g, $cpzone;
if (!isset($config['voucher'][$cpzone]['enable'])) if (!isset($config['voucher'][$cpzone]['enable']))
return; // no vouchers or don't want to save DB's return; // no vouchers or don't want to save DB's
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment