//-----------------------------------------------------------------------
//Hit counter by Mustals (c)2002 : last update 04.09.02
//Contact info@mustalweb.co.uk
//This script is free to use, please leave in this blurb though.
//See a working copy at http://www.mustalweb.co.uk/download/
//
// SIMPLE HIT COUNT WITH IP LOGGING.
// The script stores a visitors IP number to prevent
// repeat visitors clocking the counter.
//
//WHAT YOU NEED to use this script is...
//A server with PHP and SSI installed and operational
//and the ability to CHMOD your files on UNIX/LINUX severs.
//
//FTP remember to upload as ASCII, using BINARY mode will mung the script.
//and it will not work.
//
//SETUP: Make two files: ip_data.dat & count.dat.
//Change the variables $IPfilePath and $countFilePath to where
//you are going to put these two files on your server.
//CHMOD this file to 644 and 666 for the two .dat files
//if in a UNIX environment.
//
//Give the webpage on which you wish to use the counter an
//extension of .shtm or .shtml, ie index.shtml.
//Put this line where you want the counter:
//you might have to change the path eg
//Using HTML tags or Styles change the output to match your site.
//For example will cause the
//numbers to be displayed as Bold.
//
//The variables $hitMessage1 & $hitMessage2 allows text to
//be placed before and after the counter. Change this to
//anything as long as the " "; are in place, for no message
//leave the quotes empty ie $hitMessage1="";
//
// There are two error messages in case bad things start to
// happen when running this script. $readErr & $writeErr,
//you may like to customise these to your own e-mail address.
//
// You are not limited to a single number in the count file try for example 00086
//
//The script will store your own IP NUMBER AND WILL STAY THE SAME THE SAME EVERY TIME YOU LOAD THE PAGE so test everything is working set the variable $overRide to 1 this turns IP checking off.
// Normal usage setting $overRide to 0 turns on IP logging.
//
//Done
//-----------------------------------------------------------------------
//echo "Executed";
//Set Variables
$IPfilePath = "ip_data.dat"; // Path to IP number file
$countFilePath ="count.dat"; //Path to Count file
$overRide = 0;//Toggles IP logging: 0=On 1 =Off
$readErr = "Read error, contact info@mustalweb.co.uk for help";
$writeErr = "Write error, contact info@mustalweb.co.uk for help";
$hitMessage1 ="Simple hit counter ";//Text before...
$hitMessage2 =" override = ";// and after counter.
//================= No need to change anything after here ========================
$IPnum = "0.0.0.0"; //Set as a String
$userStatus = 0;
// Get the current IP number ------------------------------
$IPnum = getenv("REMOTE_ADDR");
//echo $IPnum;
//Get stored IP's from a file --------------------------------
$IPlist = @fopen($IPfilePath, "r")or die($readErr);
$IPdata = fread($IPlist,filesize($IPfilePath));
fclose($IPlist);
//Compare it to the ones stored in ip_data.dat ---
$IParray = explode(" ",$IPdata); //Make array of IPs
// Start comparing IPs
for($ipCount=0;$ipCount