Latest Release: September 17, 1995
Initial Release: April 13, 1995
Count 2.0 will be released this weekend. It will have resonable defaults for all parameters. Therefore, QUERY_STRING can become significantly short.
Features of Count 2.0
(Expected release date: October 22, 1995)
- Resonable defaults for all QUERY_STRING parameters.
- QUERY_STRING parameters can be in any order and not case sensitive.
- Counter can be displayed without incrementing.
- A literal digit string can be displayed.
- A random digit string can be displayed as counter.
- No need to specify width and height of digit images.
- The frame and transparent color can be a name (e.g., red, violet etc) as well as RGB triplets as before.
- The counter can be called as simply as:
<img src="/cgi-bin/Count.cgi?df=count.dat">or as complex as before. or any attribute can be set independently.Note: all the coding of release 2.0 is done by Kevin J. Walsh. Please do not bother him with any questions regaring the counter.
October 10, 1995
This program is compiled and tested on a Sparc 10 (SunOS 4.1.4) running NCSA httpd 1.4 , CERN httpd 3.0, APACHE httpd, (gcc 2.6.3).
It is reported that it runs on
Linux, Solaris 2.x, BSDI SGI IRIX 5.3, AIX 3.2.5, HP-UX-?, Ultrix 4.3, SCO
Note for BSDI: remove the line #include <malloc.h> from count.h and combine/combine.h.
Note for AIX: add a flag -lbsd in Makefile, (reported by pivari@agip.geis.com.)
$(CC) $(CFLAGS) -o Count.cgi $(OBJS) combine/libCombine.a -lbsd
Note for Solaris: add -DSYSV with CFLAGS in Makefile.
The program is distributed as a gzip'd tar archive. If you do not have gzip/gunzip, it's available at: prep.ai.mit.edu.
For a huge collection of GIF digits, check out the Digit Mania page.
This machine is getting enormous number of ftp requests lately. Therefore, I had to impose a limit of maximum 10 ftp connections at one time. The limit will go up to 50 maximum connections at 11:00 PM US Easern Statndard Time and go back to 10 maximum connections at 6:00 AM US Eastern Standard Time.
Sorry for the inconvenience!
current local time is:
You can look at the log of the latest 10 ftp sessions.
For your information, here's the file transfer statistics from Septermber 15 till today.
gunzip < wwwcount1.5.tar.gz | tar xvf - cd wwwcount1.5The program will compile with ANSI or non-ANSI C compiler.
Note that the directives ConfigDir, DigitDir, DataDir and LogDir must define 4 separate directories, that is any of them can NOT have the same directory. Ok, this is what you need to do, first decide where you want to keep Counter related things. Let say, you want to keep Counter related things to the directory /usr/local/etc/Counter. If this directory does not exist, create it first, and then create 4 separate directories inside it, for example:
mkdir /usr/local/etc/Counter cd /usr/local/etc/Counter mkdir conf mkdir digits mkdir data mkdir logs
#define ConfigDir "/usr/local/etc/Counter/conf"
#define ConfigFile "count.conf"
#define DigitDir "/usr/local/etc/Counter/digits"
Make sure that this directory is searchable by the User defined in httpd.conf or by the Group defined in httpd.conf.
#define DataDir "/usr/local/etc/Counter/data"
#define LogDir "/usr/local/etc/Counter/logs"
#define LogFile "Count15.log"
make clean make
A block starts with { and ends with } in two separate lines. Note however, that this file can not have any empty line anywhere outside the blocks. If any empty line exists in this file, the program will act crazy. Therefore,
{ }is a valid block. The beginning block defines the IP address of the hosts to ignore from counting. Example,
{ 192.160.166.90 192.160.166.92 }Each IP address has to be in a separate line and the maximum number of 100 hosts can be ignored. If you want to change it, edit the variable MaxSites in count.h. If you do not want to ignore any machine, just keep the block empty, like:
{ }Wildcard can be used to ignore a entire domain, if the IP address starts with a number >= 192 and <= 223, the network is Class C, to ignore the entire domain of class C, put a * at the 4th octet like, 192.134.144.*
If the IP address starts with a number >= 128 and <= 191, the network class is B, to ignore the entire domain of class B, put a * at the 3rd octet like, 128.116.* or 128.116.*.*
If the IP address starts with a number < 128, the network class is A, to ignore the entire domain of class A, put a * at the 2nd octet like, 20.* or 20.*.*.*
You can use the full IP address for a specific host ofcourse, but if wildcard exist for this domain, it will take precedence.
However you CAN NOT omit this block. The left and right braces must present at two separate lines if you want to keep the block empty.
The second block is called Authentication block. This block must exist if compiled with -DACCESS_AUTH option. Each line contain hostname/IP address of the host who can access the counter. In my configuration file, this block looks like this:
{ warm.semcor.com www.semcor.com warm www 192.160.166.1 }Here, warm.semcor.com is the machine I run the httpd server. I also have an alias defined for it, which is www.semcor.com. It also can be accessed locally by warm or www. The machine can be addressed with it's IP address as well. Replace them with your host. If you do not have any alias defined, just remove the line with www.semcor.com. Here, you also can give remote access to any hosts you like, just add another line with the host name.
For example, look at the supplied count.conf file. A Complete configuration file might look like this:
############################################# # sample configuration file for Count 1.5 # by muquit@semcor.com # 09/13/95, 9:15 PM ############################################## # # Note: NO EMPTY LINE IS ALLOWED IN THIS FILE # ############################################## # Ignore hosts block, you might want to ignore the local sites. # THIS IS A REQUIRED BLOCK. If you do not want to ignore any hosts from # counting, just put { on one line and } on the next line but make sure # the braces exist! ###### # # wildcard can be used to ignore a entire domain, if the IP address starts # with a number >= 192 and <= 223, the network is Class C, to ignore the # entire domain of class C, put a * at the 4th octet like, # 192.134.144.* # if the IP address starts with a number >= 128 and <= 191, the network class # is B, to ignore the entire domain of class B, put a * at the 3rd octet like, # 128.116.* or 128.116.*.* # if the IP address starts with a number < 128, the network class is A # to ignore the entire domain of class A, put a * at the 2nd octet like, # 20.* or 20.*.*.* # # you can use the full IP address for a specific host ofcourse, but if # wildcard exist for this domain, it will take precedence # { } #### # Access authentication aka "Counter Terrorism" handling block # This block must be present if you compile with -DACCESS_AUTH option # If you do not compile with -DACCESS_AUTH, this block will not be # read # Each line contain the hostname/IP address of the host who can access the # counter remotely. Yout hostname must be here. ### { warm.semcor.com warm www.semcor.com www 192.160.166.1 charlie }
testcount.sh
Copy the configuration file (you defined with ConfigFile)to the directory (you defined with ConfigDir). Make sure that the directory is accesible and the configuration file is readable by httpd.
Copy the digit directories A, B, C, D etc. to the directory you defined with DigitDir
If you already didn't create the data directory (you defined with DataDir make the directory to the correct place.
If you didn't create the log file directory (you defined with LogDir), create the directory as well. You do not have to create the log file, it will be created if needed, only make sure that the log file directory has write permission to httpd.
ft=9 ft means frame thickness. If you want to wrap the counter with a ornamental frame, you define the frame thickness like this. Here 9 is the thickness of the frame in pixel. This value can be any positive number more than 1. For nice 3D effect, use a number more than 5. If you do not want frame, just use ft=0. frgb=69;139;50 frgb defines the color of the frame. Here 69 is the red component, 139 is the green component and 50 is the blue component of the color. The valid range of each component is >=0 and <= 255. The components must be separated by ; character. Note even if you define ft=0, these components must be present, just use 0;0;0 in that case. tr=0 tr defines if you want transparency in the counter image. here tr=0, that is I do not want transparent image. If you want transparent image, define tr=1. Note that Coun.cgi, does not care if your digits are transparent GIFs or not. You must tell explicitly which color you want to make transparent. trgb=0;0;0 if tr=1, then black color of the image will get transparent. Here 0;0;0 are the red, green and blue component of the color you want to make transparent. wxh=15;20 wxh string defines the width and height of an individual digit image. Each digits must have the same width and height. If you like to use digits not supplied with my distribution, find out the width and height of the digits and specify them here. md=6 md defines the maximum number of digits to display. It can be >= 5 and <= 10. If your counter number is less than md, the left digits will be padded with zeros. Here md=6 means, display the counter with maximum 6 digits. f you do not want to left pad with zeros, use pad=0 instead of md=6. Note you can either use md=some_number of pad=0, in this field, you can not use both. If you use pad=0, then the digits will be displayed exactly without padding. dd=A dd means digit directory. A indicates, it will use my LED digits located at the directory A. The base of the directory A is defined with DigitDir at step 1. st=5 st means start, that is start the counter with this value. st is only significant if you compiled the program with -DALLOW_FILE_CREATION. If you compiled with this option, the datafile will be created to the directory defined byDataDir in the config.h file and 5 will be written to it. . sh=1 sh mean show. If sh=0, then no digit images will be displayed, however a transparent 1x1 transparent GIF image will be returned, which will give the illusion of nothing being displayed. Althouh it will seem that nothing is displayed, the counter will be incremented all right. . df=count.dat finally df means data file. This is the file which will contain the counter number. The base directory of this file is defined with DataDir in config.h file. If you did not compile with the flag -DALLOW_FILE_CREATION, this file must exist. To create this file, at the shell prompt do this: echo 1 > count.dat or use a editor to create it. If you compiled with the flag -DALLOW_FILE_CREATION, the file will be created and the value defined by st will be written to it. Make sure that the directory has write permission to httpd.
<img src="http://foo.com/cgi-bin/x.cgi">That is, someone somewhere on the Internet can refer to your counter and increase the hits and you will not have a clue. You will get the false impression of many people visiting your page. You can look at the so called "Counter Terrorist" page for demo.
So how this program handles this? It handles it in two ways, first if you compile with -DACCES_AUTH flag, it will try to get a environment variable called HTTP_REFERER for remote referer. It is necessary to check this variable because when someone remotely refer to a CGI program to your machine, the variable REMOTE_ADDR will be the address of your machine. So checking REMOTE_ADDR will not work. Most of the moderm browsers returns the env variable HTTP_REFERER. If the browser does not return the variable, counter will be served anyway. But you are not lost totally here. If you decided to ignore count for your host running httpd, the counter will be served but it will not be increased. So, I suggest ignore count for your host and also compile with authentication feature.
Change directory to the directory where GIF images of digits zero through nine are kept. Then use display program comes with ImageMagick to edit the color. type:
display *.gif click middle mouse button on image for magnification window click left mouse button on image for command window Image Edit->Color Pixel Color-> Method->replace place cursor anywhere on green area and click left mouse button Dismiss File->Save Save for next digit, press right mouse button image and select Next or press n. Change color the same wayOr use the program mogrify comes with ImageMagick. mogrify can change a specific color of all the images at one shot. For example, if you want to change the green color to white, do this:
mogrify -pen white -opaque green *.gif
Muhammad A Muquit SEMCOR, Inc. 65 West Street Road Warminster, PA 18974 USAThanks.
Enjoy!
Thanks to John Anthony Ruchak for beta testing Count 1.5.
(September 10, 1995)
Last Update: September 17, 1995