Amazing FlatFile Statistics
Awsum stats script, easy to use, displays Total Hits, Unique Hits, Todays Hits, & Todays Unique Hits!
Now first create a blank text file called stats.txt
Now upload stats.txt and chmod it to 777 so it can record the hits.
CODE
<?php
// iHits - Created by Braunson
// Copyright 2007 ? TotalDream
// You Rip & You Will Pay!
// todays stats;
$counter = "stats.txt";
// Date logging;
$today = getdate();
$month = $today[month];
$mday = $today[mday];
$year = $today[year];
$current_date = $mday . $month . $year;
// Log visit;
$fp = fopen($counter, "a");
$line = $REMOTE_ADDR . "|" . $mday . $month . $year . "n";
$size = strlen($line);
fputs($fp, $line, $size);
fclose($fp);
// Read log file into array;
$contents = file($counter);
// Total hits;
$total_hits = sizeof($contents);
// Total hosts;
$total_hosts = array();
for ($i=0;$i<sizeof($contents);$i++) {
$entry = explode("|", $contents[$i]);
array_push($total_hosts, $entry[0]);
}
$total_hosts_size = sizeof(array_unique($total_hosts));
// Daily hits;
$daily_hits = array();
for ($i=0;$i<sizeof($contents);$i++) {
$entry = explode("|", $contents[$i]);
if ($current_date == chop($entry[1])) {
array_push($daily_hits, $entry[0]);
}
}
$daily_hits_size = sizeof($daily_hits);
// Daily hosts;
$daily_hosts = array();
for ($i=0;$i<sizeof($contents);$i++) {
$entry = explode("|", $contents[$i]);
if ($current_date == chop($entry[1])) {
array_push($daily_hosts, $entry[0]);
}
}
$daily_hosts_size = sizeof(array_unique($daily_hosts));
?>
<? echo "
<b>Total Hits:</b> " . $total_hits . "<br>
<b>Unique Hits:</b> " . $total_hosts_size . "<br>
<b>Todays Hits:</b> " . $daily_hits_size . "<br>
<b>Todays Unique Hits:</b> " . $daily_hosts_size;
// iHits - Created by Braunson
// Copyright 2006 ? Total Dream
// You Rip & You Will Pay!
?>
Copy that whole code in ihits (below) to your site somewhere, or you can include it with php include.
Feel free to download the full zipped copy located in our downloads section under web applications
Sunday May 27, 2007 | http://www.totaldream.org/article/25-amazing_flatfile_statistics.html