";
exit;
}
$by = "id"; //$_GET["by"];
if($_POST["dirsort"] != "")
{
$sort = mysql_real_escape_string($_POST["dirsort"]);
}
else
{
$sort = $_POST["dirsort"];
}
if($_POST["table"] != "")
{
$table = mysql_real_escape_string($_POST["table"]);
}
else
{
$table = $_POST["table"];
}
function Potenz($sent_sum)
{
if($sent_sum>1024)
{
$sent_sum_anz=round($sent_sum/1024,2) . "kiB";
if($sent_sum>1024*1024)
{
$sent_sum_anz=round($sent_sum/(1024*1024),2) . "MiB";
if($sent_sum>1024*1024*1024)
{
$sent_sum_anz=round($sent_sum/(1024*1024*1024),2) . "GiB";
}
}
}
else
{
$sent_sum_anz=$sent_sum . "Byte";
}
return $sent_sum_anz;
}
?>
// MYsql befehl basteln
$sql = "SELECT * FROM $table ORDER BY $by $sort;";
$result = mysql_query($sql);
echo "
";
if($table=='connections')
{
echo "Start Time | Stop Time | Client IP | Download
| Upload |
\n";
}
else if($table=='month')
{
echo "Month | Year | Connection Time | Download
| Upload |
\n";
}
else if($table=='year')
{
echo "Year | Connection Time | Download
| Upload |
\n";
}
else
{
}
// ------------------------------------------------ Mysql lesen
if ($result)
{
//Zusammenzaehlen
$time_sum=0;
$month=0;
$year=0;
$sent_sum=0;
$received_sum=0;
while ($ar=mysql_fetch_array($result,MYSQL_ASSOC))
{
if($table=='connections')
{
if($ar["stop"] != 0)
{
$stop = date("r",$ar["stop"]);
}
else
{
$stop = "running session";
}
echo "",date("r",$ar["start"])," | ",$stop," | ",$ar["ip"],
" | ",Potenz($ar["sent"])," | ",Potenz($ar["received"]),
" |
\n";
}
else if($table=='month')
{
if($month!=$ar["month"] && $month!=0)
{
$hour = floor($time_sum/3600);
$min = floor($time_sum/60 - $hour *60);
$sec = $time_sum-$hour*3600-$min*60;
$timestring = $hour .":". $min .":". $sec;
$sent_sum_anz = Potenz($sent_sum);
$received_sum_anz = Potenz($received_sum);
echo "",$month," | ",$year," | ",$timestring,
" | ",$sent_sum_anz," | ",$received_sum_anz,
" |
\n";
$sent_sum=0;
$received_sum=0;
$time_sum=0;
}
else
{
}
$month=$ar["month"];
$year=$ar["year"];
$time_sum += $ar["time"];
$sent_sum += $ar["sent"];
$received_sum += $ar["received"];
}
else if($table=='year')
{
if($year!=$ar["year"] && $year!=0)
{
$hour = floor($time_sum/3600);
$min = floor($time_sum/60 - $hour *60);
$sec = $time_sum-$hour*3600-$min*60;
$timestring = $hour .":". $min .":". $sec;
$sent_sum_anz = Potenz($sent_sum);
$received_sum_anz = Potenz($received_sum);
echo "",$year," | ",$timestring,
" | ",$sent_sum_anz," | ",$received_sum_anz,
" |
\n";
$sent_sum=0;
$received_sum=0;
$time_sum=0;
}
else
{
}
$year=$ar["year"];
$time_sum += $ar["time"];
$sent_sum += $ar["sent"];
$received_sum += $ar["received"];
}
else
{
}
}
//letzen Datensatz ausgeben
$hour = floor($time_sum/3600);
$min = floor($time_sum/60 - $hour *60);
$sec = $time_sum-$hour*3600-$min*60;
$timestring = $hour .":". $min .":". $sec;
$sent_sum_anz = Potenz($sent_sum);
$received_sum_anz = Potenz($received_sum);
if($table=='year')
{
echo "",$year," | ",$timestring,
" | ",$sent_sum_anz," | ",$received_sum_anz,
" |
\n";
}
else if($table=='month')
{
echo "",$month," | ",$year," | ",$timestring,
" | ",$sent_sum_anz," | ",$received_sum_anz,
" |
\n";
}
$sent_sum=0;
$received_sum=0;
$time_sum=0;
//---------------------------------
}
else
{
echo "
";
}
echo "
";
mysql_close();
?>