Commit 80d80743 authored by Ad Schellevis's avatar Ad Schellevis

remove unused function from voucher.inc

parent de6ef316
......@@ -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 = <<<EOF
global \$cpzone;
require_once('captiveportal.inc');
require_once('voucher.inc');
\$cpzone = "$cpzone";
voucher_expire("$vouchers");
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_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 = <<<EOF
global \$cpzone;
require_once('captiveportal.inc');
require_once('voucher.inc');
\$cpzone = "$cpzone";
\$radiusservers = captiveportal_get_radius_servers();
\$dbent = unserialize("$dbent_str");
captiveportal_disconnect(\$dbent, \$radiusservers, $term_cause, $tmp_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, $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 = <<<EOF
global \$cpzone;
require_once('voucher.inc');
\$cpzone = "$cpzone";
\$timeleft = voucher_auth("$voucher_received");
\$toreturn = array();
\$toreturn['timeleft'] = \$timeleft;
\$toreturn['voucher'] = array();
\$toreturn['voucher']['roll'] = \$config['voucher'][\$cpzone]['roll'];
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 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;
......
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