예제 #1
0
 /**
  * @param string $method
  */
 private function _apiSystemCall($server, $method, $params = array())
 {
     require_once dirname(__FILE__) . '/ccapiclient.php';
     $centovacast_url = $server['url'];
     $admin_password = $server['secret'];
     $system = new CCSystemAPIClient($centovacast_url);
     $system->cc_initialize($centovacast_url);
     $system->call($method, $admin_password, $params);
     if (!$system->success) {
         throw new \Exception($system->error);
     }
     return $system->bb_data;
 }
예제 #2
0
/**
 * WHMCS account usage update.
 *
 * @api
 *
 * @param array   $params The $params array passed by WHMCS.
 *
 * @return string
 */
function centovacast_UsageUpdate($params)
{
    list($serverusername, $serverpassword) = centovacast_GetServerCredentials($params);
    if (false === ($ccurl = centovacast_GetCCURL($params, &$urlerror))) {
        return $urlerror;
    }
    $system = new CCSystemAPIClient($ccurl);
    if ($_REQUEST['ccmoduledebug']) {
        $system->debug = true;
    }
    $arguments = array();
    $system->call("usage", $serverpassword, $arguments);
    logModuleCall("centovacast", "usageupdate", $system->raw_request, $system->raw_response, NULL, NULL);
    if (!$system->success) {
        return $system->error;
    }
    if (!is_array($system->data) || !count($system->data)) {
        return "Error fetching account information from Centova Cast";
    }
    $accounts = $system->data['row'];
    if (!is_array($accounts) || !count($accounts)) {
        return "No accounts in Centova Cast";
    }
    $serverid = $params['serverid'];
    foreach ($accounts as $k => $values) {
        update_query("tblhosting", array("diskused" => $values['diskusage'], "disklimit" => max(0, $values['diskquota']), "bwused" => $values['transferusage'], "bwlimit" => max(0, $values['transferlimit']), "lastupdate" => "now()"), array("server" => $serverid, "username" => $values['username']));
    }
    return "success";
}