/////////////////////////////////////////////////////
//                                                 //
//                  PHPClickLog                    //
//                 Version 1.0.0                   //
//                                                 //
//                 Copyright 2001                  //
//                  David Broker                   //
//                php@warpedweb.net                //
//              All Rights Reserved                //
//                                                 //
//          In using this script you               //
//           agree to the following:               //
//                                                 //
//      This script may be used and modified       //
//              freely as long as this             //
//             copyright remains intact.           //
//                                                 //
//     You may not distibute this script, or       //
//           any modifications of it.              //
//                                                 //
//   A link must be provided on the website that   //
//             uses the script to:                 //
//          http://php.warpedweb.net/              //
//                                                 //
//      Any breaches of these conditions           //
//        will result in legal action.             //
//                                                 //
//      This script is distributed with            //
//        no warrenty, free of charge.             //
//                                                 //
/////////////////////////////////////////////////////

README for PHPClickLog Version 1.0

Please read this file thoroughly before emailing for help.

Contents:

 - About
 - Included Files
 - Installation
 - Change log
 - To do

+-------+
| About |
+-------+

 A script written in PHP 4 which logs a user's statistics
 when they click on a link.
 The log is stored in a flatfile (text) database and
 can be viewed/inspected through an administration section.

+----------------+
| Included Files |
+----------------+

Here is a list of files included in this distribution:
 1. click.php
  The actual PHP scripts.
 2. click_config.dat
  The file which stores the script configuration.
 3. click_log.dat
  The file which will store the log.
 4. readme.txt
  This file.

+--------------+
| Installation |
+--------------+

 Installation of this script is pretty simple.

 1. Unpack the distribution using either Winzip or Tar and 
    open up click.php in a text editor.

 2. You need to change a few lines of code:

  a. First you need to set the username and password.
      $user = "Admin";
      $pass = "BlaH";
     Please note that they are CaSe SeNsItIvE.
  b. This line needs to be set to the URL of the script. 
      $script = "http://www.abc.com/php/click.php";s

  c. The next line is the full server path to the log file.
     When using Windows please make sure to use double slashes:
      Windows: $log_file = "c:\\html\\logs\\click_log.dat";
      Unix:   $log_file = "/home/www/logs/click_log.dat";

  d. The next line is the full server path to the config file.
     When using Windows please make sure to use double slashes:
      Windows: $log_file = "c:\\html\\logs\\click_config.dat";
      Unix:   $log_file = "/home/www/logs/click_config.dat";

  e. The next line $date_format can be changed if you wish, but
     you can leave it as is.

 3. Upload the files to your PHP enabled server.

 4. Is you are using Unix you will need to change some file permissions:

  a. click_log.dat needs read/write permission. CHMOD 666 (or 777 on some servers).

  b.  click_config.dat also need to be CHMODed to 666 (or 777 if needed).

 Now thats the basic installation of the script. 

+------------------+
| Using the Script |
+------------------+

 You must now run the administration module. 
 To do this you must go to your script and enter the URL like this:
  http://path.to/the/click.php?action=admin

 It will ask you to enter your username and password is. 
 Enter it and press "Logon".

 You should now be viewing the administration section with a 
 number of options: 
 
  Log Functions:
   View Log: Shows the log file of all the users who have clicked on a link.
   View Count: Shows a count of how many times people have click on a link.
   Clear Log: Clear the log file.

  Administration Functions:
   Add Link: Adds a link to the script.
    When you select this option you will be asked for 3 pieces of info:
     - URL: the address you the site you want to track.
        IE: http://www.warpedweb.net/php/
     - Name: The name of the site. 
        IE: David's PHP Scripts
     - Link Code: A shorthand code you reffer to the link (must be unique).
        IE: dphps
   Edit Link: Allows you to edit the info above of an existing link.
   Remove Links: Allows you to remove one or more links.
   Remove All Links: Clears the link database. The script won't work until
    you add more links.

 Thats how you administer the script.
 Now, how do you track the links?
 
 There are two ways to do this:
  Link directly to the script in HTML:
   <a href="http://www.abc.com/click.php?action=go&to='Link Code'">Link</a>
  Make sure you change 'Link Code' to whatever you entered when 
  administering the script. For example (as above) "dphps".

  Or use this piece of PHP code in another PHP file to list all links:
   <?php
    include "http://www.acb.com/click.php";
    print_links("all");
   ?>

+------------+
| Change Log |
+------------+

19-02-01 V 1.0
 - Initial release.
 - ClickLog logs a user's information into a text file.
 - An Administration module controls the log file, 
   script and allows users to view the stats.
 - Remembered to insert lots of "file open" error checking this time.

+-------+
| To Do |
+-------+

 - Checking referer so as script cannot be linked to from other sites.
 - Add more options to the "print_links" function.
 - Sort "View Count" by number of counts (couldn't get array_multisort() to work.
 - Confirmation when clearing log and config file.
 - More options in the Admin section. (Any suggestions???)

Thanks for download this script, please send and comments, suggestions,
bugs, errors, contribution's to: php@warpedweb.net


David Broker
php@warpedweb.net
http://www.warpedweb.net/php/