Simple Site Stats Counter

3 posts Page 1 of 1
Contributors
User avatar
wrighty1986
VIP - Donator
VIP - Donator
Posts: 119
Joined: Sat Sep 12, 2009 11:55 am

Simple Site Stats Counter
wrighty1986
This script is simple because it's using this flatfile thingy and it uses files as databases. That means you will take info and write it into another file so back to this tutorial.

First make a file called counter.txt and change it's CHMOD to 777
Code: Select all
<?php

//User referer
$referer = $_SERVER['HTTP_REFERER'];

// User ip
$ip = $_SERVER['REMOTE_ADDR'];

//Your browser info
$browser = $_SERVER['HTTP_USER_AGENT'];

//Date
$date = date('r'); 

// Theres no referer then it will be marked with -
if($ref == ""){
$ref = "-";
}

//Text what will be written into counter.txt file
$text = "

IP: $ip
Browser: $browser
referer: $referer
Date: $date

";

// Opens counter.txt file 
$open = fopen("counter.txt", "a");

//This writes all this text into counter.txt
fputs($open, $text);

// Closes counter.txt file
fclose($open);

?>
So now if someone will visit this page where's this script then her/his/its
IP, BROWSER, REFERER and date when he/she/it visited this page, will be written into counter.txt

Have fun!
Back Aegean sorry not been on i.v just been moving.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Simple Site Stats Counter
mandai
I have seen this code elsewhere.
Last edited by mandai on Sun Apr 29, 2012 9:27 pm, edited 1 time in total.
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Simple Site Stats Counter
Lewis
Mandai have a little appreciation that he posted it here :)

Wow, and this is my 1000th post WD Me :P
Image
3 posts Page 1 of 1
Return to “Tutorials”