readme.txt This explains the workings of the PHP/mySQL graphical counter (hopefully) Please contact me for further information Tom Smith scripts@davas-online.co.uk Introduction This counter is designed to log visits to a particular page within a specified domain, write the details (time, referer etc) to a mySQL database and the count value to another mySQL database, then display the counter as a graphic on the page. The script was written to make analysis of counters easy, without using pre-formed graphics and to enable me to learn a bit more about mySQL and PHP and Dreamweaver UltraDev! It draws heavily from other scripts, but acheives something that they, in the main, do not. In particular I'd like to aknowledge the counter.cgi script from P Lutis Ashland which has been my "stock" counter for many years. It also uses the new PHP extension for Dreamweaver UltraDEv from www.interakt.ro - many thanks to them too. As a learner I'm sure many parts of the script could be greatly improved, as could the security of the table. However this was not what I was trying to acheieve in the first place - maybe when I get time! History 5.02 Allows choice of colour/fonts 5.01 Uses PNG to overcome Windows XP SP2 issues with x-bitmaps 4.02 Creation date/ last accessed date added 4.01 Graphical counter added 3.01 Databases written to correctly Files included log.txt - mySQL table creation for log table counters.txt - mySQL table creation for counters table count1.htm - sample html file to incorporate counters config.php - configuration file DOLcounter.php - redirection program file (for compatability)(does not need editing) DOLcounter2.php - main program file analysis.php - administration script - shows all counters for domain DOL.css - Stle sheet for analysis.php /images/*.* - images needed for analysis.php /adodb/*.* - connection Requirements Given that this is a PHP script using mySQL you will need the following:- mySQL PHP (version 4) on your server. It was written and tested with mySQL 3.23 and PHP 4.0.6 running on Apache 1.3.6 on Red Hat linux 6.2! Installation Upload the DOLcounter.php and config.php scripts to a suitable directory on your site (eg /php/) You need to create a mySQL database called "access" (this can be diffferent if config.php is changed") and thenb create two tables "log" and "counters". Two mySQL creation files are included to do this. I use phpMyAdmin to administer all my mySQL tables where creating databases and tables is easy - see http://phpwizard.net/projects/phpMyAdmin/ Then edit the config.php file to include the database name (defaults is access) username (default is "counter") password (default is "counter") Then you need to issue a mySQL grant command GRANT all on access.* to counter@localhost identified by "counter" to create the users and give them permissions for this database. Then insert into your webpage an image as follows:- pointing at the correct place! The two parameters are counter=test1 - the name of the counter. You can have as many counters as you like - but on each domain (see below) the name must be unique domain=www.... - the name of your domain. You could choose any name here - but this name will be what you can analyse the results with Options You can now call the script with a variety of options - to retain compatibility none of the following is required - but it does give you the chance to tweak the look to your webpage Foreground colours - to set the colour of the text col_r=xxx col_g=xxx col_b=xxx where xxx=0 to 255 (RGB colour values) - default = 0,0,0 ie black Background colours bgcol_r=xxx bgcol_g=xxx bgcol_b=xxx where xxx=0 to 255 (RGB colour values) - default = 255,255,255 ie white Fonts Using PHP and GD's built in fonts font=x where x=1 to 5 - default=3 (because I think that font is best!) To see these options in action load test1.htm onto your server - or look at www.davas2.co.uk/DOLcounter/test1.htm That's it - when the html page runs an image will be generated. If it is the first time you have called the script for a particular domain or counter a recors will be written to the counter table. If not then this table will just be uipdated with the new counter value. Analysis of your counters Please use the analysis.php script to analyse your counter data. At present all this does is to return the entries in the counter table for your domain. A more detailed analysis if the data in the log table will come later! Call the script as .../analysis.php?domain=xxx.yyy.zzz whatever the domain was you used for your counter Notes The counter table has extra fields which are not used in this version. For compatability with later versions please do not remove these fields Demo To see the script in action visit www.davas-online.co.uk/counters/ Tom Smith Davas Ltd Dec 2004