Reply
Special hit counter
Old 03-24-2006, 04:32 AM Special hit counter
Skilled Talker

Posts: 81
Hi, im looking for a hit counter (text) but I wan't to be able to exclude a specif IP. I want to be show how many hits my site gets, not including my own.
__________________
Watch anime online
TBLTK is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-24-2006, 05:29 AM Re: Special hit counter
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,114
Name: Matt. (>',')>
Location: London, England.
Get a normal flat file hit counter and just put in an if condition around your ip
something like..
PHP Code:
$ip $_SERVER["REMOTE_ADDR"]; 

if(
$ip == "your ip here");
{
exit;
}
else
{
Hit counter sctipt here
}
?> 
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 03-24-2006, 06:18 AM Re: Special hit counter
Super Spam Talker

Posts: 882
Yup, so just to deepen on that .. I will chuck the whole thing together for you quickly.

Code:
<?php
//Counter Quickly Bodged together by Sir P for Webmaster-Talk.com
$ip = $_SERVER["REMOTE_ADDR"]; 

if($ip != "your ip here");
{
$file = fopen("counter.txt","r+"); 
$counter = fread($file, filesize("counter.txt"));
fclose($file);
$counter +=1;
$file = fopen("counter.txt","w+");
fputs($file, $counter);
fclose($file); 
	}
?>
To display the count on a page, just use something like ...

Code:
Hits: <? include("counter.txt"); ?>
Let me know how it works for you,
cheers,
Sir P
Sir P is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 08:10 AM Re: Special hit counter
Skilled Talker

Posts: 81
Do I just add that code to my site because i got this: http://www.tbldesign.net/hit.php? I probably need the counter.txt file.
Also can you include the code for the counter to start of at a number.
Thanx
__________________
Watch anime online

Last edited by TBLTK : 03-24-2006 at 08:17 AM.
TBLTK is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 09:01 AM Re: Special hit counter
Super Spam Talker

Posts: 882
Hi TBLTK...

Just paste my code onto any PHP page you have that you want to count visitors.. that second bit of code I gave you.. paste that on any page you want to show the counter.

So if you want to only count the people who come to you index page.. put my code on your index page only..

The counter.txt file.. just create a blank new text file.. call it counter.txt and put it in the same directory as your page you have the counter on... chmod it to 777 ...

If you want to start at a certain open, open up that counter.txt you should have just created.. and put any number in it, on the first line.. dont put anything else in there.. just a number.. and no decimal places

Let me know how it goes
P
Sir P is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 09:22 AM Re: Special hit counter
Skilled Talker

Posts: 81
Just two more question. If I put the code on index.php and page.php. Some one goes to my home page then to page.php, does that count as 2 hits?
Also how do I get it so the number come out as: 1,000/10,000/1,000,000...?
Thanx again
__________________
Watch anime online
TBLTK is offline
Reply With Quote
View Public Profile
 
Old 03-24-2006, 01:55 PM Re: Special hit counter
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Yes, it will count as two hits,
and you can use number_format() to get the commas in the number. You'll need to read the line with the number out of the file, assuming there is only one line in the file:
PHP Code:
$lines file("counter.txt");
echo(
number_format($lines[0])); 
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Scribble Pad MOD for phpBB (aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-24-2006, 04:58 PM Re: Special hit counter
Skilled Talker

Posts: 81
The hit counter worked
__________________
Watch anime online

Last edited by TBLTK : 03-24-2006 at 05:09 PM.
TBLTK is offline
Reply With Quote
View Public Profile
 
Old 03-27-2006, 08:16 AM Re: Special hit counter
Super Spam Talker

Posts: 882
yay
Sir P is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Special hit counter
 

Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16841 seconds with 12 queries