Simple PHP Unique Visitor and Hits Counter without MySQL
- Superfast, no overloading
- Simple and Easy to use
- Tiny Size, less than 1kb
The required files are inside /counter
folder
- counter.php
- iplist.txt
- hits.txt
Learn how to use this counter
Just include or require /counter/counter.php in your homepage or wherever you want .
<?php
require __DIR__. '/counter/counter.php';
?>
to make hit to your total hit counter, use simply this function
<?php
require __DIR__. '/counter/counter.php';
// to make hit
makeHit();
?>
<?php
require __DIR__. '/counter/counter.php';
// to get hit
echo getHit();
?>
First of all you have to use this function to add visitor's ip address into your iplist.txt file .
<?php
require __DIR__. '/counter/counter.php';
// to save unique visitors ip
addUniqueIP();
?>
You can use a parameter inside this functions like
// addUniqueIP(YOUR_IP_ADDRESS);
addUniqueIP('127.0.0.1');
If parameter is NULL
it will automatically catch the ip address of requested client .
to get total unique visitors count, simply use this function
<?php
require __DIR__. '/counter/counter.php';
// to get unique visitors ip
echo getUniqueVisitor();
?>
NOTE : getHit()
and getUniqueVisitor()
just return the value, so you have to must print or echo these .
If you have any query, feel free to contact me at jafranhasan@outlook.com
Dhaka Polytechnic Institute .