Skip to content

Commit

Permalink
fixs to the softaculous/webuzo code
Browse files Browse the repository at this point in the history
  • Loading branch information
detain committed Aug 30, 2019
1 parent 228d2e2 commit f8a0f95
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/SoftaculousNOC.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function removeautorenewal($key = '')
*/
public function webuzoBuy($ipAddress, $toadd, $servertype, $authemail, $autorenew)
{
$this->params['ca'] = 'webuzoBuy';
$this->params['ca'] = 'webuzo_buy';
$this->params['purchase'] = 1;
$this->params['ips'] = $ipAddress;
$this->params['toadd'] = $toadd;
Expand All @@ -380,7 +380,7 @@ public function webuzoBuy($ipAddress, $toadd, $servertype, $authemail, $autorene
*/
public function webuzoRefund($actid)
{
$this->params['ca'] = 'webuzoRefund';
$this->params['ca'] = 'webuzo_refund';
$this->params['actid'] = $actid;
return $this->req();
}
Expand Down Expand Up @@ -421,7 +421,7 @@ public function webuzoLicenses($key = '', $ipAddress = '', $expiry = '', $start
*/
public function webuzoCancel($key = '', $ipAddress = '')
{
$this->params['ca'] = 'webuzoCancel';
$this->params['ca'] = 'webuzo_cancel';
$this->params['lickey'] = $key;
$this->params['licip'] = $ipAddress;
$this->params['cancel_license'] = 1;
Expand Down Expand Up @@ -504,7 +504,7 @@ public function webuzoEditips($lid, $ips)
*/
public function webuzoLicenselogs($key, $limit = 0, $ipAddress = '')
{
$this->params['ca'] = 'webuzoLicenselogs';
$this->params['ca'] = 'webuzo_licenselogs';
$this->params['key'] = $key;
$this->params['licip'] = $ipAddress;
if (!empty($limit)) {
Expand Down
69 changes: 39 additions & 30 deletions src/activate_webuzo.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,43 @@
*/
function activate_webuzo($ipAddress, $field = '', $email = '')
{
myadmin_log('softaculous', 'info', "activating webuzo({$ipAddress}, {$field}, {$email})", __LINE__, __FILE__);
try {
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(WEBUZO_USERNAME, WEBUZO_PASSWORD);
// Buy / renew a License
$matches = $noc->webuzoLicenses('', $ipAddress);
if ($matches['num_results'] > 0) {
myadmin_log('softaculous', 'info', "Found Existing webuzo licenses on {$ipAddress}, scanning them", __LINE__, __FILE__);
foreach ($matches['licenses'] as $lid => $ldata) {
if ($ldata['type'] == $field) {
myadmin_log('softaculous', 'info', 'Found matching license type, skipping creating a new one', __LINE__, __FILE__);
$need = false;
return $ldata['license'];
} else {
myadmin_log('softaculous', 'info', "Found different webuzo license type {$ldata['type']}, canceling {$lid}", __LINE__, __FILE__);
$noc->webuzoCancel($ldata['license']);
}
}
}
$response = $noc->webuzoBuy($ipAddress, '1M', $field, $email, 1);
if ($response === false) {
myadmin_log('softaculous', 'error', "webuzo->buy({$ipAddress}, 1M, {$field}, {$email}) failed with error".json_encode($noc->error), __LINE__, __FILE__);
//$output = $noc->error;
} else {
myadmin_log('softaculous', 'info', 'webuzo order output '.json_encode($response), __LINE__, __FILE__);
}
return $response['license'];
} catch (Exception $e) {
myadmin_log('softaculous', 'info', 'Canceling Caught exception: '.$e->getMessage(), __LINE__, __FILE__);
return false;
}
myadmin_log('softaculous', 'info', "activating webuzo({$ipAddress}, {$field}, {$email})", __LINE__, __FILE__);
try {
$noc = new \Detain\MyAdminSoftaculous\SoftaculousNOC(WEBUZO_USERNAME, WEBUZO_PASSWORD);
//$noc->json = 1;
// Buy / renew a License
$matches = $noc->webuzoLicenses('', $ipAddress);
if ($matches['num_results'] > 0) {
myadmin_log('softaculous', 'info', "Found Existing webuzo licenses on {$ipAddress}, scanning them", __LINE__, __FILE__);
foreach ($matches['licenses'] as $lid => $ldata) {
if ($ldata['type'] == $field) {
myadmin_log('softaculous', 'info', 'Found matching license type, skipping creating a new one', __LINE__, __FILE__);
$need = false;
return $ldata['license'];
} else {
myadmin_log('softaculous', 'info', "Found different webuzo license type {$ldata['type']}, canceling {$lid}", __LINE__, __FILE__);
$noc->webuzoCancel($ldata['license']);
}
}
}
$response = $noc->webuzoBuy($ipAddress, '1M', $field, $email, 1);
// Check for any error
if(empty($noc->error)){
myadmin_log('myadmin', 'debug', 'webuzoBuy SUCCRESS!', __LINE__, __FILE__);
// Everything went perfect
}else{
// Dump the error
myadmin_log('myadmin', 'debug', 'webuzoBuy error:'.print_r($noc->error,true), __LINE__, __FILE__);
}
if ($response === false) {
myadmin_log('softaculous', 'error', "webuzo->buy({$ipAddress}, 1M, {$field}, {$email}) failed with error".json_encode($noc->error), __LINE__, __FILE__);
//$output = $noc->error;
} else {
myadmin_log('softaculous', 'info', 'webuzo order output '.json_encode($response), __LINE__, __FILE__);
}
return $response['license'];
} catch (Exception $e) {
myadmin_log('softaculous', 'info', 'Canceling Caught exception: '.$e->getMessage(), __LINE__, __FILE__);
return false;
}
}

0 comments on commit f8a0f95

Please sign in to comment.