getSpaceBandwidthUsage($packageId, $startDate, date('Y-m-d', time())); return websitepanel_CalculateUsage($result, WebsitePanel::USAGE_BANDWIDTH); } catch (Exception $e) { // Do nothing, just catch the Exception to keep PHP from exploding :) } } /** * websitepanel_CalculateDiskspaceUsage() * * @access public * @param mixed $params * @param mixed $packageId * @return int */ function websitepanel_CalculateDiskspaceUsage($params, $packageId) { // Create the ASPnix websitepanel_EnterpriseServer class object $wsp = new WebsitePanel($params['serverusername'], $params['serverpassword'], $params['serverip'], $params['configoption6'], $params['serversecure']); try { $result = $wsp->getSpaceDiskspaceUsage($packageId); return websitepanel_CalculateUsage($result, WebsitePanel::USAGE_DISKSPACE); } catch (Exception $e) { // Do nothing, just catch the Exception to keep PHP from exploding :) } } /** * websitepanel_CalculateUsage() * * @access public * @param mixed $result * @param int $usageType * @return int */ function websitepanel_CalculateUsage($result, $usageType) { // Process results $xml = simplexml_load_string($result->any); $total = 0; if (count($xml->NewDataSet->Table) > 0) { foreach ($xml->NewDataSet->Table as $table) { switch ($usageType) { case WebsitePanel::USAGE_BANDWIDTH: $total = $total + $table[0]->MegaBytesTotal; break; case WebsitePanel::USAGE_DISKSPACE: $total = $total + $table[0]->Diskspace; break; default: $total = $total + $table[0]->MegaBytesTotal; break; } } } return $total; } /** * websitepanel_GetServerSettings * * @access public * @return array */ function websitepanel_GetServerSettings() { $settings = array('username' => '', 'password' => ''); // Retrieve the settings from the modules configuration table $results = select_query('tblservers', 'username,password', array('type' => 'websitepanel')); if (mysql_num_rows($results) != 0) { $row = mysql_fetch_array($results, MYSQL_ASSOC); $settings['username'] = $row['username']; $settings['password'] = decrypt($row['password']); } return $settings; }