Changeset 459 for branches/htmlform/cgi-bin/newcity.cgi
- Timestamp:
- 08/04/10 16:08:41 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/newcity.cgi
r447 r459 14 14 #use CGI::Carp qw(fatalsToBrowser); 15 15 use CGI::Simple; 16 use HTML::Template; 16 17 use DBI; 17 use CommonWeb qw(:ALL);18 #use CommonWeb qw(:ALL); 18 19 #use POSIX qw(ceil); 19 20 use NetAddr::IP; … … 48 49 my $sth; 49 50 51 $ENV{HTML_TEMPLATE_ROOT} = '../templates'; 52 53 my $page = HTML::Template->new(filename => "newcity.tmpl"); 54 55 if ($webvar{city}) { 56 if ($webvar{pop} eq 'on') { 57 $sth = $dbh->prepare("insert into cities (city,routing) values (?,'y')"); 58 } else { 59 $sth = $dbh->prepare("insert into cities (city,routing) values (?,'n')"); 60 } 61 ##fixme: don't allow duplicate cities 62 $sth->execute($webvar{city}); 63 $page->param(city => $webvar{city}); 64 if ($sth->err) { 65 $page->param(err => $sth->errstr); 66 my $msg = "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr; 67 mailNotify($dbh, 'f:nci', "IPDB city add failure", $msg); 68 syslog "err", $msg; 69 } else { 70 syslog "notice", "$authuser added city/location '$webvar{pop}'". 71 (($webvar{pop} eq 'on') ? ' as POP location' : ''); 72 } 73 } 74 50 75 print "Content-type: text/html\n\n"; 51 76 52 if ($webvar{pop} eq 'on') { 53 $sth = $dbh->prepare("insert into cities (city,routing) values ('$webvar{city}','y')"); 54 } else { 55 $sth = $dbh->prepare("insert into cities (city,routing) values ('$webvar{city}','n')"); 56 } 57 $sth->execute; 58 59 if ($sth->err) { 60 print "Error adding city to database: ".$sth->errstr; 61 mailNotify($dbh, 'f:nci', "IPDB city add failure", 62 "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr); 63 syslog "err", "$authuser could not add city '$webvar{city}' to database: ".$sth->errstr; 64 } else { 65 print "City added. Closing this window should refresh the page."; 66 syslog "notice", "$authuser added city/location '$webvar{pop}'". 67 (($webvar{pop} eq 'on') ? ' as POP location' : ''); 68 } 77 print $page->output; 69 78 70 79 finish($dbh); 80
Note:
See TracChangeset
for help on using the changeset viewer.