CGI script for Site admins/users to manipulate counter databases
(This program is part of WWW Homepage Access Counter 2.6+)
count_admin.plis a CGI program written in Perl for users to manipulate their own counter values. If the admin authorizes, the user can also add delete URL in the authentication database. The program supports Berkeley Db 1.x, 2.x, 3.x or GNU gdbm. It uses Perl modules DB_File for Berkeley db and DBM_File for GNU gdbm.
count_admin.plhas a list of DBM format preferences, defined by @AnyDBM_File::ISA at the beginning of the program. The first found library will be the library
count_admin.plwill attempt to use for all DBM_File transactions. The counter installation program detects the type of database the counter is compiled with and put the database module at the beginning of the list. The installation program will copy it to your cgi-bin directory. Before using it, you have to create the text file for user authorization in cgi-bin directory (default path).
MS NT specific issues
The NT version of the counter is compiled to use Berkeley Db 3.3.11 Before using count_admin.pl CGI program on NT, you need to have Perl installed. I use freely availble ActiveState Perl on NT. You will also need the DB_File Perl module. I compiled DB_File with latest Berkeley Db 3.3.11
- Download DB_File-1.78_bin.zip (219521 bytes) (md5=6c38af61bde22acb146254037e5953bd)
After unzipping it, please read the README file.
In short, open a command shell and do the following:cd DB_File-1.78 ppm PPM> set repository a ./ PPM> remove DB_File PPM> install DB_File PPM> query DB_FileFor more info, please read the README file.
How to use
Before using the cgi program, you must create a text file called count_admin.txt in the same directory where the cgi program count_amdin.pl is. If you want to change the location modify the following line:my $guser_textdb='count_admin.txt';You can specify a different path if you like, but make sure the file is not accessible from a web browser.
The syntax of the file is user id, boolean value for user's counter hits editing permission, boolean value for user's auth database editing permission, Unix crypted password, comma separated url of document root/s user can manipulate, all separated by a vertical bar |.
userid|1 or 0| 1 or 0|crypted password|comma separated doc root
In the first line, the first field admin is the user id, the 2nd field 1 indicates that the user admin can edit the counter hits, the 3rd field 1 indicates that the user admin can edit the authentication database, the third field is the Unix crypted password and the fourth field http://www.muquit.com/,http://22.214.171.124/ are the URLs of document root user admin is allowed to manipulate.
In the second line, user muquit is not allowed to edit the counter database but can edit the authentication database.
Please be very careful about the document root you set for the user. In our example, the user admin can edit the counter values and auth db for the entire site, but the user muquit can only edit his counter values and manipulate his URLs in authentication database.
A CGI program called
count_admin_help.plis supplied to help you to create the count_admin.txt file. Have a look at the screenshot
Authentication database is a database of URL WWW Homepage Access Counter uses. If strict_mode=yes in count.cfg file, then anyone wants to put a counter in a web page, the URL of the web page must be in this database. If the URL is not in the auth database, then the user will get a message like below:
Putting URL is authentication database is analogous to creating data files for the users in older versions of counter. It gives the administrators some control.
Authentication database can be manipulated by the program editdb or by the CGI program count_admin.pl.
If you allow the users to edit this database by putting 1 in the second field in the line of the file count_admin.txt for the user, the user will be able ot put her URL by herself.
How to call
The installation script install the programs
count_admin_help.plto your cgi-bin directory. To run the scripts, access the URL via your web browser:
Some screenshots of count_admin.pl CGI
Figure 1: Authenticating as user muquit
Figure 2: After pressing View/Edit Hits (user is allowed to edit)
FIgure 3: After pressing View/Edit Authdb (user is allowed to edit)
FIgure 4: After pressing View/Edit Hits, (user is not allowed to edit)
FIgure 5: After pressing View/Edit Authdb, (user is not allowed to edit)
Page last updated: Tue Oct 23 23:24:43 2001