| @@ -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 | } | 
| @@ -57,8 +57,9 @@ discard block | ||
| 57 | 57 |  	public function __construct($login, $key, $type = 'rest') { | 
| 58 | 58 | $this->login = $login; | 
| 59 | 59 | $this->key = $key; | 
| 60 | - if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) | |
| 61 | -			$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input'); | |
| 60 | +		if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { | |
| 61 | +					$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input'); | |
| 62 | + } | |
| 62 | 63 |  		//if ($api_type == 'xml') { | 
| 63 | 64 |  			include_once('XML/RPC2/Client.php'); | 
| 64 | 65 | $this->xml_options['prefix'] = $this->prefix; | 
| @@ -108,10 +109,11 @@ discard block | ||
| 108 | 109 | } | 
| 109 | 110 | |
| 110 | 111 |  	public function log($level, $text, $line = '', $file = '') { | 
| 111 | -		if (function_exists('myadmin_log')) | |
| 112 | -			myadmin_log('cloudlinux', $level, $text, $line, $file); | |
| 113 | - else | |
| 114 | - error_log($text); | |
| 112 | +		if (function_exists('myadmin_log')) { | |
| 113 | +					myadmin_log('cloudlinux', $level, $text, $line, $file); | |
| 114 | +		} else { | |
| 115 | + error_log($text); | |
| 116 | + } | |
| 115 | 117 | } | 
| 116 | 118 | |
| 117 | 119 | /** | 
| @@ -143,10 +145,11 @@ discard block | ||
| 143 | 145 |  	public function check($ip) { | 
| 144 | 146 | $this->response = $this->getcurlpage($this->rest_url.'ipl/check.json?ip='.$ip.'&token='.$this->authToken(), '', $this->rest_options); | 
| 145 | 147 | $response = json_decode($this->response, true); | 
| 146 | - if ($response['success'] == 1) | |
| 147 | - return $response['data']; | |
| 148 | - else | |
| 149 | - return false; | |
| 148 | +		if ($response['success'] == 1) { | |
| 149 | + return $response['data']; | |
| 150 | +		} else { | |
| 151 | + return false; | |
| 152 | + } | |
| 150 | 153 | } | 
| 151 | 154 | |
| 152 | 155 | /** | 
| @@ -169,10 +172,11 @@ discard block | ||
| 169 | 172 | * @return bool | 
| 170 | 173 | */ | 
| 171 | 174 |  	public function rest_remove($ip, $type = 0) { | 
| 172 | - if ($type != 0) | |
| 173 | - $this->response = $this->getcurlpage($this->rest_url.'ipl/remove.json?ip='.$ip.'&type='.$type.'&token='.$this->authToken(), '', $this->rest_options); | |
| 174 | - else | |
| 175 | - $this->response = $this->getcurlpage($this->rest_url.'ipl/remove.json?ip='.$ip.'&token='.$this->authToken(), '', $this->rest_options); | |
| 175 | +		if ($type != 0) { | |
| 176 | + $this->response = $this->getcurlpage($this->rest_url.'ipl/remove.json?ip='.$ip.'&type='.$type.'&token='.$this->authToken(), '', $this->rest_options); | |
| 177 | +		} else { | |
| 178 | + $this->response = $this->getcurlpage($this->rest_url.'ipl/remove.json?ip='.$ip.'&token='.$this->authToken(), '', $this->rest_options); | |
| 179 | + } | |
| 176 | 180 | return json_decode($this->response, true); | 
| 177 | 181 | } | 
| 178 | 182 | |
| @@ -184,10 +188,11 @@ discard block | ||
| 184 | 188 | * @return bool | 
| 185 | 189 | */ | 
| 186 | 190 |  	public function remove($ip, $type = 0) { | 
| 187 | - if ($this->api_type == 'xml') | |
| 188 | - return $this->remove_license($ip, $type); | |
| 189 | - else | |
| 190 | - return $this->rest_remove($ip, $type); | |
| 191 | +		if ($this->api_type == 'xml') { | |
| 192 | + return $this->remove_license($ip, $type); | |
| 193 | +		} else { | |
| 194 | + return $this->rest_remove($ip, $type); | |
| 195 | + } | |
| 191 | 196 | } | 
| 192 | 197 | |
| 193 | 198 | /** | 
| @@ -249,10 +254,11 @@ discard block | ||
| 249 | 254 |  	public function remove_license($ip, $type = false) { | 
| 250 | 255 |  		$this->log('info', "Calling CLoudLinux->xml_client->remove_license({$this->authToken()}, {$ip}, {$type})", __LINE__, __FILE__); | 
| 251 | 256 |  		try { | 
| 252 | - if ($type === false) | |
| 253 | - return $this->response = $this->remove($ip); | |
| 254 | - else | |
| 255 | - return $this->response = $this->remove($ip, $type); | |
| 257 | +			if ($type === false) { | |
| 258 | + return $this->response = $this->remove($ip); | |
| 259 | +			} else { | |
| 260 | + return $this->response = $this->remove($ip, $type); | |
| 261 | + } | |
| 256 | 262 |  		} catch (Exception $e) { | 
| 257 | 263 |  			$this->log('error', 'Caught exception code: ' . $e->getCode()); | 
| 258 | 264 |  			$this->log('error', 'Caught exception message: ' . $e->getMessage()); | 
| @@ -269,10 +275,11 @@ discard block | ||
| 269 | 275 | * @return array (list<int>): List of registered license types or empty list if no license found | 
| 270 | 276 | */ | 
| 271 | 277 |  	public function is_licensed($ip, $checkAll = true) { | 
| 272 | - if ($this->api_type == 'xml') | |
| 273 | - return $this->xml_is_licensed($ip, $checkAll); | |
| 274 | - else | |
| 275 | - return $this->check($ip, $checkAll); | |
| 278 | +		if ($this->api_type == 'xml') { | |
| 279 | + return $this->xml_is_licensed($ip, $checkAll); | |
| 280 | +		} else { | |
| 281 | + return $this->check($ip, $checkAll); | |
| 282 | + } | |
| 276 | 283 | } | 
| 277 | 284 | /** | 
| 278 | 285 | * Check if IP license was registered by any customer. Arguments: | 
| @@ -1,2 +1,2 @@ | ||
| 1 | 1 | <?php | 
| 2 | -require_once(__DIR__ . '/../vendor/autoload.php'); | |
| 2 | +require_once(__DIR__.'/../vendor/autoload.php'); | |