Changeset 502 for branches/htmlform/cgi-bin/search.cgi
- Timestamp:
- 09/23/11 17:36:06 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/search.cgi
r481 r502 40 40 } 41 41 42 # Global variables 43 my $RESULTS_PER_PAGE = 25; 44 45 # anyone got a better name? :P 46 my $thingroot = $ENV{SCRIPT_FILENAME}; 47 $thingroot =~ s|cgi-bin/search.cgi||; 48 49 # Set up the CGI object... 50 my $q = new CGI::Simple; 51 # ... and get query-string params as well as POST params if necessary 52 $q->parse_query_string; 53 54 # Convenience; saves changing all references to %webvar 55 ##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection) 56 my %webvar = $q->Vars; 57 58 if (defined($webvar{rpp})) { 59 ($RESULTS_PER_PAGE) = ($webvar{rpp} =~ /(\d+)/); 60 } 61 42 62 # Why not a global DB handle? (And a global statement handle, as well...) 43 63 # Use the connectDB function, otherwise we end up confusing ourselves … … 46 66 my $errstr; 47 67 ($ip_dbh,$errstr) = connectDB_My; 48 if (!$ip_dbh) { 49 printAndExit("Failed to connect to database: $errstr\n"); 50 } 51 checkDBSanity($ip_dbh); 52 initIPDBGlobals($ip_dbh); 53 54 # Global variables 55 my $RESULTS_PER_PAGE = 25; 56 57 # anyone got a better name? :P 58 my $thingroot = $ENV{SCRIPT_FILENAME}; 59 $thingroot =~ s|cgi-bin/search.cgi||; 60 61 # Set up the CGI object... 62 my $q = new CGI::Simple; 63 # ... and get query-string params as well as POST params if necessary 64 $q->parse_query_string; 65 66 # Convenience; saves changing all references to %webvar 67 ##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection) 68 my %webvar = $q->Vars; 69 70 if (defined($webvar{rpp})) { 71 ($RESULTS_PER_PAGE) = ($webvar{rpp} =~ /(\d+)/); 68 if ($ip_dbh) { 69 checkDBSanity($ip_dbh); 70 initIPDBGlobals($ip_dbh); 72 71 } 73 72 … … 88 87 print "Content-type: text/html\n\n", $header->output; 89 88 90 if ($webvar{stype} eq 'q') { 89 # Handle the DB error first 90 if (!$ip_dbh) { 91 $page = HTML::Template->new(filename => "dberr.tmpl"); 92 $page->param(errmsg => $errstr); 93 } elsif ($webvar{stype} eq 'q') { 91 94 # Quick search. 92 95 … … 131 134 $sqlconcat = "UNION"; 132 135 } else { 133 # We can't get here. PTHBTT! 134 printAndExit "PTHBTT!! Your search has been rejected due to Microsoft excuse #4432: ". 135 "Not enough mana"; 136 # sum-buddy tryn'a game the system. Match "all" 137 $sqlconcat = "INTERSECT"; 136 138 } 137 139 … … 210 212 "text(cidr) like '$webvar{cidr}%')"; 211 213 } else { 212 # This shouldn't happen, but if it does, whoever gets it deserves what they get...213 printAndExit("Invalid netblock query.");214 # do nothing. 215 ##fixme we'll ignore this to clear out the references to legacy code. 214 216 } # done with CIDR query options. 215 217
Note:
See TracChangeset
for help on using the changeset viewer.