summaryrefslogtreecommitdiffstats
path: root/etc/inc/voucher.inc
diff options
context:
space:
mode:
authorVinicius Coque <vinicius.coque@bluepex.com>2011-03-25 08:59:29 -0300
committerVinicius Coque <vinicius.coque@bluepex.com>2011-03-25 08:59:29 -0300
commit152ab4d0c036889d5d983cef0f612c2dcf211e7b (patch)
tree2120aa2834d2b0218a8bede4629aaac4acfbd5ec /etc/inc/voucher.inc
parent54bdff758f68e2e1b1ebd42b8b0b629b68ed1a3d (diff)
parentd93ee937f2305f06148d972be92224a2a52ba9e5 (diff)
downloadpfsense-152ab4d0c036889d5d983cef0f612c2dcf211e7b.zip
pfsense-152ab4d0c036889d5d983cef0f612c2dcf211e7b.tar.gz
Merge remote-tracking branch 'mainline/master' into inc
Conflicts: etc/inc/interfaces.inc etc/inc/priv.defs.inc etc/inc/shaper.inc etc/inc/system.inc
Diffstat (limited to 'etc/inc/voucher.inc')
-rw-r--r--etc/inc/voucher.inc48
1 files changed, 48 insertions, 0 deletions
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index cb13770..7d618ee 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -37,6 +37,54 @@
if(!function_exists('captiveportal_syslog'))
require_once("captiveportal.inc");
+function xmlrpc_sync_voucher_disconnect($dbent, $syncip, $port, $password, $username, $term_cause = "1", $stop_time = null) {
+ global $g, $config;
+ 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/captiveportal.inc');
+ require_once('/etc/inc/voucher.inc');
+ \$radiusservers = captiveportal_get_radius_servers();
+ captiveportal_disconnect(\$dbent, \$radiusservers, \$term_cause, \$stop_time);
+
+EOF;
+
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($execcmd)
+ );
+
+ log_error("Captive Portal Voucher XMLRPC sync data {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials($username, $password);
+ $resp = $cli->send($msg, "250");
+ 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", "");
+ return false;
+ } 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 false;
+ } else {
+ log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
+ }
+
+ $toreturn = XML_RPC_Decode($resp->value());
+
+ return $toreturn;
+}
+
function xmlrpc_sync_used_voucher($voucher_received, $syncip, $port, $password, $username) {
global $g, $config;
require_once("xmlrpc.inc");
OpenPOWER on IntegriCloud