Revision e3b0eeb2
Added by Pi Ba almost 9 years ago
src/etc/inc/voucher.inc | ||
---|---|---|
42 | 42 |
voucher_expire("$vouchers"); |
43 | 43 |
|
44 | 44 |
EOF; |
45 |
$rpc_client = new pfsense_xmlrpc_client_extended($syncip, $port, $username, $password); |
|
45 |
$rpc_client = new pfsense_xmlrpc_client(); |
|
46 |
$rpc_client->setConnectionData($syncip, $port, $username, $password); |
|
46 | 47 |
$resp = $rpc_client->xmlrpc_exec_php($execcmd); |
47 | 48 |
if (empty($resp)) { |
48 | 49 |
return false; |
... | ... | |
66 | 67 |
captiveportal_disconnect(\$dbent, \$radiusservers, $term_cause, $tmp_stop_time); |
67 | 68 |
|
68 | 69 |
EOF; |
69 |
$rpc_client = new pfsense_xmlrpc_client_extended($syncip, $port, $username, $password); |
|
70 |
$rpc_client = new pfsense_xmlrpc_client(); |
|
71 |
$rpc_client->setConnectionData($syncip, $port, $username, $password); |
|
70 | 72 |
$resp = $rpc_client->xmlrpc_exec_php($execcmd); |
71 | 73 |
if (empty($resp)) { |
72 | 74 |
return false; |
... | ... | |
90 | 92 |
\$toreturn['voucher']['roll'] = \$config['voucher'][\$cpzone]['roll']; |
91 | 93 |
|
92 | 94 |
EOF; |
93 |
$rpc_client = new pfsense_xmlrpc_client_extended($syncip, $port, $username, $password); |
|
95 |
$rpc_client = new pfsense_xmlrpc_client(); |
|
96 |
$rpc_client->setConnectionData($syncip, $port, $username, $password); |
|
94 | 97 |
$resp = $rpc_client->xmlrpc_exec_php($execcmd); |
95 | 98 |
|
96 | 99 |
if (!is_array($config['voucher'])) { |
src/etc/inc/xmlrpc_client.inc | ||
---|---|---|
21 | 21 |
|
22 | 22 |
require_once("XML/RPC2/Client.php"); |
23 | 23 |
|
24 |
class pfsense_xmlrpc_client_extended {
|
|
24 |
class pfsense_xmlrpc_client { |
|
25 | 25 |
|
26 | 26 |
private $username, $password, $url, $filenotice, $error; |
27 | 27 |
|
28 |
public function __construct($syncip, $port, $username, $password) { |
|
28 |
public function __construct() { |
|
29 |
global $config; |
|
30 |
$hasync = $config['hasync']; |
|
31 |
|
|
32 |
if (empty($hasync['username'])) { |
|
33 |
$username = "admin"; |
|
34 |
} else { |
|
35 |
$username = $hasync['username']; |
|
36 |
} |
|
37 |
/* if port is empty lets rely on the protocol selection */ |
|
38 |
$port = $config['system']['webgui']['port']; |
|
39 |
if (empty($port)) { |
|
40 |
if ($config['system']['webgui']['protocol'] == "http") { |
|
41 |
$port = "80"; |
|
42 |
} else { |
|
43 |
$port = "443"; |
|
44 |
} |
|
45 |
} |
|
46 |
$this->setConnectionData($hasync['synchronizetoip'], $port, $username, $hasync['password']); |
|
47 |
} |
|
48 |
|
|
49 |
public function setConnectionData($syncip, $port, $username, $password) { |
|
29 | 50 |
global $config; |
30 | 51 |
$this->username = $username; |
31 | 52 |
$this->password = $password; |
... | ... | |
41 | 62 |
if (is_ipaddrv6($syncip)) { |
42 | 63 |
$syncip = "[{$syncip}]"; |
43 | 64 |
} |
44 |
//TODO: check if the url needs to end with?: |
|
45 | 65 |
if ($protocol == "https" || $port == "443") { |
46 | 66 |
$this->url = "https://{$syncip}:{$port}/xmlrpc.php"; |
47 | 67 |
} else { |
... | ... | |
110 | 130 |
$resp = $this->xmlrpc_internal($method, $parameter, $timeout); |
111 | 131 |
return $resp; |
112 | 132 |
} |
133 |
|
|
113 | 134 |
function get_error() { |
114 | 135 |
return $this->error; |
115 | 136 |
} |
116 |
} |
|
117 |
|
|
118 |
class pfsense_xmlrpc_client extends pfsense_xmlrpc_client_extended { |
|
119 |
/* Default sync class */ |
|
120 |
public function __construct() { |
|
121 |
global $config; |
|
122 |
$hasync = $config['hasync']; |
|
123 |
|
|
124 |
if (empty($hasync['username'])) { |
|
125 |
$username = "admin"; |
|
126 |
} else { |
|
127 |
$username = $hasync['username']; |
|
128 |
} |
|
129 |
/* if port is empty lets rely on the protocol selection */ |
|
130 |
$port = $config['system']['webgui']['port']; |
|
131 |
if (empty($port)) { |
|
132 |
if ($config['system']['webgui']['protocol'] == "http") { |
|
133 |
$port = "80"; |
|
134 |
} else { |
|
135 |
$port = "443"; |
|
136 |
} |
|
137 |
} |
|
138 |
parent::__construct($hasync['synchronizetoip'], $port, $username, $hasync['password']); |
|
139 |
} |
|
140 |
|
|
141 | 137 |
} |
src/usr/local/www/services_captiveportal_vouchers.php | ||
---|---|---|
300 | 300 |
|
301 | 301 |
EOF; |
302 | 302 |
require_once("xmlrpc_client.inc"); |
303 |
$rpc_client = new pfsense_xmlrpc_client_extended( |
|
303 |
$rpc_client = new pfsense_xmlrpc_client(); |
|
304 |
$rpc_client->setConnectionData( |
|
304 | 305 |
$newvoucher['vouchersyncdbip'], $newvoucher['vouchersyncport'], |
305 | 306 |
$newvoucher['vouchersyncusername'], $newvoucher['vouchersyncpass']); |
306 | 307 |
$rpc_client->set_noticefile("CaptivePortalVoucherSync"); |
Also available in: Unified diff
XMLRPC, xmlrpc_client remove extended class and define setConnectionData(.) function instead.