<?PHP
global $REMOTE_HOST,$REMOTE_ADDR;
$border=0;
include "zorbconf.php";
include "zorblib.php";
include("zorblang$lang.php");
mysql_connect($dbhost,$dbuname,$dbpass);
$tab=mysql_list_tables($dbname);
$ret=mysql_query("select count(*) from zhost");
$row = mysql_fetch_array($ret);
$cpt=($row["count(*)"]+2)*18;
$today=getdate();
$day+=0;$month+=0;$year+=0;
if ($day==0) $day=$today["mday"];
if ($month==0) $month=$today["mon"];
if ($year==0) $year=$today["year"];
If(empty($graphip)) $graphip="sum";
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'DTD/xhtml1-transitional.dtd'>";
echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n";
echo "<head>\n";
echo" <title>ZorbIPtraffic 0.10</title>";
echo " <meta http-equiv='Content-Type' content='text/html; charset=utf-8'></meta>";
echo "</head>\n";
echo"<body bgcolor='#E6E3F4'>";
echo "<center><a href='http://www.atout.be'><img src='images/zorbsta.gif' alt='ZorbIPtraffic (http://www.atout.be)'/></a>";
echo "<table width='800'>";
echo " <tr>";
echo " <td align='center'>";
if ($applet=="true")
{
#$ip = $_SERVER["REMOTE_ADDR"];
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
echo "
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'
width='500' height='".(21+($nbhost*18)+round($nbhost*0.57)+16)."' id='zorbiptraffic' >
<embed src='zorbiptraffic.swf' width='400' height='".(21+($nbhost*18)+round($nbhost*0.57)+16)."' id='zorbiptraffic'
quality='high' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></embed>
<param name='movie' value='zorbiptraffic.swf' />
<param name='quality' value='high' />
<param name='bgcolor' value='#FFFFFF' />
</object>";
}
echo " </td>";
echo " </tr>";
$get=$_GET;
$getkeys=array_keys($get);
$getcount=count($get) -1;
while($getcount>=0)
{
$key=$getkeys[$getcount];
$variable=$get[$key];
$$key=$variable;
$getcount=$getcount-1;
}
$ret=mysql_query("select ip,hostname from zhost order by ip");
if ($year==null) $centval=$today["year"]; else $centval=$year;
$leftval=$centval-1;
$rightval=$centval+1;
$year=$centval;
$leftday=$rightday=$day;
while (!checkdate($month,$leftday,$leftval)) $leftday--;;
while (!checkdate($month,$rightday,$rightval)) $rightday--;
echo " <tr>";
echo " <td>";
echo " <table border='0' width='100%'>";
echo " <tr>";
echo " <td width='35' align='center'><a href='zorbiptraffic.php?year=$leftval&month=$month&day=$leftday&graphip=$graphip'><img src='numgraph.php?num=$leftval' border='0' alt=''/></a></td>";
echo " <td align='center'><img src='zorbipyeargraph.php?ip=$graphip&year=$year' width='600' alt=''/></td>";
if ($rightval>$today["year"])
echo " <td width='35' align='center'><img src='numgraph.php?num=$rightval' alt=''/></td>";
else
echo " <td width='35' align='center'><a href='zorbiptraffic.php?year=$rightval&month=$month&day=$rightday&graphip=$graphip'><img src='numgraph.php?num=$rightval' border='0' alt=''/></a></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
if ($month==null) $centval=$today["mon"]; else $centval=$month;
$leftval=$centval - 1;
$rightval=$centval + 1;
$rightyear=$leftyear=$year;
if ($rightval==13) { $rightval=1; $rightyear++; }
if ($leftval==0) { $leftval=12; $leftyear--; }
$leftday=$rightday=$day;
while (!checkdate($leftval,$leftday,$leftyear)) $leftday--;
while (!checkdate($rightval,$rightday,$rightyear)) $rightday--;
$month=$centval;
if (($month<10)&& (substr($month,0,1)!=0)) $month="0".$month;
echo " <tr>";
echo " <td align='center'>";
echo " <table border='0' width='100%'>";
echo " <tr>";
echo " <td width='35' align='center'><a href='zorbiptraffic.php?year=$leftyear&month=$leftval&day=$leftday&graphip=$graphip'><img src='monthgraph.php?num=$leftval' border='0' alt=''/></a></td>";
echo " <td align='center'><img src='zorbipmonthgraph.php?ip=$graphip&year=$year&month=$month' width='600' alt=''/></td>";
echo " <td width='35' align='center'><a href='zorbiptraffic.php?year=$rightyear&month=$rightval&day=$rightday&graphip=$graphip'><img src='monthgraph.php?num=$rightval' border='0' alt=''/></a></td>";echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
if ($day==null) $centval=$today["mday"]; else $centval=$day;
$leftval=$centval - 1;
$rightval=$centval + 1;
$day=$centval;
$leftmonth=$rightmonth=$month;
$leftyear=$rightyear=$year;
if (($rightval>28) and !checkdate($rightmonth,$rightval,$rightyear)) {$rightval=1;$rightmonth++;
if ($rightmonth==13) {$rightmonth=1;$rightyear++;}}
if ($leftval==0) {$leftval=31; $leftmonth--; if ($leftmonth==0) {$leftmonth=12;$leftyear--;}}
if (($day<10)&& (substr($day,0,1)!=0)) $day="0".$day;
echo " <tr>";
echo " <td align='center'>";
echo " <table border='0' width='100%'>";
echo " <tr>";
echo " <td width='35' align='center'><a href='zorbiptraffic.php?year=$leftyear&month=$leftmonth&day=$leftval&graphip=$graphip'><img src='numgraph.php?num=$leftval' border='0' alt=''/></a></td>";
echo " <td align='center'><img src='zorbipdaygraph.php?ip=$graphip&year=$year&month=$month&day=$day' width='600' alt=''/></td>";
echo " <td width='35' align='center'><a href='zorbiptraffic.php?year=$rightyear&month=$rightmonth&day=$rightval&graphip=$graphip'><img src='numgraph.php?num=$rightval' border='0' alt=''/></a></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td align='center'>";
echo " <table width='80%' border='0' cellspacing='1' cellpadding='0' bgcolor='#101070'>";
echo " <tr>";
echo " <td>";
echo " <table width='100%' border='0' cellspacing='1' cellpadding='1' bgcolor='#FFFFFF'>";
echo " <tr>";
echo " <td width='250'><u><b>".zorbtrans("Hostname")."</b></u></td><td align='center'><u><b>".zorbtrans("Today")."</b></u></td>";
echo " <td align='center'><u><b>".zorbtrans("This Month")."</b></u></td><td align='center'><u><b>".zorbtrans("This Year")."</b></u></td>";
echo " </tr>";
echo " <tr>";
echo " <td></td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
echo " <td width='50%' align='center'><font size='1'><u><b>".zorbtrans("Download")."</b></u></font></td>";
echo " <td align='center'><font size='1'><u><b>".zorbtrans("Upload")."</b></u></font></td></tr></table></td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
echo " <td width='50%' align='center'><font size='1'><u><b>".zorbtrans("Download")."</b></u></font></td>";
echo " <td align='center'><font size='1'><u><b>".zorbtrans("Upload")."</b></u></font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
echo " <td width='50%' align='center'><font size='1'><u><b>".zorbtrans("Download")."</b></u></font></td>";
echo " <td align='center'><font size='1'><u><b>".zorbtrans("Upload")."</b></u></font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
while ($row = mysql_fetch_array($ret))
{
$ip=$row["ip"];
echo " <tr>";
echo " <td><a href='zorbiptraffic.php?year=$year&month=$month&day=$day&graphip=$ip'>".$row["hostname"]." <font size='1'>(".$row["ip"].")</font></a></td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
$ret2=mysql_query("select totin totin,totout totout from zdays where ip='$ip' and dayid=date_format(now(),'%Y%m%d')");
$row2 = mysql_fetch_array($ret2);
echo " <td width='50%' align='center'><font size='1' color='#0000FF'>".fncScale($row2["totin"],0,0) ."</font></td>";
echo " <td width='50%' align='center'><font size='1' color='#FF0000'>".fncScale($row2["totout"],0,0) ."</font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
$ret2=mysql_query("select totin totin,totout totout from zmonth where ip='$ip' and monthid=date_format(now(),'%Y%m')");
$row2 = mysql_fetch_array($ret2);
echo " <td width='50%' align='center'><font size='1' color='#0000FF'>".fncScale($row2["totin"],0,0) ."</font></td>";
echo " <td width='50%' align='center'><font size='1' color='#FF0000'>".fncScale($row2["totout"],0,0) ."</font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
$ret2=mysql_query("select sum(totin) totin,sum(totout) totout from zmonth where ip='$ip' and monthid like '$today[year]%'");
$row2 = mysql_fetch_array($ret2);
echo " <td width='50%' align='center'><font size='1' color ='#0000FF'>".fncScale($row2["totin"],0,0) ."</font></td>";
echo " <td width='50%' align='center'><font size='1' color ='#FF0000'>".fncScale($row2["totout"],0,0) ."</font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
}
echo " <tr>";
echo " <td height='10'></td>";
echo " </tr>";
echo " <tr>";
echo " <td><a href='zorbiptraffic.php?year=$year&month=$month&day=$day&graphip=sum'>".zorbtrans("Total")."</a></td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
$ret2=mysql_query("select sum(totin) totin,sum(totout) totout from zdays where dayid=date_format(now(),'%Y%m%d')");
$row2 = mysql_fetch_array($ret2);
echo " <td width='50%' align='center'><font size='2'>".fncScale($row2["totin"],1,0) ."</font></td>";
echo " <td width='50%' align='center'><font size='2'>".fncScale($row2["totout"],1,0) ."</font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
$ret2=mysql_query("select sum(totin) totin,sum(totout) totout from zmonth where monthid=date_format(now(),'%Y%m')");
$row2 = mysql_fetch_array($ret2);
echo " <td width='50%' align='center'><font size='2'>".fncScale($row2["totin"],1,0) ."</font></td>";
echo " <td width='50%' align='center'><font size='2'>".fncScale($row2["totout"],1,0) ."</font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " <td>";
echo " <table width='100%'>";
echo " <tr>";
$ret2=mysql_query("select sum(totin) totin,sum(totout) totout from zmonth where monthid like '$today[year]%'");
$row2 = mysql_fetch_array($ret2);
echo " <td width='50%' align='center'><font size='2'>".fncScale($row2["totin"],1,0) ."</font></td>";
echo " <td width='50%' align='center'><font size='2'>".fncScale($row2["totout"],1,0) ."</font></td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
echo " </table>";
echo " </td>";
echo " </tr>";
echo " </table>";
echo "</td></tr></table>";
echo "</center>";
echo "<center>ZorbIPtraffic 0.10 <a href='http://www.atout.be'>http://www.atout.be</a></center><br/>";
echo "<center><a href='http://www.atout.be'><img src='images/zorbsta.gif' alt='ZorbIPtraffic(http://atout.be)'/></a></center><br/>";
echo "</body>";
echo "</html>";
?>