<?php
	$sPage="stats";
	require("admin/§lib_inc.php");

	$sTitle=decode_lng_text("STATS_TITLE");
	require("§menu.php");
?>
<P>
<table border="1" width="60%" bgcolor="#c1c1FF" bordercolor="#7777aa" cellpadding="1" cellspacing="0">
<TR bgcolor="red" align="center">
<TD><B><FONT COLOR=white><?php display_lng_text("STATS_MONTH") ?></FONT></B></TD>
<TD><B><FONT COLOR=white><?php display_lng_text("STATS_VISITOR") ?></FONT></B></TD>
<TD><B><FONT COLOR=white><?php display_lng_text("STATS_PAGE") ?></FONT></B></FONT></TD>
<TD><B><FONT COLOR=white><?php display_lng_text("STATS_HITS") ?></FONT></B></FONT></TD>
</TR>
<?php
	$total_visites=0;
	$total_pages=0;
	$total_hits=0;

	$indice_mois=floor(date("m"));
	$indice_annee=date("Y");

	$result = mysql_query( "select heure from oxg_visites order by heure desc") or mysql_die();
	if($row = mysql_fetch_array($result))
	{
		$indice_mois=date("m", $row["heure"]);
		$indice_mois+=0;
		$indice_annee=date("Y", $row["heure"]);
	}

	for(;;)
	{
		$debut_mois=mktime(0,0,0,$indice_mois,1,$indice_annee);
		if($indice_mois==12)
		{
			$debut_mois_suivant=mktime(0,0,0,1,1,$indice_annee+1);
		}
		else
		{
			$debut_mois_suivant=mktime(0,0,0,$indice_mois+1,1,$indice_annee);
		}

		$result = mysql_query( "select count(distinct IP,NAVIGATEUR, FLOOR(HEURE/3600)) as SOMME1, count(distinct IP,NAVIGATEUR,FLOOR(HEURE/3600),PAGE) as SOMME2, count(*) as SOMME3 from OXG_VISITES WHERE HEURE>$debut_mois AND HEURE<$debut_mois_suivant") or mysql_die();
		$iCptMois=0;
		$row = mysql_fetch_array($result);

		if($row['SOMME1']==0)
		{
			break;
		}

		echo "<tr><td align=\"center\">";
//		affiche_lien("stat_month", "$indice_mois/$indice_annee", "?indice_mois=$indice_mois&indice_annee=$indice_annee");
		echo "<A HREF='§stat_month.php?indice_mois=$indice_mois&indice_annee=$indice_annee'>$$indice_mois/$indice_annee</A>";
		echo "</td><td align=\"right\">";
		echo $row['SOMME1'];
		echo "</td><td align=\"right\">";
		echo $row['SOMME2'];
		echo "</td><td align=\"right\">";
		echo $row['SOMME3'];
		echo "</td>";
		echo "</tr>";
		
		$total_visites+=$row['SOMME1'];
		$total_pages+=$row['SOMME2'];
		$total_hits+=$row['SOMME3'];

		$indice_mois--;
		if($indice_mois==0)
		{
			$indice_annee--;
			$indice_mois=12;
		}
	}
	echo "<tr bgcolor=\"#AAAAAA\"><td align=\"center\"><b>");
	display_lng_text("STATS_TOTAL");
	echo "</td>");
	echo "<td align=right><b>$total_visites</b></td>";
	echo "<td align=right><b>$total_pages</b></td>";
	echo "<td align=right><b>$total_hits</b></td>";
	echo "<td align=right><b>$total_email</b></td>";
	echo "<td align=right><b>$total_download</b></td>";
	echo "<td align=right><b>$total_version</b></td>";
?>
</TR>
</TABLE>
<?php
	affiche_pied_page(false);
?>