CCount
PHP Click Counter
- PHP Click Counter (CCount)
- Version: 1.2 from 29th October 2007
- Author: Klemen Stirn
- PHPJunkyard.com - Free PHP scripts
- PHP Click Counter
- Support and developers forum
PLEASE NOTE: I cannot provide free installation support for this free script! Please contact me ONLY about possible bug reports, suggestions or comments! Thank you!
INDEX
- Copyright notice and license
- Description & requirements
- Installation
- Upgrading from old versions
- Displaying number of clicks on a link
- HELP and Troubleshooting
- Newsletter, rating this script and other
COPYRIGHT NOTICE
Copyright 2004-2007 Klemen Stirn. All Rights Reserved.
The CCount may be used and modified free of charge by anyone AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS 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, in part or full, without prior written consent is expressly forbidden.
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.
Removing copyright notice ("Powered by" statement)
Removing any of the copyright notices without purchasing a license is illegal! To remove PHPJunkyard copyright notice you must purchase a license for this script. For more information on how to obtain a license please visit the site below:
http://www.phpjunkyard.com/copyright-removal.php
DESCRIPTION
CCount is a PHP click counter. With it's help you can count clicks on any link on your website. A great tool if you want to know how many times a link has been clicked, a file downloaded or similar. You can also hide your affiliate links with PHP click counter. As long as it's a link - CCount can count clicks on it!
Changes in 1.2
- links can now be edited
- added file locking to minimize the chance of database getting corrupted
- can count unique clicks now
- re-written parts of code for efficiency
- other minor changes
REQUIREMENTS
- UNIX, Windows, FreeBSD server (or other with working PHP/MySQL)
- PHP 4.3 or never
- FTP access and a FTP program
» Installation
Please take 5 minutes time and read installation instructions carefully and completely! This will ensure a proper and easy installation.
If you have problems/questions see the "Troubleshooting and HELP" section further down.
- Open file settings.php in your favorite PLAIN TEXT editor (like Notepad or Wordpad on Windows systems, DO NOT use MS Word or similar editor), scroll down to where it says "SETUP YOUR COUNTER" and set these variables:
Variable Description/Setup $settings['apass'] Change the default password admin to the password you will use to login to the Admin panel. Use only letters a-Z, A-Z and digits 0-9.
TIP: For security reasons choose a unique password and not a password you use to access other parts of your website (like FTP, control panel, e-mail, ...).$settings['click_url'] Set this variable to the URL of click.php file when uploaded to your server, for example:
http://www.yourdomain.com/ccount/click.php$settings['count_unique'] Enable counting clicks hits only. For more information read Counting UNIQUE clicks below. $settings['unique_hours'] Number of hours a click is considered unique. For more information read Counting UNIQUE clicks below. TIP: There are few optional advanced settings in the settings.php file, don't change any of them unless you understand what they do.
-
Save and close the settings.php file.
-
FTP to the public folder of your server (where the rest of your website is; usually called "public_html", "www" or "site") and create a folder where you will install CCount (for example named "ccount").
Example: /public_html/ccount
Corresponding URL: http://www.yourdomain.com/ccountTIP: If you don't know how to FTP or CHMOD files read my simple FTP and CHMOD tutorial
-
Upload all CCount files to this folder. Images (delete.gif, edit.gif, line.gif and reset.gif) must be transferred in BINARY mode, all other files in ASCII mode (refer to your FTP client instructions for details on how to set transfer mode properly).
-
Make sure that the PHP scripts have permission to write to files clicks.txt and ids.txt. On Unix (Linux) servers CHMOD these files to 666 (rw-rw-rw-).
That's it, your CCount should work now! In your browser open
URL where you have installed CCount, for example:
http://www.yourdomain.com/ccount
Type in the admin password you set in settings.php, click Enter admin panel and voila, you are in the Admin panel! Things should be easy from now on. Use the Add a link form to add links you wish to count clicks on and follow instructions.
Got an error message or can'tlogin? A few solutions can be found below under HELP and Troubleshooting.
» Using PHP Click Counter
Not sure how to use CCount to count click? Here is a sample setup:
- You want to count how many times the link to Yahoo.com has been clicked
from your website. You have the link pointing to http://www.yahoo.com
and this is the HTML code on your website:
<a href="http://www.yahoo.com">Go to Yahoo!</a> - Login into the CCount Admin panel. Open
http://www.yourdomain.com/ccount
and enter your admin password. - Find the form titled Add a link. In the Link URL: enter
the link you want to count clicks on. In this example you would enter
http://www.yahoo.com
Optionally you can also choose a name for your link (for example Link to Yahoo from homepage) and the number you want to start counting from (if you want to start counting from 100 enter 100 in the box). - Click the Add link button and the link will be added to CCount.
You will be given a link ending with click.php?id=ID where ID is a number, for example:
http://www.yourdomain.com/ccount/click.php?id=1
This is called a tracking link. - Now instead of linking directly to the link you
are counting clicks on, you need
to link to your tracking link instead! In our example instead of
linking directly to http://www.yahoo.com, you must link to
http://www.yourdomain.com/ccount/click.php?id=1
The HTML code you would use for your link is for example
<a href="http://www.yourdomain.com/ccount/click.php?id=1">Go to Yahoo!</a>
When someone clicks on the tracking link CCount will count click on the link and then redirect your visitor to http://www.yahoo.com
» Counting UNIQUE hits
If you wish to count unique clicks only, then set $settings['count_unique'] to 1 in the settings.php file. Doing so CCount will only count clicks considered unique.
Unique clicks are tracked with the help of cookies. Number of hours a click is considered unique can be adjusted by modifying value for $settings['count_unique'] in the settings.php file. A value of 24 means only one click from the same browser will count as unique within a 24-hour period.
» Upgrading from CCount version 1.0 and 1.1
Please take 5 minutes time and read upgrade instructions carefully and completely! This will ensure a proper and easy upgrade.
- backup all existing CCount files!
- Edit the new settings.php file
- Upload all CCount files to your server except files clicks.txt and ids.txt! Do NOT upload these two files, leave the old ones already on your server!
That's it, you are ready to go! Your old links and counts will remain intact.
» Displaying number of clicks on a link
CCount fallows you to display the number of clicks on a link on your website. To display number of clicks on your web page follow these two steps:
1. Add this code in your HTML document HEAD (paste it somewhere between <head> and </head> HTML tags):
<script language="Javascript"
src="http://www.domain.com/ccount/display.php">
<!--
//-->
</script>
CHANGE http://www.domain.com/ccount/display.php to the URL of display.php on your server!
2. Add this code where you want the number of clicks to appear:
<script language="Javascript">ccount_display('LINK_ID')</script>
REPLACE LINK_ID with the ID number of the link you want to display the count for (IDs can be found when you login to CCount admin panel)! To display number of clicks on the link with ID 13 you would use this code:
<script language="Javascript">ccount_display('13')</script>
You may add any HTML tags around this code to format the count number. This
code for example:
This link has been clicked <font color="#FF0000"><script
language="Javascript">ccount_display('9')</script></font>
times
would produce such output:
This link has been clicked 478 times
If you get an undefined error instead of a number please double-check the ID number you entered in the code above!
» HELP and Troubleshooting
1. 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.
2. I get an ERROR saying "Can't write to the log file, please make sure this file exists and is CHMOD to 666 (rw-rw-rw-)!"
PHP script doesn't have permission to write to your file(s). Make sure PHP scripts have permission to write to clicks.txt and ids.txt. On Unix (Linux) servers CHMOD these files to 666 (rw-rw-rw-). If you are not sure how, see my FTP and CHMOD tutorial.
3. I get an ERROR saying "This ID doesn't exist!" or "Invalid ID, numbers (0-9) only!"
Make sure you added the link inside the Admin panel (see Using CCount above) and that you are using the correct link ID number.
4. How can I show my visitors how many times a link has been clicked?
Read the section Displaying number of clicks on a link.
5. Displaying click count on my website doesn't work! Why?
Read the section Displaying number of clicks on a link again.
Some FREE hosts automatically add code to your web pages. This code may break Javascript code generated by display.php file. Solution? I'm afraid you will need to find a better host, probably paid php hosting.
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
» Please rate this script
If you like this script please rate it or even write a review at:
Rate this Script @ The PHP Resource Index
Rate this Script @ Hot Scripts
» 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 StirnPHP JunkYard
http://www.PHPJunkYard.com