summaryrefslogtreecommitdiffstats
path: root/etc/inc/voucher.inc
diff options
context:
space:
mode:
authorVinicius Coque <vinicius.coque@bluepex.com>2011-03-25 08:49:04 -0300
committerVinicius Coque <vinicius.coque@bluepex.com>2011-03-25 08:49:04 -0300
commit54bdff758f68e2e1b1ebd42b8b0b629b68ed1a3d (patch)
tree27b7d45e582e3d84cdf8d0fa0f3bc93b65f3c986 /etc/inc/voucher.inc
parentb845290619244e8cfe3bc2aa6271c6629eeb86b5 (diff)
parent401fb0ad8fa7ad06743435808dac8e913b3c16bb (diff)
downloadpfsense-54bdff758f68e2e1b1ebd42b8b0b629b68ed1a3d.zip
pfsense-54bdff758f68e2e1b1ebd42b8b0b629b68ed1a3d.tar.gz
Merge remote-tracking branch 'mainline/master' into inc
Conflicts: etc/inc/auth.inc etc/inc/config.lib.inc etc/inc/filter.inc etc/inc/pfsense-utils.inc etc/inc/pkg-utils.inc etc/inc/priv.defs.inc etc/inc/services.inc etc/inc/shaper.inc etc/inc/voucher.inc etc/inc/vpn.inc usr/local/www/fbegin.inc
Diffstat (limited to 'etc/inc/voucher.inc')
-rw-r--r--etc/inc/voucher.inc26
1 files changed, 13 insertions, 13 deletions
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index 74d83d9..cb13770 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -100,11 +100,11 @@ EOF;
function voucher_auth($voucher_received, $test = 0) {
global $g, $config;
- $voucherlck = lock('voucher');
+ $voucherlck = lock('voucher', LOCK_EX);
// XMLRPC Call over to the master Voucher node
$a_voucher = &$config['voucher'];
- if($a_voucher['vouchersyncdbip']) {
+ if(!empty($a_voucher['vouchersyncdbip'])) {
$syncip = $a_voucher['vouchersyncdbip'];
$syncport = $a_voucher['vouchersyncport'];
$syncpass = $a_voucher['vouchersyncpass'];
@@ -154,10 +154,10 @@ function voucher_auth($voucher_received, $test = 0) {
if (!isset($active_vouchers[$roll]))
$active_vouchers[$roll] = voucher_read_active_db($roll);
// valid voucher. Store roll# and ticket#
- if ($line = $active_vouchers[$roll][$voucher]) {
- list($timestamp,$minutes) = explode(",", $line);
+ if (!empty($active_vouchers[$roll][$voucher])) {
+ list($timestamp,$minutes) = explode(",", $active_vouchers[$roll][$voucher]);
// we have an already active voucher here.
- $remaining = intval((($timestamp + 60*$minutes) - time())/60);
+ $remaining = intval((($timestamp + (60*$minutes)) - time())/60);
$test_result[] = sprintf(gettext('%1$s (%2$s/%3$s) active and good for %4$d Minutes'), $voucher, $roll, $nr, $remaining);
$total_minutes += $remaining;
} else {
@@ -215,7 +215,7 @@ function voucher_auth($voucher_received, $test = 0) {
}
// If we did a XMLRPC sync earlier check the timeleft
- if($a_voucher['vouchersyncdbip'])
+ if(!empty($a_voucher['vouchersyncdbip']))
if($remote_time_used['timeleft'] < $total_minutes)
$total_minutes = $remote_time_used['timeleft'];
@@ -238,8 +238,8 @@ function voucher_auth($voucher_received, $test = 0) {
// log in later using just the first voucher. It also keeps username limited
// to one voucher and that voucher shows the correct time credit in 'active vouchers'
- if ($line = $active_vouchers[$first_voucher_roll][$first_voucher]) {
- list($timestamp, $minutes) = explode(",", $line);
+ if (!empty($active_vouchers[$first_voucher_roll][$first_voucher])) {
+ list($timestamp, $minutes) = explode(",", $active_vouchers[$first_voucher_roll][$first_voucher]);
} else {
$timestamp = time(); // new voucher
$minutes = $total_minutes;
@@ -298,13 +298,13 @@ function voucher_configure() {
fwrite($fd, "{$config['voucher']['rollbits']},{$config['voucher']['ticketbits']},{$config['voucher']['checksumbits']},{$config['voucher']['magic']},{$config['voucher']['charset']}\n");
fclose($fd);
@chmod("{$g['varetc_path']}/voucher.cfg", 0600);
- unlock($voucherlck);
+ unlock($voucherlck);
if ($g['booting'] && is_array($config['voucher']['roll'])) {
// create active and used DB per roll on ramdisk from config
$a_roll = &$config['voucher']['roll'];
- $voucherlck = lock('voucher');
+ $voucherlck = lock('voucher', LOCK_EX);
foreach ($a_roll as $rollent) {
@@ -325,8 +325,8 @@ function voucher_configure() {
}
voucher_write_active_db($roll, $active_vouchers);
}
-
- unlock($voucherlck);
+
+ unlock($voucherlck);
echo gettext("done") . "\n";
}
@@ -363,7 +363,7 @@ function voucher_read_active_db($roll) {
$line = trim(fgets($fd));
if ($line) {
list($voucher,$timestamp,$minutes) = explode(",", $line); // voucher,timestamp
- if ((($timestamp + 60*$minutes) - time()) > 0)
+ if ((($timestamp + (60*$minutes)) - time()) > 0)
$active[$voucher] = "$timestamp,$minutes";
else
$dirty=1;
OpenPOWER on IntegriCloud