#!/usr/local/bin/perl alarm (300); # File name: db_util.pl # dbEase version 1.03 # MODIFICATIONS: Version upgrade to dbEase version 1.03 # # MODIFICATIONS to db_util.pl # 1. Simple text edit (09/29/98) # # Files affected as of (12/04/98) that instigated a version upgrade : # 1. go_get.pl last modified (12/04/98) # 2. idm.pl last modified (09/29/98) # 3. db_util.pl last modified (09/29/98) # 4. script_util.pl last modified (09/29/98) # 5. search.pl last modified (12/01/98) # Written by Kenneth Hubert ("production unit 6") # Copyright 1998, Stratum New Media, Inc. All rights reserved ## # #PROPRIETARY NOTICE # # (C) 1998 Stratum New Media, Inc. All rights reserved. Any unauthorized use of # this unpublished work (including reproduction) is prohibited. # Stratum New Media owns all rights to this work and intends to maintain this # information as proprietary and confidential. In the event of any inadvertent # or deliberate and unauthorized use or publication of such work, # Stratum New Media, Inc. will enforce any and all of its rights under all # applicable laws. # # Stratum New Media provides this report for the sole purpose of permitting the # recipient, a representative of InfiNet, to evaluate the proposal submitted. # In consideration of receiving this report, the recipient and any other agents # and representatives of InfiNet, agree to maintain the information in this # report confidential, and refrain from disclosing such information to any # third party or person outside the group directly responsible for this # evaluation. # # ############################################################### # Requires Perl 5.xx and CGI.pm ############################################################### ## ## This script provide interfaces for adding data to, modifying the data of, ## or deleting data from a table, as well as exporting to a comma delimited ## file of a table or deleting an entire table along with the tables Search ## and Result pages, if they exist. ## ## It excepts an array of parameters. the main routine handles the following ## parameters or the lack of these parameters : ## param 'tableName' ## param 'util' with values of : ## ADD, MODIFY, DELETE, EXPORT, ## EXPORT Table, DELETE Table, or VIEW. ## param 'view_what' with values of : ## View Definitions or View Data ## param 'CANCEL' ## the subroutines expect and pass a variety of parameters as well as the ## params listed above, and will be describe in the subroutines. ### use CGI; $query = new CGI; my $conf_file = "./dbEase.config"; require $conf_file; ################################################################### #---------------------------- MAIN -------------------------------# # # Conditionals to decides whether we're viewing : # - a 'text-box' from the Edit Search page screen of the # script_util.pl # - or an actual .._Search_HTML.page being called live ################################################################### ## if a table is not specified provide an interface to select one. if (!($query->param('tableName'))) { &print_form(); } ## if param 'util' is ADD goto the add screen elsif ($query->param('util') eq 'ADD') { &add(); } ## if param 'util' is MODIFY goto the modify screen elsif ($query->param('util') eq 'MODIFY') { &modify(); } ## if param 'util' is DELETE goto the delete screen elsif ($query->param('util') eq 'DELETE') { &delet(); } ## if param 'util' is EXPORT (calling from the navigation menu or ## from the delete table screen) ## goto the add screen. elsif ($query->param('util') eq 'EXPORT') { &export(); } ## if param 'view_what' is View Definitions ## (called from print_form if param 'util' is VIEW) ## goto the view definitions screen elsif ($query->param('view_what') eq 'View Definitions') { &view_defs(); } ## if param 'view_what' is View Data ## (called from print_form if param 'util' is VIEW) ## goto the view data screen elsif ($query->param('view_what') eq 'View Data') { &view_data(); } ## if param 'util' is DELETE Table goto the add screen elsif ($query->param('util') eq 'DELETE TABLE' || $query->param('drop')) { &drop_table(); } ## if param 'CANCEL' exist then it was called from ## the warning screen of the delete table screen. elsif ($query->param('CANCEL')) { &cancel(); } ## none of expexted parameters were pass else { print $query->header; print $query->start_html(-title=>"Error", -bgcolor=>"#ffffff"); print "
param('util'), "\" target=\"HELP\">HELP
"; print "| "; print $query->popup_menu(-name=>"view_what", -"values"=>['View Definitions', 'View Data']); print " | What to view. |
|---|
| "; print "Save as a | "; print $query->popup_menu(-name=>"delimiter", -"values"=>[keys %delimit], -default=>',', -labels=>\%delimit); print " | ", "delimited File |
|---|
", "After you have finished populating the table, ", "you can use the menu to the left to edit any further portions.", ""; } ## need to use multipart_form for a filefield to work. print $query->start_multipart_form(-action=>'./idm.pl'), "\n"; print $query->hidden('tableName','$table'); # pass along table name print $query->hidden('action','insert'); # pass action, so idm.pl knows ## what to do ## what are we doing manual entry or adding a file. my @radio_butts = $query->radio_group(-name=>'which', -"values"=>['rows','file'], -default=>'none', -nolabels=>"true"); ## file to export print "
"; print $radio_butts[1], " Click here to IMPORT", " an entire File
Enter the name File to append or use the Browse Button :
\n";
print $query->filefield(-name=>'export',
-size=>30), "
";
print "Field Separator ";
print $query->popup_menu(-name=>"delimiter",
-"values"=>[keys %delimit],
-default=>',',
-labels=>\%delimit);
print "
", $radio_butts[0], "Click here to ADD", " a specified number of records", "
param('util'), "\" target=\"HELP\">HELP
"; ## hit data base for info about fields (ie field names, if char, int or real) my $dbh = &dbConnect(); my $sth = $dbh->listfields($table); my $noCols = $sth->numfields - 1; my @colnames = $sth->name; my @coltype = $sth->type; print "| ", "The $colnames[$i] Field", " | "; if ($type{$coltype[$i]} eq 'char') { ## if char give only two possible matching options print $query->popup_menu(-name=>"$colnames[$i],match", -"values"=>['exact','like'], -labels=>{'exact'=>'Exactly Matches ', 'like'=>' Contains '}), " | \n\n"; } else { ## else it real or int give four possible matching options print $query->popup_menu(-name=>"$colnames[$i],match", -"values"=>['=','<>','<=','>='], -labels=>{'='=>'is Equal to', '<>'=>'is Not Equal to', '<='=>'is Less than', '>='=>'is Greater than'}), " | \n\n"; } if ($query->param('refine')) { print $query->textfield(-name=>"$colnames[$i]", -value=>"$query->param('$colnames[$i]')", -size=>15), " |
",
"All conditions are connected with the 'logical AND'.
",
"Leaving a field blank will invoke a search on all elements in that field.",
"
The \"is Less than\" and \"is Greater than\" options for fields ",
"of types
\'int\' and \'real\' are inclusive.
",
"If using the \'DELETE INDISCRIMINATELY!\' option,",
"fields of type\'char\' will default to the \'Exactly Matches\' ",
"option. Fields of types \'int\' and \'real\' will match as specified.",
"
";
## show and select or just delete option
my @radio_butts = $query->radio_group(-name=>"show_select",
-"values"=>['show','delete'],
-nolabels=>"true");
print $radio_butts[0], " SHOW RESULTS AND SELECT. ",
$radio_butts[1], " DELETE INDISCRIMINATELY!
";
print $query->submit(-name=>'SUBMIT'), "
param('util'), "\" target=\"HELP\">HELP
"; ##db stuff my $dbh = &dbConnect(); my $table = $query->param('tableName'); my $sth = $dbh->listfields($table); my $noCols = $sth->numfields - 1; my @colnames = $sth->name; my @coltype = $sth->type; print "| ", "The $colnames[$i] Field ", " | "; if ($type{$coltype[$i]} eq 'char') { print $query->popup_menu(-name=>"$colnames[$i],match", -"values"=>['exact','like'], -labels=>{'exact'=>'Exactly Matches ', 'like'=>' Contains '}), " | \n\n"; } else { print $query->popup_menu(-name=>"$colnames[$i],match", -"values"=>['=','<>','<=','>='], -labels=>{'='=>'is Equal to', '<>'=>'is Not Equal to', '<='=>'is Less than', '>='=>'is Greater than'}), " | \n\n"; } if ($query->param('refine') eq 'refine') { print $query->textfield(-name=>"$colnames[$i]", -value=>"$query->param('$colnames[$i]')", -size=>15), " |
",
"All conditions are connected with the 'logical AND'.
",
"Leaving a field blank will invoke a search on all elements in that field.",
"
The \"is Less than\" and \"is Greater than\" options for fields of ",
"types
\'int\' and \'real\' are inclusive.
";
print $query->submit(-name=>'SUBMIT'), "
| "; print "\n | Field Name | "; print "\nField Type | "; print "\nField Length | "; for ($i=0; $i < $noCols; $i++) { if ($colnames[$i] ne 'dbEase_key') { if ($colopt[$i] eq '1') { $opt= "Required"; $fontcolor[$i] = 'green'; } else { $opt= "Optional"; $fontcolor[$i] = 'black'; } print "
|---|---|---|---|
| ", "", "$opt | "; print "", " ", "$colnames[$i] | "; print "", "", " $type{$coltype[$i]} | "; if ($type{$coltype[$i]} ne 'char') { print "", "", " | ", " ", "$collen[$i] | "; } } } print "
NOTE: Once a Table has been defined/created", " it CANNOT be changed. To change a previously defined Table you MUST ", "re-define and re-create the Table."; print $query->end_html; exit; } ############################################################# # # view_data expects the tableName parameter as well as the # view_what = View Data parameter to get to this subroutine # ############################################################# sub view_data { print $query->header; print $query->start_html(-title=>"$table 's Data", -bgcolor=>"#ffffff"); print ""; print ""; my $table = $query->param('tableName'); ## db stuff my $dbh = &dbConnect(); print "
| ", "", "$opt | "; } } print "
|---|
| ", "", "$colnames[$i] | "; } } print "
| ", "", " $row[$i] | "; } } print "
| " , $query->start_form(-method=>GET, -action=>'./db_util.pl'); print $query->hidden('tableName','$table'); print $query->submit(-name=>'drop', value=>"DELETE $table"), "\n | \n"; print $query->end_form; print "", $query->start_form(-method=>GET, -action=>'./db_util.pl'); print $query->hidden('tableName','$table'); print $query->submit(-name=>"CANCEL"), "\n | \n"; print $query->end_form, "
|---|