@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | * @package Detain\Cpanel |
| 9 | 9 | */ |
| 10 | -class Cpanel |
|
| 11 | -{ |
|
| 10 | +class Cpanel { |
|
| 12 | 11 | public $format; |
| 13 | 12 | public $curl; |
| 14 | 13 | public $opts; |
@@ -19,8 +18,7 @@ discard block |
||
| 19 | 18 | * @param $user |
| 20 | 19 | * @param $pass |
| 21 | 20 | */ |
| 22 | - public function __construct($user, $pass) |
|
| 23 | - { |
|
| 21 | + public function __construct($user, $pass) { |
|
| 24 | 22 | $this->opts = []; |
| 25 | 23 | $this->format = 'simplexml'; |
| 26 | 24 | $this->setCredentials($user, $pass); |
@@ -32,8 +30,7 @@ discard block |
||
| 32 | 30 | * @param $option |
| 33 | 31 | * @param $value |
| 34 | 32 | */ |
| 35 | - public function setopt($option, $value) |
|
| 36 | - { |
|
| 33 | + public function setopt($option, $value) { |
|
| 37 | 34 | $this->opts[$option] = $value; |
| 38 | 35 | } |
| 39 | 36 | |
@@ -42,8 +39,7 @@ discard block |
||
| 42 | 39 | * @param string $user the username |
| 43 | 40 | * @param string $pass the password |
| 44 | 41 | */ |
| 45 | - public function setCredentials($user, $pass) |
|
| 46 | - { |
|
| 42 | + public function setCredentials($user, $pass) { |
|
| 47 | 43 | $this->setopt(CURLOPT_USERPWD, $user.':'.$pass); |
| 48 | 44 | } |
| 49 | 45 | |
@@ -52,8 +48,7 @@ discard block |
||
| 52 | 48 | * |
| 53 | 49 | * @param string $format can be any of xml,json,yaml,simplexml |
| 54 | 50 | */ |
| 55 | - public function setFormat($format) |
|
| 56 | - { |
|
| 51 | + public function setFormat($format) { |
|
| 57 | 52 | if ($format != 'xml' && $format != 'json' && $format != 'yaml' && $format != 'simplexml') { |
| 58 | 53 | error_log('setFormat requires that the format is xml, json, yaml or simplexml'); |
| 59 | 54 | return; |
@@ -67,8 +62,7 @@ discard block |
||
| 67 | 62 | * @param array $args |
| 68 | 63 | * @return array|mixed|void |
| 69 | 64 | */ |
| 70 | - private function get($function, $args = []) |
|
| 71 | - { |
|
| 65 | + private function get($function, $args = []) { |
|
| 72 | 66 | if (!$function) { |
| 73 | 67 | error_log('cPanelLicensing::get requires that a function is defined'); |
| 74 | 68 | return; |
@@ -107,8 +101,7 @@ discard block |
||
| 107 | 101 | * @param array $result the result array to format |
| 108 | 102 | * @return array the rormatted arrray |
| 109 | 103 | */ |
| 110 | - private function formatResult($result) |
|
| 111 | - { |
|
| 104 | + private function formatResult($result) { |
|
| 112 | 105 | if (is_array($result)) { |
| 113 | 106 | foreach ($result as $key => $value) { |
| 114 | 107 | if (is_array($value)) { |
@@ -127,8 +120,7 @@ discard block |
||
| 127 | 120 | * @param $id |
| 128 | 121 | * @return int |
| 129 | 122 | */ |
| 130 | - private function validateID($id) |
|
| 131 | - { |
|
| 123 | + private function validateID($id) { |
|
| 132 | 124 | if (preg_match("/^(L|P|G)?\d*$/", $id)) { |
| 133 | 125 | return 1; |
| 134 | 126 | } else { |
@@ -140,8 +132,7 @@ discard block |
||
| 140 | 132 | * @param $ipAddress |
| 141 | 133 | * @return int |
| 142 | 134 | */ |
| 143 | - private function validateIP($ipAddress) |
|
| 144 | - { |
|
| 135 | + private function validateIP($ipAddress) { |
|
| 145 | 136 | return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ipAddress); |
| 146 | 137 | } |
| 147 | 138 | |
@@ -149,8 +140,7 @@ discard block |
||
| 149 | 140 | * @param $args |
| 150 | 141 | * @return array|mixed|void |
| 151 | 142 | */ |
| 152 | - public function reactivateLicense($args) |
|
| 153 | - { |
|
| 143 | + public function reactivateLicense($args) { |
|
| 154 | 144 | if (!array_key_exists('liscid', $args)) { |
| 155 | 145 | error_log('cpanelLicensing::reactivateLicense requires that the argument array contains element liscid'); |
| 156 | 146 | return; |
@@ -166,8 +156,7 @@ discard block |
||
| 166 | 156 | * @param $args |
| 167 | 157 | * @return array|mixed|void |
| 168 | 158 | */ |
| 169 | - public function expireLicense($args) |
|
| 170 | - { |
|
| 159 | + public function expireLicense($args) { |
|
| 171 | 160 | if (!array_key_exists('liscid', $args)) { |
| 172 | 161 | error_log('cPanelLicensing::expireLicense requires that liscid elements exists in the array passed to it'); |
| 173 | 162 | return; |
@@ -183,8 +172,7 @@ discard block |
||
| 183 | 172 | * @param $args |
| 184 | 173 | * @return array|mixed|void |
| 185 | 174 | */ |
| 186 | - public function extendOnetimeUpdates($args) |
|
| 187 | - { |
|
| 175 | + public function extendOnetimeUpdates($args) { |
|
| 188 | 176 | if (!array_key_exists('ip', $args)) { |
| 189 | 177 | error_log('cpanelLicensing::extendOnetimeUpdates requires that the element ip exists in the array is passed to it'); |
| 190 | 178 | return; |
@@ -200,8 +188,7 @@ discard block |
||
| 200 | 188 | * @param $args |
| 201 | 189 | * @return array|mixed|void |
| 202 | 190 | */ |
| 203 | - public function changeip($args) |
|
| 204 | - { |
|
| 191 | + public function changeip($args) { |
|
| 205 | 192 | if (!array_key_exists('oldip', $args) || !array_key_exists('newip', $args)) { |
| 206 | 193 | error_log('cpanelLicensing::changeip requires that oldip and newip elements exist in the array passed to it'); |
| 207 | 194 | return; |
@@ -217,8 +204,7 @@ discard block |
||
| 217 | 204 | * @param $args |
| 218 | 205 | * @return array|mixed|void |
| 219 | 206 | */ |
| 220 | - public function requestTransfer($args) |
|
| 221 | - { |
|
| 207 | + public function requestTransfer($args) { |
|
| 222 | 208 | if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packagegroup', $args)) { |
| 223 | 209 | error_log('cpanelLicensing::requestTransfer requires that ip, groupid and packageid elements exist in the array passed to it'); |
| 224 | 210 | return; |
@@ -242,8 +228,7 @@ discard block |
||
| 242 | 228 | * @param $args |
| 243 | 229 | * @return array|mixed|void |
| 244 | 230 | */ |
| 245 | - public function activateLicense($args) |
|
| 246 | - { |
|
| 231 | + public function activateLicense($args) { |
|
| 247 | 232 | if (!array_key_exists('ip', $args) || !array_key_exists('groupid', $args) || !array_key_exists('packageid', $args)) { |
| 248 | 233 | error_log('cpanelLicensing::activateLicense requires that ip, groupid and packageid elements exist in the array passed to it'); |
| 249 | 234 | return; |
@@ -268,8 +253,7 @@ discard block |
||
| 268 | 253 | * @param $args |
| 269 | 254 | * @return array|mixed|void |
| 270 | 255 | */ |
| 271 | - public function addPickupPass($args) |
|
| 272 | - { |
|
| 256 | + public function addPickupPass($args) { |
|
| 273 | 257 | if (!array_key_exists('pickup', $args)) { |
| 274 | 258 | error_log('cPanelLicensing::addPickupPass requires a pickup param'); |
| 275 | 259 | return; |
@@ -281,8 +265,7 @@ discard block |
||
| 281 | 265 | * @param $args |
| 282 | 266 | * @return array|mixed|void |
| 283 | 267 | */ |
| 284 | - public function registerAuth($args) |
|
| 285 | - { |
|
| 268 | + public function registerAuth($args) { |
|
| 286 | 269 | if (!array_key_exists('user', $args)) { |
| 287 | 270 | error_log('cPanelLicensing::registerAuth requires a user param'); |
| 288 | 271 | return; |
@@ -307,8 +290,7 @@ discard block |
||
| 307 | 290 | * |
| 308 | 291 | * @return array|mixed|void |
| 309 | 292 | */ |
| 310 | - public function fetchGroups() |
|
| 311 | - { |
|
| 293 | + public function fetchGroups() { |
|
| 312 | 294 | return $this->get('XMLgroupInfo.cgi'); |
| 313 | 295 | } |
| 314 | 296 | |
@@ -318,8 +300,7 @@ discard block |
||
| 318 | 300 | * @param array $args |
| 319 | 301 | * @return array|mixed|void |
| 320 | 302 | */ |
| 321 | - public function fetchLicenseRiskData($args = []) |
|
| 322 | - { |
|
| 303 | + public function fetchLicenseRiskData($args = []) { |
|
| 323 | 304 | if (!array_key_exists('ip', $args)) { |
| 324 | 305 | error_log('cpanelLicensing::fetchLicenseRiskData requires that ip exists as an element in the array is passed to it'); |
| 325 | 306 | return; |
@@ -337,8 +318,7 @@ discard block |
||
| 337 | 318 | * @param array $args optional array of arguments |
| 338 | 319 | * @return array|mixed|void |
| 339 | 320 | */ |
| 340 | - public function fetchLicenseRaw($args = []) |
|
| 341 | - { |
|
| 321 | + public function fetchLicenseRaw($args = []) { |
|
| 342 | 322 | $args = array_merge(['all' => 1], $args); |
| 343 | 323 | if (!array_key_exists('ip', $args)) { |
| 344 | 324 | error_log('cpanelLicesning::fetchLicenseRaw requires that ip exists as an element in the array is passed to it'); |
@@ -357,8 +337,7 @@ discard block |
||
| 357 | 337 | * @param array $args optional array of arguments |
| 358 | 338 | * @return array|mixed|void |
| 359 | 339 | */ |
| 360 | - public function fetchLicenseId($args = []) |
|
| 361 | - { |
|
| 340 | + public function fetchLicenseId($args = []) { |
|
| 362 | 341 | $args = array_merge(['all' => 1], $args); |
| 363 | 342 | if (!array_key_exists('ip', $args)) { |
| 364 | 343 | error_log('cpanelLicensing::getLicenseId requires that an IP is passed to it'); |
@@ -374,8 +353,7 @@ discard block |
||
| 374 | 353 | /** |
| 375 | 354 | * @return array|mixed|void |
| 376 | 355 | */ |
| 377 | - public function fetchPackages() |
|
| 378 | - { |
|
| 356 | + public function fetchPackages() { |
|
| 379 | 357 | return $this->get('XMLpackageInfo.cgi'); |
| 380 | 358 | } |
| 381 | 359 | |
@@ -385,8 +363,7 @@ discard block |
||
| 385 | 363 | * @param array $args optional arguments |
| 386 | 364 | * @return array|mixed|void |
| 387 | 365 | */ |
| 388 | - public function fetchLicenses($args = []) |
|
| 389 | - { |
|
| 366 | + public function fetchLicenses($args = []) { |
|
| 390 | 367 | return $this->get('XMLlicenseInfo.cgi'); |
| 391 | 368 | } |
| 392 | 369 | |
@@ -394,8 +371,7 @@ discard block |
||
| 394 | 371 | * return sa list of expired licenses |
| 395 | 372 | * @return array|mixed|void |
| 396 | 373 | */ |
| 397 | - public function fetchExpiredLicenses() |
|
| 398 | - { |
|
| 374 | + public function fetchExpiredLicenses() { |
|
| 399 | 375 | return $this->fetchLicenses(['expired' => '1']); |
| 400 | 376 | } |
| 401 | 377 | |
@@ -404,8 +380,7 @@ discard block |
||
| 404 | 380 | * @param $xmlObj |
| 405 | 381 | * @return string|void |
| 406 | 382 | */ |
| 407 | - public function findKey($search, $xmlObj) |
|
| 408 | - { |
|
| 383 | + public function findKey($search, $xmlObj) { |
|
| 409 | 384 | $xmlObj = (array) $xmlObj; |
| 410 | 385 | if (array_key_exists('packages', $xmlObj)) { |
| 411 | 386 | $type = 'packages'; |