typecast parameter values for sizeReadable(), fixes #1103
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -33,8 +33,6 @@ namespace Froxlor\Cron\Traffic;
|
||||
use Exception;
|
||||
use Froxlor\Cron\FroxlorCron;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\PhpHelper;
|
||||
use Froxlor\Settings;
|
||||
@@ -99,8 +97,8 @@ class ReportsCron extends FroxlorCron
|
||||
'COMPANY' => $rep_userinfo['company'],
|
||||
'USERNAME' => $rep_userinfo['loginname'],
|
||||
'CUSTOMER_NO' => $rep_userinfo['customernumber'],
|
||||
'TRAFFIC' => PhpHelper::sizeReadable($row['traffic'], null, 'bi'),
|
||||
'TRAFFICUSED' => PhpHelper::sizeReadable($row['traffic_used'], null, 'bi'),
|
||||
'TRAFFIC' => PhpHelper::sizeReadable((int)$row['traffic'], null, 'bi'),
|
||||
'TRAFFICUSED' => PhpHelper::sizeReadable((int)$row['traffic_used'], null, 'bi'),
|
||||
'USAGE_PERCENT' => round(($row['traffic_used'] * 100) / $row['traffic'], 2),
|
||||
'MAX_PERCENT' => Settings::Get('system.report_trafficmax')
|
||||
];
|
||||
@@ -182,8 +180,8 @@ class ReportsCron extends FroxlorCron
|
||||
if (isset($row['traffic']) && $row['traffic'] > 0 && (($row['traffic_used_total'] * 100) / ($row['traffic'])) >= (int)Settings::Get('system.report_trafficmax')) {
|
||||
$replace_arr = [
|
||||
'NAME' => $row['name'],
|
||||
'TRAFFIC' => PhpHelper::sizeReadable($row['traffic'], null, 'bi'),
|
||||
'TRAFFICUSED' => PhpHelper::sizeReadable($row['traffic_used_total'], null, 'bi'),
|
||||
'TRAFFIC' => PhpHelper::sizeReadable((int)$row['traffic'], null, 'bi'),
|
||||
'TRAFFICUSED' => PhpHelper::sizeReadable((int)$row['traffic_used_total'], null, 'bi'),
|
||||
'USAGE_PERCENT' => round(($row['traffic_used_total'] * 100) / $row['traffic'], 2),
|
||||
'MAX_PERCENT' => Settings::Get('system.report_trafficmax')
|
||||
];
|
||||
@@ -265,10 +263,10 @@ class ReportsCron extends FroxlorCron
|
||||
|
||||
while ($customer = $customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$customer['traffic'] *= 1024;
|
||||
$t = $customer['traffic_used_total'] * 1024;
|
||||
$t = (int) $customer['traffic_used_total'] * 1024;
|
||||
if ($customer['traffic'] > 0) {
|
||||
$p = (($t * 100) / $customer['traffic']);
|
||||
$tg = $customer['traffic'];
|
||||
$tg = (int) $customer['traffic'];
|
||||
$str = sprintf('%s ( %00.1f %% )', PhpHelper::sizeReadable($t, null, 'bi'), $p);
|
||||
$mail_body .= sprintf('%-15s', $customer['loginname']) . ' ' . sprintf('%-25s', $str) . ' ' . sprintf('%s', PhpHelper::sizeReadable($tg, null, 'bi')) . "\n";
|
||||
} elseif ($customer['traffic'] == 0) {
|
||||
@@ -282,10 +280,10 @@ class ReportsCron extends FroxlorCron
|
||||
|
||||
$mail_body .= '---------------------------------------------------------------' . "\n";
|
||||
|
||||
$t = $row['traffic_used_total'];
|
||||
$t = (int) $row['traffic_used_total'];
|
||||
if ($row['traffic'] > 0) {
|
||||
$p = (($t * 100) / $row['traffic']);
|
||||
$tg = $row['traffic'];
|
||||
$tg = (int) $row['traffic'];
|
||||
$str = sprintf('%s ( %00.1f %% )', PhpHelper::sizeReadable($t, null, 'bi'), $p);
|
||||
$mail_body .= sprintf('%-15s', $row['loginname']) . ' ' . sprintf('%-25s', $str) . ' ' . sprintf('%s', PhpHelper::sizeReadable($tg, null, 'bi')) . "\n";
|
||||
} elseif ($row['traffic'] == 0) {
|
||||
@@ -369,8 +367,8 @@ class ReportsCron extends FroxlorCron
|
||||
'COMPANY' => $rep_userinfo['company'],
|
||||
'USERNAME' => $rep_userinfo['loginname'],
|
||||
'CUSTOMER_NO' => $rep_userinfo['customernumber'],
|
||||
'DISKAVAILABLE' => PhpHelper::sizeReadable($row['diskspace'], null, 'bi'),
|
||||
'DISKUSED' => PhpHelper::sizeReadable($row['diskspace_used'], null, 'bi'),
|
||||
'DISKAVAILABLE' => PhpHelper::sizeReadable((int)$row['diskspace'], null, 'bi'),
|
||||
'DISKUSED' => PhpHelper::sizeReadable((int)$row['diskspace_used'], null, 'bi'),
|
||||
'USAGE_PERCENT' => round(($row['diskspace_used'] * 100) / $row['diskspace'], 2),
|
||||
'MAX_PERCENT' => Settings::Get('system.report_webmax')
|
||||
];
|
||||
@@ -443,8 +441,8 @@ class ReportsCron extends FroxlorCron
|
||||
if (isset($row['diskspace']) && $row['diskspace_used'] != null && $row['diskspace_used'] > 0 && (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)Settings::Get('system.report_webmax')) {
|
||||
$replace_arr = [
|
||||
'NAME' => $row['name'],
|
||||
'DISKAVAILABLE' => PhpHelper::sizeReadable($row['diskspace'], null, 'bi'),
|
||||
'DISKUSED' => PhpHelper::sizeReadable($row['diskspace_used'], null, 'bi'),
|
||||
'DISKAVAILABLE' => PhpHelper::sizeReadable((int)$row['diskspace'], null, 'bi'),
|
||||
'DISKUSED' => PhpHelper::sizeReadable((int)$row['diskspace_used'], null, 'bi'),
|
||||
'USAGE_PERCENT' => ($row['diskspace_used'] * 100) / $row['diskspace'],
|
||||
'MAX_PERCENT' => Settings::Get('system.report_webmax')
|
||||
];
|
||||
|
||||
@@ -78,7 +78,7 @@ class TrafficCron extends FroxlorCron
|
||||
// Fork failed
|
||||
return 1;
|
||||
}
|
||||
} else if (!defined('CRON_NOFORK_FLAG')) {
|
||||
} elseif (!defined('CRON_NOFORK_FLAG')) {
|
||||
if (extension_loaded('pcntl')) {
|
||||
$msg = "PHP compiled with pcntl but pcntl_fork function is not available.";
|
||||
} else {
|
||||
@@ -406,7 +406,7 @@ class TrafficCron extends FroxlorCron
|
||||
} else {
|
||||
// Use the old fashioned way with "du"
|
||||
if (file_exists($row['documentroot']) && is_dir($row['documentroot'])) {
|
||||
$back = FileDir::safe_exec('du -sk ' . escapeshellarg($row['documentroot']) . '');
|
||||
$back = FileDir::safe_exec('du -sk ' . escapeshellarg($row['documentroot']));
|
||||
foreach ($back as $backrow) {
|
||||
$webspaceusage = explode(' ', $backrow);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ class TrafficCron extends FroxlorCron
|
||||
|
||||
$maildir = FileDir::makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']);
|
||||
if (file_exists($maildir) && is_dir($maildir)) {
|
||||
$back = FileDir::safe_exec('du -sk ' . escapeshellarg($maildir) . '');
|
||||
$back = FileDir::safe_exec('du -sk ' . escapeshellarg($maildir));
|
||||
foreach ($back as $backrow) {
|
||||
$emailusage = explode(' ', $backrow);
|
||||
}
|
||||
@@ -627,7 +627,7 @@ class TrafficCron extends FroxlorCron
|
||||
* @param string $caption Caption for webalizer output
|
||||
* @param array $monthyear_arr
|
||||
* @param int $current_stamp
|
||||
*
|
||||
*
|
||||
* @return int Used traffic
|
||||
*/
|
||||
private static function callGoaccessGetTraffic($customerid, $logfile, $outputdir, $caption, array $monthyear_arr = [], int $current_stamp = 0)
|
||||
@@ -705,7 +705,7 @@ class TrafficCron extends FroxlorCron
|
||||
* @param string $outputdir Place where stats should be build
|
||||
* @param string $caption Caption for webalizer output
|
||||
* @param array $usersdomainlist
|
||||
*
|
||||
*
|
||||
* @return float Used traffic
|
||||
*/
|
||||
private static function callWebalizerGetTraffic($logfile, $outputdir, $caption, array $usersdomainlist = [])
|
||||
|
||||
Reference in New Issue
Block a user