|
Introduction What Can It Do How 2 Use it Advance Features Installation Data Structure ksl-count in Action! Gimme! Example Good News GuestBook Credits
|
|
| 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:
|
| 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. |
| |
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.
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:
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.
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):
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.
|
|
|
|
| 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?
| |
| |
|
| 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!
| |
| |
|
| 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:
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 |
| 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 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
First created: Sat Jul 22 1995, 08:07:01 AM
Copyright © 1996
|