diff --git a/src/etc/inc/voucher.inc b/src/etc/inc/voucher.inc index 78ab717a6..0b1769331 100644 --- a/src/etc/inc/voucher.inc +++ b/src/etc/inc/voucher.inc @@ -37,183 +37,6 @@ if(!function_exists('captiveportal_syslog')) require_once("captiveportal.inc"); -function xmlrpc_sync_voucher_expire($vouchers, $syncip, $port, $password, $username) { - global $g, $config, $cpzone; - require_once("xmlrpc.inc"); - - $protocol = "http"; - if (is_array($config['system']) && is_array($config['system']['webgui']) && !empty($config['system']['webgui']['protocol']) && - $config['system']['webgui']['protocol'] == "https") - $protocol = "https"; - if ($protocol == "https" || $port == "443") - $url = "https://{$syncip}"; - else - $url = "http://{$syncip}"; - - /* Construct code that is run on remote machine */ - $method = 'pfsense.exec_php'; - $execcmd = <<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_voucher_disconnect($dbent, $syncip, $port, $password, $username, $term_cause = 1, $stop_time = null) { - global $g, $config, $cpzone; - require_once("xmlrpc.inc"); - - $protocol = "http"; - if (is_array($config['system']) && is_array($config['system']['webgui']) && !empty($config['system']['webgui']['protocol']) && - $config['system']['webgui']['protocol'] == "https") - $protocol = "https"; - if ($protocol == "https" || $port == "443") - $url = "https://{$syncip}"; - else - $url = "http://{$syncip}"; - - /* Construct code that is run on remote machine */ - $dbent_str = serialize($dbent); - $tmp_stop_time = (isset($stop_time)) ? $stop_time : "null"; - $method = 'pfsense.exec_php'; - $execcmd = <<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, $cpzone; - require_once("xmlrpc.inc"); - - $protocol = "http"; - if (is_array($config['system']) && is_array($config['system']['webgui']) && !empty($config['system']['webgui']['protocol']) && - $config['system']['webgui']['protocol'] == "https") - $protocol = "https"; - if ($protocol == "https" || $port == "443") - $url = "https://{$syncip}"; - else - $url = "http://{$syncip}"; - - /* Construct code that is run on remote machine */ - $method = 'pfsense.exec_php'; - $execcmd = <<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 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 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']) && is_array($toreturn['voucher']['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']; -} function voucher_expire($voucher_received) { global $g, $config, $cpzone;