@@ -109,6 +109,9 @@ discard block |
||
109 | 109 | return $ret; |
110 | 110 | } |
111 | 111 | |
112 | + /** |
|
113 | + * @param string $level |
|
114 | + */ |
|
112 | 115 | public function log($level, $text, $line = '', $file = '') { |
113 | 116 | if (function_exists('myadmin_log')) |
114 | 117 | myadmin_log('cloudlinux', $level, $text, $line, $file); |
@@ -246,7 +249,7 @@ discard block |
||
246 | 249 | * Remove IP licenses with specified type for customer. Also unÂregisters from CLN server associated with IP. |
247 | 250 | * @param string $ipAddress ip address to remove |
248 | 251 | * @param int $type optional parameter to specify the type of license to remove (1,2, or 16) or 0 for all |
249 | - * @return false|integer 0 on success, -1 on error, Error will be returned also if account have no licenses for provided IP. |
|
252 | + * @return boolean 0 on success, -1 on error, Error will be returned also if account have no licenses for provided IP. |
|
250 | 253 | */ |
251 | 254 | public function removeLicense($ipAddress, $type = 0) { |
252 | 255 | $this->log('info', "Calling CLoudLinux->xmlClient->removeLicense({$this->authToken()}, {$ipAddress}, {$type})", __LINE__, __FILE__); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if (is_array($postfields)) { |
92 | 92 | $postdata = []; |
93 | 93 | foreach ($postfields as $field => $value) { |
94 | - $postdata[] = $field . '=' . urlencode($value); |
|
94 | + $postdata[] = $field.'='.urlencode($value); |
|
95 | 95 | } |
96 | 96 | curl_setopt($curl, CURLOPT_POSTFIELDS, implode('&', $postdata)); |
97 | 97 | } else { |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | public function authToken() { |
211 | 211 | $time = time(); |
212 | 212 | try { |
213 | - return $this->login . '|' . $time . '|' . sha1($this->key . $time); |
|
213 | + return $this->login.'|'.$time.'|'.sha1($this->key.$time); |
|
214 | 214 | } catch (\Exception $e) { |
215 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
216 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
215 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
216 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | } |
@@ -227,15 +227,15 @@ discard block |
||
227 | 227 | * @return false|integer 0 on success, -1 on error |
228 | 228 | */ |
229 | 229 | public function license($ipAddress, $type) { |
230 | - $type = (int)$type; |
|
230 | + $type = (int) $type; |
|
231 | 231 | try { |
232 | - $this->log('error', 'Calling License(' . $this->authToken() . ',' . $ipAddress . ',' . $type . ')'); |
|
232 | + $this->log('error', 'Calling License('.$this->authToken().','.$ipAddress.','.$type.')'); |
|
233 | 233 | $this->response = $this->xmlClient->license($this->authToken(), $ipAddress, $type); |
234 | - $this->log('error', 'Response: ' . var_export($this->response, true)); |
|
234 | + $this->log('error', 'Response: '.var_export($this->response, true)); |
|
235 | 235 | return $this->response; |
236 | 236 | } catch (\Exception $e) { |
237 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
238 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
237 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
238 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | } |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | try { |
254 | 254 | return $this->response = $this->remove($ipAddress, $type); |
255 | 255 | } catch (\Exception $e) { |
256 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
257 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
256 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
257 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | } |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | try { |
286 | 286 | return $this->response = $this->xmlClient->isLicensed($this->authToken(), $ipAddress, $checkAll); |
287 | 287 | } catch (\Exception $e) { |
288 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
289 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
288 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
289 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
290 | 290 | return false; |
291 | 291 | } |
292 | 292 | } |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function licenseList() { |
298 | 298 | try { |
299 | - return json_decode($this->getcurlpage($this->restUrl.'ipl/list.json?token=' . $this->authToken())); |
|
299 | + return json_decode($this->getcurlpage($this->restUrl.'ipl/list.json?token='.$this->authToken())); |
|
300 | 300 | } catch (\Exception $e) { |
301 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
302 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
301 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
302 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
303 | 303 | return false; |
304 | 304 | } |
305 | 305 | } |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | try { |
318 | 318 | return $this->response = $this->xmlClient->reconcile($this->authToken()); |
319 | 319 | } catch (\Exception $e) { |
320 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
321 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
320 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
321 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | } |
@@ -28,8 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | * @access public |
30 | 30 | */ |
31 | -class Cloudlinux |
|
32 | -{ |
|
31 | +class Cloudlinux { |
|
33 | 32 | private $login = ''; |
34 | 33 | private $key = ''; |
35 | 34 | public $prefix = 'registration.'; |