PHP hit counter (PHPcount)
Version: 1.0
File name: counter.php
Written 15th July 2004 by Klemen Stirn (info AT phpjunkyard DOT com)
PHPJunkYard.com - Free PHP scripts
PHP text hit counter
Support and developers forum
COPYRIGHT NOTICE
Copyright 2004 Klemen Stirn. All Rights Reserved.
The PHPcount may be used and modified free of charge by anyone so long as this copyright notice and the comments above remain intact. By using this code you agree to indemnify Klemen Stirn from any liability that might arise from it's use.
Selling the code for this program without prior written consent is expressly forbidden. In other words, please ask first before you try and make money off this program.
Obtain permission before redistributing this software over the Internet or in any other medium. In all cases copyright and header must remain intact. This Copyright is in full effect in any country that has International Trade Agreements with the United States of America or with the European Union.
DESCRIPTION
PHPcount is a simple yet effective PHP text hit counter. It uses flat-text database so no SQL databases are necessary. It can count hits for multiple pages of your website or even websites on other servers. To prevent others taking advantage of your script a HTTP referer validation has been included as an option.
Requirements
phpcount10.zip file contains following files:
In case your phpcount10.zip does not include all listed files please download the script again.
>> Quick installation
Upload counter.php file into a folder in your public directory (where the rest
of your website is; usually "public_html", "www" or "site").
Example: /public_html/counter
Corresponding URL: http://www.yourdomain.com/counter/counter.php
Within the same folder create a new folder called "logs" (on many servers names are CaSe SeNsiTiVE).
Make sure this folder is world-writable (on UNIX servers issue command CHMOD 777 (rwx-rwx-rwx))
Example: public_html/counter/logs
Now to make your counter work just use this piece of code on your site:
<SCRIPT LANGUAGE="Javascript" SRC="http://www.domain.com/counter/counter.php?page=PAGENAME"><!--
//--></SCRIPT>
Change the SRC parameter accordingly (to your counter.php URL)! Change PAGENAME to a unique name for each page you want
track hits on (use numbers and letter only, no spaces or other chars).
Example:
On index.html you would use http://www.domain.com/counter/counter.php?page=index
On someotherpage.html you would use http://www.domain.com/counter/counter.php?page=otherpage
etc...
>> Enabling HTTP referer validation
Enabling HTML validation will prevent other people from using the script installed on your server to count hits on their site.
Open counter.php file in a PLAIN TEXT editor (like Notepad or Wordpad on Windows systems, DO NOT use MS Word or similar editor) and scroll down to "SETUP YOUR COUNTER".
Set $check_referer = 0; to 1 to enable HTML referer validation.
In $referers = array ("domain.com","someotherdomain.com"); set the domains
you allow to use the counter.
Example of a correctly configured counter which will only allow counting hits on
pages under PHPJUNKYARD.COM domain:
$check_referer = 1;
$referers = array ("phpjunkyard.com");
Save the file and upload it to server.
>> Troubleshooting
What is CHMOD and FTP?
I have prepared a simple FTP and CHMOD tutorial which will help you FTP files to your server and set correct CHMOD settings.
My counter doesn't work, HELP!
Ok, first of all don't panic, it's only a counter :-) Here are a few things to check:
Since these scripts are free no support is guaranteed. If you can't get the script to work please go through this readme file again carefully and repeat the installation step-by-step (also delete old files and folders from the server). Also please feel free to post any questions or problems you might have in PHPJunkyard forum!
>> Stay updated!
Join my FREE newsletter and you will be notified about new scripts, new versions of the existing scripts
and other important news from PHPJunkYard.
Click here for more info
>> What else?
That's it! If you use PHPJunkYard free scripts or any portion of their code please place a link to PHPJunkYard.com on your website. I won't sue you if you don't, but I believe it is a fair trade for a free script/code. Think about it. You can find link suggestions here.
Best regards,
Klemen Stirn
PHP JunkYard
http://www.PHPJunkYard.com