Using Awstats to make a hitcounter |
Author: |
Message: |
user27089
Disabled Account
Posts: 6321
Joined: Nov 2003
Status: Away
|
O.P. Using Awstats to make a hitcounter
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 .
|
|
05-22-2005 08:16 PM |
|
|
saralk
Veteran Member
Posts: 2598 Reputation: 38
35 / /
Joined: Feb 2003
|
RE: Using Awstats to make a hitcounter
if your using php...
code: <?php
$file = fopen("counter.txt", "r+");
$file++;
fwrite("counter.txt", $file);
echo $file;
?>
I haven't tested it out, but it should work.
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
|
|
05-22-2005 08:23 PM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
RE: Using Awstats to make a hitcounter
I'm no PHP person, but wouldn't you have a problem with '$file++;'?
|
|
05-22-2005 08:32 PM |
|
|
saralk
Veteran Member
Posts: 2598 Reputation: 38
35 / /
Joined: Feb 2003
|
RE: Using Awstats to make a hitcounter
that makes the number increase by one.
and $file-- make it, yes you guessed it, decrease by 1
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
|
|
05-22-2005 08:33 PM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
RE: Using Awstats to make a hitcounter
Looks more to me like (Increase file pointer by 1', or have I just too much C++?
|
|
05-22-2005 08:36 PM |
|
|
saralk
Veteran Member
Posts: 2598 Reputation: 38
35 / /
Joined: Feb 2003
|
RE: Using Awstats to make a hitcounter
im not sure, i did that pretty quickly, i can't remember if $file = fread() will put the file contents in the var, or make it some sort of identification var. WDZ WDZ WDZ where for art thou?
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
|
|
05-22-2005 08:38 PM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: Using Awstats to make a hitcounter
nah you need to do stuff in this order
fopen with r parameter to read it
fread it
store in a variable
fclose
fopen again with w parameter to clear it and prepare it for writing
add 1 to the variable
fwrite
and then echo it
code: <?
$counter = fopen("counter.txt", "r");
$blah = fread($counter, filesize("counter.txt"));
fclose($counter);
$counter = fopen("counter.txt", "w");
$blah = $blah + 1; //not sure if $blah++ would work, try it
fwrite($counter, $blah);
fclose($counter);
echo $blah;
?>
This post was edited on 05-22-2005 at 08:41 PM by Eljay.
|
|
05-22-2005 08:39 PM |
|
|
Veggie
Full Member
Posts: 415 Reputation: 21
37 / /
Joined: Sep 2004
|
RE: Using Awstats to make a hitcounter
$blah++;
would work, it simply adds one.
|
|
05-22-2005 08:53 PM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
RE: Using Awstats to make a hitcounter
LJ's code looks more correct to me.
You gotta remember though, I don't know any PHP.
|
|
05-23-2005 08:33 AM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: Using Awstats to make a hitcounter
quote: Originally posted by Veggie
$blah++;
would work, it simply adds one.
yeh but what if the txt file contains like "1000 hits" ?
it wouldnt change to 1001 because its not all integers
EDIT: actually in this case mine wouldnt work
This post was edited on 05-23-2005 at 08:36 AM by Eljay.
|
|
05-23-2005 08:36 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|