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)
                                 )
                          );
    
        }
    */
}
Esempio n. 2
0
/**
 * @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)));
}
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');
    }
}
Esempio n. 4
0
/**
 * @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)));
}