Ignore:
Timestamp:
09/17/10 18:49:45 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Convert initial DB connection error output to a sane page. Could arguably provide
space for this (and other) errors on all normal pages. (See #3).
This allows us to:

  • Remove editError sub in main.cgi
  • Remove printHeader sub in CommonWeb.pm (see #15, #26)

Removed duplicate "exit if we get this far"
Tweak IPDB::finish so it doesn't spit a fatal error when called with a null database handle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/main.cgi

    r478 r479  
    4646syslog "debug", "$authuser active, $ENV{'REMOTE_ADDR'}";
    4747
     48##fixme there *must* be a better order to do things in so this can go back where it was
     49# CGI fiddling done here so we can declare %webvar so we can alter $webvar{action}
     50# to show the right page on DB errors.
     51# Set up the CGI object...
     52my $q = new CGI::Simple;
     53# ... and get query-string params as well as POST params if necessary
     54$q->parse_query_string;
     55
     56# Convenience;  saves changing all references to %webvar
     57##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
     58my %webvar = $q->Vars;
     59
    4860# Why not a global DB handle?  (And a global statement handle, as well...)
    4961# Use the connectDB function, otherwise we end up confusing ourselves
     
    5365($ip_dbh,$errstr) = connectDB_My;
    5466if (!$ip_dbh) {
    55   exitError("Database error: $errstr\n");
    56 }
    57 initIPDBGlobals($ip_dbh);
     67  $webvar{action} = "dberr";
     68} else {
     69  initIPDBGlobals($ip_dbh);
     70}
    5871
    5972# Set up some globals
     
    6679$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
    6780print "Content-type: text/html\n\n", $header->output;
    68 
    69 # Set up the CGI object...
    70 my $q = new CGI::Simple;
    71 # ... and get query-string params as well as POST params if necessary
    72 $q->parse_query_string;
    73 
    74 # Convenience;  saves changing all references to %webvar
    75 ##fixme:  tweak for handling <select multiple='y' size=3> (list with multiple selection)
    76 my %webvar = $q->Vars;
    7781
    7882
     
    153157  }
    154158  $page->param(nodelist => \@nodelist);
     159}
     160
     161# DB failure.  Can't do much here, really.
     162elsif ($webvar{action} eq 'dberr') {
     163  $page->param(errmsg => $errstr);
    155164}
    156165
     
    192201# Just in case something waaaayyy down isn't in place
    193202# properly... we exit explicitly.
    194 exit;
    195 
     203exit 0;
    196204
    197205
     
    12571265
    12581266} # finalDelete
    1259 
    1260 
    1261 # going, going, gone... this sub to be removed Any Day Real Soon Now(TM)
    1262 sub exitError {
    1263   my $errStr = $_[0];
    1264   printHeader('','');
    1265   print qq(<center><p class="regular"> $errStr </p>
    1266 <input type="button" value="Back" onclick="history.go(-1)">
    1267 </center>
    1268 );
    1269 
    1270   # We print the footer here, so we don't have to do it elsewhere.
    1271   # include the admin tools link in the output?
    1272   $footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/));
    1273 
    1274   print $footer->output;
    1275 
    1276   exit;
    1277 } # errorExit
    1278 
    1279 
    1280 # Just in case we manage to get here.
    1281 exit 0;
Note: See TracChangeset for help on using the changeset viewer.