@@ -107,6 +107,9 @@ discard block |
||
| 107 | 107 | return $ret; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | + /** |
|
| 111 | + * @param string $level |
|
| 112 | + */ |
|
| 110 | 113 | public function log($level, $text, $line = '', $file = '') { |
| 111 | 114 | if (function_exists('myadmin_log')) |
| 112 | 115 | myadmin_log('cloudlinux', $level, $text, $line, $file); |
@@ -243,8 +246,8 @@ discard block |
||
| 243 | 246 | * or |
| 244 | 247 | * Remove IP licenses with specified type for customer. Also unÂregisters from CLN server associated with IP. |
| 245 | 248 | * @param string $ip ip address to remove |
| 246 | - * @param bool|false|int $type optional parameter to specify the type of license to remove (1,2, or 16) |
|
| 247 | - * @return integer 0 on success, -1 on error, Error will be returned also if account have no licenses for provided IP. |
|
| 249 | + * @param integer $type optional parameter to specify the type of license to remove (1,2, or 16) |
|
| 250 | + * @return boolean 0 on success, -1 on error, Error will be returned also if account have no licenses for provided IP. |
|
| 248 | 251 | */ |
| 249 | 252 | public function remove_license($ip, $type = false) { |
| 250 | 253 | $this->log('info', "Calling CLoudLinux->xml_client->remove_license({$this->authToken()}, {$ip}, {$type})", __LINE__, __FILE__); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | if (is_array($postfields)) { |
| 90 | 90 | $postdata = []; |
| 91 | 91 | foreach ($postfields as $field => $value) { |
| 92 | - $postdata[] = $field . '=' . urlencode($value); |
|
| 92 | + $postdata[] = $field.'='.urlencode($value); |
|
| 93 | 93 | } |
| 94 | 94 | curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $postdata)); |
| 95 | 95 | } else { |
@@ -208,10 +208,10 @@ discard block |
||
| 208 | 208 | public function authToken() { |
| 209 | 209 | $time = time(); |
| 210 | 210 | try { |
| 211 | - return $this->login . '|' . $time . '|' . sha1($this->key . $time); |
|
| 211 | + return $this->login.'|'.$time.'|'.sha1($this->key.$time); |
|
| 212 | 212 | } catch (Exception $e) { |
| 213 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
| 214 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
| 213 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
| 214 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -225,15 +225,15 @@ discard block |
||
| 225 | 225 | * @return integer 0 on success, -1 on error |
| 226 | 226 | */ |
| 227 | 227 | public function license($ip, $type) { |
| 228 | - $type = (int)$type; |
|
| 228 | + $type = (int) $type; |
|
| 229 | 229 | try { |
| 230 | - $this->log('error', 'Calling License(' . $this->authToken() . ',' . $ip . ',' . $type . ')'); |
|
| 230 | + $this->log('error', 'Calling License('.$this->authToken().','.$ip.','.$type.')'); |
|
| 231 | 231 | $this->response = $this->xml_client->license($this->authToken(), $ip, $type); |
| 232 | - $this->log('error', 'Response: ' . var_export($this->response, true)); |
|
| 232 | + $this->log('error', 'Response: '.var_export($this->response, true)); |
|
| 233 | 233 | return $this->response; |
| 234 | 234 | } catch (Exception $e) { |
| 235 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
| 236 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
| 235 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
| 236 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
| 237 | 237 | return false; |
| 238 | 238 | } |
| 239 | 239 | } |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | else |
| 255 | 255 | return $this->response = $this->remove($ip, $type); |
| 256 | 256 | } catch (Exception $e) { |
| 257 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
| 258 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
| 257 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
| 258 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
| 259 | 259 | return false; |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | try { |
| 287 | 287 | return $this->response = $this->xml_client->is_licensed($this->authToken(), $ip, $checkAll); |
| 288 | 288 | } catch (Exception $e) { |
| 289 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
| 290 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
| 289 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
| 290 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
| 291 | 291 | return false; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | public function license_list() { |
| 299 | 299 | try { |
| 300 | - return json_decode($this->getcurlpage($this->rest_url.'ipl/list.json?token=' . $this->authToken())); |
|
| 300 | + return json_decode($this->getcurlpage($this->rest_url.'ipl/list.json?token='.$this->authToken())); |
|
| 301 | 301 | } catch (Exception $e) { |
| 302 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
| 303 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
| 302 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
| 303 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
| 304 | 304 | return false; |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | try { |
| 319 | 319 | return $this->response = $this->xml_client->reconcile($this->authToken()); |
| 320 | 320 | } catch (Exception $e) { |
| 321 | - $this->log('error', 'Caught exception code: ' . $e->getCode()); |
|
| 322 | - $this->log('error', 'Caught exception message: ' . $e->getMessage()); |
|
| 321 | + $this->log('error', 'Caught exception code: '.$e->getCode()); |
|
| 322 | + $this->log('error', 'Caught exception message: '.$e->getMessage()); |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | } |