ksl-count Page


Introduction
What Can It Do
How 2 Use it
Advance Features
Installation
Data Structure
ksl-count in Action!
Gimme!
Example
Good News
GuestBook
Credits


Do not send me mail regarding on what's going on/wrong before you read this page! VISIT THIS PAGE! Book Mark This Page.

Counter service has been shut down from now on. It has generated too much traffic to the server load. I appreciate all the support that you all have given to me so far. Unless, there is a new host for this service, it will not be servicing from now on. 14/June/96

What's New?

Sponsorship is welcome!


Introduction I started to get involved in writing the counter script when I became the webmaster of the KU EECS department. I got a counter script(PERL) from a friend; however, I wasn't able to get it to work. Therefore I started to hack in to the code. Finally, I came out with a very simple counter, ksl-count. After that, I became more interested in when the requests from a friend started to increase. Now the script is totally different from the original code.
What Can It Do? This counter allows you to have as many counters as you want. Therefore, you can put one counter to every single page to check out which is the WORST page that you should get rid of! :)

Also, it generates a file that has all the valuable information:

  • Hits perday
  • Last 20 users
  • Highest hit so far
  • Daily statistics
  • Monthly statistics
  • Number of different countries that has visited your page
  • Number of accesses by each country
  • This file is already in HTML format!
Not Servicing Anymore!!
How 2 Use it? There are two ways that you can use this service. If you have a falcon account, then you follow the KU Falcon Users section. Otherwise, follow the section on Everyone Else.


KU Falcon Users

First, you have to create a file in your HTML directory, let say count1. I recommend creating a directory specifically for all the counter files. This will make the directory looks a bit cleaner. : ) Then change the mode to group writable. You can do this by using:

	chmod 664 count1

Next, create another file with the exact file name but with the extension .html, that is for count1, it will be count1.html. eg:

	touch count1.html
Change its permission to 664 as well. This file contains valuable information that you want.

Finally, you have to call this script as an image file, because the script generates a bitmap file on the fly. Here is an example:

	<a href="counter/count1.html">
	<img src="/cgi-bin/buddha/ksl-count2?homee/buddha&counter/count1"> 
	</a>
 
Here counter is the directory that you created earlier for all the counter files, and ksl-count2 is the cgi-bin script that generates the bitmap file. homee/buddha is the home directory and counter/count is the path to where the count is written. So, it is clear that you have to pass in your home directory and the path of the counter file. In case that you still do not know what I am talking about, use this form to help yourself.

Actually there is an easy way to skip all those file creations, and mode changing troubles. You can just change your directory to world writable, that is change the permission of counter directory to 646. This allows the script to create the file itself. But, there might be a security problem for this way. People might do something to that directory. However, it all depends to you user. I DO NOT ENCOURAGE THIS METHOD.


Everyone Else!

You have to call the script as an image file. Perhaps an example would better explain it all. (just add something like this to your page)

	<a href="http://falcon.cc.ukans.edu/~buddha/counters/KU_skang_num1.html"><img 
	src="http://falcon.cc.ukans.edu/cgi-bin/cgiwrap/buddha/ksl-count2?KU_skang_num1"></a>

Here KU stands for the name of my college, skang is my username, and num1 is the file name. Therefore, you must put in your:
  • university's name(it's better to use shortform here)
  • username
  • file name
If you find out that the counter does not return a number "1", then there is a possibility that you are using a file that has already been created by another user. Then, change your file name to another name.

Here is a help page for your convenience.

The reference allows you to look at the last 20 visitors and some useful information which you die to know. : )

Advance Features There are currently four features available.
  • font : Font style. Default is d2.
  • len : Length of digits to be displayed. If set to 0, then you will have a hiden counter.
  • num : Reset the counter value.
  • border : Border, 1 for a border, and 0 for no border. Default is 0.

There are 2 font styles available right now. However, with the invertion, it sort of makes it become 4! They look like these(without border):
  • id1(inverted)
  • d1
  • id2 (inverted)
  • d2

When using an option, you should use "[" after the filename followed by the option argument(s) and a "-" followed by the value. For example, to use font d2, you do something like this,
	<img src="http://www.eecs.ukans.edu/cgi-bin/ksl-count2?skang&counter/num1[font-d2">

Here is another example showing all the options being used for one single counter.
	<img src="http://www.eecs.ukans.edu/cgi-bin/ksl-count2?skang&counter/num1[font-id2&border-1&len-7&num-54321">

This will create a counter which looks like this :
Here, font is the option argument, and - as a separator between the value and the argument. An "&" to separate arguments. Remember if you are reseting the counter, please, use it for once and remove that option then. If you do not remove the option, it will print the same number all the time. I encourage doing this on the browser without putting it on your page. Just open the URL to the image file. For example, click on the open button, and type this in,
	<img src="http://www.eecs.ukans.edu/cgi-bin/ksl-count2?skang&counter/num1[num-100">

This should bring you to an image file with value equal to 100. Then only you call the counter script.
Do not forget to change the username and the filename.
Installation If you just need a counter to appear in your home page, then you do not need to install the script. You need to go to the section on How 2 Use It. If you do not know what cgi-bin is, then you probably do not need to install.

To install this script is easy. First you have to have access to the cgi-bin directory. Second you must have Perl installed. If you have both of them, then put this script to that directory, and modify the file paths in the script. There are three types of services that you can set up for.

  • Single user, only you can use it
  • Multi users, all users on the server can use it
  • All users, everyone in this world can use it

All Users
If you are willing to offer the counter service to all other people that are not users on your machine, then you have to modify these(they are at the initialize sub routine):
	$root = "/tools/www/common/db/counters" ;
	$htmldir = "/users/$user/.public_html" ;        # html directory

Here, $root is the directory where you want the counter files to be written to(for users that are not on your machine). Change the $htmldir to the path of where the local users would put their html documents at.

Then, you need to create a directory as it was specified by $root, and make it with permission 747. This will allow the script to create counter files in that directory. You are done! Isn't that EASY?

Single User
If you are using it for yourself, then comment out the second block of the if-else block in initialize,
	#if ( length ($file) == 0 ) {    # for users other than EECS students   
                $logfile = "$root/$user-visit.html" ;
                if (!-e $logfile) {     # new file! use new extension
                        $logfile = "$root/$user.html";
                }
                $counterFile = "$root/$user" ;
        #} else {
        #	$htmldir = "/users/$user/.public_html" ;        # html directory
        #	# file where all data is written
        #	$logfile = "$htmldir/$file.html" ;
	#
        #	# path to where the count should be written to
        #	$counterFile = "$htmldir/$file" ;
	#}

Change the $root to the dir where you want the log files to be. You are DONE!

Multi User
Comment out the first block of the if-else statement. It should look like this,
        #if ( length ($file) == 0 ) {    # for users other than EECS students
        #        $logfile = "$root/$user-visit.html" ;
        #        if (!-e $logfile) {     # new file! use new extension
        #                $logfile = "$root/$user.html";
        #        }
        #        $counterFile = "$root/$user" ;
        #} else {
               $htmldir = "/users/$user/.public_html" ;        # html directory
               # file where all data is written
               $logfile = "$htmldir/$file.html" ;
        
               # path to where the count should be written to
               $counterFile = "$htmldir/$file" ;
        #}

Modify the $htmldir to the home dir of the users on your server. This setup requires username and counter file as arguments when calling the script in the html file.

How To Call It?
Now that you have already set up the server, it is time to call the script from you web page. There are a few things that you need to know before you can make the call:
  • What is the user ID of your web server?
  • What is the path that you set for the script to write the data files to?
Normally, the web ID is set to nobody or not to you. The best way to try this out is to set the directory where you want the data files to be stored to 755. If this does not work, then change it to 775. If this still doesn't work, then change it to 757. If these three do not work, then there is something wrong with your setup, or your path. I DO NOT recommend setting up the dir to this kind of permission, I recommend setting it for the files.

FOr information on how to call it, please refer to How 2 Use it?

Data Structure For the Falcon users who have the counters in their directories, and wish to modify their records, here is the information on what each line represent. Here is a sample data file and its meaning:
	3253   	 current count
	1501	 yesterday's hits
	1090	 total hits in a day
	28	 date counter last accessed 
	1501	 highest count
	96/03/26 date counter first created or reset
	2162	 total count for this month
	31 03	 total days of the month & the month

I encourage you not to mess with it because you might screw things up. ;->
ksl-count in Action! Here are a list of the sites that are currently running ksl-count2 on their sites which I found using the search engines.
Gimme! These source codes can be freely copied by non-profitable use. You cannot use it to make any profit.

There are two source codes available right now, ksl-count and ksl-count2. ksl-count is just a very simple counter. It allows only one counter per user. On the other hand, ksl-count2 is more powerful. It allows multiple use for one user, and it generates a useful information page which is described above. Now, get the source.

Here is a version history of the code.

There are some other cgi-bin scripts that I have written since my addiction to the web. They are basically form manipulation scripts. You can get them at FreeNShare.

Example You are user number counter . Just click on the number to view the valuable information!
GuestBook It will be much appreciated if you could sign the guest book, and tell what you feel about this counter.
Credits Here are a few people who deserve the credits for this ksl-count script. I don't know any of them, but I did get the original code from these people, odometer.xbm.

Original C code: Frans van Hoesel (hoesel@chem.rug.nl)
Original port to Perl: Dan Rich (drich@corp.sgi.com)
Modifications for cgi: Michael Nelson (m.l.nelson@larc.nasa.gov)
Modifications for NSF: Mike Morse (mmorse@nsf.gov)
Original version: Michael Breen mbreen@ucsd.edu


buddha
First created: Sat Jul 22 1995, 08:07:01 AM

Copyright © 1996
Author: Kang SoonLai EMAIL