function generate_page(&$tpl) { global $month, $year, $sql, $cfg; $start_index = 0; $rows_per_page = $cfg['DOMAIN_ROWS_PER_PAGE']; if (isset($_GET['psi']) && is_numeric($_GET['psi'])) { $start_index = $_GET['psi']; } else { if (isset($_POST['psi']) && is_numeric($_GET['psi'])) { $start_index = $_POST['psi']; } } $tpl->assign(array('POST_PREV_PSI' => $start_index)); // count query $count_query = <<<SQL_QUERY select count(admin_id) as cnt from admin where admin_type = 'reseller' SQL_QUERY; $query = <<<SQL_QUERY select admin_id, admin_name from admin where admin_type = 'reseller' order by admin_id desc limit {$start_index}, {$rows_per_page} SQL_QUERY; $rs = exec_query($sql, $count_query, array()); $records_count = $rs->fields['cnt']; $rs = exec_query($sql, $query, array()); if ($rs->RowCount() == 0) { /* $tpl -> assign( array( 'TRAFFIC_TABLE' => '', 'MESSAGE' => tr('Not found reseller(s) in your system!') ) ); */ $tpl->assign(array('TRAFFIC_TABLE' => '', 'SCROLL_PREV' => '', 'SCROLL_NEXT' => '')); set_page_message(tr('Not found reseller(s) in your system!')); return; } else { $prev_si = $start_index - $rows_per_page; if ($start_index == 0) { $tpl->assign('SCROLL_PREV', ''); } else { $tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prev_si)); } $next_si = $start_index + $rows_per_page; if ($next_si + 1 > $records_count) { $tpl->assign('SCROLL_NEXT', ''); } else { $tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $next_si)); } $tpl->assign(array('PAGE_MESSAGE' => '')); gen_select_lists($tpl, @$month, @$year); $row = 1; while (!$rs->EOF) { generate_reseller_entry($tpl, $rs->fields['admin_id'], $rs->fields['admin_name'], $row++); $rs->MoveNext(); } } $tpl->parse('TRAFFIC_TABLE', 'traffic_table'); }
$month = intval($_POST['month']); } else { if (isset($_GET['month']) && isset($_GET['year'])) { $month = intval($_GET['month']); $year = intval($_GET['year']); } } if (!is_numeric($rid) || !is_numeric($month) || !is_numeric($year)) { user_goto('./reseller_statistics.php'); } // static page messages gen_logged_from($tpl); $tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Admin/Reseller User Statistics'), 'TR_RESELLER_USER_STATISTICS' => tr('Reseller users table'), 'TR_MONTH' => tr('Month'), 'TR_YEAR' => tr('Year'), 'TR_SHOW' => tr('Show'), 'TR_NO_DOMAINS' => tr('This reseller has no domains yet.'), 'TR_DOMAIN_NAME' => tr('Domain'), 'TR_TRAFF' => tr('Traffic<br />usage'), 'TR_DISK' => tr('Disk<br />usage'), 'TR_WEB' => tr('Web<br />traffic'), 'TR_FTP_TRAFF' => tr('FTP<br />traffic'), 'TR_SMTP' => tr('SMTP<br />traffic'), 'TR_POP3' => tr('POP3/IMAP<br />traffic'), 'TR_SUBDOMAIN' => tr('Subdomain'), 'TR_ALIAS' => tr('Alias'), 'TR_MAIL' => tr('Mail'), 'TR_FTP' => tr('FTP'), 'TR_SQL_DB' => tr('SQL<br />database'), 'TR_SQL_USER' => tr('SQL<br />user'), 'VALUE_NAME' => $name, 'VALUE_RID' => $rid)); gen_reseller_mainmenu($tpl, 'reseller/main_menu_statistics.tpl'); gen_reseller_menu($tpl, 'reseller/menu_statistics.tpl'); gen_select_lists($tpl, $month, $year); generate_page($tpl, $rid, $name); gen_page_message($tpl); if ($cfg->DUMP_GUI_DEBUG) { dump_gui_debug($tpl); } $tpl->display($template); unset_messages(); /** * @param EasySCP_TemplateEngine $tpl * @param int $reseller_id * @param string $reseller_name */ function generate_page($tpl, $reseller_id, $reseller_name) { $sql = EasySCP_Registry::get('Db');
/** * @param EasySCP_TemplateEngine $tpl */ function generate_page($tpl) { global $month, $year; $cfg = EasySCP_Registry::get('Config'); $sql = EasySCP_Registry::get('Db'); $start_index = 0; $rows_per_page = $cfg->DOMAIN_ROWS_PER_PAGE; if (isset($_GET['psi']) && is_numeric($_GET['psi'])) { $start_index = $_GET['psi']; } else { if (isset($_POST['psi']) && is_numeric($_GET['psi'])) { $start_index = $_POST['psi']; } } $tpl->assign(array('POST_PREV_PSI' => $start_index)); // count query $count_query = "\n\t\tSELECT\n\t\t\tCOUNT(`admin_id`) AS cnt\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'reseller'\n\t"; $query = "\n\t\tSELECT\n\t\t\t`admin_id`, `admin_name`\n\t\tFROM\n\t\t\t`admin`\n\t\tWHERE\n\t\t\t`admin_type` = 'reseller'\n\t\tORDER BY\n\t\t\t`admin_name` DESC\n\t\tLIMIT\n\t\t\t{$start_index}, {$rows_per_page};\n\t"; $rs = exec_query($sql, $count_query); $records_count = $rs->fields['cnt']; $rs = exec_query($sql, $query); if ($rs->rowCount() == 0) { set_page_message(tr('There are no resellers in your system!'), 'info'); return; } else { $prev_si = $start_index - $rows_per_page; if ($start_index == 0) { $tpl->assign('SCROLL_PREV', ''); } else { $tpl->assign(array('SCROLL_PREV_GRAY' => '', 'PREV_PSI' => $prev_si)); } $next_si = $start_index + $rows_per_page; if ($next_si + 1 > $records_count) { $tpl->assign('SCROLL_NEXT', ''); } else { $tpl->assign(array('SCROLL_NEXT_GRAY' => '', 'NEXT_PSI' => $next_si)); } gen_select_lists($tpl, @$month, @$year); $row = 1; while (!$rs->EOF) { generate_reseller_entry($tpl, $rs->fields['admin_id'], $rs->fields['admin_name'], $row++); $rs->moveNext(); } } }