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 ![:)](images/smilies/msn_happy.gif) .
|
|
05-22-2005 08:16 PM |
|
![](images/pixel.gif) |
saralk
Veteran Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](avatar.php?uid=4992-933)
Posts: 2598 Reputation: 38
35 / / ![United Kingdom Flag](images/flags/gb.png)
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 |
|
![](images/pixel.gif) |
RaceProUK
Elite Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](http://rpsoftware.net/img/icon96.png)
Posts: 6073 Reputation: 57
39 / / ![United Kingdom Flag](images/flags/gb.png)
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 |
|
![](images/pixel.gif) |
saralk
Veteran Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](avatar.php?uid=4992-933)
Posts: 2598 Reputation: 38
35 / / ![United Kingdom Flag](images/flags/gb.png)
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 ![:banana:](images/smilies/banana.gif)
The Artist Formerly Known As saralk
London · New York · Paris
Est. 1989
|
|
05-22-2005 08:33 PM |
|
![](images/pixel.gif) |
RaceProUK
Elite Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](http://rpsoftware.net/img/icon96.png)
Posts: 6073 Reputation: 57
39 / / ![United Kingdom Flag](images/flags/gb.png)
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 |
|
![](images/pixel.gif) |
saralk
Veteran Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](avatar.php?uid=4992-933)
Posts: 2598 Reputation: 38
35 / / ![United Kingdom Flag](images/flags/gb.png)
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 |
|
![](images/pixel.gif) |
Eljay
Elite Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](avatar.php?uid=32264-5599)
: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 |
|
![](images/pixel.gif) |
Veggie
Full Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](http://chris.lane.org.uk/msn/dp/)
Posts: 415 Reputation: 21
37 / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Sep 2004
|
RE: Using Awstats to make a hitcounter
$blah++;
would work, it simply adds one.
|
|
05-22-2005 08:53 PM |
|
![](images/pixel.gif) |
RaceProUK
Elite Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](http://rpsoftware.net/img/icon96.png)
Posts: 6073 Reputation: 57
39 / / ![United Kingdom Flag](images/flags/gb.png)
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 |
|
![](images/pixel.gif) |
Eljay
Elite Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](avatar.php?uid=32264-5599)
: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 ![:-o](images/smilies/msn_surprised.gif)
This post was edited on 05-23-2005 at 08:36 AM by Eljay.
|
|
05-23-2005 08:36 AM |
|
![](images/pixel.gif) |
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|