summaryrefslogtreecommitdiffstats
path: root/etc/inc/voucher.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2014-02-24 14:57:04 +0000
committerErmal <eri@pfsense.org>2014-02-24 14:57:04 +0000
commit62f965689c4adb1ab9424080c784c463bd024aec (patch)
treea7633f961c53114b6e1df58deca3a298ffb85e37 /etc/inc/voucher.inc
parentac420abd1df2b9fb68ca1877a07e1f33fac19f85 (diff)
downloadpfsense-62f965689c4adb1ab9424080c784c463bd024aec.zip
pfsense-62f965689c4adb1ab9424080c784c463bd024aec.tar.gz
Properly detect when there are issues with communicating with syncip and to use the local DB for this. Otherwise detect if the remote says the voucher is not valid say its not valid.
Diffstat (limited to 'etc/inc/voucher.inc')
-rw-r--r--etc/inc/voucher.inc15
1 files changed, 10 insertions, 5 deletions
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index a3f8caa..e4fc23e 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -188,24 +188,26 @@ EOF;
$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 0; // $timeleft
+ return null; // $timeleft
} elseif($resp->faultCode()) {
$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 0; // $timeleft
+ return null; // $timeleft
} else {
log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
}
$toreturn = XML_RPC_Decode($resp->value());
if (!is_array($config['voucher']))
$config['voucher'] = array();
+
if (is_array($toreturn['voucher']) && (count($toreturn['voucher']['roll']) <> count($config['voucher'][$cpzone]['roll']))) {
$config['voucher'][$cpzone]['roll'] = $toreturn['voucher']['roll'];
write_config("Captive Portal Voucher database synchronized with {$url}");
voucher_configure_zone(true);
unset($toreturn['voucher']);
- }
+ } else if (!isset($toreturn['timeleft']))
+ return null;
return $toreturn['timeleft'];
}
@@ -440,9 +442,12 @@ function voucher_auth($voucher_received, $test = 0) {
}
// If we did a XMLRPC sync earlier check the timeleft
- if (!empty($config['voucher'][$cpzone]['vouchersyncdbip']))
- if($remote_time_used < $total_minutes)
+ if (!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) {
+ if (!is_null($remote_time_used))
+ $total_minutes = $remote_time_used;
+ else if ($remote_time_used < $total_minutes)
$total_minutes -= $remote_time_used;
+ }
// All given vouchers were valid and this isn't simply a test.
// Write back the used DB's
OpenPOWER on IntegriCloud