Hi guys,
I've been searching around, and I found quite of PHP scripts out there. I'm still searching the finest one to my purpouse though.
The following script will count page views, and output the results in the template, as seen here (not tested).
<?php
/**
* Create an empty text file called counterlog.txt and
* upload to the same directory as the page you want to
* count hits for. [Note: in my current theme's folder?]
*
* Add this line of code on your page: [Note: anywhere in a template?]
* <?php include "text_file_hit_counter.php"; ?>
*/
// Open the file for reading
$fp = fopen("counterlog.txt", "r");
// Get the existing count
$count = fread($fp, 1024);
// Close the file
fclose($fp);
// Add 1 to the existing count
$count = $count + 1;
// Display the number of hits
// If you don't want to display it, comment out this line
echo "Page views:" . $count . "
";
// Reopen the file and erase the contents
$fp = fopen("counterlog.txt", "w");
// Write the new count to the file
fwrite($fp, $count);
// Close the file
fclose($fp);
?>
Thanks if someone have some extra idea about that (unique hits in a link ?).