For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2008 > PHP script for a AWstats based counter









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PHP script for a AWstats based counter
Sandro kensan

2008-03-22, 7:01 pm

I'm an italian guy and i'm a basic PHP coders.

This is the counter:

http://www.kensan.it/extra/stats/stats.phps
store it in
public_html/extra/stats/stats.php

put in your cron:
wget --output-document=public_html/extra/stats/cron.html
http://www.kensan.it/extra/stats/stats.php

that start stats.php every day and make a file impression.txt in
public_html/extra/stats/

impression.txt is used for the counter.

Use this php code in your article page for displaying the total
readers of the article.

<?php
//Numero di letture di questo articolo tratte da awstats
$stats_dir = "/home/kensan/public_html/extra/stats";
$file_impressions = "impressions.txt";

$filename= $stats_dir . "/" . $file_impressions;
if (is_readable($filename)) {
$vet_art_impression = file($filename);
$nome_this = basename($_SERVER['PHP_SELF'], ".php");
$impressions=0;

foreach($vet_art_impression as $val){
$vet = explode(" ",$val);
if($vet[0] == $nome_this){
$impressions=$vet[1];

}

}
if ($impressions != 0){
echo "readers: <b>$impressions<b>" ;
}
}
?>
sorry for my english.
change kensan with your site.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com