/** * Generate page data * * @param iMSCP_pTemplate $tpl * @return void */ function admin_generatePageData($tpl) { $senderName = isset($_POST['sender_name']) ? $_POST['sender_name'] : ''; $senderEmail = isset($_POST['sender_email']) ? $_POST['sender_email'] : ''; $rcptTo = isset($_POST['rcpt_to']) ? $_POST['rcpt_to'] : ''; $subject = isset($_POST['subject']) ? $_POST['subject'] : ''; $body = isset($_POST['body']) ? $_POST['body'] : ''; if ($senderName == '' && $senderEmail == '') { $query = 'SELECT `admin_name`, `fname`, `lname`, `email` FROM `admin` WHERE `admin_id` = ?'; $stmt = exec_query($query, $_SESSION['user_id']); $data = $stmt->fetchRow(); if (!empty($data['fname']) && !empty($data['lname'])) { $senderName = $data['fname'] . ' ' . $data['lname']; } elseif (!empty($data['fname'])) { $senderName = $stmt->fields['fname']; } elseif (!empty($data['lname'])) { $senderName = $stmt->fields['lname']; } else { $senderName = $data['admin_name']; } if ($data['email'] != '') { $senderEmail = $data['email']; } else { $config = iMSCP_Registry::get('config'); if (isset($config['DEFAULT_ADMIN_ADDRESS']) && $config['DEFAULT_ADMIN_ADDRESS'] != '') { $senderEmail = $config['DEFAULT_ADMIN_ADDRESS']; } else { $senderEmail = 'webmaster@' . $config['BASE_SERVER_VHOST']; } } } $tpl->assign(array('SENDER_NAME' => tohtml($senderName), 'SENDER_EMAIL' => tohtml($senderEmail), 'SUBJECT' => tohtml($subject), 'BODY' => tohtml($body))); $rcptToOptions = array(array('all_users', tr('All users'))); if (systemHasManyAdmins() && systemHasResellers()) { $rcptToOptions[] = array('administrators_resellers', tr('Administrators and resellers')); } if (systemHasManyAdmins() && systemHasCustomers()) { $rcptToOptions[] = array('administrators_customers', tr('Administrators and customers')); } if (systemHasResellers() && systemHasCustomers()) { $rcptToOptions[] = array('resellers_customers', tr('Resellers and customers')); } if (systemHasManyAdmins()) { $rcptToOptions[] = array('administrators', tr('Administrators')); } if (systemHasResellers()) { $rcptToOptions[] = array('resellers', tr('Resellers')); } if (systemHasCustomers()) { $rcptToOptions[] = array('customers', tr('Customers')); } foreach ($rcptToOptions as $option) { $tpl->assign(array('RCPT_TO' => $option[0], 'TR_RCPT_TO' => $option[1], 'SELECTED' => $rcptTo == $option[0] ? ' selected="selected"' : '')); $tpl->parse('RCPT_TO_OPTION', '.rcpt_to_option'); } }
$tpl->parse('TRAFFIC_TABLE_ITEM', '.traffic_table_item'); } $tpl->assign(array('USER_ID' => tohtml($userId), 'USERNAME' => tohtml($adminName), 'ALL_WEB_TRAFFIC' => tohtml(bytesHuman($all[0])), 'ALL_FTP_TRAFFIC' => tohtml(bytesHuman($all[1])), 'ALL_SMTP_TRAFFIC' => tohtml(bytesHuman($all[2])), 'ALL_POP3_TRAFFIC' => tohtml(bytesHuman($all[3])), 'ALL_ALL_TRAFFIC' => tohtml(bytesHuman(array_sum($all))))); } else { set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info'); $tpl->assign(array('USERNAME' => tohtml($adminName), 'USER_ID' => tohtml($userId), 'RESELLER_USER_STATISTICS_DETAIL_BLOCK' => '')); } } /*********************************************************************************************************************** * Main */ require 'imscp-lib.php'; $eventManager = iMSCP_Events_Aggregator::getInstance(); $eventManager->dispatch(iMSCP_Events::onAdminScriptStart); check_login('admin'); if (systemHasCustomers()) { if (isset($_GET['user_id'])) { $userId = intval($_GET['user_id']); $_SESSION['stats_user_id'] = $userId; } elseif (isset($_SESSION['admin_stats_user_id'])) { redirectTo('reseller_user_statistics_detail.php?user_id=' . $_SESSION['admin_stats_user_id']); exit; } else { showBadRequestErrorPage(); exit; } $tpl = new iMSCP_pTemplate(); $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'admin/reseller_user_statistics_details.tpl', 'page_message' => 'layout', 'month_list' => 'page', 'year_list' => 'page', 'reseller_user_statistics_detail_block' => 'page', 'traffic_table_item' => 'reseller_user_statistics_detail_block')); $tpl->assign(array('TR_PAGE_TITLE' => tohtml(tr("Admin / Statistics / Reseller Statistics / User Statistics / {USERNAME} user statistics")), 'TR_MONTH' => tohtml(tr('Month')), 'TR_YEAR' => tohtml(tr('Year')), 'TR_SHOW' => tohtml(tr('Show'), 'htmlAttr'), 'TR_WEB_TRAFFIC' => tohtml(tr('Web traffic')), 'TR_FTP_TRAFFIC' => tohtml(tr('FTP traffic')), 'TR_SMTP_TRAFFIC' => tohtml(tr('SMTP traffic')), 'TR_POP3_TRAFFIC' => tohtml(tr('POP3/IMAP traffic')), 'TR_ALL_TRAFFIC' => tohtml(tr('All traffic')), 'TR_ALL' => tohtml(tr('All')), 'TR_DAY' => tohtml(tr('Day')))); generateNavigation($tpl); generatePage($tpl, $userId);
/** * Whether or not system has registered resellers or customers. * * @return bool */ function systemHasResellersOrCustomers() { if (systemHasResellers() || systemHasCustomers()) { return true; } return false; }