@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | $ipAddress = $_SERVER['argv'][3]; |
6 | 6 | $cpl->format = 'json'; |
7 | -$lisc = json_decode($cpl->fetchLicenseId(['ip' => $ipAddress]), TRUE); |
|
7 | +$lisc = json_decode($cpl->fetchLicenseId(['ip' => $ipAddress]), true); |
|
8 | 8 | print_r($lisc); |
9 | 9 | $liscid = $lisc['licenseid'][0]; |
10 | 10 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | reason => 'Automagic Expiration', |
16 | 16 | expcode => 'normal' |
17 | 17 | ] |
18 | - ), TRUE); |
|
18 | + ), true); |
|
19 | 19 | print $expire['result'].PHP_EOL; |
20 | 20 | } else { |
21 | 21 | print "There is no valid license for $ipAddress\n"; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | $cpl = new \Detain\Cpanel\Cpanel($_SERVER['argv'][1], $_SERVER['argv'][2]); |
6 | 6 | $cpl->format = 'json'; |
7 | -$licenses = json_decode($cpl->fetchLicenses(), TRUE); |
|
7 | +$licenses = json_decode($cpl->fetchLicenses(), true); |
|
8 | 8 | echo json_encode($licenses, JSON_PRETTY_PRINT); |
9 | 9 | /* |
10 | 10 | foreach ( $licenses->licenses as $lisc ) { |
@@ -72,7 +72,7 @@ |
||
72 | 72 | curl_setopt($this->curl, $option, $value); |
73 | 73 | $result = curl_exec($this->curl); |
74 | 74 | curl_close($this->curl); |
75 | - if ($result == FALSE) { |
|
75 | + if ($result == false) { |
|
76 | 76 | error_log('cPanelLicensing::get failed: "'.curl_error($this->curl).'"'); |
77 | 77 | return; |
78 | 78 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public $opts; |
14 | 14 | |
15 | 15 | /** |
16 | - * Cpanel constructor. |
|
17 | - * |
|
18 | - * @param $user |
|
19 | - * @param $pass |
|
20 | - */ |
|
16 | + * Cpanel constructor. |
|
17 | + * |
|
18 | + * @param $user |
|
19 | + * @param $pass |
|
20 | + */ |
|
21 | 21 | public function __construct($user, $pass) { |
22 | 22 | $this->opts = []; |
23 | 23 | $this->format = 'simplexml'; |
@@ -27,27 +27,27 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | - * @param $option |
|
31 | - * @param $value |
|
32 | - */ |
|
30 | + * @param $option |
|
31 | + * @param $value |
|
32 | + */ |
|
33 | 33 | public function setopt($option, $value) { |
34 | 34 | $this->opts[$option] = $value; |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * sets the login credentials |
|
39 | - * @param string $user the username |
|
40 | - * @param string $pass the password |
|
41 | - */ |
|
38 | + * sets the login credentials |
|
39 | + * @param string $user the username |
|
40 | + * @param string $pass the password |
|
41 | + */ |
|
42 | 42 | public function setCredentials($user, $pass) { |
43 | 43 | $this->setopt(CURLOPT_USERPWD, $user.':'.$pass); |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | - * sets the output format |
|
48 | - * |
|
49 | - * @param string $format can be any of xml,json,yaml,simplexml |
|
50 | - */ |
|
47 | + * sets the output format |
|
48 | + * |
|
49 | + * @param string $format can be any of xml,json,yaml,simplexml |
|
50 | + */ |
|
51 | 51 | public function setFormat($format) { |
52 | 52 | if ($format != 'xml' && $format != 'json' && $format != 'yaml' && $format != 'simplexml') { |
53 | 53 | error_log('setFormat requires that the format is xml, json, yaml or simplexml'); |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * @param string $function |
|
62 | - * @param array $args |
|
63 | - * @return array|mixed|void |
|
64 | - */ |
|
61 | + * @param string $function |
|
62 | + * @param array $args |
|
63 | + * @return array|mixed|void |
|
64 | + */ |
|
65 | 65 | private function get($function, $args = []) { |
66 | 66 | if (!$function) { |
67 | 67 | error_log('cPanelLicensing::get requires that a function is defined'); |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | - * formats the response |
|
98 | - * @param array $result the result array to format |
|
99 | - * @return array the rormatted arrray |
|
100 | - */ |
|
97 | + * formats the response |
|
98 | + * @param array $result the result array to format |
|
99 | + * @return array the rormatted arrray |
|
100 | + */ |
|
101 | 101 | private function formatResult($result) { |
102 | 102 | if (is_array($result)) { |
103 | 103 | foreach ($result as $key => $value) { |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * @param $id |
|
118 | - * @return int |
|
119 | - */ |
|
117 | + * @param $id |
|
118 | + * @return int |
|
119 | + */ |
|
120 | 120 | private function validateID($id) { |
121 | 121 | if (preg_match("/^(L|P|G)?\d*$/", $id)) { |
122 | 122 | return 1; |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | - * @param $ipAddress |
|
130 | - * @return int |
|
131 | - */ |
|
129 | + * @param $ipAddress |
|
130 | + * @return int |
|
131 | + */ |
|
132 | 132 | private function validateIP($ipAddress) { |
133 | 133 | return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ipAddress); |
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * @param $args |
|
138 | - * @return array|mixed|void |
|
139 | - */ |
|
137 | + * @param $args |
|
138 | + * @return array|mixed|void |
|
139 | + */ |
|
140 | 140 | public function reactivateLicense($args) { |
141 | 141 | if (!array_key_exists('liscid', $args)) { |
142 | 142 | error_log('cpanelLicensing::reactivateLicense requires that the argument array contains element liscid'); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * @param $args |
|
154 | - * @return array|mixed|void |
|
155 | - */ |
|
153 | + * @param $args |
|
154 | + * @return array|mixed|void |
|
155 | + */ |
|
156 | 156 | public function expireLicense($args) { |
157 | 157 | if (!array_key_exists('liscid', $args)) { |
158 | 158 | error_log('cPanelLicensing::expireLicense requires that liscid elements exists in the array passed to it'); |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * @param $args |
|
170 | - * @return array|mixed|void |
|
171 | - */ |
|
169 | + * @param $args |
|
170 | + * @return array|mixed|void |
|
171 | + */ |
|
172 | 172 | public function extendOnetimeUpdates($args) { |
173 | 173 | if (!array_key_exists('ip', $args)) { |
174 | 174 | error_log('cpanelLicensing::extendOnetimeUpdates requires that the element ip exists in the array is passed to it'); |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * @param $args |
|
186 | - * @return array|mixed|void |
|
187 | - */ |
|
185 | + * @param $args |
|
186 | + * @return array|mixed|void |
|
187 | + */ |
|
188 | 188 | public function changeip($args) { |
189 | 189 | if (!array_key_exists('oldip', $args) || !array_key_exists('newip', $args)) { |
190 | 190 | error_log('cpanelLicensing::changeip requires that oldip and newip elements exist in the array passed to it'); |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | - * @param $args |
|
202 | - * @return array|mixed|void |
|
203 | - */ |
|
201 | + * @param $args |
|
202 | + * @return array|mixed|void |
|
203 | + */ |
|
204 | 204 | public function requestTransfer($args) { |
205 | 205 | if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packagegroup', $args)) { |
206 | 206 | error_log('cpanelLicensing::requestTransfer requires that ip, groupid and packageid elements exist in the array passed to it'); |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
225 | - * @param $args |
|
226 | - * @return array|mixed|void |
|
227 | - */ |
|
225 | + * @param $args |
|
226 | + * @return array|mixed|void |
|
227 | + */ |
|
228 | 228 | public function activateLicense($args) { |
229 | 229 | if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packageid', $args)) { |
230 | 230 | error_log('cpanelLicensing::activateLicense requires that ip, groupid and packageid elements exist in the array passed to it'); |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | - * @param $args |
|
251 | - * @return array|mixed|void |
|
252 | - */ |
|
250 | + * @param $args |
|
251 | + * @return array|mixed|void |
|
252 | + */ |
|
253 | 253 | public function addPickupPass($args) { |
254 | 254 | if (!array_key_exists('pickup', $args)) { |
255 | 255 | error_log('cPanelLicensing::addPickupPass requires a pickup param'); |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | - * @param $args |
|
263 | - * @return array|mixed|void |
|
264 | - */ |
|
262 | + * @param $args |
|
263 | + * @return array|mixed|void |
|
264 | + */ |
|
265 | 265 | public function registerAuth($args) { |
266 | 266 | if (!array_key_exists('user', $args)) { |
267 | 267 | error_log('cPanelLicensing::registerAuth requires a user param'); |
@@ -282,20 +282,20 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | - * return s a list of groups |
|
286 | - * |
|
287 | - * @return array|mixed|void |
|
288 | - */ |
|
285 | + * return s a list of groups |
|
286 | + * |
|
287 | + * @return array|mixed|void |
|
288 | + */ |
|
289 | 289 | public function fetchGroups() { |
290 | 290 | return $this->get('XMLgroupInfo.cgi'); |
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | - * fetches license risk data |
|
295 | - * |
|
296 | - * @param array $args |
|
297 | - * @return array|mixed|void |
|
298 | - */ |
|
294 | + * fetches license risk data |
|
295 | + * |
|
296 | + * @param array $args |
|
297 | + * @return array|mixed|void |
|
298 | + */ |
|
299 | 299 | public function fetchLicenseRiskData($args = []) { |
300 | 300 | if (!array_key_exists('ip', $args)) { |
301 | 301 | error_log('cpanelLicensing::fetchLicenseRiskData requires that ip exists as an element in the array is passed to it'); |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
312 | - * gets raw license information |
|
313 | - * |
|
314 | - * @param array $args optional array of arguments |
|
315 | - * @return array|mixed|void |
|
316 | - */ |
|
312 | + * gets raw license information |
|
313 | + * |
|
314 | + * @param array $args optional array of arguments |
|
315 | + * @return array|mixed|void |
|
316 | + */ |
|
317 | 317 | public function fetchLicenseRaw($args = []) { |
318 | 318 | $args = array_merge(['all' => 1], $args); |
319 | 319 | if (!array_key_exists('ip', $args)) { |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
331 | - * gets license information |
|
332 | - * |
|
333 | - * @param array $args optional array of arguments |
|
334 | - * @return array|mixed|void |
|
335 | - */ |
|
331 | + * gets license information |
|
332 | + * |
|
333 | + * @param array $args optional array of arguments |
|
334 | + * @return array|mixed|void |
|
335 | + */ |
|
336 | 336 | public function fetchLicenseId($args = []) { |
337 | 337 | $args = array_merge(['all' => 1], $args); |
338 | 338 | if (!array_key_exists('ip', $args)) { |
@@ -347,35 +347,35 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | - * @return array|mixed|void |
|
351 | - */ |
|
350 | + * @return array|mixed|void |
|
351 | + */ |
|
352 | 352 | public function fetchPackages() { |
353 | 353 | return $this->get('XMLpackageInfo.cgi'); |
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * gets a list of licenses |
|
358 | - * |
|
359 | - * @param array $args optional arguments |
|
360 | - * @return array|mixed|void |
|
361 | - */ |
|
357 | + * gets a list of licenses |
|
358 | + * |
|
359 | + * @param array $args optional arguments |
|
360 | + * @return array|mixed|void |
|
361 | + */ |
|
362 | 362 | public function fetchLicenses($args = []) { |
363 | 363 | return $this->get('XMLlicenseInfo.cgi'); |
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
367 | - * return sa list of expired licenses |
|
368 | - * @return array|mixed|void |
|
369 | - */ |
|
367 | + * return sa list of expired licenses |
|
368 | + * @return array|mixed|void |
|
369 | + */ |
|
370 | 370 | public function fetchExpiredLicenses() { |
371 | 371 | return $this->fetchLicenses(['expired' => '1']); |
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
375 | - * @param $search |
|
376 | - * @param $xmlObj |
|
377 | - * @return string|void |
|
378 | - */ |
|
375 | + * @param $search |
|
376 | + * @param $xmlObj |
|
377 | + * @return string|void |
|
378 | + */ |
|
379 | 379 | public function findKey($search, $xmlObj) { |
380 | 380 | $xmlObj = (array) $xmlObj; |
381 | 381 | if (array_key_exists('packages', $xmlObj)) { |