What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Using Awstats to make a hitcounter

Pages: (2): « First « 1 [ 2 ] Last »
Using Awstats to make a hitcounter
Author: Message:
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
20 / Other / Flag
Joined: Jul 2003
RE: Using Awstats to make a hitcounter
this works pefectly fine for me, and can go over 1000 :P

code:
<?PHP
    $file="hitscount.dat";
    $handle=fopen($file, "r+");
    $hits=fread($handle,filesize("$file"));
    $hits+=1;
    fclose($handle);
    $handle=fopen($file, "w");
    fwrite($handle, $hits);
    fclose($handle);
?>

just change hitcounter.dat to some filename and then run the page, the dat file should be created automaticly. but you will get a error on first run.
05-23-2005 08:52 AM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Using Awstats to make a hitcounter
quote:
Originally posted by traxor
Does anybody know how I can use Awstats to make a hit counter, I want it a text hit counter on my site, showing the "Hits" that I have received.

Not unique :).
=/ why are you all making normal file based ones insted of ones that fetch their data from "awstats"




quote:
Originally posted by Stigmata
<?PHP
    $file="hitscount.dat";
    $handle=fopen($file, "r+");
    $hits=fread($handle,filesize("$file"));
    $hits+=1;
    fclose($handle);
    $handle=fopen($file, "w");
    fwrite($handle, $hits);
    fclose($handle);
?>

=/ why do you use r+ if your just going to read from it , you should just use r then open the file with w place your data and close it. OR use w+  read from the file then write to it and close the file like so...

code:
<?php
    $file="hitscount.dat";
    $handle=fopen($file, "w+");
    $hits=fread($handle,filesize("$file"));
    $hits++;
    fwrite($handle, $hits);
    fclose($handle);
?>


Really not the best code because of no error checking but eh...

This post was edited on 05-23-2005 at 01:22 PM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
05-23-2005 01:20 PM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On