1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Fantastico |
4
|
|
|
* Fantastico Class for interfacing with there API. Their API is pretty simple, so this |
5
|
|
|
* might not be needed, it just simplifies things a little more. |
6
|
|
|
* |
7
|
|
|
* @package MyAdmin |
8
|
|
|
* @author Joe Huss <[email protected]> |
9
|
|
|
* @copyright 2019 |
10
|
|
|
* @version $Id$ |
11
|
|
|
* @access public |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Detain\Fantastico; |
15
|
|
|
|
16
|
|
|
require_once __DIR__.'/../../../workerman/statistics/Applications/Statistics/Clients/StatisticClient.php'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class Fantastico |
20
|
|
|
* |
21
|
|
|
* @package Detain\Fantastico |
22
|
|
|
*/ |
23
|
|
|
class Fantastico |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* All fantastico license types |
28
|
|
|
*/ |
29
|
|
|
const ALL_TYPES = 0; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Normal/Server license types |
33
|
|
|
*/ |
34
|
|
|
const NORMAL_TYPES = 1; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* VPS license types |
38
|
|
|
*/ |
39
|
|
|
const VPS_TYPES = 2; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* the WSDL API file |
43
|
|
|
*/ |
44
|
|
|
public $wsdl = 'https://netenberg.com/api/netenberg.wsdl'; |
45
|
|
|
|
46
|
|
|
public $connected = false; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* the username to use for API access |
50
|
|
|
*/ |
51
|
|
|
private $apiUsername; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* the password to use for api access |
55
|
|
|
*/ |
56
|
|
|
private $apiPassword; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* this will hold the soap client, which hopefully we can reuse for multiple queries if need be |
60
|
|
|
*/ |
61
|
|
|
private $soapClient; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* this will hold responses from the API for future caching use |
65
|
|
|
*/ |
66
|
|
|
private $cache; |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* this holds an array of possible license types you can use and there descriptions |
72
|
|
|
* note the ALL_TYPES is only for listing, you cant buy one thats all_types |
73
|
|
|
*/ |
74
|
|
|
public $types = [ |
75
|
|
|
self::ALL_TYPES => 'All IPs', |
76
|
|
|
self::NORMAL_TYPES => 'Normal Licenses', |
77
|
|
|
self::VPS_TYPES => 'VPS Licenses' |
78
|
|
|
]; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Starts an instance of the fantastico license API. |
82
|
|
|
* |
83
|
|
|
* @param string $username username to connect to fantastico api with |
84
|
|
|
* @param string $password password to connect to fantastico api with |
85
|
|
|
*/ |
86
|
|
|
public function __construct($username, $password) |
87
|
|
|
{ |
88
|
|
|
$this->cache = []; |
89
|
|
|
$this->soapClient = null; |
90
|
|
|
$this->apiUsername = $username; |
91
|
|
|
$this->apiPassword = $password; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
1 |
|
* Fantastico::connect() |
96
|
1 |
|
* function called automatically to ensure that we're connected to the API |
97
|
1 |
|
* |
98
|
1 |
|
* @return void |
99
|
1 |
|
*/ |
100
|
1 |
|
public function connect() |
101
|
|
|
{ |
102
|
1 |
|
$nusoap = false; |
103
|
|
|
if (null === $this->soapClient) { |
104
|
|
|
ini_set('soap.wsdl_cache_enabled', '0'); |
105
|
|
|
ini_set('max_execution_time', 1000); |
106
|
|
|
ini_set('default_socket_timeout', 1000); |
107
|
1 |
|
try { |
108
|
|
|
$this->soapClient = new \SoapClient($this->wsdl, ['soap_version' => SOAP_1_1, 'connection_timeout' => 1000, 'trace' => 1, 'exception' => 1]); |
109
|
|
|
} catch (\Exception $e) { |
110
|
|
|
$nusoap = true; |
111
|
|
|
} |
112
|
1 |
|
} |
113
|
|
|
if (true === $nusoap) { |
114
|
|
|
require_once INCLUDE_ROOT.'/../vendor/detain/nusoap/lib/nusoap.php'; |
|
|
|
|
115
|
|
|
$this->soapClient = new \nusoap_client($this->wsdl); |
|
|
|
|
116
|
|
|
$this->connected = true; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Fantastico::getIpTypes() |
122
|
1 |
|
* returns an array of the possible license types in the format of |
123
|
1 |
|
* ID => Description |
124
|
|
|
* where ID is the Type ID you need to pass to various functions asking for a license type |
125
|
|
|
* |
126
|
|
|
* @return array returns an array of possible license types and descriptions of them |
127
|
|
|
*/ |
128
|
|
|
public function getIpTypes() |
129
|
|
|
{ |
130
|
|
|
return $this->types; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Fantastico::isType() |
135
|
|
|
* a check to make sure the passed type is valid |
136
|
|
|
* |
137
|
|
|
* @param mixed the license type your trying to validate |
|
|
|
|
138
|
|
|
* @param integer $type |
139
|
|
|
* @return bool whether or not its a valid fantastico license type |
140
|
|
|
*/ |
141
|
|
|
public function isType($type) |
142
|
|
|
{ |
143
|
|
|
return array_key_exists($type, $this->types); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Fantastico::getHash() |
148
|
|
|
* returns the login hash |
149
|
|
|
* |
150
|
|
|
* @return string the login hash |
151
|
|
|
*/ |
152
|
|
|
private function getHash() |
153
|
|
|
{ |
154
|
|
|
return md5($this->apiUsername.$this->apiPassword); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Fantastico::getIpList() |
159
|
|
|
* returns a list of all license types. |
160
|
|
|
* |
161
|
|
|
* Sample Return Output |
162
|
|
|
* Array |
163
|
|
|
* ( |
164
|
|
|
* [0] => 130.253.175.32 |
165
|
|
|
* [1] => 140.99.16.206 |
166
|
|
|
* [2] => 150.101.195.140 |
167
|
|
|
* ) |
168
|
|
|
* |
169
|
|
|
* @param integer $type one of the possible fantastico license types, defaults to {@link self::ALL_TYPES} |
170
|
|
|
* @return FALSE|array returns FALSE on error or an array of license details |
171
|
|
|
*/ |
172
|
|
|
public function getIpList($type = self::ALL_TYPES) |
173
|
|
|
{ |
174
|
|
|
if (isset($this->cache['getIpList_'.$type])) { |
175
|
|
|
return $this->cache['getIpList_'.$type]; |
176
|
|
|
} |
177
|
|
|
if (!$this->isType($type)) { |
178
|
|
|
return false; |
179
|
|
|
} |
180
|
|
|
$this->connect(); |
181
|
|
|
\StatisticClient::tick('Fantastico', 'getIpList'); |
|
|
|
|
182
|
|
|
$this->cache['getIpList_'.$type] = json_decode($this->soapClient->getIpList($this->getHash(), $type), true); |
183
|
|
|
if ($this->cache['getIpList_'.$type] === false) { |
184
|
|
|
\StatisticClient::report('Fantastico', 'getIpList', false, 1, 'Soap Client Error', STATISTICS_SERVER); |
|
|
|
|
185
|
|
|
} else { |
186
|
|
|
\StatisticClient::report('Fantastico', 'getIpList', true, 0, '', STATISTICS_SERVER); |
187
|
|
|
} |
188
|
|
|
myadmin_log('fantastico', 'debug', json_encode($this->cache['getIpList_'.$type]), __LINE__, __FILE__); |
|
|
|
|
189
|
|
|
return $this->cache['getIpList_'.$type]; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Fantastico::getIpListDetailed() |
194
|
|
|
* returns a list of all license types and details about each one |
195
|
|
|
* |
196
|
|
|
* Sample Return Output |
197
|
|
|
* |
198
|
|
|
* |
199
|
|
|
* Array |
200
|
|
|
* ( |
201
|
|
|
* [0] => { |
202
|
|
|
* Array |
203
|
|
|
* ( |
204
|
|
|
* [ipAddress] => 130.253.175.32 |
205
|
|
|
* [addedOn] => 2010-03-01 00:00:00 |
206
|
|
|
* [isVPS] => ( Yes || No ) |
207
|
|
|
* [status] => ( Active || Inactive ) |
208
|
|
|
* ) |
209
|
|
|
* } |
210
|
|
|
* [1] => { |
211
|
|
|
* Array |
212
|
|
|
* ( |
213
|
|
|
* [ipAddress] => 131.253.175.32 |
214
|
|
|
* [addedOn] => 2011-03-01 00:00:00 |
215
|
|
|
* [isVPS] => ( Yes || No ) |
216
|
|
|
* [status] => ( Active || Inactive ) |
217
|
|
|
* ) |
218
|
|
|
* } |
219
|
|
|
* [2] => { |
220
|
|
|
* Array |
221
|
|
|
* ( |
222
|
|
|
* [ipAddress] => 132.253.175.32 |
223
|
|
|
* [addedOn] => 2012-03-01 00:00:00 |
224
|
|
|
* [isVPS] => ( Yes || No ) |
225
|
|
|
* [status] => ( Active || Inactive ) |
226
|
|
|
* ) |
227
|
|
|
* } |
228
|
|
|
* ) |
229
|
|
|
* |
230
|
|
|
* @param integer $type one of the possible fantastico license types, defaults to {@link self::ALL_TYPES} |
231
|
|
|
* @return FALSE|array returns FALSE on error or an array of license details |
232
|
|
|
*/ |
233
|
|
|
public function getIpListDetailed($type = self::ALL_TYPES) |
234
|
|
|
{ |
235
|
|
|
if (!$this->isType($type)) { |
236
|
|
|
return false; |
237
|
|
|
} |
238
|
|
|
if (isset($this->cache['getIpListDetailed_'.$type])) { |
239
|
|
|
return $this->cache['getIpListDetailed_'.$type]; |
240
|
|
|
} |
241
|
|
|
$this->connect(); |
242
|
|
|
//try { |
243
|
|
|
\StatisticClient::tick('Fantastico', 'getIpListDetailed'); |
244
|
|
|
$response = json_decode($this->soapClient->__soapCall('getIpListDetailed', [$this->getHash(), $type]), true); |
245
|
|
|
if ($response === false) { |
246
|
|
|
\StatisticClient::report('Fantastico', 'getIpListDetailed', false, 1, 'Soap Client Error', STATISTICS_SERVER); |
|
|
|
|
247
|
|
|
} else { |
248
|
|
|
\StatisticClient::report('Fantastico', 'getIpListDetailed', true, 0, '', STATISTICS_SERVER); |
249
|
|
|
} |
250
|
|
|
myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__); |
|
|
|
|
251
|
|
|
//echo '<pre>';echo print_r($response, TRUE);echo '</pre>'; |
252
|
|
|
//$this->cache['getIpListDetailed_'.$type] = $this->cache['getIpListDetailed_'.$type]->Licenses; |
253
|
|
|
$this->cache['getIpListDetailed_'.$type] = []; |
254
|
|
|
$this->cache['getIpList_'.$type] = []; |
255
|
|
|
$responseValues = array_values($response['Licenses']); |
256
|
|
|
foreach ($responseValues as $data) { |
257
|
|
|
$tdata = [ |
258
|
|
|
'ipAddress' => $data[0], |
259
|
|
|
'addedOn' => $data[1], |
260
|
|
|
'isVPS' => $data[2], |
261
|
|
|
'status' => $data[3] |
262
|
|
|
]; |
263
|
|
|
$this->cache['getIpListDetailed_'.$type][] = $tdata; |
264
|
|
|
$this->cache['getIpList_'.$type][] = $tdata['ipAddress']; |
265
|
|
|
$this->cache['getIpDetails_'.$tdata['ipAddress']] = $tdata; |
266
|
|
|
} |
267
|
|
|
//} catch (SoapFault $fault) { |
268
|
|
|
//var_dump($fault); |
269
|
|
|
//var_dump($this->soapClient->__getLastRequest()); |
270
|
|
|
//var_dump($this->soapClient->__getLastResponse()); |
271
|
|
|
//} |
272
|
|
|
|
273
|
|
|
//foreach ($this->cache['getIpListDetailed_'.$type] as $idx => $data) |
274
|
|
|
//{ |
275
|
|
|
//$this->cache['getIpList_'.$type][] = $data['ipAddress']; |
276
|
|
|
//$this->cache['getIpDetails_'.$data['ipAddress']] = $data; |
277
|
|
|
//} |
278
|
|
|
//echo '<pre>';print_r($this->cache);echo '</pre>'; |
279
|
|
|
return $this->cache['getIpListDetailed_'.$type]; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Fantastico::validIp() |
284
|
|
|
* validates the IP address |
285
|
|
|
* |
286
|
|
|
* @param string $ipAddress IP Address to validate |
287
|
|
|
* @return bool whether or not the ip was validated |
288
|
|
|
*/ |
289
|
|
|
public function validIp($ipAddress) |
290
|
|
|
{ |
291
|
|
|
return ip2long($ipAddress) !== false; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* Fantastico::getIpDetails() |
296
|
|
|
* get details about a license |
297
|
|
|
* |
298
|
|
|
* Output Success |
299
|
|
|
* Array |
300
|
|
|
* ( |
301
|
|
|
* [ipAddress] => 130.253.175.32 |
302
|
|
|
* [addedOn] => 2010-03-01 00:00:00 |
303
|
|
|
* [isVPS] => ( Yes || No ) |
304
|
|
|
* [status] => ( Active || Inactive ) |
305
|
|
|
* ) |
306
|
|
|
* |
307
|
|
|
* |
308
|
|
|
* Output Error |
309
|
|
|
* |
310
|
|
|
* Array |
311
|
|
|
* ( |
312
|
|
|
* [faultcode] => 1801 |
313
|
|
|
* [fault ]=> "The IP Address that you have specified does not exist." |
314
|
|
|
* ) |
315
|
|
|
* |
316
|
|
|
* @param string $ipAddress ip address to get details for |
317
|
|
|
* @return mixed returns FALSE on invalid IP, or an array of the details. |
318
|
|
|
*/ |
319
|
|
|
public function getIpDetails($ipAddress) |
320
|
|
|
{ |
321
|
|
|
if (!$this->validIp($ipAddress)) { |
322
|
|
|
return ['faultcode' => 1, 'fault ' => 'Invalid IP Address '.$ipAddress]; |
323
|
|
|
} |
324
|
|
|
if (isset($this->cache['getIpDetails_'.$ipAddress])) { |
325
|
|
|
return $this->cache['getIpDetails_'.$ipAddress]; |
326
|
|
|
} |
327
|
|
|
$this->connect(); |
328
|
|
|
\StatisticClient::tick('Fantastico', 'getIpDetails'); |
329
|
|
|
$this->cache['getIpDetails_'.$ipAddress] = json_decode($this->soapClient->getIpDetails($this->getHash(), $ipAddress), true); |
330
|
|
|
if ($this->cache['getIpDetails_'.$ipAddress] === false) { |
331
|
|
|
\StatisticClient::report('Fantastico', 'getIpDetails', false, 1, 'Soap Client Error', STATISTICS_SERVER); |
|
|
|
|
332
|
|
|
} else { |
333
|
|
|
\StatisticClient::report('Fantastico', 'getIpDetails', true, 0, '', STATISTICS_SERVER); |
334
|
|
|
} |
335
|
|
|
myadmin_log('fantastico', 'debug', json_encode($this->cache['getIpDetails_'.$ipAddress]), __LINE__, __FILE__); |
|
|
|
|
336
|
|
|
return $this->cache['getIpDetails_'.$ipAddress]; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* Fantastico::editIp() |
341
|
|
|
* changes the IP address of a license |
342
|
|
|
* |
343
|
|
|
* |
344
|
|
|
* Output Success |
345
|
|
|
* |
346
|
|
|
* Array |
347
|
|
|
* ( |
348
|
|
|
* ["ip"]=>"130.253.175.32" |
349
|
|
|
* ["new_ip"]=>"130.253.175.33" |
350
|
|
|
* |
351
|
|
|
* ) |
352
|
|
|
* |
353
|
|
|
* |
354
|
|
|
* Output Error |
355
|
|
|
* |
356
|
|
|
* Array |
357
|
|
|
* ( |
358
|
|
|
* [faultcode] => 1704 |
359
|
|
|
* [fault ]=> "The new IP Address that you have specified is not a valid cPanel IP Address." |
360
|
|
|
* ) |
361
|
|
|
* |
362
|
|
|
* Array |
363
|
|
|
* ( |
364
|
|
|
* [faultcode] => 1705 |
365
|
|
|
* [fault ]=> "The new IP Address that you have specified is not a valid cPanel IP Address." |
366
|
|
|
* ) |
367
|
|
|
* |
368
|
|
|
* Array |
369
|
|
|
* ( |
370
|
|
|
* [faultcode] => 1703 |
371
|
|
|
* [fault ]=> "The IP Address that you have specified is not a valid VPS IP Address." |
372
|
|
|
* ) |
373
|
|
|
* |
374
|
|
|
* Array |
375
|
|
|
* ( |
376
|
|
|
* [faultcode] => 1804 |
377
|
|
|
* [fault ]=> "The IP Address that you have specified already exists." |
378
|
|
|
* ) |
379
|
|
|
* |
380
|
|
|
* Array |
381
|
|
|
* ( |
382
|
|
|
* [faultcode] => 1801 |
383
|
|
|
* [fault ]=> "The IP Address that you have specified does not exist." |
384
|
|
|
* ) |
385
|
|
|
* |
386
|
|
|
* |
387
|
|
|
* |
388
|
|
|
* Array |
389
|
|
|
* ( |
390
|
|
|
* [faultcode] => 1401 |
391
|
|
|
* [fault ]=> "You are trying to access the API from a server whose IP Address is not authorized." |
392
|
|
|
* ) |
393
|
|
|
* |
394
|
|
|
* Array |
395
|
|
|
* ( |
396
|
|
|
* [faultcode] => 1302 |
397
|
|
|
* [fault ]=> "You have specified an invalid hash." |
398
|
|
|
* ) |
399
|
|
|
* |
400
|
|
|
* |
401
|
|
|
* @param mixed $ipAddress old ip address currently licensed |
402
|
|
|
* @param mixed $newip new ip address to change i tot |
403
|
|
|
* @return array returns an array of ip and newip or a fault and faultcode |
404
|
|
|
*/ |
405
|
|
|
public function editIp($ipAddress, $newip) |
406
|
|
|
{ |
407
|
|
|
if (!$this->validIp($ipAddress)) { |
408
|
|
|
$response = ['faultcode' => 1, 'fault' => 'Invalid IP Address '.$ipAddress]; |
409
|
|
|
} elseif (!$this->validIp($newip)) { |
410
|
|
|
$response = ['faultcode' => 2, 'fault' => 'Invalid IP Address '.$newip]; |
411
|
|
|
} else { |
412
|
|
|
$this->connect(); |
413
|
|
|
\StatisticClient::tick('Fantastico', 'editIp'); |
414
|
|
|
$response = json_decode($this->soapClient->editIp($this->getHash(), $ipAddress, $newip), true); |
415
|
|
|
if ($response === false) { |
416
|
|
|
\StatisticClient::report('Fantastico', 'editIp', false, 1, 'Soap Client Error', STATISTICS_SERVER); |
|
|
|
|
417
|
|
|
} else { |
418
|
|
|
\StatisticClient::report('Fantastico', 'editIp', true, 0, '', STATISTICS_SERVER); |
419
|
|
|
} |
420
|
|
|
myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__); |
|
|
|
|
421
|
|
|
if (isset($response['fault '])) { |
422
|
|
|
$response['fault'] = $response['fault ']; |
423
|
|
|
unset($response['fault ']); |
424
|
|
|
} |
425
|
|
|
} |
426
|
|
|
$this->cache = []; |
427
|
|
|
return $response; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Fantastico::addIp() |
432
|
|
|
* adds a new license into the system |
433
|
|
|
* |
434
|
|
|
* Output Success |
435
|
|
|
* |
436
|
|
|
* Array |
437
|
|
|
* ( |
438
|
|
|
* ["ip"]=>"130.253.175.32" |
439
|
|
|
* ["id"]=>"112461" * |
440
|
|
|
* ) |
441
|
|
|
* |
442
|
|
|
* |
443
|
|
|
* Output Error |
444
|
|
|
* |
445
|
|
|
* Array |
446
|
|
|
* ( |
447
|
|
|
* [faultcode] => 1704 |
448
|
|
|
* [fault ]=> "The new IP Address that you have specified is not a valid cPanel IP Address." |
449
|
|
|
* ) |
450
|
|
|
* |
451
|
|
|
* Array |
452
|
|
|
* ( |
453
|
|
|
* [faultcode] => 1705 |
454
|
|
|
* [fault ]=> "The new IP Address that you have specified is not a valid cPanel IP Address." |
455
|
|
|
* ) |
456
|
|
|
* |
457
|
|
|
* Array |
458
|
|
|
* ( |
459
|
|
|
* [faultcode] => 1703 |
460
|
|
|
* [fault ]=> "The IP Address that you have specified is not a valid VPS IP Address." |
461
|
|
|
* ) |
462
|
|
|
* |
463
|
|
|
* Array |
464
|
|
|
* ( |
465
|
|
|
* [faultcode] => 1804 |
466
|
|
|
* [fault ]=> "The IP Address that you have specified already exists." |
467
|
|
|
* ) |
468
|
|
|
* |
469
|
|
|
* Array |
470
|
|
|
* ( |
471
|
|
|
* [faultcode] => 1603 |
472
|
|
|
* [fault ]=> "You are not allowed to add any more IP Addresses because you have reached your IP Address quota." |
473
|
|
|
* ) |
474
|
|
|
* |
475
|
|
|
* Array |
476
|
|
|
* ( |
477
|
|
|
* [faultcode] => 1401 |
478
|
|
|
* [fault ]=> "You are trying to access the API from a server whose IP Address is not authorized." |
479
|
|
|
* ) |
480
|
|
|
* |
481
|
|
|
* Array |
482
|
|
|
* ( |
483
|
|
|
* [faultcode] => 1302 |
484
|
|
|
* [fault ]=> "You have specified an invalid hash." |
485
|
|
|
* ) |
486
|
|
|
* |
487
|
|
|
* |
488
|
|
|
* @param string $ipAddress ip address |
489
|
|
|
* @param integer $type license type |
490
|
|
|
* @return array response array containing a faultcode and fault, or ip and id on success |
491
|
|
|
*/ |
492
|
|
|
public function addIp($ipAddress, $type) |
493
|
|
|
{ |
494
|
|
|
if (!$this->validIp($ipAddress)) { |
495
|
|
|
$response = ['faultcode' => 1, 'fault' => 'Invalid IP Address '.$ipAddress]; |
496
|
|
|
} else { |
497
|
|
|
$this->connect(); |
498
|
|
|
\StatisticClient::tick('Fantastico', 'addIp'); |
499
|
|
|
$response = json_decode($this->soapClient->addIp($this->getHash(), $ipAddress, $type), true); |
500
|
|
|
if ($response === false) { |
501
|
|
|
\StatisticClient::report('Fantastico', 'addIp', false, 1, 'Soap Client Error', STATISTICS_SERVER); |
|
|
|
|
502
|
|
|
} else { |
503
|
|
|
\StatisticClient::report('Fantastico', 'addIp', true, 0, '', STATISTICS_SERVER); |
504
|
|
|
} |
505
|
|
|
myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__); |
|
|
|
|
506
|
|
|
if (isset($response['fault '])) { |
507
|
|
|
$response['fault'] = $response['fault ']; |
508
|
|
|
unset($response['fault ']); |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
$this->cache = []; |
512
|
|
|
return $response; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* @param $function |
517
|
|
|
* @param $ipAddress |
518
|
|
|
* @return array|mixed |
519
|
|
|
*/ |
520
|
|
|
private function soapIpFunction($function, $ipAddress) |
521
|
|
|
{ |
522
|
|
|
if (!$this->validIp($ipAddress)) { |
523
|
|
|
return ['faultcode' => 1, 'fault ' => 'Invalid IP Address '.$ipAddress]; |
524
|
|
|
} |
525
|
|
|
$this->connect(); |
526
|
|
|
\StatisticClient::tick('Fantastico', $function); |
527
|
|
|
$response = json_decode($this->soapClient->$function($this->getHash(), $ipAddress), true); |
528
|
|
|
if ($response === false) { |
529
|
|
|
\StatisticClient::report('Fantastico', $function, false, 1, 'Soap Client Error', STATISTICS_SERVER); |
|
|
|
|
530
|
|
|
} else { |
531
|
|
|
\StatisticClient::report('Fantastico', $function, true, 0, '', STATISTICS_SERVER); |
532
|
|
|
} |
533
|
|
|
myadmin_log('fantastico', 'debug', json_encode($response), __LINE__, __FILE__); |
|
|
|
|
534
|
|
|
$this->cache = []; |
535
|
|
|
return $response; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* deactivateIp() |
540
|
|
|
* Deactivates a Fantastico IP License |
541
|
|
|
* Output Success |
542
|
|
|
* Array |
543
|
|
|
* ( |
544
|
|
|
* [ipAddress] => 130.253.175.32 |
545
|
|
|
* [addedOn] => 2010-03-01 00:00:00 |
546
|
|
|
* [isVPS] => ( Yes || No ) |
547
|
|
|
* [status] => ( Active || Inactive ) |
548
|
|
|
* ) |
549
|
|
|
* |
550
|
|
|
* Output Error |
551
|
|
|
* Array |
552
|
|
|
* ( |
553
|
|
|
* [faultcode] => 1801 |
554
|
|
|
* [fault ]=> "The IP Address that you have specified does not exist." |
555
|
|
|
* ) |
556
|
|
|
* |
557
|
|
|
* @param mixed $ipAddress |
558
|
|
|
* @return void |
559
|
|
|
*/ |
560
|
|
|
public function deactivateIp($ipAddress) |
561
|
|
|
{ |
562
|
|
|
return $this->soapIpFunction('deactivateIp', $ipAddress); |
563
|
|
|
} |
564
|
|
|
|
565
|
|
|
/** |
566
|
|
|
* reactivateIp() |
567
|
|
|
* Deactivates a Fantastico IP License |
568
|
|
|
* Output Success |
569
|
|
|
* Array |
570
|
|
|
* ( |
571
|
|
|
* [ipAddress] => 130.253.175.32 |
572
|
|
|
* [addedOn] => 2010-03-01 00:00:00 |
573
|
|
|
* [isVPS] => ( Yes || No ) |
574
|
|
|
* [status] => ( Active || Inactive ) |
575
|
|
|
* ) |
576
|
|
|
* |
577
|
|
|
* Output Error |
578
|
|
|
* Array |
579
|
|
|
* ( |
580
|
|
|
* [faultcode] => 1801 |
581
|
|
|
* [fault ]=> "The IP Address that you have specified does not exist." |
582
|
|
|
* ) |
583
|
|
|
* |
584
|
|
|
* @param mixed $ipAddress |
585
|
|
|
* @return void |
586
|
|
|
*/ |
587
|
|
|
public function reactivateIp($ipAddress) |
588
|
|
|
{ |
589
|
|
|
return $this->soapIpFunction('reactivateIp', $ipAddress); |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
/** |
593
|
|
|
* deleteIp() |
594
|
|
|
* Deletes a Fantastico IP License |
595
|
|
|
* |
596
|
|
|
* Output Success |
597
|
|
|
* |
598
|
|
|
* Array |
599
|
|
|
* ( |
600
|
|
|
* [ip] => 130.253.175.32 |
601
|
|
|
* [deleted] => "Yes" |
602
|
|
|
* ) |
603
|
|
|
* |
604
|
|
|
* Output Error |
605
|
|
|
* |
606
|
|
|
* Array |
607
|
|
|
* ( |
608
|
|
|
* [faultcode] => 1801 |
609
|
|
|
* [fault ]=> "The IP Address that you have specified does not exist." |
610
|
|
|
* ) |
611
|
|
|
* |
612
|
|
|
* @param mixed $ipAddress |
613
|
|
|
* @return void |
614
|
|
|
*/ |
615
|
|
|
public function deleteIp($ipAddress) |
616
|
|
|
{ |
617
|
|
|
return $this->soapIpFunction('deleteIp', $ipAddress); |
618
|
|
|
} |
619
|
|
|
} |
620
|
|
|
|