PHP script for a AWstats based counter

This is a discussion on PHP script for a AWstats based counter within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I'm an italian guy and i'm a basic PHP coders. This is the counter: http://www.kensan.it/...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-22-2008
Sandro kensan
 
Posts: n/a
Default PHP script for a AWstats based counter

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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:01 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0