OK guys, this script is a simple file based counter. This is meant for sites that do not run a db and instead, use a file and a cookie. It isn't the best I've seen but it's simple. Consider this as a tutorial. :)
Just create a file called counter.txt and put this where you want to display the counter.
Remember to set the permissions on counter.txt so that your webserver can write to the file.
<?php
$visitor_ip = $HTTP_COOKIE_VARS [ "user_ip" ];
$counter = "counter.txt" ;
$counter_file_line = file ( $counter );
if(! $visitor_ip )
{
setcookie ( "user_ip" , $REMOTE_ADDR , time ()+ 360000 );
$counter_file_line [ 0 ]++;
$cf = fopen ( $counter , "w+" );
fputs ( $cf , " $counter_file_line [ 0 ] " );
fclose ( $cf );
}
elseif( $visitor_ip != $REMOTE_ADDR )
{
$counter_file_line [ 0 ]++;
$cf = fopen ( $counter , "w+" );
fputs ( $cf , " $counter_file_line [ 0 ] " );
fclose ( $cf );
}
?>
Simple image counter Categories : PHP , Graphics , Filesystem , Beginner Guides Simple Cookie example Categories : PHP , Beginner Guides , Cookies Link Submition - Allow your visitors to submit links to the site. Categories : PHP , Arrays , Filesystem , Beginner Guides Convert a File database into MySQL Categories : PHP , Filesystem , Databases , MySQL , Beginner Guides Introduction to Language Files Categories : PHP , Filesystem , Beginner Guides Selecting a random line from a text file Categories : PHP , Filesystem , Arrays , Beginner Guides A very simple PHP single password cookie based login without usernames. Categories : PHP , Cookies , Security , Beginner Guides PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP , Email , Beginner Guides , Filesystem Store, retrieve and delete cookies using JavaScript. Categories : Java Script , Cookies , Beginner Guides , Cookies Simple PHP cookie counter Categories : PHP , Cookies , Beginner Guides Creating a Language File Categories : PHP , Beginner Guides , Filesystem How to Create a Shoutbox Using PHP & MySQL Categories : PHP , MySQL , Web Applications , Beginner Guides , HTML and PHP Extended Get File List Function Categories : PHP , Filesystem , Search , Directories Find the day of the week for any given year/month/day. Categories : PHP , Date Time , Data Validation , Algorithms , Beginner Guides Count Number Of weeks in Month Categories : PHP , Date Time , Beginner Guides