#!/usr/bin/perl -w use strict; use CGI::Request; use DBI; require 5.005; $| = 1; # OUTPUT_AUTOFLUSH my $req = new CGI::Request; my $DataKey = "domain"; my $Driver = 'mysql'; my $DataBase = 'webstat1'; my $Table = 'sites'; my $User = 'statadmin'; my $Password = 'statsrus'; my $dbh; my @Fields = qw( priority domain server_name server_type log_code log_location ip_addr username timestamp ); my $button = (defined($req->param("button"))) ? $req->param("button") : "Default"; my %FormData = getformdata(); ## MAIN ################################ MAIN: { db_connect(); search_page() if ($button eq "Search" || ( $button eq "Default" && !defined %FormData)); form_page() if ($button eq "Find Record" || $button eq "Cancel" || ($button eq "Default" && defined (%FormData))); edit_page() if ($button eq "Edit"); add_page() if ($button eq "Add Record"); save_record() if ($button eq "Save"); delete_record() if ($button eq "Delete"); db_disconnect(); } ## Subroutines ########################## sub getformdata() { my $p; my %F; foreach $p ( @Fields ) { $F{$p} = $req->param($p) if (defined ($req->param($p))); } $F{record} = $req->param("record") if (defined ($req->param("record"))); $F{savetype} = $req->param("savetype") if (defined ($req->param("savetype"))); return %F; } sub print_htmlheader() { print "Content-type: text/html\n\n"; print <<__END_OF_HTML__;