Subversion Repositories ALCASAR

Compare Revisions

Regard whitespace Rev 1674 → Rev 1675

/web/acc/manager/stats/vnstat.php
83,7 → 83,7
}
 
$tp = "./themes/$style";
if (!is_dir($tp) || !file_exists("$tp/theme.php"))
if (!is_dir($tp) || !file_exists("$tp/theme.php") || !preg_match('/^[a-z0-9-_]+$/i', $style))
{
$style = DEFAULT_COLORSCHEME;
}
90,7 → 90,7
}
 
function get_vnstat_data()
function get_vnstat_data($use_label=true)
{
global $iface, $vnstat_bin, $data_dir;
global $hour,$day,$month,$top,$summary;
123,6 → 123,10
$month = array();
$top = array();
 
if (strpos($vnstat_data[0], 'Error') !== false) {
return;
}
 
//
// extract data
//
135,12 → 139,12
$day[$d[1]]['rx'] = $d[3] * 1024 + $d[5];
$day[$d[1]]['tx'] = $d[4] * 1024 + $d[6];
$day[$d[1]]['act'] = $d[7];
if ($d[2] != 0)
if ($d[2] != 0 && $use_label)
{
$day[$d[1]]['label'] = strftime(T('datefmt_days'),$d[2]);
$day[$d[1]]['img_label'] = strftime(T('datefmt_days_img'), $d[2]);
}
else
elseif($use_label)
{
$day[$d[1]]['label'] = '';
$day[$d[1]]['img_label'] = '';
152,12 → 156,12
$month[$d[1]]['rx'] = $d[3] * 1024 + $d[5];
$month[$d[1]]['tx'] = $d[4] * 1024 + $d[6];
$month[$d[1]]['act'] = $d[7];
if ($d[2] != 0)
if ($d[2] != 0 && $use_label)
{
$month[$d[1]]['label'] = strftime(T('datefmt_months'), $d[2]);
$month[$d[1]]['img_label'] = strftime(T('datefmt_months_img'), $d[2]);
}
else
else if ($use_label)
{
$month[$d[1]]['label'] = '';
$month[$d[1]]['img_label'] = '';
169,7 → 173,7
$hour[$d[1]]['rx'] = $d[3];
$hour[$d[1]]['tx'] = $d[4];
$hour[$d[1]]['act'] = 1;
if ($d[2] != 0)
if ($d[2] != 0 && $use_label)
{
$st = $d[2] - ($d[2] % 3600);
$et = $st + 3600;
176,7 → 180,7
$hour[$d[1]]['label'] = strftime(T('datefmt_hours'), $st).' - '.strftime(T('datefmt_hours'), $et);
$hour[$d[1]]['img_label'] = strftime(T('datefmt_hours_img'), $d[2]);
}
else
else if ($use_label)
{
$hour[$d[1]]['label'] = '';
$hour[$d[1]]['img_label'] = '';
188,24 → 192,20
$top[$d[1]]['rx'] = $d[3] * 1024 + $d[5];
$top[$d[1]]['tx'] = $d[4] * 1024 + $d[6];
$top[$d[1]]['act'] = $d[7];
if($use_label)
{
$top[$d[1]]['label'] = strftime(T('datefmt_top'), $d[2]);
$top[$d[1]]['img_label'] = '';
}
}
else
{
$summary[$d[0]] = isset($d[1]) ? $d[1] : '';
}
}
if (count($day) == 0)
$day[0] = 'nodata';
 
rsort($day);
 
if (count($month) == 0)
$month[0] = 'nodata';
rsort($month);
 
if (count($hour) == 0)
$hour[0] = 'nodata';
rsort($hour);
}
?>