Real Time Site Analytics

Hi friends,
Lots of you asked about how to make real time site analytics,
Sorry I have no idea about that on ASP.Net but can help you with PHP !

The code for you !

Get page hits and store it into a text file, you can then show or hide analytics

// Reading file if exist
// Delet file to reset counter
$cpt = 1;
if(file_exists($file)) {
$inF = fopen($file,"r");
$cpt = intval(trim(fgets($inF, 4096))) + 1;
// Saving hits
$inF = fopen($file,"w");

Add this to show hits on your site

And online visitors ?

Place it wherever you like !

$Fnm = "online.txt";

$date0 = time()/60;
$vie = 5;

if (file_exists($Fnm)) {
$inF = fopen($Fnm,"r");
while (!feof($inF)) {
$ligne=fgets($inF, 4096);
$temp = explode("",$ligne);
if($temp[0]!=$IP) {
if($date0-intVal($temp[1])<=$vie) { $online++; $result .= $ligne . "\n"; } } } fclose($inF); } $result .= $IP . "" . $date0 . "\n"; $online++; // Et on sauve $inF = fopen($Fnm,"w"); fputs($inF,$result); fclose($inF); ?>

and then and online visitors will be showen on your sites !

Hope this interests lot of you game coders ;)

I forget that lots of you are lazy so I'll suggest this site (also if your server doesn't support PHP) :
I use both PHP and feedjit on
Hope you like it.
If you need pro and high startics why not try Google !


Post a Comment