CGI scripts
Here I would like to launch CGI scripts which are being used in this site.
Access Log
Access Counter
Features of these scripts
- Access Log
They work fast, minimize server's load and automate handling of log file by opening log file update mode, using seek/truncate function and avoiding to read log file through the end to count the number of log data. Similar technique is used by access counter script. Simple but works well. It's my recommendation.
- Access Counter
You can easily change the scripts when you want to reverse numeric order like Arabic digits.
They are small scripts made of scores of codes. I am pleased if they would be helpful for you.
All the scripts are in the public domain. You can use them freely at your own risk. The author bear no responsibility, no liability and no obligation for your use of these scripts. Links to this page and republishing of the scripts are free. I would like to know where this page is linked and they are republished, so please e-mail to me on later if possible. Refer here about the copyright policy in this web-site.
Script to record access and download log and mail them automatically when log file becomes full ... CGI version
Do you want to know how your visitors hit your pages and data? If you think so, this script is what you need.
This CGI takes perfect logs (access and data-download) of your site and e-mail them automatically to you. I had searched in the Internet but could not find any suitable for my purpose, so I made it.
The original script is mail-log.cgi by Mr. Walter Soldierer. I add some codes to work mail-log.cgi without SSI and I changed it to take both access-log and data-download-log. Many thanks to Mr.Soldierer permitting me to launch this CGI in my site.
The log now being recorded is here.
How to use
- Push the source button above, display the script and keep it (default name is cgilog.txt).
- Rename cgilog.txt to cgilog.cgi.
- Set up the parameters of cgilog.cgi according to your environment.
- Prepare empty LogFile. Click here and keep it with a name (zero Bytes text file, default name is logfile.txt).
- Right-click the transparent part right here (transparent GIF file named new.gif) and keep it with a name (You can use other files if you change cgi-script) .
- Change HTML sources where you want to record logs.
- Transmit logfile.txt, cgilog.cgi and the tranparent GIF file to host. Change the permission value of logfile.txt to 666 and cgilog.cgi to 755.
Refer to the comments of the script about the set-up.
Script to record access log and mail them automatically on the next day ... SSI version<
I had opened this site with the scripts above. Examining log data, I found that the browser which did not show images did not leave log data.
Only download logs and no page access log. Did this mean a script's bug? But I thought it again and noticed that would be a browsing without an image. Dear Robot!
Thereby, I knew that SSI method was inevitable to take log. So I changed the script to work in SSI mode and to send a mail on the next day.
How to use
- Push the source button above, display the script and keep it (default name is ssilog.txt) .
- Rename ssilog.txt to ssilog.pl.
- Set up the parameters of ssilog.cgi according to your environment.
- Prepare empty LogFile. Click here and keep it with a name (zero Bytes text file, default name is logfile.txt).
- Add the line below to HTML sources to record logs.
<!--#exec cmd="./ssilog.pl"-->
The part './ssilog.pl' should be changed according to your environment. The sample above means you must place ssilog.pl in the HTML's directory. You can use either absolute or relative path.
- Transmit logfile.txt, cgilog.cgi and the tranparent GIF file to host. Change the permission value of logfile.txt to 666 and cgilog.cgi to 755.
Refer to the comments of the script about the set-up. More detailed comments are in the cgilog.cgi. Setting of a gif file is unnecessary because it works by SSI method.
Arranged versions of these two scripts
- Script to record access(SSI) and download log(CGI) and mail them automatically when log file becomes full
For recording both access and download log. It is a combined version of above two scripts. You must use CGI method to record download log, thereby it becomes a hybrid script of CGI & SSI.
Add the line below to HTML source to record download log.
<A HREF="./.../downlog.cgi?xxxx">....</A>
Refer to the comments of cgilog.cgi about the part "xxxx". It is a second parameter(ARGV[1]) of cgilog.cgi.
To exchange the timing to mail is easy. Here is an arrangement of this script to send mail on the next day. Compare the scripts. You can understand how to change them.
- Scripts used in my site
They are CGI scripts to record only either access or download log.
Download-log script has not a send-mail function. Thereby it's very simple, only 20 steps.
I have used access-log script on the top page in NiftyServe(the Japanese largest commercial BBS) which has not permitted the use of CGI. Adding URL-HREF tag in that page, I can record a log by using the server which permits CGI.
In this script ARGV[0] must be written in HREF tag because I don't know how to get HTML document name with CGI method. If you know that, please tell me via Email or in the guest book.
CGI access counter
I have an access counter of Arabic digits in my top page. CGI version is for the top page placed on NiftyServe which does not permit CGI. I place this script on the server which permits CGI and call the script by HREF-URL tag.
I made it from access log scripts above. Very simple. Only 20 lines but it works well.
Click here. You can see 13 figures Arabic counter.
How to use
- Push the source button above, display the script and keep it (default name is cgicount.txt) .
- Rename cgicount.txt to cgicount.cgi.
- Set up the parameters of cgicount.cgi according to your environment. Usually you can use it with default settings.
- Prepare a counter file. Click here and keep it (zero Bytes text file, default name is counter.txt).
- Prepare count-gif file. If you don't have any, click here("Digit Mania", Great achieves of wonderful counters. I found Arabic digits there. Many thanks to "Digit Mania" and Mr Ahmad Al-Nusif, the author of Arabic digits).
- Rename them 0.gif 1.gif ... 9.gif.
- Add the lines below to HTML source where you want to set a counter.
This is a sample of four figures counter.
<IMG SRC="./cgicount.cgi?4+1" ALT="?">
<IMG SRC="./cgicount.cgi?3" ALT="?">
<IMG SRC="./cgicount.cgi?2" ALT="?">
<IMG SRC="./cgicount.cgi?1" ALT="?">
The part "./cgicount.cgi" should be changed according to your environment. Above means you must place cgicount.cgi in the same directory of the HTML page in which you want to set up a counter.
"?n" indicates a column number. "+1" indicates to count up when CGI script display the column.
Thereby, if you want to change column size, add or delete IMG tag.
- Transmit counter.txt and cgicount.cgi to host. Change the permission value of counter.txt to 666 and cgilog.cgi to 755.
- Make directory(default name is "image") for counter.gif in your cgi directory , change the "image" directory and transmit number.gif.
The vital point of this script is the use of ARGV[1] to show count-up timing explicitly from MTML source. You can only change HTML source to reverse a numeric order. It's a desperate way taken under the pressure of necessity to use Arabic digits.
SSI mode access counter
You should confirm your server allows SSI. If not, you must abandon to use this script. Use CGI script.
CGI script has problems below (practically they doesn't matter so much. You can confirm this by the sample CGI and SSI).
- As CGI counter is called per column display,
Should be slow
May display numbers in disorder
Must be increasing server's load
- As the order to display number.gif depends on cliant's request and can not be simultaneous with CGI's count-up timing,
There is a possibility of the inconsistency between counter file and monitor(The contents of counter file is exact).
There are a few measures to avoid this problems. But they make a script large and complicated.
For this reason. I decide English top page of this site uses SSI method.
SSI method makes the script simpler but its speed is only a feeling.(^^;;;Here is a sample of 13 columns SSI counter. Compare it with CGI sample.
How to use
- Push the source button above, display the script and keep it (default name is ssicount.txt) .
- Rename ssicount.txt to ssicount.cgi.
- Set up the parameters of ssicount.cgi according to your environment. Usually you can use it with default settings.
- Prepare a counter file. Click here and keep it (zero Bytes text file, default name is counter.txt).
- Prepare count-gif file. If you don't have any, click here("Digit Mania").
- Rename them 0.gif 1.gif ... 9.gif.
- Add the line below to HTML source where you want to set a counter.
<!--#exec cgi="./ssicount.cgi"-->
The part "./ssicount.cgi" should be changed according to your environment. Above means you must place ssicount.cgi on the same directory of the HTML page you want to set a counter. You can use absolute or relative path.
- Transmit counter.txt and ssicount.cgi to host. Change the permission value of counter.txt to 666 and cgilog.cgi to 755.
- Make directory(default name is "image") for counter.gif in your cgi directory , change the "image" directory and transmit number.gif.
This script is easily arranged to reverse numeric order. If you are interested in, please click here.
All codes of this script is arranged by me. Therefore I am responsible to the questions about these scripts. Do not ask Mr.Soldierer directly.
Home