#!/usr/bin/perl ## ## updatefreq.cgi -- Presents the client with a form then updates the frequency data base ## use File::Copy; $FREQDB = "../freq/freq.db"; $BOILERHTML = "../freq/freqBoiler.html"; $BAKFILE = "../freq/freq.html"; $FREQHTML = "../freq.html"; $LOCK = "../freq/freq_lock"; # Global variables local ($arg = $ARGV[0]); local ($method = $ENV{'REQUEST_METHOD'}); # Test if creating a new data base if ($arg eq "create") { printf("Creating new database: '%s'\n", $FREQDB); creatdb($FREQDB); exit(0); } ## # GET: Called from the html anchor... //hostname/cgi-bin/updatefreq.cgi?freq=nn # or "//hostname/cgi-bin/updatefreq.cgi?config" to configure the environment # Builds a form and submits it to the client. Client will then submit the form (as type POST) # and recalls this program (which is processed by the "elsif($method eq "POST")") ## if ($method eq "GET") { local ($i, $freq, @inUseMembers); # Process the query string from the URL and snatch the $freq value $freq = $ENV{'QUERY_STRING'}; # Check if configuring the environment if ($freq eq "config") { config(); exit(0); } # Check if we're simply syncing up the database if ($freq eq "update") { update(); exit(0); } # List the database if ($freq eq "list") { list(); exit(0); } #Pick off the numeric part of the query string $freq =~ s/^.*=//; # Make a list of club members using this frequency @inUseMembers = split(/,/, mklist($freq, $FREQDB)); ## Build the HTML form and send it to the client ## MIME_header("text/html", "Frequency Update Form"); printf("

Update Frequency Use Database for Channel %s

\n", $freq); if (@inUseMembers > 0) { printf("

Club members currently using Channel %s:

\n", $freq); printf("\n"); } else { printf("

There are no club members currently using this frequency

\n"); } print <

Click the appropriate button below and select