#################################################################################### THIS SOFTWARE IS DISTRIBUTED AS IS, WITHOUT ANY GUARANTEES, USE IT AT YOUR OWN RISK. YOU CAN CHANGE OR MODIFY THIS SCRIPT AS YOU PLEASE, I DON'T PARTICULARLY CARE. YOU CAN DROP ME AN EMAIL AT: kscorpy@mail.ru TO SHARE YOUR HAPPINESS WHEN YOU SET IT UP, AND I'LL GO AND CHECK OUT YOUR PAGE ;) #################################################################################### What is it ? This is a Counter script, Version 1.0. This script create a gif image which is a count element on your Web page. This script is too easy, but if you will contribute their own change you get a powerful script. I not know what you want, but i'll help you to do this. Let's begin. System Requirements: A web server, with PHP3 or newer; and GD lib installed; MySQL. What this archive contains ? This archive comes with 5 files: 1) README: This file. 2) index.php: Example page. Contain sample of count element. 3) count.php: The PHP script (counter). 4) statist.php: Example page. Contain simple example of collection of statistics. 5) counter.sql: Script for MySQL database. Installation and Configuration: It's a PHP script, so installation is pretty easy. Copy 'count.php' and 'statist.php' in your good directory. Edit 'count.php' and 'statist.php', you will have to do some configuration: 1. 'count.php': $expires_time="24"; //Time lag during which access to resources from one address is not taken into account (in hours) $db_server="localhost"; // MySQL server name (or www.your_site.com) $dbase="site"; // database name $table="counter"; // table name $db_user="countusr"; // database user $db_pass="pass"; // database password $imgname = "image/image.gif"; // If you want to see beautiful images on your pages use $imgname. Otherwise it well be transparent gif image (1x1). On the image you can draw statistics. How do is see PHP Manual->Creating and manipulating images. 2. 'statist.php' $db_server = "like below"; // mysql server name $dbase = "like below"; // database name $table = "like below"; // table name $db_user = "like below"; // database user $db_pass = "like below"; // database password $wins_count = 3; // if you want to see 3 most visited your pages $lose_count = 2; // if you want to see 2 least visited your pages How to run it ? 1.Create the "counter" table in your database using mysql database_name < sql.txt (database_name = $dbase) 2.Add code into your web pages. Contact: If you run into any problems while trying to configure these scripts first read this file carefully, if you don't find any solution, send me a Mail. Contact me with any comments, suggestions, bug fixes criticism. E-Mail: kscorpy@mail.ru Good Luck! Sergey Kitaev ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CREATE TABLE counter ( uid int(12) DEFAULT '0' NOT NULL auto_increment, url varchar(128) , hits int(12) NOT NULL DEFAULT '0' , PRIMARY KEY (uid), UNIQUE uid (uid) );

Test page:


?>

Test page:


0) { $hits = mysql_result($result, 0, "hits"); $hits++; mysql("$dbase","UPDATE $table SET hits=$hits WHERE url='$page'"); } else { $hits="1"; mysql("$dbase","INSERT INTO $table values('','$page','$hits')"); } mysql_free_result($result); setcookie ("visited", "1", time() + $expires_time); } //load (or create) gif image $im = ImageCreateFromGif ($imgname); if (!$im) { $im = ImageCreate (1, 1); ImageColorTransparent ($im, 0); } ImageGif($im); ?> "; echo "" echo "Most visited your pages:
"; while (($row = mysql_fetch_array ($dec_result)) & ($wins < 3)) { echo $row["hits"].": "; echo "".$row["url"]."
"; $wins++; } echo "
Least visited your pages
"; while (($row = mysql_fetch_array ($inc_result)) & ($lose < 2)) { echo $row["hits"].": "; echo "".$row["url"]."
"; $lose++; } echo "
All pages:
"; while ($row = mysql_fetch_array ($result)) { echo $row["hits"].": "; echo "".$row["url"]."
"; } echo "" echo "" mysql_free_result ($result); mysql_free_result ($dec_result); mysql_free_result ($inc_result); ?>