Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post God that must've SUCKED
Yesterday 09:31 PM
Last post by alvinthecat
Today 01:02 AM
2 Replies, 3 Views
Go to first new post Inuyasha or Naruto?
04-13-2008 12:58 PM
Last post by Pandox
Today 12:57 AM
84 Replies, 445 Views
Go to first new post ibuyneo is a scammer!
Yesterday 12:58 PM
Last post by Bex
Today 12:50 AM
14 Replies, 15 Views
Go to first new post Day of Defeat
11-03-2006 08:38 PM
By unlimitedorb
Last post by alvinthecat
Today 12:47 AM
10 Replies, 306 Views
Go to first new post F*CKING FORUM CLOCK!!@@!
Yesterday 08:58 AM
Last post by Bex
Today 12:46 AM
23 Replies, 24 Views
Reply
 
LinkBack Thread Tools Display Modes

 Unique Hits Counter
Old 10-18-2006, 03:39 PM   #1 (permalink)
Oosband
Guest
 
Posts: n/a
iTrader: / %
Unique Hits Counter

Open Notepad, create a blank dobument called hits.txt. Now upload it to you website directory, make sure to put it in the same folder as the php page containing the hits code.
Also Note: You must CHMOD this file to 777 - This simply means that it doesn't need specific permissions for the file to execute.

Add the following code to a blank file and call it counter.php.
Code:
<?php
$filename = "hits.txt";

$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo $hits;

$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename));
fclose($fd);
$fd = fopen ($filename , "w");
$fcounted = $fstring."n".getenv("REMOTE_ADDR");
$fout= fwrite ($fd , $fcounted );
fclose($fd);
?>
This simply tells it to add 1 pageview per IP, meaning it counts the amount of unique visitors you get.
This is then written to the hits.txt file and increases every time the page is loaded by an alternative IP address.

Now to make this counter show up simply add the following code on any .php page:
Code:
Unique Visitors: <?php include("url/to/file/counter.php"); ?>
NOTE: Remember to change url/to/file/counter.php to the correct path of your counter.php file.
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 01:02 AM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.23021412 seconds (100.00% PHP - 0% MySQL) with 20 queries