editdb.html Contents fonts.html


count_admin.pl
For Linux/Unix/NT)
CGI script for Site admins/users to manipulate counter databases
(This program is part of WWW Homepage Access Counter 2.6+)

Description
count_admin.pl is 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.85 or GNU gdbm. It uses Perl modules DB_File for Berkeley db and DBM_File for GNU gdbm. count_admin.pl has 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.pl will 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 (with 1.85 API). 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. ActiveState Perl 5.6 (as of Sep-27-2000) comes with DB_File module, but it does not work. So you've to install it again .Here is a session of mine (open a command shell first):


C:\> ppm
PPM interactive shell (2.1) - type 'help' for available commands.
PPM> help
Commands:
    exit              - leave the program.
    help [command]    - prints this screen, or help on 'command'.
    install PACKAGES  - installs specified PACKAGES.
    quit              - leave the program.
    query [options]   - query information about installed packages.
    remove PACKAGES   - removes the specified PACKAGES from the system.
    search [options]  - search information about available packages.
    set [options]     - set/display current options.
    verify [options]  - verifies current install is up to date.
    version           - displays PPM version number

PPM> install DB_File
Install package 'DB_File?' (y/N): y
Retrieving package 'DB_File'...
Installing C:\Perl\site\lib\auto\DB_File\DB_File.dll
Installing C:\Perl\site\lib\auto\DB_File\DB_File.exp
Installing C:\Perl\site\lib\auto\DB_File\DB_File.lib
Installing C:\Perl\site\lib\DB_File.pm
Installing C:\Perl\site\lib\auto\DB_File\autosplit.ix
Writing C:\Perl\site\lib\auto\DB_File\.packlist
PPM>quit

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 auth database editing permission, Unix crypted password, url of document root/s user can manipulate, all separated by a vertical bar |.
Syntax:

userid|1 or 0|crypted password|comma separated doc root

Example:

admin|1|sdfjkei78ddky|http://www.muquit.com/,http://209.145.38.154/
muquit|0|qcLbxyYBzbwHg|http://www.muquit.com/muquit/,http://209.145.38.154/muquit/

In the first line, the first field admin is the user id, the second 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://209.145.38.154/ are the URLs of document root user admin is allowed to manipulate.

In the second line all the fields are similar except the second field, which 0 indicating that the user muquit is not allowed to 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.

I supply a CGI program called count_admin_help.pl to help you to create the count_admin.txt file. Have a look at the screenshot

Authentication database
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:

images/deny_authdb.gif

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.pl and count_admin_help.pl to your cgi-bin directory. To run the scripts, access the URL via your web browser:


http://your_host/cgi-bin/count_admin.pl
http://your_host/cgi-bin/count_admin_help.pl

Some screenshots of count_admin.pl CGI

count_admin_fig1.png
Figure-1: Authenticating as user muquit

count_admin_fig2.png

Figure-2: After pressing Edit Hits:

count_admin_fig3.png
FIgure-3: After pressing Edit Authdb


Page last updated: Sun Oct 1 18:17:22 2000


editdb.html Contents fonts.html