function gen_disk_usage(&$tpl, $usage, $max_usage, $bars_max) { if (0 !== $max_usage) { list($percent, $bars) = calc_bars($usage, $max_usage, $bars_max); $max_usage = sizeit($max_usage); } else { $percent = 0; $bars = 0; $max_usage = tr('unlimited'); } $traffic_usage_data = sprintf("%s%% [%s " . tr('of') . " %s]", $percent, sizeit($usage), $max_usage); $tpl->assign(array('DISK_USAGE_DATA' => $traffic_usage_data, 'DISK_BARS' => $bars)); }
function gen_server_trafic(&$tpl, &$sql) { $query = <<<SQL_QUERY select straff_max,straff_warn from straff_settings SQL_QUERY; $rs = exec_query($sql, $query, array()); $straff_max = $rs->fields['straff_max'] * 1024 * 1024; $fdofmnth = mktime(0, 0, 0, date("m"), 1, date("Y")); $ldofmnth = mktime(1, 0, 0, date("m") + 1, 0, date("Y")); $query = <<<SQL_QUERY select IFNULL((sum(bytes_in) + sum(bytes_out)), 0) as traffic from server_traffic where traff_time > ? and traff_time < ? SQL_QUERY; $rs1 = exec_query($sql, $query, array($fdofmnth, $ldofmnth)); $traff = $rs1->fields['traffic']; $mtraff = sprintf("%.2f", $traff); if ($straff_max == 0) { $pr = 0; } else { $pr = $traff / $straff_max * 100; } $pr = sprintf("%.2f", $pr); if (($straff_max != 0 || $straff_max != '') && $mtraff > $straff_max) { $tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your traffic limit!')); } else { $tpl->assign('TRAFF_WARN', ''); } $bar_value = calc_bar_value($traff, $straff_max, 400); if ($straff_max == 0) { $show_straf_max = tr('unlimited'); } else { $show_straf_max = sizeit($straff_max); } $tpl->assign(array('TR_OF' => tr('of'), 'PERCENT' => $pr, 'VALUE' => sizeit($mtraff), 'MAX_VALUE' => $show_straf_max, 'BAR_VALUE' => $bar_value)); }
function gen_plan_details(&$tpl, &$sql, $user_id, $plan_id) { global $cfg; if (isset($cfg['HOSTING_PLANS_LEVEL']) && $cfg['HOSTING_PLANS_LEVEL'] === 'admin') { $query = <<<SQL_QUERY \t\t\tselect \t\t\t\t* \t\t\tfrom \t\t\t\thosting_plans \t\t\twhere \t\t\t\tid = ? SQL_QUERY; $rs = exec_query($sql, $query, array($plan_id)); } else { $query = <<<SQL_QUERY \t\t\tselect \t\t\t\t* \t\t\tfrom \t\t\t\thosting_plans \t\t\twhere \t\t\t\treseller_id = ? \t\t\t and \t\t\t\tid = ? SQL_QUERY; $rs = exec_query($sql, $query, array($user_id, $plan_id)); } if ($rs->RecordCount() == 0) { header("Location: index.php?user_id={$user_id}"); die; } else { $props = $rs->fields['props']; list($hp_php, $hp_cgi, $hp_sub, $hp_als, $hp_mail, $hp_ftp, $hp_sql_db, $hp_sql_user, $hp_traff, $hp_disk) = explode(";", $props); $price = $rs->fields['price']; $setup_fee = $rs->fields['setup_fee']; if ($price == 0 || $price == '') { $price = tr('free of charge'); } else { $price = $price . " " . $rs->fields['value'] . " " . $rs->fields['payment']; } if ($setup_fee == 0 || $setup_fee == '') { $setup_fee = tr('free of charge'); } else { $setup_fee = $setup_fee . " " . $rs->fields['value']; } $description = $rs->fields['description']; if ($description == '') { $description = ''; } if (is_numeric(translate_value($hp_disk))) { $hp_disk = sizeit($hp_disk * 1024 * 1024) . "<br>"; } else { $hp_disk = translate_value($hp_disk) . "<br>"; } if (is_numeric(translate_value($hp_traff))) { $hp_traff = sizeit($hp_traff * 1024 * 1024); } else { $hp_traff = translate_value($hp_traff * 1024 * 1024); } $tpl->assign(array('PACK_NAME' => $rs->fields['name'], 'DESCRIPTION' => $description, 'PACK_ID' => $rs->fields['id'], 'USER_ID' => $user_id, 'PURCHASE' => tr('Purchase'), 'ALIAS' => translate_value($hp_als), 'SUBDOMAIN' => translate_value($hp_sub), 'HDD' => $hp_disk, 'TRAFFIC' => $hp_traff, 'PHP' => translate_sse($hp_php), 'CGI' => translate_sse($hp_cgi), 'MAIL' => translate_value($hp_mail), 'FTP' => translate_value($hp_ftp), 'SQL_DB' => translate_value($hp_sql_db), 'SQL_USR' => translate_value($hp_sql_user), 'PRICE' => $price, 'SETUP' => $setup_fee)); } }
/** * Translates -1, 0 or value string into human readable string * @version 1.1 * * @param Integer input variable to be translated * @param boolean calculate value in different unit (default false) * @param String unit to calclulate to (default 'MB') * @return String */ function translate_limit_value($value, $autosize = false, $to = 'MB') { switch ($value) { case -1: return tr('disabled'); case 0: return tr('unlimited'); default: return !$autosize ? $value : sizeit($value, $to); } }
/** * @param EasySCP_TemplateEngine $tpl * @param int $user_id * @param int $row */ function generate_domain_entry($tpl, $user_id, $row) { global $crnt_month, $crnt_year; list($domain_name, $domain_id, $web, $ftp, $smtp, $pop3, $utraff_current, $udisk_current) = generate_user_traffic($user_id); list($usub_current, $usub_max, $uals_current, $uals_max, $umail_current, $umail_max, $uftp_current, $uftp_max, $usql_db_current, $usql_db_max, $usql_user_current, $usql_user_max, $utraff_max, $udisk_max) = generate_user_props($user_id); $utraff_max = $utraff_max * 1024 * 1024; $udisk_max = $udisk_max * 1024 * 1024; $traff_show_percent = calc_bar_value($utraff_current, $utraff_max, 400); $disk_show_percent = calc_bar_value($udisk_current, $udisk_max, 400); if ($utraff_max > 0) { $traff_percent = $utraff_current / $utraff_max * 100 < 99.7 ? $utraff_current / $utraff_max * 100 : 99.7; } else { $traff_percent = 0; } if ($udisk_max > 0) { $disk_percent = $udisk_current / $udisk_max * 100 < 99.7 ? $udisk_current / $udisk_max * 100 : 99.7; } else { $disk_percent = 0; } $domain_name = decode_idna($domain_name); $tpl->append(array('DOMAIN_NAME' => tohtml($domain_name), 'MONTH' => $crnt_month, 'YEAR' => $crnt_year, 'DOMAIN_ID' => $domain_id, 'TRAFF_SHOW_PERCENT' => $traff_show_percent, 'TRAFF_PERCENT' => $traff_percent, 'TRAFF_MSG' => $utraff_max ? tr('%1$s <br/>of<br/> <strong>%2$s</strong>', sizeit($utraff_current), sizeit($utraff_max)) : tr('%s <br/>of<br/> <strong>unlimited</strong>', sizeit($utraff_current)), 'DISK_SHOW_PERCENT' => $disk_show_percent, 'DISK_PERCENT' => $disk_percent, 'DISK_MSG' => $udisk_max ? tr('%1$s <br/>of<br/> <strong>%2$s</strong>', sizeit($udisk_current), sizeit($udisk_max)) : tr('%s <br/>of<br/> <strong>unlimited</strong>', sizeit($udisk_current)), 'WEB' => sizeit($web), 'FTP' => sizeit($ftp), 'SMTP' => sizeit($smtp), 'POP3' => sizeit($pop3), 'SUB_MSG' => $usub_max ? $usub_max > 0 ? tr('%1$d <br/>of<br/> <strong>%2$d</strong>', sizeit($usub_current), $usub_max) : tr('<strong>disabled</strong>') : tr('%d <br/>of<br/> <strong>unlimited</strong>', sizeit($usub_current)), 'ALS_MSG' => $uals_max ? $uals_max > 0 ? tr('%1$d <br/>of<br/> <strong>%2$d</strong>', sizeit($uals_current), $uals_max) : tr('<strong>disabled</strong>') : tr('%d <br/>of<br/> <strong>unlimited</strong>', sizeit($uals_current)), 'MAIL_MSG' => $umail_max ? $umail_max > 0 ? tr('%1$d <br/>of<br/> <strong>%2$d</strong>', $umail_current, $umail_max) : tr('<strong>disabled</strong>') : tr('%d <br/>of<br/> <strong>unlimited</strong>', $umail_current), 'FTP_MSG' => $uftp_max ? $uftp_max > 0 ? tr('%1$d <br/>of<br/> <strong>%2$d</strong>', $uftp_current, $uftp_max) : tr('<strong>disabled</strong>') : tr('%d <br/>of<br/> <strong>unlimited</strong>', $uftp_current), 'SQL_DB_MSG' => $usql_db_max ? $usql_db_max > 0 ? tr('%1$d <br/>of<br/> <strong>%2$d</strong>', $usql_db_current, $usql_db_max) : tr('<strong>disabled</strong>') : tr('%d <br/>of<br/> <strong>unlimited</strong>', $usql_db_current), 'SQL_USER_MSG' => $usql_user_max ? $usql_user_max > 0 ? tr('%1$d <br/>of<br/> <strong>%2$d</strong>', $usql_user_current, $usql_user_max) : tr('<strong>disabled</strong>') : tr('%d <br/>of<br/> <strong>unlimited</strong>', $usql_user_current))); }
function generate_page(&$tpl, $domain_id) { global $sql, $month, $year, $cfg; global $web_trf, $ftp_trf, $smtp_trf, $pop_trf, $sum_web, $sum_ftp, $sum_mail, $sum_pop; $fdofmnth = mktime(0, 0, 0, $month, 1, $year); $ldofmnth = mktime(1, 0, 0, $month + 1, 0, $year); if ($month == date('m') && $year == date('Y')) { $curday = date('j'); } else { $tmp = mktime(1, 0, 0, $month + 1, 0, $year); $curday = date('j', $tmp); } $curtimestamp = time(); $firsttimestamp = mktime(0, 0, 0, $month, 1, $year); $all[0] = 0; $all[1] = 0; $all[2] = 0; $all[3] = 0; $all[4] = 0; $all[5] = 0; $all[6] = 0; $all[7] = 0; $counter = 0; for ($i = 1; $i <= $curday; $i++) { $ftm = mktime(0, 0, 0, $month, $i, $year); $ltm = mktime(23, 59, 59, $month, $i, $year); $query = <<<SQL_QUERY select dtraff_web,dtraff_ftp,dtraff_mail,dtraff_pop,dtraff_time from domain_traffic where domain_id=? and dtraff_time>? and dtraff_time<? SQL_QUERY; $rs = exec_query($sql, $query, array($domain_id, $ftm, $ltm)); $has_data = false; list($web_trf, $ftp_trf, $pop_trf, $smtp_trf) = get_domain_trafic($ftm, $ltm, $domain_id); $date_formt = $cfg['DATE_FORMAT']; if ($web_trf == 0 && $ftp_trf == 0 && $smtp_trf == 0 && $pop_trf == 0) { $tpl->assign(array('MONTH' => $month, 'YEAR' => $year, 'DOMAIN_ID' => $domain_id, 'DATE' => date($date_formt, strtotime($year . "-" . $month . "-" . $i)), 'WEB_TRAFFIC' => 0, 'FTP_TRAFFIC' => 0, 'SMTP_TRAFFIC' => 0, 'POP3_TRAFFIC' => 0, 'ALL_TRAFFIC' => 0)); } else { if ($counter % 2 == 0) { $tpl->assign('ITEM_CLASS', 'content'); } else { $tpl->assign('ITEM_CLASS', 'content2'); } $sum_web += $web_trf; $sum_ftp += $ftp_trf; $sum_mail += $smtp_trf; $sum_pop += $pop_trf; $tpl->assign(array('DATE' => date($date_formt, strtotime($year . "-" . $month . "-" . $i)), 'WEB_TRAFFIC' => sizeit($web_trf), 'FTP_TRAFFIC' => sizeit($ftp_trf), 'SMTP_TRAFFIC' => sizeit($smtp_trf), 'POP3_TRAFFIC' => sizeit($pop_trf), 'ALL_TRAFFIC' => sizeit($web_trf + $ftp_trf + $smtp_trf + $pop_trf))); $tpl->parse('TRAFFIC_TABLE_ITEM', '.traffic_table_item'); $counter++; } $tpl->assign(array('MONTH' => $month, 'YEAR' => $year, 'DOMAIN_ID' => $domain_id, 'ALL_WEB_TRAFFIC' => sizeit($sum_web), 'ALL_FTP_TRAFFIC' => sizeit($sum_ftp), 'ALL_SMTP_TRAFFIC' => sizeit($sum_mail), 'ALL_POP3_TRAFFIC' => sizeit($sum_pop), 'ALL_ALL_TRAFFIC' => sizeit($sum_web + $sum_ftp + $sum_mail + $sum_pop))); $tpl->parse('TRAFFIC_TABLE', 'traffic_table'); } }
/** * @param EasySCP_TemplateEngine $tpl * @param int $reseller_id * @param string $reseller_name * @param int $row * @return void */ function generate_reseller_entry($tpl, $reseller_id, $reseller_name, $row) { global $crnt_month, $crnt_year; list($rdmn_current, $rdmn_max, $rsub_current, $rsub_max, $rals_current, $rals_max, $rmail_current, $rmail_max, $rftp_current, $rftp_max, $rsql_db_current, $rsql_db_max, $rsql_user_current, $rsql_user_max, $rtraff_current, $rtraff_max, $rdisk_current, $rdisk_max) = generate_reseller_props($reseller_id); list($udmn_current, , , $usub_current, , , $uals_current, , , $umail_current, , , $uftp_current, , , $usql_db_current, , , $usql_user_current, , , $utraff_current, , , $udisk_current, , ) = generate_reseller_users_props($reseller_id); $rtraff_max = $rtraff_max * 1024 * 1024; $rtraff_current = $rtraff_current * 1024 * 1024; $rdisk_max = $rdisk_max * 1024 * 1024; $rdisk_current = $rdisk_current * 1024 * 1024; $traff_show_percent = calc_bar_value($utraff_current, $rtraff_max, 400); $disk_show_percent = calc_bar_value($udisk_current, $rdisk_max, 400); if ($rtraff_max > 0) { $traff_percent = $utraff_current / $rtraff_max * 100 < 99.7 ? $utraff_current / $rtraff_max * 100 : 99.7; } else { $traff_percent = 0; } if ($rdisk_max > 0) { $disk_percent = $udisk_current / $rdisk_max * 100 < 99.7 ? $udisk_current / $rdisk_max * 100 : 99.7; } else { $disk_percent = 0; } $tpl->append(array('RESELLER_NAME' => tohtml($reseller_name), 'RESELLER_ID' => $reseller_id, 'MONTH' => $crnt_month, 'YEAR' => $crnt_year, 'TRAFF_SHOW_PERCENT' => $traff_show_percent, 'TRAFF_PERCENT' => $traff_percent, 'TRAFF_MSG' => $rtraff_max ? tr('%1$s / %2$s <br/>of<br/> <strong>%3$s</strong>', sizeit($utraff_current), sizeit($rtraff_current), sizeit($rtraff_max)) : tr('%1$s / %2$s <br/>of<br/> <strong>unlimited</strong>', sizeit($utraff_current), sizeit($rtraff_current)), 'DISK_SHOW_PERCENT' => $disk_show_percent, 'DISK_PERCENT' => $disk_percent, 'DISK_MSG' => $rdisk_max ? tr('%1$s / %2$s <br/>of<br/> <strong>%3$s</strong>', sizeit($udisk_current), sizeit($rdisk_current), sizeit($rdisk_max)) : tr('%1$s / %2$s <br/>of<br/> <strong>unlimited</strong>', sizeit($udisk_current), sizeit($rdisk_current)), 'DMN_MSG' => $rdmn_max ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $udmn_current, $rdmn_current, $rdmn_max) : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $udmn_current, $rdmn_current), 'SUB_MSG' => $rsub_max > 0 ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $usub_current, $rsub_current, $rsub_max) : ($rsub_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $usub_current, $rsub_current)), 'ALS_MSG' => $rals_max > 0 ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $uals_current, $rals_current, $rals_max) : ($rals_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $uals_current, $rals_current)), 'MAIL_MSG' => $rmail_max > 0 ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $umail_current, $rmail_current, $rmail_max) : ($rmail_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $umail_current, $rmail_current)), 'FTP_MSG' => $rftp_max > 0 ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $uftp_current, $rftp_current, $rftp_max) : ($rftp_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $uftp_current, $rftp_current)), 'SQL_DB_MSG' => $rsql_db_max > 0 ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $usql_db_current, $rsql_db_current, $rsql_db_max) : ($rsql_db_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $usql_db_current, $rsql_db_current)), 'SQL_USER_MSG' => $rsql_user_max > 0 ? tr('%1$d / %2$d <br/>of<br/> <strong>%3$d</strong>', $usql_user_current, $rsql_user_current, $rsql_user_max) : ($rsql_user_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d / %2$d <br/>of<br/> <strong>unlimited</strong>', $usql_user_current, $rsql_user_current)))); }
/** * @param EasySCP_TemplateEngine $tpl * @param int $user_id * @param int $domain_id */ function gen_detaildom_page($tpl, $user_id, $domain_id) { $sql = EasySCP_Registry::get('Db'); $cfg = EasySCP_Registry::get('Config'); // Get domain data $query = "\n\t\tSELECT\n\t\t\t*,\n\t\t\tIFNULL(`domain_disk_usage`, 0) AS domain_disk_usage\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t"; $res = exec_query($sql, $query, $domain_id); $data = $res->fetchRow(); if ($res->recordCount() <= 0) { user_goto('users.php?psi=last'); } // Get admin data $created_by = $_SESSION['user_id']; $query = "SELECT `admin_name` FROM `admin` WHERE `admin_id` = ? AND `created_by` = ?"; $res1 = exec_query($sql, $query, array($data['domain_admin_id'], $created_by)); // NXW: Unused variable so... // $data1 = $res1->fetchRow(); $res1->fetchRow(); if ($res1->recordCount() <= 0) { user_goto('users.php?psi=last'); } // Get IP info $query = "SELECT * FROM `server_ips` WHERE `ip_id` = ?"; $ipres = exec_query($sql, $query, $data['domain_ip_id']); $ipres->fetchRow(); // Get staus name $dstatus = translate_dmn_status($data['status']); // Traffic diagram $fdofmnth = mktime(0, 0, 0, date("m"), 1, date("Y")); $ldofmnth = mktime(1, 0, 0, date("m") + 1, 0, date("Y")); $query = "SELECT\n\t\t\tIFNULL(SUM(`dtraff_web_in`), 0) AS dtraff_web_in,\n\t\t\tIFNULL(SUM(`dtraff_web_out`), 0) AS dtraff_web_out,\n\t\t\tIFNULL(SUM(`dtraff_ftp_in`), 0) AS dtraff_ftp_in,\n\t\t\tIFNULL(SUM(`dtraff_ftp_out`), 0) AS dtraff_ftp_out,\n\t\t\tIFNULL(SUM(`dtraff_mail`), 0) AS dtraff_mail,\n\t\t\tIFNULL(SUM(`dtraff_pop`),0) AS dtraff_pop\n\t\tFROM\n\t\t\t`domain_traffic`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tAND\n\t\t\t`dtraff_time` > ?\n\t\tAND\n\t\t\t`dtraff_time` < ?\n\t"; $res7 = exec_query($sql, $query, array($data['domain_id'], $fdofmnth, $ldofmnth)); $dtraff = $res7->fetchRow(); $sumtraff = $dtraff['dtraff_web_in'] + $dtraff['dtraff_web_out'] + $dtraff['dtraff_ftp_in'] + $dtraff['dtraff_ftp_out'] + $dtraff['dtraff_mail'] + $dtraff['dtraff_pop']; // NXW: Unused variables so ... /* $dtraffmb = sprintf("%.1f", ($sumtraff / 1024) / 1024); $month = date("m"); $year = date("Y"); */ $query = "SELECT * FROM `server_ips` WHERE `ip_id` = ?"; $res8 = exec_query($sql, $query, $data['domain_ip_id']); $ipdat = $res8->fetchRow(); $domain_traffic_limit = $data['domain_traffic_limit']; $domain_all_traffic = $sumtraff; $traffic_percent = $domain_all_traffic != 0 ? sprintf("%.2f", 100 * $domain_all_traffic / ($domain_traffic_limit * 1024 * 1024)) : 0; // Get disk status $domdu = $data['domain_disk_usage']; $domdl = $data['domain_disk_limit']; $domduh = sizeit($domdu); $disk_percent = sprintf("%.2f", 100 * $domdu / ($domdl * 1024 * 1024)); // Get current mail count $query = "SELECT COUNT(`mail_id`) AS mcnt " . "FROM `mail_users` " . "WHERE `domain_id` = ? " . "AND `mail_type` NOT RLIKE '_catchall'"; $res6 = exec_query($sql, $query, $data['domain_id']); $dat3 = $res6->fetchRow(); $mail_limit = translate_limit_value($data['domain_mailacc_limit']); // FTP stat $query = "SELECT `gid` FROM `ftp_group` WHERE `groupname` = ?"; $res4 = exec_query($sql, $query, $data['domain_name']); $ftp_gnum = $res4->rowCount(); if ($ftp_gnum == 0) { $used_ftp_acc = 0; } else { $dat1 = $res4->fetchRow(); $query = "SELECT COUNT(*) AS ftp_cnt FROM `ftp_users` WHERE `gid` = ?"; $res5 = exec_query($sql, $query, $dat1['gid']); $dat2 = $res5->fetchRow(); $used_ftp_acc = $dat2['ftp_cnt']; } $ftp_limit = translate_limit_value($data['domain_ftpacc_limit']); // Get sql database count $query = "SELECT COUNT(*) AS dnum FROM `sql_database` WHERE `domain_id` = ?"; $res = exec_query($sql, $query, $data['domain_id']); $dat5 = $res->fetchRow(); $sql_db = translate_limit_value($data['domain_sqld_limit']); // Get sql users count $query = "SELECT COUNT(u.`sqlu_id`) AS ucnt FROM sql_user u, sql_database d WHERE u.`sqld_id` = d.`sqld_id` AND d.`domain_id` = ?"; $res = exec_query($sql, $query, $data['domain_id']); $dat6 = $res->fetchRow(); $sql_users = translate_limit_value($data['domain_sqlu_limit']); // Get subdomain $query = "SELECT COUNT(`subdomain_id`) AS sub_num FROM `subdomain` WHERE `domain_id` = ?"; $res1 = exec_query($sql, $query, $domain_id); $sub_num_data = $res1->fetchRow(); $query = "SELECT COUNT(`subdomain_alias_id`) AS sub_num FROM `subdomain_alias` WHERE `alias_id` IN (SELECT `alias_id` FROM `domain_aliasses` WHERE `domain_id` = ?)"; $res1 = exec_query($sql, $query, $domain_id); $alssub_num_data = $res1->fetchRow(); $sub_dom = translate_limit_value($data['domain_subd_limit']); // Get domain aliases $query = "SELECT COUNT(*) AS alias_num FROM `domain_aliasses` WHERE `domain_id` = ?"; $res1 = exec_query($sql, $query, $domain_id); $alias_num_data = $res1->fetchRow(); // Check if Backup support is available for this user switch ($data['allowbackup']) { case "full": $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('Full'))); break; case "sql": $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('SQL'))); break; case "dmn": $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('Domain'))); break; default: $tpl->assign(array('VL_BACKUP_SUPPORT' => tr('No'))); } $dom_alias = translate_limit_value($data['domain_alias_limit']); // Fill in the fields $tpl->assign(array('DOMAIN_ID' => $data['domain_id'], 'VL_DOMAIN_NAME' => tohtml(decode_idna($data['domain_name'])), 'VL_DOMAIN_IP' => tohtml($ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')'), 'VL_STATUS' => $dstatus, 'VL_PHP_SUPP' => $data['domain_php'] == 'yes' ? tr('Enabled') : tr('Disabled'), 'VL_CGI_SUPP' => $data['domain_cgi'] == 'yes' ? tr('Enabled') : tr('Disabled'), 'VL_DNS_SUPP' => $data['domain_dns'] == 'yes' ? tr('Enabled') : tr('Disabled'), 'VL_MYSQL_SUPP' => $data['domain_sqld_limit'] >= 0 ? tr('Enabled') : tr('Disabled'), 'VL_TRAFFIC_PERCENT' => $traffic_percent, 'VL_TRAFFIC_USED' => sizeit($domain_all_traffic), 'VL_TRAFFIC_LIMIT' => sizeit($domain_traffic_limit, 'MB'), 'VL_DISK_PERCENT' => $disk_percent, 'VL_DISK_USED' => $domduh, 'VL_DISK_LIMIT' => sizeit($data['domain_disk_limit'], 'MB'), 'VL_MAIL_ACCOUNTS_USED' => $dat3['mcnt'], 'VL_MAIL_ACCOUNTS_LIIT' => $mail_limit, 'VL_FTP_ACCOUNTS_USED' => $used_ftp_acc, 'VL_FTP_ACCOUNTS_LIIT' => $ftp_limit, 'VL_SQL_DB_ACCOUNTS_USED' => $dat5['dnum'], 'VL_SQL_DB_ACCOUNTS_LIIT' => $sql_db, 'VL_SQL_USER_ACCOUNTS_USED' => $dat6['ucnt'], 'VL_SQL_USER_ACCOUNTS_LIIT' => $sql_users, 'VL_SUBDOM_ACCOUNTS_USED' => $sub_num_data['sub_num'] + $alssub_num_data['sub_num'], 'VL_SUBDOM_ACCOUNTS_LIIT' => $sub_dom, 'VL_DOMALIAS_ACCOUNTS_USED' => $alias_num_data['alias_num'], 'VL_DOMALIAS_ACCOUNTS_LIIT' => $dom_alias)); }
/** * @param EasySCP_TemplateEngine $tpl * @param int $month * @param int $year * @param int $user_id */ function gen_dmn_traff_list($tpl, $month, $year, $user_id) { $cfg = EasySCP_Registry::get('Config'); $sql = EasySCP_Registry::get('Db'); $query = "\n\t\tSELECT\n\t\t\t`domain_id`\n\t\tFROM\n\t\t\t`domain`\n\t\tWHERE\n\t\t\t`domain_admin_id` = ?\n\t"; $rs = exec_query($sql, $query, $user_id); $domain_id = $rs->fields('domain_id'); if ($month == date('m') && $year == date('Y')) { $curday = date('j'); } else { $tmp = mktime(1, 0, 0, $month + 1, 0, $year); $curday = date('j', $tmp); } $sum_web_in = 0; $sum_web_out = 0; $sum_ftp = 0; $sum_mail = 0; $sum_pop = 0; for ($i = 1; $i <= $curday; $i++) { $ftm = mktime(0, 0, 0, $month, $i, $year); $ltm = mktime(23, 59, 59, $month, $i, $year); /* $query = " SELECT `dtraff_web_in`, `dtraff_web_out`, `dtraff_ftp_in`, `dtraff_ftp_out`, `dtraff_mail`, `dtraff_pop`, `dtraff_time` FROM `domain_traffic` WHERE `domain_id` = ? AND `dtraff_time` >= ? AND `dtraff_time` <= ? "; exec_query($sql, $query, array($domain_id, $ftm, $ltm)); */ list($web_trf_in, $web_trf_out, $ftp_trf_in, $ftp_trf_out, $pop_trf, $smtp_trf) = get_domain_trafic($ftm, $ltm, $domain_id); $sum_web_in += $web_trf_in; $sum_web_out += $web_trf_out; $sum_ftp += $ftp_trf_in; $sum_ftp += $ftp_trf_out; $sum_mail += $smtp_trf; $sum_pop += $pop_trf; $date_formt = $cfg->DATE_FORMAT; $tpl->append(array('DATE' => date($date_formt, strtotime($year . "-" . $month . "-" . $i)), 'WEB_TRAFFIC_IN' => sizeit($web_trf_in), 'WEB_TRAFFIC_OUT' => sizeit($web_trf_out), 'FTP_TRAFFIC' => sizeit($ftp_trf_in + $ftp_trf_out), 'SMTP_TRAFFIC' => sizeit($smtp_trf), 'POP3_TRAFFIC' => sizeit($pop_trf), 'SUM_TRAFFIC' => sizeit($web_trf_in + $web_trf_out + $ftp_trf_in + $ftp_trf_out + $smtp_trf + $pop_trf))); } $tpl->assign(array('WEB_ALL_IN' => sizeit($sum_web_in), 'WEB_ALL_OUT' => sizeit($sum_web_out), 'FTP_ALL' => sizeit($sum_ftp), 'SMTP_ALL' => sizeit($sum_mail), 'POP3_ALL' => sizeit($sum_pop), 'SUM_ALL' => sizeit($sum_web_in + $sum_web_out + $sum_ftp + $sum_mail + $sum_pop))); }
/** * @param int $month * @param int $year */ function generate_page($month, $year) { $tpl = EasySCP_TemplateEngine::getInstance(); $sql = EasySCP_Registry::get('Db'); if ($month == date('m') && $year == date('Y')) { $curday = date('j'); } else { $tmp = mktime(1, 0, 0, $month + 1, 0, $year); $curday = date('j', $tmp); } $all[0] = 0; $all[1] = 0; $all[2] = 0; $all[3] = 0; $all[4] = 0; $all[5] = 0; $all[6] = 0; $all[7] = 0; for ($i = 1; $i <= $curday; $i++) { $ftm = mktime(0, 0, 0, $month, $i, $year); $ltm = mktime(0, 0, 0, $month, $i + 1, $year); $query = "\n\t\t\tSELECT\n\t\t\t\tCOUNT(`bytes_in`) AS cnt\n\t\t\tFROM\n\t\t\t\t`server_traffic`\n\t\t\tWHERE\n\t\t\t\t`traff_time` > ? AND `traff_time` <= ?\n\t\t"; $rs = exec_query($sql, $query, array($ftm, $ltm)); // if ($rs->fields['cnt'] > 0) { if ($rs->recordCount() > 0) { list($web_in, $web_out, $smtp_in, $smtp_out, $pop_in, $pop_out, $other_in, $other_out, $all_in, $all_out) = get_server_trafic($ftm, $ltm); $tpl->append(array('DAY' => $i, 'YEAR' => $year, 'MONTH' => $month, 'WEB_IN' => sizeit($web_in), 'WEB_OUT' => sizeit($web_out), 'SMTP_IN' => sizeit($smtp_in), 'SMTP_OUT' => sizeit($smtp_out), 'POP_IN' => sizeit($pop_in), 'POP_OUT' => sizeit($pop_out), 'OTHER_IN' => sizeit($other_in), 'OTHER_OUT' => sizeit($other_out), 'ALL_IN' => sizeit($all_in), 'ALL_OUT' => sizeit($all_out), 'ALL' => sizeit($all_in + $all_out))); $all[0] = $all[0] + $web_in; $all[1] = $all[1] + $web_out; $all[2] = $all[2] + $smtp_in; $all[3] = $all[3] + $smtp_out; $all[4] = $all[4] + $pop_in; $all[5] = $all[5] + $pop_out; $all[6] = $all[6] + $all_in; $all[7] = $all[7] + $all_out; } // if count } // end for $all_other_in = $all[6] - ($all[0] + $all[2] + $all[4]); $all_other_out = $all[7] - ($all[1] + $all[3] + $all[5]); $tpl->assign(array('WEB_IN_ALL' => sizeit($all[0]), 'WEB_OUT_ALL' => sizeit($all[1]), 'SMTP_IN_ALL' => sizeit($all[2]), 'SMTP_OUT_ALL' => sizeit($all[3]), 'POP_IN_ALL' => sizeit($all[4]), 'POP_OUT_ALL' => sizeit($all[5]), 'OTHER_IN_ALL' => sizeit($all_other_in), 'OTHER_OUT_ALL' => sizeit($all_other_out), 'ALL_IN_ALL' => sizeit($all[6]), 'ALL_OUT_ALL' => sizeit($all[7]), 'ALL_ALL' => sizeit($all[6] + $all[7]))); }
/** * @param EasySCP_TemplateEngine $tpl * @param int $month * @param int $year * @param int $domain_id */ function generate_page($tpl, $month, $year, $domain_id) { $cfg = EasySCP_Registry::get('Config'); $sql = EasySCP_Registry::get('Db'); if ($month == date('m') && $year == date('Y')) { $curday = date('j'); } else { $tmp = mktime(1, 0, 0, $month + 1, 0, $year); $curday = date('j', $tmp); } $sum_web = 0; $sum_ftp = 0; $sum_mail = 0; $sum_pop = 0; for ($i = 1; $i <= $curday; $i++) { $ftm = mktime(0, 0, 0, $month, $i, $year); $ltm = mktime(23, 59, 59, $month, $i, $year); $query = "\n\t\t\tSELECT\n\t\t\t\t`dtraff_web_in`, `dtraff_web_out`, `dtraff_ftp_in`, `dtraff_ftp_out`, `dtraff_mail`, `dtraff_pop`, `dtraff_time`\n\t\t\tFROM\n\t\t\t\t`domain_traffic`\n\t\t\tWHERE\n\t\t\t\t`domain_id` = ?\n\t\t\tAND\n\t\t\t\t`dtraff_time` >= ?\n\t\t\tAND\n\t\t\t\t`dtraff_time` <= ?\n\t\t"; exec_query($sql, $query, array($domain_id, $ftm, $ltm)); list($web_trf, $ftp_trf, $pop_trf, $smtp_trf) = get_domain_trafic($ftm, $ltm, $domain_id); if ($web_trf == 0 && $ftp_trf == 0 && $smtp_trf == 0 && $pop_trf == 0) { $tpl->append(array('DATE' => date($cfg->DATE_FORMAT, strtotime($year . "-" . $month . "-" . $i)), 'WEB_TRAFFIC' => 0, 'FTP_TRAFFIC' => 0, 'SMTP_TRAFFIC' => 0, 'POP3_TRAFFIC' => 0, 'ALL_TRAFFIC' => 0)); } else { $sum_web += $web_trf; $sum_ftp += $ftp_trf; $sum_mail += $smtp_trf; $sum_pop += $pop_trf; $tpl->append(array('DATE' => date($cfg->DATE_FORMAT, strtotime($year . "-" . $month . "-" . $i)), 'WEB_TRAFFIC' => sizeit($web_trf), 'FTP_TRAFFIC' => sizeit($ftp_trf), 'SMTP_TRAFFIC' => sizeit($smtp_trf), 'POP3_TRAFFIC' => sizeit($pop_trf), 'ALL_TRAFFIC' => sizeit($web_trf + $ftp_trf + $smtp_trf + $pop_trf))); } } $sql_param = array(':domain_id' => $domain_id); $sql_query = "\n\t\tSELECT\n\t\t\ta.admin_id, a.admin_name\n\t\tFROM\n\t\t\tadmin a,\n\t\t\tdomain b\n\t\tWHERE\n\t\t\tb.domain_created_id = a.admin_id\n\t\tAND\n\t\t\tb.domain_id = :domain_id\n\t"; // Einzelne Schreibweise DB::prepare($sql_query); $row = DB::execute($sql_param, true); $tpl->assign(array('RESELLER_NAME' => $row['admin_name'], 'RESELLER_ID' => $row['admin_id'], 'MONTH' => $month, 'YEAR' => $year, 'DOMAIN_ID' => $domain_id, 'ALL_WEB_TRAFFIC' => sizeit($sum_web), 'ALL_FTP_TRAFFIC' => sizeit($sum_ftp), 'ALL_SMTP_TRAFFIC' => sizeit($sum_mail), 'ALL_POP3_TRAFFIC' => sizeit($sum_pop), 'ALL_ALL_TRAFFIC' => sizeit($sum_web + $sum_ftp + $sum_mail + $sum_pop))); }
/** * @param EasySCP_TemplateEngine $tpl * @param float $usage * @param float $max_usage * @param float $bars_max */ function gen_disk_usage($tpl, $usage, $max_usage, $bars_max) { list($percent, $bars) = calc_bars($usage, $max_usage, $bars_max); if ($max_usage != 0) { $traffic_usage_data = tr('%1$s%% [%2$s of %3$s]', $percent, sizeit($usage), sizeit($max_usage)); } else { $traffic_usage_data = tr('%1$s%% [%2$s of unlimited]', $percent, sizeit($usage)); } $tpl->assign(array('DISK_USAGE_DATA' => $traffic_usage_data, 'DISK_BARS' => $bars, 'DISK_PERCENT' => $percent)); if ($max_usage != 0 && $usage > $max_usage) { $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk limit!')); } else { $tpl->assign('DISK_WARN', ''); } }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @link http://www.easyscp.net * @author EasySCP Team */ require '../../include/easyscp-lib.php'; check_login(__FILE__); $cfg = EasySCP_Registry::get('Config'); $tpl = EasySCP_TemplateEngine::getInstance(); $template = 'admin/system_info.tpl'; $sysinfo = new EasySCP_SystemInfo(); $tpl->assign(array('CPU_MODEL' => tohtml($sysinfo->cpu['model']), 'CPU_COUNT' => tohtml($sysinfo->cpu['cpus']), 'CPU_MHZ' => tohtml($sysinfo->cpu['cpuspeed']), 'CPU_CACHE' => tohtml($sysinfo->cpu['cache']), 'CPU_BOGOMIPS' => tohtml($sysinfo->cpu['bogomips']), 'UPTIME' => tohtml($sysinfo->uptime), 'KERNEL' => tohtml($sysinfo->kernel), 'LOAD' => $sysinfo->load[0] . ' ' . $sysinfo->load[1] . ' ' . $sysinfo->load[2], 'RAM_TOTAL' => sizeit($sysinfo->ram['total'], 'KB'), 'RAM_USED' => sizeit($sysinfo->ram['used'], 'KB'), 'RAM_FREE' => sizeit($sysinfo->ram['free'], 'KB'), 'SWAP_TOTAL' => sizeit($sysinfo->swap['total'], 'KB'), 'SWAP_USED' => sizeit($sysinfo->swap['used'], 'KB'), 'SWAP_FREE' => sizeit($sysinfo->swap['free'], 'KB'))); $mount_points = $sysinfo->filesystem; foreach ($mount_points as $mountpoint) { $tpl->append(array('MOUNT' => tohtml($mountpoint['mount']), 'TYPE' => tohtml($mountpoint['fstype']), 'PARTITION' => tohtml($mountpoint['disk']), 'PERCENT' => $mountpoint['percent'], 'FREE' => sizeit($mountpoint['free'], 'KB'), 'USED' => sizeit($mountpoint['used'], 'KB'), 'SIZE' => sizeit($mountpoint['size'], 'KB'))); } // static page messages $tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Virtual Hosting Control System'), 'TR_CPU_BOGOMIPS' => tr('CPU bogomips'), 'TR_CPU_CACHE' => tr('CPU cache'), 'TR_CPU_COUNT' => tr('Number of CPU Cores'), 'TR_CPU_MHZ' => tr('CPU MHz'), 'TR_CPU_MODEL' => tr('CPU model'), 'TR_CPU_SYSTEM_INFO' => tr('CPU system Info'), 'TR_FILE_SYSTEM_INFO' => tr('Filesystem system Info'), 'TR_FREE' => tr('Free'), 'TR_KERNEL' => tr('Kernel Version'), 'TR_LOAD' => tr('Load (1 Min, 5 Min, 15 Min)'), 'TR_MEMRY_SYSTEM_INFO' => tr('Memory system info'), 'TR_MOUNT' => tr('Mount'), 'TR_RAM' => tr('RAM'), 'TR_PARTITION' => tr('Partition'), 'TR_PERCENT' => tr('Percent'), 'TR_SIZE' => tr('Size'), 'TR_SWAP' => tr('Swap'), 'TR_SYSTEM_INFO_TITLE' => tr('System info'), 'TR_SYSTEM_INFO' => tr('Vital system info'), 'TR_TOTAL' => tr('Total'), 'TR_TYPE' => tr('Type'), 'TR_UPTIME' => tr('Up time'), 'TR_USED' => tr('Used'))); gen_admin_mainmenu($tpl, 'admin/main_menu_system_tools.tpl'); gen_admin_menu($tpl, 'admin/menu_system_tools.tpl'); gen_page_message($tpl); if ($cfg->DUMP_GUI_DEBUG) { dump_gui_debug($tpl); } $tpl->display($template); unset_messages();
function gen_dmn_traff_list(&$tpl, &$sql, $month, $year, $user_id) { global $web_trf, $ftp_trf, $smtp_trf, $pop_trf, $sum_web, $sum_ftp, $sum_mail, $sum_pop; $domain_admin_id = $_SESSION['user_id']; $query = <<<SQL_QUERY select domain_id from domain where domain_admin_id = ? SQL_QUERY; $rs = exec_query($sql, $query, array($domain_admin_id)); $domain_id = $rs->fields('domain_id'); $fdofmnth = mktime(0, 0, 0, $month, 1, $year); $ldofmnth = mktime(1, 0, 0, $month + 1, 0, $year); if ($month == date('m') && $year == date('Y')) { $curday = date('j'); } else { $tmp = mktime(1, 0, 0, $month + 1, 0, $year); $curday = date('j', $tmp); } $curtimestamp = time(); $firsttimestamp = mktime(0, 0, 0, $month, 1, $year); $all[0] = 0; $all[1] = 0; $all[2] = 0; $all[3] = 0; $all[4] = 0; $all[5] = 0; $all[6] = 0; $all[7] = 0; $counter = 0; for ($i = 1; $i <= $curday; $i++) { $ftm = mktime(0, 0, 0, $month, $i, $year); $ltm = mktime(23, 59, 59, $month, $i, $year); $query = <<<SQL_QUERY select dtraff_web,dtraff_ftp,dtraff_mail,dtraff_pop,dtraff_time from domain_traffic where domain_id = ? and dtraff_time > ? and dtraff_time < ? SQL_QUERY; $rs = exec_query($sql, $query, array($domain_id, $ftm, $ltm)); $has_data = false; list($web_trf, $ftp_trf, $pop_trf, $smtp_trf) = get_domain_trafic($ftm, $ltm, $domain_id); if ($counter % 2 == 0) { $tpl->assign('ITEM_CLASS', 'content'); } else { $tpl->assign('ITEM_CLASS', 'content2'); } $sum_web += $web_trf; $sum_ftp += $ftp_trf; $sum_mail += $smtp_trf; $sum_pop += $pop_trf; global $cfg; $date_formt = $cfg['DATE_FORMAT']; $tpl->assign(array('DATE' => date($date_formt, strtotime($year . "-" . $month . "-" . $i)), 'WEB_TRAFFIC' => sizeit($web_trf), 'FTP_TRAFFIC' => sizeit($ftp_trf), 'SMTP_TRAFFIC' => sizeit($smtp_trf), 'POP3_TRAFFIC' => sizeit($pop_trf), 'ALL_TRAFFIC' => sizeit($web_trf + $ftp_trf + $smtp_trf + $pop_trf), 'WEB_TRAFF' => sizeit($web_trf), 'FTP_TRAFF' => sizeit($ftp_trf), 'SMTP_TRAFF' => sizeit($smtp_trf), 'POP_TRAFF' => sizeit($pop_trf), 'SUM_TRAFF' => sizeit($web_trf + $ftp_trf + $smtp_trf + $pop_trf), 'CONTENT' => $i % 2 == 0 ? 'content' : 'content2')); $tpl->assign(array('MONTH' => $month, 'YEAR' => $year, 'DOMAIN_ID' => $domain_id, 'WEB_ALL' => sizeit($sum_web), 'FTP_ALL' => sizeit($sum_ftp), 'SMTP_ALL' => sizeit($sum_mail), 'POP_ALL' => sizeit($sum_pop), 'SUM_ALL' => sizeit($sum_web + $sum_ftp + $sum_mail + $sum_pop))); $tpl->parse('TRAFF_ITEM', '.traff_item'); $counter++; } /* $start_date = mktime(0,0,0, $month, 1, $year); $end_date = mktime(0,0,0, $month + 1, 1, $year); $dmn_id = get_user_domain_id($sql, $user_id); $query = <<<SQL_QUERY select dtraff_time as traff_date, dtraff_web as web_traff, dtraff_ftp as ftp_traff, dtraff_mail as smtp_traff, dtraff_pop as pop_traff, (dtraff_web + dtraff_ftp + dtraff_mail + dtraff_pop) as sum_traff from domain_traffic where domain_id = '$dmn_id' and dtraff_time >= '$start_date' and dtraff_time < '$end_date' order by dtraff_time SQL_QUERY; $rs = execute_query($sql, $query); if ($rs -> RecordCount() == 0) { $tpl -> assign('TRAFF_LIST', ''); set_page_message(tr('Traffic accounting for the selected month is missing!')); } else { $web_all = 0; $ftp_all = 0; $smtp_all = 0; $pop_all = 0; $sum_all = 0; $i = 1; while (!$rs -> EOF) { $tpl -> assign( array( 'DATE' => date("d.m.Y, G:i", $rs -> fields['traff_date']), 'WEB_TRAFF' => sizeit($rs -> fields['web_traff']), 'FTP_TRAFF' => sizeit($rs -> fields['ftp_traff']), 'SMTP_TRAFF' => sizeit($rs -> fields['smtp_traff']), 'POP_TRAFF' => sizeit($rs -> fields['pop_traff']), 'SUM_TRAFF' => sizeit($rs -> fields['sum_traff']), 'CONTENT' => ($i % 2 == 0) ? 'content3' : 'content2' ) ); $tpl -> parse('TRAFF_ITEM', '.traff_item'); $web_all += $rs -> fields['web_traff']; $ftp_all += $rs -> fields['ftp_traff']; $smtp_all += $rs -> fields['smtp_traff']; $pop_all += $rs -> fields['pop_traff']; $sum_all += $rs -> fields['sum_traff']; $rs -> MoveNext(); $i++; } $tpl -> assign( array( 'WEB_ALL' => sizeit($web_all), 'FTP_ALL' => sizeit($ftp_all), 'SMTP_ALL' => sizeit($smtp_all), 'POP_ALL' => sizeit($pop_all), 'SUM_ALL' => sizeit($sum_all) ) ); } */ }
function gen_disk_usage(&$tpl, $usage, $max_usage, $bars_max) { list($percent, $bars) = calc_bars($usage, $max_usage, $bars_max); if ($max_usage != 0) { $traffic_usage_data = sprintf("%s%% [%s " . tr('of') . " %s]", $percent, sizeit($usage), sizeit($max_usage)); } else { $traffic_usage_data = sprintf("%s%% [%s " . tr('of') . " %s]", $percent, sizeit($usage), tr('unlimited')); } $tpl->assign(array('DISK_USAGE_DATA' => $traffic_usage_data, 'DISK_BARS' => $bars)); if ($max_usage != 0 && $usage > $max_usage) { $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk limit!')); } else { $tpl->assign('DISK_WARN', ''); } }
/** * @param EasySCP_TemplateEngine $tpl * @param int $reseller_id * @param string $reseller_name */ function generate_page_data($tpl, $reseller_id, $reseller_name) { global $crnt_month, $crnt_year; $sql = EasySCP_Registry::get('Db'); $crnt_month = date("m"); $crnt_year = date("Y"); // global $tmpArr = get_reseller_default_props($sql, $reseller_id); if ($tmpArr != NULL) { // there are data in db list($rdmn_current, $rdmn_max, $rsub_current, $rsub_max, $rals_current, $rals_max, $rmail_current, $rmail_max, $rftp_current, $rftp_max, $rsql_db_current, $rsql_db_max, $rsql_user_current, $rsql_user_max, $rtraff_current, $rtraff_max, $rdisk_current, $rdisk_max) = $tmpArr; } else { list($rdmn_current, $rdmn_max, $rsub_current, $rsub_max, $rals_current, $rals_max, $rmail_current, $rmail_max, $rftp_current, $rftp_max, $rsql_db_current, $rsql_db_max, $rsql_user_current, $rsql_user_max, $rtraff_current, $rtraff_max, $rdisk_current, $rdisk_max) = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); } list($udmn_current, , , $usub_current, , , $uals_current, , , $umail_current, , , $uftp_current, , , $usql_db_current, , , $usql_user_current, , , $utraff_current, , , $udisk_current) = generate_reseller_user_props($reseller_id); // Convert into MB values $rtraff_max = $rtraff_max * 1024 * 1024; $rtraff_current = $rtraff_current * 1024 * 1024; $rdisk_max = $rdisk_max * 1024 * 1024; $rdisk_current = $rdisk_current * 1024 * 1024; if ($rtraff_max != 0) { $traff_percent = sprintf("%.2f", 100 * $utraff_current / $rtraff_max); } else { $traff_percent = 0; } gen_traff_usage($tpl, $utraff_current, $rtraff_max, 400); gen_disk_usage($tpl, $udisk_current, $rdisk_max, 400); if ($rtraff_max > 0) { if ($utraff_current > $rtraff_max) { $tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your traffic limit!')); } } // warning HDD Usage if ($rdisk_max > 0) { if ($udisk_current > $rdisk_max) { $tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk limit!')); } } $tpl->assign(array("ACCOUNT_NAME" => tr("Account name"), "GENERAL_INFO" => tr("General information"), "DOMAINS" => tr("User accounts"), "SUBDOMAINS" => tr("Subdomains"), "ALIASES" => tr("Aliases"), "MAIL_ACCOUNTS" => tr("Mail account"), "TR_FTP_ACCOUNTS" => tr("FTP account"), "SQL_DATABASES" => tr("SQL databases"), "SQL_USERS" => tr("SQL users"), "TRAFFIC" => tr("Traffic"), "DISK" => tr("Disk"), "TR_EXTRAS" => tr("Extras"))); $tpl->assign(array('RESELLER_NAME' => tohtml($reseller_name), 'TRAFF_PERCENT' => $traff_percent, 'TRAFF_MSG' => $rtraff_max ? tr('%1$s used / %2$s assigned of <strong>%3$s</strong>', sizeit($utraff_current), sizeit($rtraff_current), sizeit($rtraff_max)) : tr('%1$s used / %2$s assigned of <strong>unlimited</strong>', sizeit($utraff_current), sizeit($rtraff_current)), 'DISK_MSG' => $rdisk_max ? tr('%1$s used / %2$s assigned of <strong>%3$s</strong>', sizeit($udisk_current), sizeit($rdisk_current), sizeit($rdisk_max)) : tr('%1$s used / %2$s assigned of <strong>unlimited</strong>', sizeit($udisk_current), sizeit($rdisk_current)), 'DMN_MSG' => $rdmn_max ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $udmn_current, $rdmn_current, $rdmn_max) : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $udmn_current, $rdmn_current), 'SUB_MSG' => $rsub_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $usub_current, $rsub_current, $rsub_max) : ($rsub_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $usub_current, $rsub_current)), 'ALS_MSG' => $rals_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $uals_current, $rals_current, $rals_max) : ($rals_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $uals_current, $rals_current)), 'MAIL_MSG' => $rmail_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $umail_current, $rmail_current, $rmail_max) : ($rmail_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $umail_current, $rmail_current)), 'FTP_MSG' => $rftp_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $uftp_current, $rftp_current, $rftp_max) : ($rftp_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $uftp_current, $rftp_current)), 'SQL_DB_MSG' => $rsql_db_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $usql_db_current, $rsql_db_current, $rsql_db_max) : ($rsql_db_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $usql_db_current, $rsql_db_current)), 'SQL_USER_MSG' => $rsql_user_max > 0 ? tr('%1$d used / %2$d assigned of <strong>%3$d</strong>', $usql_user_current, $rsql_user_current, $rsql_user_max) : ($rsql_user_max === "-1" ? tr('<strong>disabled</strong>') : tr('%1$d used / %2$d assigned of <strong>unlimited</strong>', $usql_user_current, $rsql_user_current)), 'EXTRAS' => '')); }
/** * @param EasySCP_TemplateEngine $tpl * @return void */ function gen_server_trafic($tpl) { $sql_query = "\n\t\tSELECT\n\t\t\tstraff_max, straff_warn\n\t\tFROM\n\t\t\tstraff_settings;\n\t"; $row = DB::query($sql_query, true); $straff_max = $row['straff_max'] * 1024 * 1024; $straff_warn = $row['straff_warn'] * 1024 * 1024; $sql_param = array(':fdofmnth' => mktime(0, 0, 0, date("m"), 1, date("Y")), ':ldofmnth' => mktime(1, 0, 0, date("m") + 1, 0, date("Y"))); $query = "\n\t\tSELECT\n\t\t\tIFNULL((SUM(bytes_in) + SUM(bytes_out)), 0) AS traffic\n\t\tFROM\n\t\t\tserver_traffic\n\t\tWHERE\n\t\t\ttraff_time > :fdofmnth\n\t\tAND\n\t\t\ttraff_time < :ldofmnth;\n\t"; DB::prepare($sql_query); $row = DB::execute($sql_param, true); $traff = isset($row['traffic']) ? $row['traffic'] : 0; $mtraff = sprintf("%.2f", $traff); if ($straff_max == 0) { $pr = 0; } else { $pr = $traff / $straff_max * 100; } if (($straff_max != 0 || $straff_max != '') && $mtraff > $straff_max) { $tpl->assign(array('TR_TRAFFIC_WARNING' => tr('You are exceeding your traffic limit!'))); } else { if (($straff_warn != 0 || $straff_warn != '') && $mtraff > $straff_warn) { $tpl->assign(array('TR_TRAFFIC_WARNING' => tr('You traffic limit will be reached soon!'))); } else { $tpl->assign('TRAFF_WARN', ''); } } $bar_value = calc_bar_value($traff, $straff_max, 400); $percent = 0; if ($straff_max == 0) { $traff_msg = tr('%1$d%% [%2$s of unlimited]', $pr, sizeit($mtraff)); } else { $traff_msg = tr('%1$d%% [%2$s of %3$s]', $pr, sizeit($mtraff), sizeit($straff_max)); $percent = $traff / $straff_max * 100 < 99.7 ? $traff / $straff_max * 100 : 99.7; } $tpl->assign(array('TRAFFIC_WARNING' => $traff_msg, 'BAR_VALUE' => $bar_value, 'TRAFFIC_PERCENT' => $percent)); }
/** * @param EasySCP_TemplateEngine $tpl */ function generate_page($tpl) { $sql = EasySCP_Registry::get('Db'); global $month, $year, $day; $all[0] = 0; $all[1] = 0; $all[2] = 0; $all[3] = 0; $all[4] = 0; $all[5] = 0; $all[6] = 0; $all[7] = 0; $all_other_in = 0; $all_other_out = 0; $ftm = mktime(0, 0, 0, $month, $day, $year); $ltm = mktime(0, 0, 0, $month, $day + 1, $year); $query = "\n\t\tSELECT\n\t\t\tCOUNT(`bytes_in`) AS cnt\n\t\tFROM\n\t\t\t`server_traffic`\n\t\tWHERE\n\t\t\t`traff_time` > ? AND `traff_time` <= ?\n\t"; $rs = exec_query($sql, $query, array($ftm, $ltm)); $dnum = $rs->fields['cnt']; $query = "\n\t\tSELECT\n\t\t\t`traff_time` AS ttime,\n\t\t\t`bytes_in` AS sbin,\n\t\t\t`bytes_out` AS sbout,\n\t\t\t`bytes_mail_in` AS smbin,\n\t\t\t`bytes_mail_out` AS smbout,\n\t\t\t`bytes_pop_in` AS spbin,\n\t\t\t`bytes_pop_out` AS spbout,\n\t\t\t`bytes_web_in` AS swbin,\n\t\t\t`bytes_web_out` AS swbout\n\t\tFROM\n\t\t\t`server_traffic`\n\t\tWHERE\n\t\t\t`traff_time` > ? AND `traff_time` <= ?\n\t"; $rs1 = exec_query($sql, $query, array($ftm, $ltm)); if ($dnum != 0) { for ($i = 0; $i < $dnum; $i++) { // make it in kb mb or bytes :) $ttime = date('H:i', $rs1->fields['ttime']); // make other traffic $other_in = $rs1->fields['sbin'] - ($rs1->fields['swbin'] + $rs1->fields['smbin'] + $rs1->fields['spbin']); $other_out = $rs1->fields['sbout'] - ($rs1->fields['swbout'] + $rs1->fields['smbout'] + $rs1->fields['spbout']); $tpl->append(array('HOUR' => $ttime, 'WEB_IN' => sizeit($rs1->fields['swbin']), 'WEB_OUT' => sizeit($rs1->fields['swbout']), 'SMTP_IN' => sizeit($rs1->fields['smbin']), 'SMTP_OUT' => sizeit($rs1->fields['smbout']), 'POP_IN' => sizeit($rs1->fields['spbin']), 'POP_OUT' => sizeit($rs1->fields['spbout']), 'OTHER_IN' => sizeit($other_in), 'OTHER_OUT' => sizeit($other_out), 'ALL_IN' => sizeit($rs1->fields['sbin']), 'ALL_OUT' => sizeit($rs1->fields['sbout']), 'ALL' => sizeit($rs1->fields['sbin'] + $rs1->fields['sbout']))); $all[0] = $all[0] + $rs1->fields['swbin']; $all[1] = $all[1] + $rs1->fields['swbout']; $all[2] = $all[2] + $rs1->fields['smbin']; $all[3] = $all[3] + $rs1->fields['smbout']; $all[4] = $all[4] + $rs1->fields['spbin']; $all[5] = $all[5] + $rs1->fields['spbout']; $all[6] = $all[6] + $rs1->fields['sbin']; $all[7] = $all[7] + $rs1->fields['sbout']; $rs1->moveNext(); } // end for $all_other_in = $all[6] - ($all[0] + $all[2] + $all[4]); $all_other_out = $all[7] - ($all[1] + $all[3] + $all[5]); } $tpl->assign(array('WEB_IN_ALL' => sizeit($all[0]), 'WEB_OUT_ALL' => sizeit($all[1]), 'SMTP_IN_ALL' => sizeit($all[2]), 'SMTP_OUT_ALL' => sizeit($all[3]), 'POP_IN_ALL' => sizeit($all[4]), 'POP_OUT_ALL' => sizeit($all[5]), 'OTHER_IN_ALL' => sizeit($all_other_in), 'OTHER_OUT_ALL' => sizeit($all_other_out), 'ALL_IN_ALL' => sizeit($all[6]), 'ALL_OUT_ALL' => sizeit($all[7]), 'ALL_ALL' => sizeit($all[6] + $all[7]))); }
function gen_hp(&$tpl, &$sql, $user_id) { global $cfg; $availabe_order = 0; $hp_title = tr('Hosting plans available for update'); // lets see if we have an order $query = <<<SQL_QUERY select \t\t\t* from orders where \t\t\tcustomer_id=? \t\tand \t\t\tstatus<>? SQL_QUERY; $rs = exec_query($sql, $query, array($user_id, 'added')); if ($rs->RecordCount() > 0) { $availabe_order = 1; $availabe_hp_id = $rs->fields['plan_id']; $query = <<<SQL_QUERY select \t\t\t* from hosting_plans where \t\t\tid=? SQL_QUERY; $rs = exec_query($sql, $query, array($availabe_hp_id)); $count = 2; $purchase_text = tr('Cancel order'); $purchase_link = 'delete_id'; $hp_title = tr('Your order'); } else { // generate all hosting plans available for purchasing if (isset($cfg['HOSTING_PLANS_LEVEL']) && $cfg['HOSTING_PLANS_LEVEL'] === 'admin') { $query = <<<SQL_QUERY \t\t\t\tselect \t\t\t\t\tt1.*, \t\t\t\t\tt2.admin_id, t2.admin_type \t\t\t\tfrom \t\t\t\t\thosting_plans as t1, \t\t\t\t\tadmin as t2 \t\t\t\twhere \t\t\t\t\tt2.admin_type=? \t\t\t\tand \t\t\t\t\tt1.reseller_id = t2.admin_id \t\t\t\tand \t\t\t\t\tt1.status=1 \t\t\t\torder by \t\t\t\t\tt1.id SQL_QUERY; $rs = exec_query($sql, $query, array('admin')); $count = $rs->RecordCount(); $count++; } else { $query = <<<SQL_QUERY \t\t\t\tselect \t\t\t\t\t* \t\t\t\tfrom \t\t\t\t\thosting_plans \t\t\t\twhere (reseller_id=? and status='1') SQL_QUERY; $count_query = <<<SQL_QUERY \t\t\t\tselect \t\t\t\t\tcount(id) as cnum \t\t\t\tfrom \t\t\t\t\thosting_plans \t\t\t\twhere (reseller_id=? and status='1') SQL_QUERY; $cnt = exec_query($sql, $count_query, array($_SESSION['user_created_by'])); $rs = exec_query($sql, $query, array($_SESSION['user_created_by'])); $count = $cnt->fields['cnum'] + 1; } $purchase_text = tr('Purchase'); $purchase_link = 'order_id'; } if ($rs->RecordCount() == 0) { $tpl->assign(array('TR_HOSTING_PLANS' => $hp_title, 'HOSTING_PLANS' => '', 'HP_ORDER' => '', 'COLSPAN' => 2)); set_page_message(tr('There are no available updates')); return; } $tpl->assign('COLSPAN', $count); $i = 0; while (!$rs->EOF) { $details = $rs->fields['props']; list($hp_php, $hp_cgi, $hp_sub, $hp_als, $hp_mail, $hp_ftp, $hp_sql_db, $hp_sql_user, $hp_traff, $hp_disk) = explode(";", $details); $details = ''; if ($hp_php === '_yes_') { $details = tr('PHP Support: enabled') . "<br>"; $php = "yes"; } else { $details = tr('PHP Support: disabled') . "<br>"; $php = "no"; } if ($hp_cgi === '_yes_') { $cgi = "yes"; $details = $details . " " . tr('CGI Support: enabled') . "<br>"; } else { $cgi = "no"; $details = $details . " " . tr('CGI Support: disabled') . "<br>"; } if (is_numeric(gen_num_limit_msg($hp_disk))) { $hdd_usage = tr('HDD') . ": " . sizeit(gen_num_limit_msg($hp_disk * 1024 * 1024)) . "<br>"; } else { $hdd_usage = tr('HDD') . ": " . gen_num_limit_msg($hp_disk) . "<br>"; } if (is_numeric(gen_num_limit_msg($hp_traff))) { $traffic_usage = tr('Traffic') . ": " . sizeit(gen_num_limit_msg($hp_traff * 1024 * 1024)); } else { $traffic_usage = tr('Traffic') . ": " . gen_num_limit_msg($hp_traff * 1024 * 1024); } $details = $details . " " . tr('Aliases') . ": " . gen_num_limit_msg($hp_als) . "<br>" . tr('Subdomains') . ": " . gen_num_limit_msg($hp_sub) . "<br>" . tr('Emails') . ": " . gen_num_limit_msg($hp_mail) . "<br>" . tr('FTPs') . ": " . gen_num_limit_msg($hp_ftp) . "<br>" . tr('SQL Databases') . " " . gen_num_limit_msg($hp_sql_db) . "<br>" . tr('SQL Users') . ": " . gen_num_limit_msg($hp_sql_user) . "<br>" . $hdd_usage . $traffic_usage; $price = $rs->fields['price']; if ($price == 0 || $price == '') { $price = tr('free of charge'); } else { $price = $price . " " . $rs->fields['value'] . " " . $rs->fields['payment']; } $check_query = <<<SQL_QUERY \t select \t\t\t\tdomain_id \t from \t domain \twhere \t\t\t\tdomain_admin_id=? \t\t\tand \t\t\t\tdomain_mailacc_limit=? \t\t\tand \t\t\t\tdomain_ftpacc_limit=? \t\t\tand \t\t\t\tdomain_traffic_limit=? \t\t\tand \t\t\t\tdomain_sqld_limit=? \t\t\tand \t\t\t\tdomain_sqlu_limit=? \t\t\tand \t\t\t\tdomain_alias_limit=? \t\t\tand \t\t\t\tdomain_subd_limit=? \t\t\tand \t\t\t\tdomain_disk_limit=? \t\t\tand \t\t\t\tdomain_php=? \t\t\tand \t\t\t\tdomain_cgi=? \t SQL_QUERY; $check = exec_query($sql, $check_query, array($_SESSION['user_id'], $hp_mail, $hp_ftp, $hp_traff, $hp_sql_db, $hp_sql_user, $hp_als, $hp_sub, $hp_disk, $php, $cgi)); if ($check->RecordCount() == 0) { $tpl->assign(array('HP_NAME' => stripslashes($rs->fields['name']), 'HP_DESCRIPTION' => stripslashes($rs->fields['description']), 'HP_DETAILS' => stripslashes($details), 'HP_COSTS' => $price, 'ID' => $rs->fields['id'], 'TR_PURCHASE' => $purchase_text, 'LINK' => $purchase_link, 'TR_HOSTING_PLANS' => $hp_title, 'ITHEM' => $i % 2 == 0 ? 'content' : 'content2')); $tpl->parse('HOSTING_PLANS', '.hosting_plans'); $tpl->parse('HP_ORDER', '.hp_order'); $i++; } $rs->MoveNext(); } if ($i == 0) { $tpl->assign(array('HOSTING_PLANS' => '', 'HP_ORDER' => '', 'TR_HOSTING_PLANS' => $hp_title, 'COLSPAN' => '2')); set_page_message(tr('There are no available hosting plans for update')); } }