database.html Contents count_admin.html

Program to manipulate WWW Homepage Access Counter databases
(This program is part of WWW Homepage Access Counter 2.6+)


 Usage: ./editdb [options] <db file>
 Where the optins include:
  -c              show the command set
  -f textfile     read items from text file and insert to the database
  -n              don't lock database (use for testing only)
  -o              overwrite items while loading data
  -v              show the version info
  -q              be quiet

The syntax of text file to load in database is:
If the value is empty, it will be calculated.
To specify key from stdin, use the filename as -
 echo ">" | editdb -f - foo.db

Note: If the database does not exist, it will be created

editdb is a program to manipulate WWW Homepage Access Counter databases. It can be used to manipulate existing database or to create a new one. The program is compiled with one of the Berkeley Db 1.x, 2.x, 3.x, GNU gdbm, ndbm or sdbm. The system is probed for the available databases, first for Berkeley Db, then GNU gdbm and then ndbm. For robustness and reliability, use Berkeley Db. It's available at

The program takes the database path as its first argument. If the database does not exist, it will be created. The type of database is compiled in the program. The data is stored in the database as key and value pairs. For example, For the counter database, the key is the HTTP referer URL and value is the hit:remote_IP. For authentication database, the key is the URL and value is the comment.

New data to the database can be loaded in two ways, interactively or from a text file. Text file should be used if you want to insert large amount of database. Please read the section LOADING DATA for the format of the text file.

Note, the program locks the database while editing, so do not stay long in vedit mode as database will be locked and counter will hang. You'll see messages about locking and releasing the lock.

Command set
After the successful startup, the program goes to a command loop, the following commands are available:

 add            add data
 edit string    search database and edit
 md5 string     show MD5 digest of a string
 vedit string   search database and edit with your editor
 delete string  search database and delete
 dump [file]    dump the content of database
 !command       execute a shell command
 search string  search database and show
 load file.txt  load to database from text file, same as -f switch
 cls            clear screen
 version        show the version info
 quit           quit

add - the program will prompt for the key and value to store.

edit string - the program will search the database for the string and display the out by numbering 1 to n. You will be prompted to enter the number to edit. As all the keys of the counter database has http in it, you search for http to search for all the items in counter database. The search is case in-sensitive and partial.

vedit string - works same as edit. Only difference is you will edit the items via your editor. The default editor is vi. You can set your editor by setting the environment variable EDITOR. When in your editor, separate the key and value with the string =>.

$ editdb /usr/local/etc/Counter/db/Authdb
(Current database:Authdb)
Command> vedit http
<*> Locking database
<*> Unocking database
<->Lock released.

8 items matched.
   3. http://localhost/=>c9db569cb388e160e4b86ca1ddff84d7
   4. http://localhost/index.html.en=>c9db569cb388e160e4b86ca1ddff84d7
   5. http://localhost/tc/=>d255dbabb12267dd9da769d529fc474e
   6. http://localhost/tc/index.html=>d255dbabb12267dd9da769d529fc474e
   7. http://localhost/tc/test.html=>5613f9e2ab0b292ca8a7b582f73e22bc
Enter the number to edit, * to edit all, Q to quit: *

Starting editor: vim

## editdb 1.2
## Edit WWW Homepage Access Counter database editor
## Syntax is:
## key=>value
## Lines beginning with a hash mark are comments.

delete string - search the database for the string and prompt for deletion. The deleted items can not be recovered.

dump [file] - dump the content of database. If no file is specified, the content will be dumped to stdout.

!command - execute a shell command (unix only).

search string - searches the database for the string and display the item on stdout. On Unix, the output will be piped to your pager. The default pager is more. You can change it by setting the environment variable PAGER.

load file.txt - loads the data to the database by reading a text file. It is same as the command line switch -f filename. The format of the file is:


Example of Authdb:

Example of Countdb:

cls - clears the screen (only on Unix).

version - shows version info. Example:

$ editdb version
(Current database:muquit.db)
Command> version

editdb version 1.2
Edit WWW Homepage Counter database. It supprts Berkeley DB
1.x, 2.x, 3.x, GNU gdbm, ndbm and sdbm.

*This version is compiled with Berkeyley DBHASH support

Author: Muhammad A Muquit
(Current database:muquit.db)
Command> q

quit - exit the program.

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:


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

See also

Muhammad A Muquit

Page last updated: Thu Jan 4 23:13:47 2001

database.html Contents count_admin.html