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