<?
###################################################################################
# TXcounter v4.0 #
# Written and Developed by: Aaron Bishell #
# Homepage: http://binary.gamer.net.nz #
# Copyright (C) 2002 Aaron Bishell - Please see readme.txt for more information #
###################################################################################
$sTime=time()+microtime();
?>
<html>
<head>
<title>TXcounter v4.0 (Trial Version) >> Output</title>
<style>
BODY
{
COLOR: #000000;
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 9pt
}
TR
{
COLOR: #000000;
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 9pt
}
TD
{
COLOR: #000000;
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 9pt
}
FONT
{
COLOR: #000000;
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 9pt
}
A:link
{
COLOR: #000000;
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 9pt;
}
A:visited
{
COLOR: #000000;
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 9pt;
}
</style>
</head>
<body>
<?
//Globals:
//Gets the relative path
$fp=fopen("cc_install.dat","r");
$relativePath=fread($fp,filesize("cc_install.dat"));
fclose($fp);
//Opens simplehits.dat
$fileNameWithPathSimple=$relativePath."simplehits.dat";
$fp=fopen($fileNameWithPathSimple,"r");
$simpleHitsContents=fread($fp,filesize($fileNameWithPathSimple));
fclose($fp);
//Opens hits.dat into an array
$fileNameWithPathFull=$relativePath."hits.dat";
$hitsContents=file($fileNameWithPathFull);
if(!(strcmp($type,"simple_total")==0) && !(strcmp($type,"simple_unique")==0))
{
$totalHits=explode("[total]",$simpleHitsContents);
if($totalHits[1]==0)
{
?> No hits have been recorded yet. <?
exit();
}
else
{
?>
<table cellspacing="0" cellpadding="10" border="0" width="100%" height="90%">
<tr valign="top">
<td width="30%">
<a href="<? $relativePath ?>tx_output.php">Main</a><br>
<a href="<? $relativePath ?>tx_output.php?type=th">Total Hits</a><br>
<a href="<? $relativePath ?>tx_output.php?type=uh">Unique Hits</a><br>
<a href="<? $relativePath ?>tx_output.php?type=ps">Page Statistics</a><br>
<a href="<? $relativePath ?>tx_output.php?type=gp">Graphical Progression</a><br>
<a href="<? $relativePath ?>tx_output.php?type=bos">Browser and OS Statistics</a>
</td>
<?
}
}
if(strcmp($type,"simple_total")==0)
{
$totalHits=explode("[total]",$simpleHitsContents);
echo($totalHits[1]);
exit();
}
if(strcmp($type,"simple_unique")==0)
{
$uniqueHits=explode("[unique]",$simpleHitsContents);
echo($uniqueHits[1]);
exit();
}
if(strcmp($type,"th")==0)
{
//Date info
$date=getdate();
$yday=$date['yday'];
$year=$date['year'];
$todaysTotalHits=0;
$yesterdaysTotalHits=0;
$readFirstLine=0;
$busiesthour[0]=0;
$thehour=0;
for($i=0;$i<count($hitsContents);$i++)
{
if(strlen($hitsContents[$i])>21) //Checks for the important part of the line to be there
{
$line=explode("|",$hitsContents[$i]);
$line[0] = str_replace("[~]","", $line[0]);
if($readFirstLine==0)
{
$firstLine=$line;
$readFirstLine=1;
}
//read the first complete line so i can determine the period and thus the averages
if($line[5]==$year && $line[2]==$yday) //If its this year and the yday is todays
{
$todaysTotalHits=$todaysTotalHits+1;
}
if(($line[2]==($yday-1)) && ($line[5]==$year)) //If its this year and the yday is yesterdays
{
$yesterdaysTotalHits=$yesterdaysTotalHits+1;
}
if(($line[5]==$year-1) && ($line[2]==364) && ($yday==0)) //If yesterday was last year
{
$yesterdaysTotalHits=$yesterdaysTotalHits+1;
}
}
}
$totalHits=explode("[total]",$simpleHitsContents);
//Calculates the period
$yearsBehind=$year-$firstLine[5];
$period=($yday+((365*$yearsBehind)-$firstLine[2]))+1;
$averageHitsPerDay=round(($totalHits[1]/$period),1);
?>
<td width="70%">
<table border="1" bordercolor="black" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td width="50%"><center>Todays</center></td>
<td width="50%"><center><? echo($todaysTotalHits); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Yesterdays</center></td>
<td width="50%"><center><? echo($yesterdaysTotalHits); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Overall</center></td>
<td width="50%"><center><? echo($totalHits[1]); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Average Per Day</center></td>
<td width="50%"><center><? echo($averageHitsPerDay); ?></center></td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
if(strcmp($type,"uh")==0)
{
//Date info
$date=getdate();
$yday=$date['yday'];
$year=$date['year'];
$todaysUniqueHits=0;
$yesterdaysUniqueHits=0;
$readFirstLine=0;
$busiesthour[0]=0;
$thehour=0;
for($i=0;$i<count($hitsContents);$i++)
{
if(strlen($hitsContents[$i])>21) //Checks for the important part of the line to be there
{
$line=explode("|",$hitsContents[$i]);
$line[0] = str_replace("[~]","", $line[0]);
if($readFirstLine==0)
{
$firstLine=$line;
$readFirstLine=1;
}
//read the first complete line so i can determine the period and thus the averages
if($line[5]==$year && $line[2]==$yday && $line[6]=="1") //If its this year and the yday is todays
{
$todaysUniqueHits=$todaysUniqueHits+1;
}
if(($line[2]==($yday-1)) && ($line[5]==$year) && $line[6]=="1") //If its this year and the yday is yesterdays
{
$yesterdaysUniqueHits=$yesterdaysUniqueHits+1;
}
if(($line[5]==$year-1) && ($line[2]==364) && ($yday==0) && $line[6]=="1") //If yesterday was last year
{
$yesterdaysUniqueHits=$yesterdaysUniqueHits+1;
}
}
}
$uniqueHits=explode("[unique]",$simpleHitsContents);
//Calculates the period
$yearsBehind=$year-$firstLine[5];
$period=($yday+((365*$yearsBehind)-$firstLine[2]))+1;
$averageHitsPerDay=round(($uniqueHits[1]/$period),1);
?>
<td width="70%">
<table border="1" bordercolor="black" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td width="50%"><center>Todays</center></td>
<td width="50%"><center><? echo($todaysUniqueHits); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Yesterdays</center></td>
<td width="50%"><center><? echo($yesterdaysUniqueHits); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Overall</center></td>
<td width="50%"><center><? echo($uniqueHits[1]); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Average Per Day</center></td>
<td width="50%"><center><? echo($averageHitsPerDay); ?></center></td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
if(strcmp($type,"ps")==0)
{
$pageName[0]="";
$pageNumber[0]=0;
$pagePercent[0]=0;
$incremented=0;
$z=0; //The number of unique pages
for($i=0;$i<count($hitsContents);$i++)
{
if(strlen($hitsContents[$i])>21) //Checks for the important part of the line to be there
{
$line=explode("|",$hitsContents[$i]);
for($p=0;$p<=$z;$p++)
{
if(strcmp("$pageName[$p]","$line[7]")==0)
{
$pageNumber[$p]=$pageNumber[$p]+1;
$incremented=1;
}
}
if($incremented==0) //If that page doesnt not exist in the pageName[] array
{
$pageName[$z+1]=$line[7];
$z=$z+1;
}
}
$incremented=0;
}
?>
<td width="70%">
Statistics for counters contained within the following directories:
<table border="1" bordercolor="black" cellspacing="0" cellpadding="2" width="100%">
<?
$u=0;
while($u<=$z)
{
if(!strcmp($pageName[$u],"")==0) //If the pageName is not nothing
{
$pageNumber[$u]=$pageNumber[$u]+1; //Fixes a bug
echo("
<tr>
<td><center>$pageName[$u]</center></td>
<td><center>$pageNumber[$u] hit(s)</center></td>
</tr>
");
}
$u=$u+1;
}
?>
</table>
<br>
Note: Some browsers dont support the method used to obtain these url's and as such
will not appear as a hit in the above table.
</td>
</tr>
</table>
<br>
<?
}
if(strcmp($type,"gp")==0)
{
//Date info
$date=getdate();
$yday=$date['yday'];
$year=$date['year'];
$progressionTotal[0]=0;
$progressionUnique[0]=0;
for($i=0;$i<count($hitsContents);$i++)
{
if(strlen($hitsContents[$i])>21) //Checks for the important part of the line to be there
{
$line=explode("|",$hitsContents[$i]);
//If it is over 40 days into this current year and the hit is this year
if($yday>39 && $line[5]==$year)
{
if($line[6]==1)
{
$progressionUnique[($yday-$line[2])]=$progressionUnique[($yday-$line[2])]+1;
}
$progressionTotal[($yday-$line[2])]=$progressionTotal[($yday-$line[2])]+1;
}
//If going 40 days back crosses over into last year
else
{
//NB: This block is untested
$yearsBehind=$year-$line[5];
$toSubtract=($yearsBehind*364)-$line[2]+$yday;
if($line[6]==1)
{
$progressionUnique[($yday-$toSubtract)]=$progressionUnique[($yday-$toSubtract)]+1;
}
$progressionTotal[($yday-$toSubtract)]=$progressionTotal[($yday-$toSubtract)]+1;
}
}
}
//Finds the heighest day
$heighestDay=0;
for($i=0;$i<40;$i++)
{
if($progressionTotal[$i]>$heighestDay)
{
$heighestDay=$progressionTotal[$i];
}
}
?>
<td width="70%">
Relative summary of the last 40 days:
<table border="0" bordercolor="black" cellspacing="0" cellpadding="1" width="100%" height="250">
<tr valign="bottom">
<?
for($i=39;$i>=0;$i--)
{
if($heighestDay==0)
{
$heightUnique=0;
$heightTotal=0;
}
else
{
$heightUnique=round((($progressionUnique[$i]/$heighestDay)*100),0);
$heightTotal=round((($progressionTotal[$i]/$heighestDay)*100),0)-$heightUnique;
}
?>
<td width="2%">
<div align="left">
<img src="bar-vertical-blue.gif" width="5" height="
<?
echo($heightTotal);
?>
%" align="bottom">
<img src="bar-vertical.gif" width="5" height="
<?
echo($heightUnique);
?>
%" align="bottom">
</div>
</td>
<?
}
?>
</tr>
</table>
<div align="right">Today</div>
<br>
The largest day in the graph is: <? echo($heighestDay); ?> total hits.
<br><br>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td>
<div align="left">
<img src="bar-blue.gif" height="10" width="40"><img src="barclose-blue.gif" height="10">
>> Total Hits
</div>
</td>
</tr>
<tr>
<td>
<div align="left">
<img src="bar.gif" height="10" width="40"><img src="barclose.gif" height="10">
>> Unique Hits
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
if(strcmp($type,"bos")==0)
{
$browser[0]=0; //IE
$browser[1]=0; //Opera
$browser[2]=0; //Mozilla
$browser[3]=0; //Other
$os[0]=0; //Windows
$os[1]=0; //Mac
$os[2]=0; //Linux
$os[3]=0; //Unix
$os[4]=0; //Other
for($i=0;$i<count($hitsContents);$i++)
{
if(strlen($hitsContents[$i])>21) //Checks for the important part of the line to be there
{
$line=explode("|",$hitsContents[$i]);
$line[10]=substr("$line[10]", 0, -4); //Trims "[~]\n"
if(strcmp($line[8],"Internet Explorer")==0)
{
$browser[0]=$browser[0]+1;
}
if(strcmp($line[8],"Opera")==0)
{
$browser[1]=$browser[1]+1;
}
if(strcmp($line[8],"Mozilla")==0)
{
$browser[2]=$browser[2]+1;
}
if(strcmp($line[8],"Other")==0)
{
$browser[3]=$browser[3]+1;
}
if(strcmp($line[10],"Windows")==0)
{
$os[0]=$os[0]+1;
}
if(strcmp($line[10],"Mac")==0)
{
$os[1]=$os[1]+1;
}
if(strcmp($line[10],"Linux")==0)
{
$os[2]=$os[2]+1;
}
if(strcmp($line[10],"Unix")==0)
{
$os[3]=$os[3]+1;
}
if(strcmp($line[10],"Other")==0)
{
$os[4]=$os[4]+1;
}
}
}
//Process the totals into percentages
$total=$browser[0]+$browser[1]+$browser[2]+$browser[3];
if($total==0)
{
$percentIE=0;
$percentOpera=0;
$percentMoz=0;
$percentOther=0;
}
else
{
$percentIE=round((($browser[0]/$total)*100),0);
$percentOpera=round((($browser[1]/$total)*100),0);
$percentMoz=round((($browser[2]/$total)*100),0);
$percentOther=round((($browser[3]/$total)*100),0);
}
$totalOS=$os[0]+$os[1]+$os[2]+$os[3]+$os[4];
if($totalOS==0)
{
$percentWin=0;
$percentMac=0;
$percentLin=0;
$percentUnix=0;
$percentOtherOS=0;
}
else
{
$percentWin=round((($os[0]/$totalOS)*100),0);
$percentMac=round((($os[1]/$totalOS)*100),0);
$percentLin=round((($os[2]/$totalOS)*100),0);
$percentUnix=round((($os[3]/$totalOS)*100),0);
$percentOtherOS=round((($os[4]/$totalOS)*100),0);
}
?>
<td width="70%">
Browser:
<table border="1" bordercolor="black" cellspacing="0" cellpadding="2" width="500">
<tr>
<td width="120"><center>Internet Explorer</center></td>
<td>
<div align="left"><img src="bar.gif" height="100%" width="
<?
if($percentIE>98)
{
echo("98");
}
else
{
echo($percentIE);
}
?>
%"><img src="barclose.gif" height="100%"></div>
</td>
<td width="40"><center><? echo("$percentIE%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Opera</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentOpera); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentOpera%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Mozilla</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentMoz); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentMoz%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Other</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentOther); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentOther%"); ?></center></td>
</tr>
</table>
<br>
Operating System:
<table border="1" bordercolor="black" cellspacing="0" cellpadding="2" width="500">
<tr>
<td width="120"><center>Windows</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="
<?
if($percentWin>98)
{
echo("98");
}
else
{
echo($percentWin);
}
?>
%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentWin%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Macintosh</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentMac); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentMac%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Linux</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentLin); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentLin%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Unix</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentUnix); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentUnix%"); ?></center></td>
</tr>
<tr>
<td width="120"><center>Other</center></td>
<td><div align="left"><img src="bar.gif" height="100%" width="<? echo($percentOtherOS); ?>%"><img src="barclose.gif" height="100%"></div></td>
<td width="40"><center><? echo("$percentOtherOS%"); ?></center></td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
//The main output
if(strcmp($type,"")==0)
{
$date=getdate();
$year=$date['year'];
$yday=$date['yday'];
$readFirstLine=0;
//Reads the first line complete with the important data in it into the variable $firstLine
for($i=0;$i<count($hitsContents);$i++)
{
if(strlen($hitsContents[$i])>21) //Checks for the important part of the line to be there
{
$line=explode("|",$hitsContents[$i]);
$line[0] = str_replace("[~]","", $line[0]);
if($readFirstLine==0)
{
$firstLine=$line;
$readFirstLine=1;
}
//Busiest Hour
if($line[0]!="10" && $line[0]!="20" && $line[0]!="00")
{
$thehour=$line[0];
$thehour = str_replace("0","", $thehour);
}
if($line[0]=="00")
{
$thehour=$line[0];
$thehour = str_replace("00","24", $thehour);
}
if($busiesthour[$thehour]=="")
{
$busiesthour[$thehour]==1;
}
else
{
$busiesthour[$thehour]=$busiesthour[$thehour]+1;
}
$busiesthour[$thehour]=$busiesthour[$thehour]+1;
//Busiest Hour END
}
}
//Gets the date of the first hit
$startDate=$firstLine[3]." / ".$firstLine[4]." / ".$firstLine[5];
//Gets todays date
$date=getdate();
$todaysDate=$date['mday']." / ".$date['mon']." / ".$year;
//Calculates the period
$yearsBehind=$year-$firstLine[5];
$period=($yday+((365*$yearsBehind)-$firstLine[2]))+1;
//Processors the busiest hour array
$l=1;
$mostbusyhour=1;
while($l<=24)
{
if($busiesthour[$mostbusyhour]<$busiesthour[$l])
{
$mostbusyhour=$l;
}
$l=$l+1;
}
if($mostbusyhour=="24")
{
$mostbusyhour2="00.59";
$mostbusyhour="00.00";
}
else
{
$mostbusyhour2=$mostbusyhour.".59";
$mostbusyhour=$mostbusyhour.".00";
}
?>
<td width="70%">
<table border="1" bordercolor="black" cellspacing="0" cellpadding="2" width="100%">
<tr>
<td width="50%"><center>Counting Since</center></td>
<td width="50%"><center><? echo("$startDate"); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Current Report</center></td>
<td width="50%"><center><? echo("$todaysDate"); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Period</center></td>
<td width="50%"><center><? echo("$period day(s)"); ?></center></td>
</tr>
<tr>
<td width="50%"><center>Busiest Hour</center></td>
<td width="50%"><center><? echo("$mostbusyhour - $mostbusyhour2"); ?></center></td>
</tr>
</table>
</td>
</tr>
</table>
<?
}
?>
</body>
</html>
<? $eTime=round(((time()+microtime())-$sTime),6); echo($eTime); echo("s"); ?>