|
|
@@ -226,35 +226,36 @@ function cwp7_ChangePackage($params){
|
|
|
}
|
|
|
|
|
|
function cwp7_UsageUpdate($params) {
|
|
|
-/* $postvars = array('key' => $params["serveraccesshash"],'action' => 'list');
|
|
|
- $postdata = http_build_query($postvars);
|
|
|
- $curl = curl_init();
|
|
|
- curl_setopt($curl, CURLOPT_URL, 'https://'. $params["serverhostname"] . ':2304/v1/account');
|
|
|
- curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
- curl_setopt($curl, CURLOPT_POST, true);
|
|
|
- curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
|
|
|
- if (curl_errno($curl)) {
|
|
|
- $error_msg = curl_error($curl);
|
|
|
- }
|
|
|
- $answer = curl_exec($curl);
|
|
|
- $resp=json_decode($answer,true);
|
|
|
-
|
|
|
- if($resp['status']=='OK'){
|
|
|
- $results=$resp['msj'];
|
|
|
- for($i=0;$i<count($results);$i++){
|
|
|
- $date=date('Y-m-d H:i:s');
|
|
|
- if($results[$i]['diskusage']==''){$diskusage=0;}else{$diskusage=trim($results[$i]['diskusage']);}
|
|
|
- if($results[$i]['disklimit']==''){$disklimit=0;}else{$disklimit=trim($results[$i]['disklimit']);}
|
|
|
- if($results[$i]['bandwidth']==''){$bandwidth=0;}else{$bandwidth=trim($results[$i]['bandwidth']);}
|
|
|
- if($results[$i]['bwlimit']==''){$bwlimit=0;}else{$bwlimit=trim($results[$i]['bwlimit']);}
|
|
|
- $domian=trim($results[$i]['domain']);
|
|
|
-
|
|
|
+ $cwp7 = new cwp7_Admin($params['serverhostname'], $params['serveraccesshash']);
|
|
|
+ $response = $cwp7->getAllAccounts();
|
|
|
+ if($response['status'] == 'OK'){
|
|
|
+ $results = $response['msj'];
|
|
|
+ for($i = 0; $i < count($results); $i++){
|
|
|
+ if($results[$i]['diskusage'] == '') {
|
|
|
+ $diskusage = 0;
|
|
|
+ } else {
|
|
|
+ $diskusage = trim($results[$i]['diskusage']);
|
|
|
+ }
|
|
|
+ if($results[$i]['disklimit'] == '') {
|
|
|
+ $disklimit = 0;
|
|
|
+ } else {
|
|
|
+ $disklimit = trim($results[$i]['disklimit']);
|
|
|
+ }
|
|
|
+ if($results[$i]['bandwidth'] == '') {
|
|
|
+ $bandwidth = 0;
|
|
|
+ } else {
|
|
|
+ $bandwidth =trim($results[$i]['bandwidth']);
|
|
|
+ }
|
|
|
+ if($results[$i]['bwlimit'] == '') {
|
|
|
+ $bwlimit = 0;
|
|
|
+ } else {
|
|
|
+ $bwlimit = trim($results[$i]['bwlimit']);
|
|
|
+ }
|
|
|
+ $domain = trim($results[$i]['domain']);
|
|
|
try {
|
|
|
\WHMCS\Database\Capsule::table('tblhosting')
|
|
|
- ->where('dedicatedip', $results[$i]['ip_address'])
|
|
|
- ->where('domain', $domian)
|
|
|
+ ->where('server', $params['serverid'])
|
|
|
+ ->where('domain', $domain)
|
|
|
->update([
|
|
|
'diskusage' => $diskusage,
|
|
|
'disklimit' => $disklimit,
|
|
|
@@ -266,5 +267,5 @@ function cwp7_UsageUpdate($params) {
|
|
|
logActivity('ERROR: Unable to update server usage: ' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
- } */
|
|
|
+ }
|
|
|
}
|