Changeset 479
- Timestamp:
- 09/17/10 18:49:45 (14 years ago)
- Location:
- branches/htmlform/cgi-bin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/CommonWeb.pm
r450 r479 16 16 $VERSION = 1.00; 17 17 @ISA = qw(Exporter); 18 @EXPORT_OK = qw( &print Header &printError &printAndExit &desanitize &cleanInput &desanitize);18 @EXPORT_OK = qw( &printError &printAndExit &desanitize &cleanInput &desanitize); 19 19 20 20 @EXPORT = (); #export nothing by default … … 25 25 ); 26 26 27 28 sub printHeader {29 my $title = shift;30 print "Content-type: text/html\n\n";31 # This doesn't work well. Must investigate.32 # my $realm = shift;33 # print qq(WWW-Authenticate: Basic realm="$realm"\n) if $realm;34 open FILE, "../header.inc"35 or carp $!;36 my $html = join('',<FILE>);37 close FILE;38 39 $html =~ s/\$\$TITLE\$\$/$title/;40 # Necessary for mangling arbitrary bits of the header41 my $i=0;42 while (defined(my $param = shift)) {43 $html =~ s/\$\$EXTRA$i\$\$/$param/g;44 $i++;45 }46 print $html;47 }48 27 49 28 sub printError($) -
branches/htmlform/cgi-bin/IPDB.pm
r468 r479 174 174 sub finish { 175 175 my $dbh = $_[0]; 176 $dbh->disconnect ;176 $dbh->disconnect if $dbh; 177 177 } # end finish 178 178 -
branches/htmlform/cgi-bin/main.cgi
r478 r479 46 46 syslog "debug", "$authuser active, $ENV{'REMOTE_ADDR'}"; 47 47 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... 52 my $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) 58 my %webvar = $q->Vars; 59 48 60 # Why not a global DB handle? (And a global statement handle, as well...) 49 61 # Use the connectDB function, otherwise we end up confusing ourselves … … 53 65 ($ip_dbh,$errstr) = connectDB_My; 54 66 if (!$ip_dbh) { 55 exitError("Database error: $errstr\n"); 56 } 57 initIPDBGlobals($ip_dbh); 67 $webvar{action} = "dberr"; 68 } else { 69 initIPDBGlobals($ip_dbh); 70 } 58 71 59 72 # Set up some globals … … 66 79 $header->param(addperm => $IPDBacl{$authuser} =~ /a/); 67 80 print "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 necessary72 $q->parse_query_string;73 74 # Convenience; saves changing all references to %webvar75 ##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection)76 my %webvar = $q->Vars;77 81 78 82 … … 153 157 } 154 158 $page->param(nodelist => \@nodelist); 159 } 160 161 # DB failure. Can't do much here, really. 162 elsif ($webvar{action} eq 'dberr') { 163 $page->param(errmsg => $errstr); 155 164 } 156 165 … … 192 201 # Just in case something waaaayyy down isn't in place 193 202 # properly... we exit explicitly. 194 exit; 195 203 exit 0; 196 204 197 205 … … 1257 1265 1258 1266 } # 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 } # errorExit1278 1279 1280 # Just in case we manage to get here.1281 exit 0;
Note:
See TracChangeset
for help on using the changeset viewer.