2011-04-23 22:01:37 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
|
|
|
* @author Morton Jonuschat <m.jonuschat@chrome-it.de>
|
|
|
|
* @license GPLv2 http://files.syscp.org/misc/COPYING.txt
|
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2011-04-23 22:01:37 +00:00
|
|
|
*/
|
2022-02-20 17:00:44 +00:00
|
|
|
|
|
|
|
const AREA = 'admin';
|
|
|
|
require __DIR__ . '/lib/init.php';
|
2011-04-23 22:01:37 +00:00
|
|
|
|
2018-12-21 18:16:49 +00:00
|
|
|
use Froxlor\Database\Database;
|
|
|
|
use Froxlor\Settings;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\UI\Request;
|
2018-12-18 12:45:05 +00:00
|
|
|
|
2022-02-20 17:00:44 +00:00
|
|
|
$id = (int) Request::get('id');
|
2011-04-23 22:01:37 +00:00
|
|
|
|
|
|
|
$months = array(
|
|
|
|
'0' => 'empty',
|
|
|
|
'1' => 'jan',
|
|
|
|
'2' => 'feb',
|
|
|
|
'3' => 'mar',
|
|
|
|
'4' => 'apr',
|
|
|
|
'5' => 'may',
|
|
|
|
'6' => 'jun',
|
|
|
|
'7' => 'jul',
|
|
|
|
'8' => 'aug',
|
|
|
|
'9' => 'sep',
|
|
|
|
'10' => 'oct',
|
|
|
|
'11' => 'nov',
|
2018-12-21 11:24:07 +00:00
|
|
|
'12' => 'dec'
|
2011-04-23 22:01:37 +00:00
|
|
|
);
|
|
|
|
|
2013-10-31 14:46:38 +00:00
|
|
|
if ($page == 'overview' || $page == 'customers') {
|
|
|
|
|
2011-04-23 22:01:37 +00:00
|
|
|
$customerview = 1;
|
|
|
|
$stats_tables = '';
|
2018-12-21 11:24:07 +00:00
|
|
|
$minyear_stmt = Database::query("SELECT `year` FROM `" . TABLE_PANEL_TRAFFIC . "` ORDER BY `year` ASC LIMIT 1");
|
2013-10-31 14:46:38 +00:00
|
|
|
$minyear = $minyear_stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
if (! isset($minyear['year']) || $minyear['year'] == 0) {
|
2011-04-23 22:57:08 +00:00
|
|
|
$maxyears = 0;
|
2013-10-31 14:46:38 +00:00
|
|
|
} else {
|
2011-04-23 22:57:08 +00:00
|
|
|
$maxyears = date("Y") - $minyear['year'];
|
|
|
|
}
|
2013-10-31 14:46:38 +00:00
|
|
|
|
2021-02-11 11:09:42 +00:00
|
|
|
$params = [];
|
|
|
|
if ($userinfo['customers_see_all'] == '0') {
|
|
|
|
$params = [
|
|
|
|
'id' => $userinfo['adminid']
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$customer_name_list_stmt = Database::prepare("
|
|
|
|
SELECT `customerid`,`company`,`name`,`firstname`
|
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
|
|
|
WHERE `deactivated`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :id") . "
|
|
|
|
ORDER BY name"
|
|
|
|
);
|
|
|
|
|
|
|
|
$traffic_list_stmt = Database::prepare("
|
|
|
|
SELECT month, SUM(http+ftp_up+ftp_down+mail)*1024 AS traffic
|
|
|
|
FROM `" . TABLE_PANEL_TRAFFIC . "`
|
|
|
|
WHERE year = :year AND `customerid` = :id
|
|
|
|
GROUP BY month ORDER BY month"
|
|
|
|
);
|
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
for ($years = 0; $years <= $maxyears; $years ++) {
|
2013-10-31 14:46:38 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
$overview['year'] = date("Y") - $years;
|
2018-12-22 07:15:31 +00:00
|
|
|
$overview['type'] = $lng['traffic']['customer'];
|
2011-04-23 22:01:37 +00:00
|
|
|
$domain_list = '';
|
|
|
|
$totals = array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'jan' => 0,
|
|
|
|
'feb' => 0,
|
|
|
|
'mar' => 0,
|
|
|
|
'apr' => 0,
|
|
|
|
'may' => 0,
|
|
|
|
'jun' => 0,
|
|
|
|
'jul' => 0,
|
|
|
|
'aug' => 0,
|
|
|
|
'sep' => 0,
|
|
|
|
'oct' => 0,
|
|
|
|
'nov' => 0,
|
|
|
|
'dec' => 0
|
2013-10-31 14:46:38 +00:00
|
|
|
);
|
|
|
|
|
2021-02-11 11:09:42 +00:00
|
|
|
Database::pexecute($customer_name_list_stmt, $params);
|
2013-10-31 14:46:38 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
while ($customer_name = $customer_name_list_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-10-31 14:46:38 +00:00
|
|
|
|
2011-04-23 22:01:37 +00:00
|
|
|
$virtual_host = array(
|
|
|
|
'name' => ($customer_name['company'] == '' ? $customer_name['name'] . ", " . $customer_name['firstname'] : $customer_name['company']),
|
|
|
|
'customerid' => $customer_name['customerid'],
|
|
|
|
'jan' => '-',
|
|
|
|
'feb' => '-',
|
|
|
|
'mar' => '-',
|
|
|
|
'apr' => '-',
|
|
|
|
'may' => '-',
|
|
|
|
'jun' => '-',
|
|
|
|
'jul' => '-',
|
|
|
|
'aug' => '-',
|
|
|
|
'sep' => '-',
|
|
|
|
'oct' => '-',
|
|
|
|
'nov' => '-',
|
2018-12-21 11:24:07 +00:00
|
|
|
'dec' => '-'
|
2011-04-23 22:01:37 +00:00
|
|
|
);
|
2013-10-31 14:46:38 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
Database::pexecute($traffic_list_stmt, array(
|
|
|
|
'year' => (date("Y") - $years),
|
|
|
|
'id' => $customer_name['customerid']
|
|
|
|
));
|
2013-10-31 14:46:38 +00:00
|
|
|
|
|
|
|
while ($traffic_month = $traffic_list_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-24 12:50:45 +00:00
|
|
|
$virtual_host[$months[(int) $traffic_month['month']]] = \Froxlor\PhpHelper::sizeReadable($traffic_month['traffic'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
2018-12-21 11:24:07 +00:00
|
|
|
$totals[$months[(int) $traffic_month['month']]] += $traffic_month['traffic'];
|
2011-04-23 22:01:37 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$domain_list .= sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table_row") . "\");");
|
2011-04-23 22:01:37 +00:00
|
|
|
}
|
|
|
|
// sum up totals
|
|
|
|
$virtual_host = array(
|
2018-12-22 07:15:31 +00:00
|
|
|
'name' => $lng['traffic']['months']['total']
|
2011-04-23 22:01:37 +00:00
|
|
|
);
|
2013-10-31 14:46:38 +00:00
|
|
|
foreach ($totals as $month => $bytes) {
|
2018-12-24 12:50:45 +00:00
|
|
|
$virtual_host[$month] = ($bytes == 0 ? '-' : \Froxlor\PhpHelper::sizeReadable($bytes, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'));
|
2011-04-23 22:01:37 +00:00
|
|
|
}
|
|
|
|
$customerview = 0;
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$total_list = sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table_row") . "\");");
|
|
|
|
eval("\$stats_tables .= sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table") . "\");");
|
2011-04-23 22:01:37 +00:00
|
|
|
}
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("traffic/index") . "\";");
|
2011-04-23 22:01:37 +00:00
|
|
|
}
|