<?php // styles.php -> Admin Panel options for Statistics.
require("access.php");
require("global.php");
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ @@
// @@ ++++++++++++++++++ @@
// @@ ++ InstaCounter ++ Version: 1.0 @@
// @@ ++++++++++++++++++ @@
// @@ @@
// @@ InstaCounter was developed by Christophe Johanns. Therefore @@
// @@ he owns the copyright to all files of this script. Feel free @@
// @@ to modify the code for PERSONAL use. @@
// @@ @@
// @@ Copyright © 2001 Christophe Johanns. All rights reserved. @@
// @@ @@
// @@ Support: http://www.freesources.net/instacounter.php @@
// @@ Comments: hide@address.com @@
// @@ @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ LEFT MENU @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if($public!="1") {
$otherfile="1";
$action2="firsthtml";
include("./admin.php");
}
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ LIST OPTIONS @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if ($action=="viewoptions") {
echo "<DIV align=\"center\"> <CENTER> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\"> <TR> <TD width=\"100%\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\"> <TR> <TD width=\"100%\" bgcolor=\"#006D8A\"><FONT face=\"Verdana\" size=\"2\" color=\"#FFFFFF\"> <B>Statistics</B></FONT></TD> </TR> <TR> <TD width=\"100%\" bgcolor=\"#CCCCCC\"> <P style=\"margin-left: 10; margin-right: 10\"><FONT size=\"2\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> » <A href=\"statistics.php?action=listcounters&start=0\">Individual counter statistics</A><BR> <IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> » <A href=\"statistics.php?action=globalstats\">Global statistics</A><BR> <IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> » <A href=\"statistics.php?action=topten\">Top 10</A><BR> <IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></TD> </TR> </TABLE> </DIV> </TD> </TR> </TABLE> </CENTER> </DIV>";
}
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ LIST COUNTERS FOR STATS @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if ($action=="listcounters") {
if (!$db) { print "There was an error connecting to the database."; } else {
// Get Prev/Next links.
$limit="10";
$query=mysql_query("SELECT * FROM InstaCounter_Counter");
$numrows = mysql_num_rows($query);
$pages=intval($numrows/$limit);
if ($numrows%$limit) { $pages++; }
$first_record=$start+"1";
if (!((($start)/$limit)+1==$pages)) { $last_record = $start + $limit; } else { $last_record = $numrows; }
if ($start != 0) { $prevoffset=$start-$limit; $prevlink="« <a href=\"statistics.php?start=$prevoffset&action=listcounters\">Prev</a> \n"; }
if ($pages != 1 ) { for ($i=1;$i<=$pages;$i++) { $newoffset=$limit*($i-1); if ( ((($start)/$limit)==($i-1)) ) { $current="$i \n"; } else { $links="<a href=\"statistics.php?start=$newoffset&action=listcounters\">$i</a> \n"; } } } if (!((($start)/$limit)+1==$pages) && $pages!=1) { $newoffset=$start+$limit; $nextlink="<a href=\"statistics.php?start=$newoffset&action=listcounters\">Next</a> »"; }
$q=mysql_query("SELECT * FROM InstaCounter_Counter ORDER BY cid ASC LIMIT $start,$limit");
while ($latest_array = mysql_fetch_array($q)) {
// Get Counter.
$totalhits=""; $count=""; $number="";
$query = mysql_query("SELECT * FROM InstaCounter_Styles WHERE cid='$latest_array[Style]'"); $handle = mysql_fetch_array($query);
$number=$latest_array[Hits]; $count="0";
while($count<strlen($latest_array[Hits])) { $hitschar=substr($latest_array[Hits], $count, 1); $stylechar="n" . $hitschar; $totalhits=$totalhits.$handle[$stylechar]; $count=$count+"1"; }
// Build HTML
$htmlcode = $htmlcode . "<TR> <TD width=\"100%\" bgcolor=\"#000000\"><B><FONT face=\"Verdana\" size=\"1\" color=\"#FFFFFF\"> " . $latest_array[Name] . "</FONT></B></TD> </TR> <TR> <TD width=\"100%\" bgcolor=\"#CCCCCC\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <TR> <TD width=\"50%\"> <P style=\"margin-left: 10; margin-right: 10\"><FONT face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR>" . $totalhits . "<BR> <IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></TD> <TD width=\"50%\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\"> <TR> <TD width=\"100%\"><FONT face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></TD> </TR> <TR> <TD width=\"100%\" bgcolor=\"#EAEAEA\"> <P align=\"center\"><FONT face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT><FONT face=\"Verdana\" size=\"2\"><BR> » <A href=\"statistics.php?action=counterstats&id=" . $latest_array[cid] . "\">View statistics</A> «<BR> </FONT><FONT face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></TD> </TR> <TR> <TD width=\"100%\"><FONT face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></TD> </TR> </TABLE> </DIV> </TD> </TR> </TABLE> </DIV> </TD> </TR> ";
}
if (isset($htmlcode)){
echo "<DIV align=\"center\"> <CENTER> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\"> <TR> <TD width=\"100%\" colspan=\"2\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\"> <TR> <TD width=\"100%\" bgcolor=\"#006D8A\"><FONT face=\"Verdana\" size=\"2\" color=\"#FFFFFF\"> <B>List of counters</B></FONT></TD></TR>$htmlcode</TABLE> </DIV> </TD> </TR><TR> <TD width=\"50%\" bgcolor=\"#CCCCCC\"><FONT face=\"Verdana\" size=\"1\" color=\"#000000\"><BR>Displaying counters $first_record to $last_record of a total of $numrows.</TD><TD width=\"50%\" bgcolor=\"#CCCCCC\" align=\"right\"><FONT face=\"Verdana\" size=\"2\" color=\"#000000\"><B>$prevlink $nextlink</B></TD></TR> </TABLE> </CENTER> </DIV>";
} else {
echo "<p align=\"left\" style=\"margin-left: 70; margin-right: 70\"><br><font face=verdana size=2 color=#006D8A>No counters to display!</font><br><br><br><br><br><br><br><br><br><br><br><br>";
}
}
}
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ LIST TOP 10 @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if ($action=="topten") {
if (!$db) { print "There was an error connecting to the database."; } else {
echo "<div align=\"center\"><center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\"><tr><td width=\"100%\" bgcolor=\"#FFFFFF\"><div align=\"center\"><center><table border=\"0\" cellspacing=\"1\" width=\"100%\"><tr><td width=\"100%\" bgcolor=\"#006D8A\"><b><font face=\"Verdana\" color=\"#FFFFFF\" size=\"2\"> Top 10</font></b></td></tr><tr><td width=\"100%\" bgcolor=\"#CCCCCC\"><table width=\"100%\" border=\"0\">";
$topten_query = "SELECT * FROM InstaCounter_Counter ORDER BY Hits DESC LIMIT 10"; $topten_handle = mysql_query($topten_query,$db);
while ($latest_array = mysql_fetch_array($topten_handle)) {
$currentplace = $currentplace + "1";
if($currentplace=="1"){ $htmlcode = $htmlcode . "<tr><td width=\"50%\"><font size=\"2\" face=\"Verdana\"><b>" . $currentplace . ". </font><font size=\"3\" face=\"Verdana\">" . $latest_array[Name] . "</b></font></td><td width=\"50%\"><font size=\"3\" face=\"Verdana\">" . $latest_array[Hits] . "</font></td></tr>"; }
if(($currentplace>="2") && ($currentplace<="10")){ $htmlcode = $htmlcode . "<tr><td width=\"50%\"><font size=\"2\" face=\"Verdana\"><b>" . $currentplace . ". " . $latest_array[Name] . "</b></font></td><td width=\"50%\"><font size=\"2\" face=\"Verdana\">" . $latest_array[Hits] . "</font></td></tr>"; }
}
echo "$htmlcode</table></td></tr></table></center></div></td></tr></table></center></div>";
}
}
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ GET COUNTER STATS @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if ($action=="counterstats") {
if (!$db) { print "There was an error connecting to the database."; } else {
$query = mysql_query("SELECT * FROM InstaCounter_Counter WHERE cid='$id'"); $handle = mysql_fetch_array($query);
$days=(date("d")-substr($handle[DateCreate], 8, 2)); $months=(date("m")-substr($handle[DateCreate], 5, 2)); $years=(date("Y")-substr($handle[DateCreate], 0, 4)); $days=($days+(($months/"12")*"365")+($year*"365")); if($days=="0") { $days="1"; }
$avgday=round(($handle[Hits]/$days) / 1); $avgyear=round((($handle[Hits]/$days)*"365") / 1); $avgmonth=round((($handle[Hits]/$days)*("365"/"12")) / 1); $avgweek=round((($handle[Hits]/$days)*("365"/"56")) / 1);
echo "<DIV align=\"center\"> <CENTER> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\"> <TR> <TD width=\"100%\" bgcolor=\"#FFFFFF\"> <DIV align=\"center\"> <CENTER> <TABLE border=\"0\" cellspacing=\"1\" width=\"100%\" cellpadding=\"0\"> <TR> <TD width=\"100%\" bgcolor=\"#006D8A\"><B><FONT face=\"Verdana\" color=\"#FFFFFF\" size=\"2\"> Statistics</FONT></B></TD> </TR> <TR> <TD width=\"100%\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><TR> <TD width=\"100%\" bgcolor=\"#000000\"><B><FONT size=\"1\" face=\"Verdana\" color=\"#FFFFFF\"> $handle[Name]</FONT></B></TD> </TR> </CENTER> <TR> <TD width=\"100%\" bgcolor=\"#FFFFFF\"><FONT size=\"1\"><IMG border=\"0\" src=\"pixel.gif\" width=\"1\" height=\"1\"></FONT></TD> </TR> <TR> <TD width=\"100%\" bgcolor=\"#CCCCCC\" valign=\"top\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> Current hits:<BR> <IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$handle[Hits]</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><FONT size=\"1\" face=\"Verdana\"> </FONT></TD> <TD width=\"66%\"></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT><FONT size=\"1\" face=\"Verdana\"><BR> Average hits/day:<BR> </FONT><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgday</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> </FONT></B><FONT size=\"1\" face=\"Verdana\"><B>Average hits/week:<BR> </B></FONT><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgweek</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> </FONT></B><FONT size=\"1\" face=\"Verdana\"><B>Average hits/month:<BR> </B></FONT><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgmonth</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> </FONT></B><FONT size=\"1\" face=\"Verdana\"><B>Average hits/year:<BR> </B></FONT><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgyear</FONT></TD> </TR> </TABLE> </DIV> </TD> </TR> </TABLE> </DIV> </TD> </TR> </CENTER> </TABLE> </DIV> </TD> </TR> </TABLE> </DIV>";
}
}
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ GLOBAL STATS @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if ($action=="globalstats") {
if (!$db) { print "There was an error connecting to the database."; } else {
$query = mysql_query("SELECT Hits,DateCreate FROM InstaCounter_Counter ORDER BY Hits"); $handle = mysql_fetch_array($query);
while ($latest_array = mysql_fetch_array($query)) {
$hits=$hits+$latest_array[Hits];
$days=(date("d")-substr($latest_array[DateCreate], 8, 2)); $months=(date("m")-substr($latest_array[DateCreate], 5, 2)); $years=(date("Y")-substr($latest_array[DateCreate], 0, 4)); $days=($days+(($months/"12")*"365")+($year*"365")); if($days=="0") { $days="1";
}
$avgday=$avgday + round(($latest_array[Hits]/$days) / 1); $avgmonth=$avgmonth + round((($latest_array[Hits]/$days)*("365"/"12")) / 1); $avgyear=$avgyear + round((($latest_array[Hits]/$days)*"365") / 1); $avgweek=$avgweek + round((($latest_array[Hits]/$days)*("365"/"56")) / 1); }
echo "<DIV align=\"center\"> <CENTER> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"80%\"> <TR> <TD width=\"100%\" bgcolor=\"#FFFFFF\"> <DIV align=\"center\"> <CENTER> <TABLE border=\"0\" cellspacing=\"1\" width=\"100%\" cellpadding=\"0\"> <TR> <TD width=\"100%\" bgcolor=\"#006D8A\"><B><FONT face=\"Verdana\" color=\"#FFFFFF\" size=\"2\"> Statistics</FONT></B></TD> </TR> <TR> <TD width=\"100%\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><TR> <TD width=\"100%\" bgcolor=\"#000000\"><B><FONT size=\"1\" face=\"Verdana\" color=\"#FFFFFF\"> Global Stats</FONT></B></TD> </TR> </CENTER> <TR> <TD width=\"100%\" bgcolor=\"#FFFFFF\"><FONT size=\"1\"><IMG border=\"0\" src=\"pixel.gif\" width=\"1\" height=\"1\"></FONT></TD> </TR> <TR> <TD width=\"100%\" bgcolor=\"#CCCCCC\" valign=\"top\"> <DIV align=\"center\"> <TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> Current hits:<BR> <IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$hits</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><FONT size=\"1\" face=\"Verdana\"> </FONT></TD> <TD width=\"66%\"></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT><FONT size=\"1\" face=\"Verdana\"><BR> Average hits/day:<BR> </FONT><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgday</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> </FONT></B><FONT size=\"1\" face=\"Verdana\"><B>Average hits/week:<BR> </B></FONT><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgweek</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> </FONT></B><FONT size=\"1\" face=\"Verdana\"><B>Average hits/month:<BR> </B></FONT><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgmonth</FONT></TD> </TR> <TR> <TD width=\"34%\"> <P style=\"margin-left: 10; margin-right: 10\"><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"><BR> </FONT></B><FONT size=\"1\" face=\"Verdana\"><B>Average hits/year:<BR> </B></FONT><B><FONT size=\"1\" face=\"Verdana\"><IMG border=\"0\" src=\"pixel.gif\" width=\"5\" height=\"5\"></FONT></B></TD> <TD width=\"66%\"><FONT size=\"1\" face=\"Verdana\">$avgyear</FONT></TD> </TR> </TABLE> </DIV> </TD> </TR> </TABLE> </DIV> </TD> </TR> </CENTER> </TABLE> </DIV> </TD> </TR> </TABLE> </DIV>";
}
}
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@ FOOTER @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if($public!="1") {
$otherfile="1";
$action2="lasthtml";
include("./admin.php");
}
?>