public static function addOmsConfUsageClientAreaPage($vars) { global $product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url; $clientId = $_SESSION['uid']; if (is_numeric($clientId)) { $whmcsDbService = new \Opennode\Whmcs\Service\WhmcsDbService(); $whmcsExternalService = new \Opennode\Whmcs\Service\WhmcsExternalService($whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url, $oms_usage_db); $omsReduction = new \Opennode\Whmcs\Service\OmsReductionService($product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcsExternalService, $whmcsDbService); $startDate = date_sub(date_create(), date_interval_create_from_date_string("1 months")); $endDate = date_create(); $confChanges = $omsReduction->findClientConfChanges($clientId, $startDate, $endDate); $parsedChanges = $omsReduction->parseClientConfChanges($confChanges, $clientId); return array("omsconfs" => $parsedChanges); } }
<?php require_once "configuration.php"; require_once "includes/hooks/inc/oms_config.php"; require_once "Classes/Autoloader.php"; try { // Check MySQL Configuration $db_conn = mysql_connect($db_host, $db_username, $db_password); if (empty($db_conn)) { throw new Exception('Unable to connect to DB'); } $db_select = @mysql_select_db($db_name, $db_conn); if (empty($db_select)) { throw new Exception('Unable to select WHMCS database'); } } catch (Exception $e) { echo 'Error: ', $e->getMessage(), "\n"; } global $product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url, $oms_usage_db; $whmcsDbService = new \Opennode\Whmcs\Service\WhmcsDbService(); $whmcsExternalService = new \Opennode\Whmcs\Service\WhmcsExternalService($whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url, $oms_usage_db); $omsReduction = new \Opennode\Whmcs\Service\OmsReductionService($product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcsExternalService, $whmcsDbService); $omsReduction->reduce_users_credit();
<?php require "init.php"; require_once dirname(__FILE__) . '/includes/hooks/inc/oms_config.php'; require_once __DIR__ . '/Classes/Autoloader.php'; $ca = new WHMCS_ClientArea(); $ca->setPageTitle("Resource consumption summary"); $ca->addToBreadCrumb('index.php', $whmcs->get_lang('globalsystemname')); $ca->addToBreadCrumb('oms_usage.php', 'OMS usage'); $ca->initPage(); //get parameters $user_id = mysql_real_escape_string($_GET['user_id']); $clientId = $_SESSION['uid']; global $product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url, $oms_usage_db; $whmcsDbService = new \Opennode\Whmcs\Service\WhmcsDbService(); $whmcsExternalService = new \Opennode\Whmcs\Service\WhmcsExternalService($whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url, $oms_usage_db); $omsReduction = new \Opennode\Whmcs\Service\OmsReductionService($product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcsExternalService, $whmcsDbService); $confChanges = $omsReduction->findClientConfChanges($clientId, null, null); $parsedChanges = $omsReduction->parseClientConfChanges($confChanges, $clientId); $ca->assign('omsconfs', $parsedChanges); $ca->setTemplate('omsclientusage'); $ca->output();