Changeset 517 for trunk/cgi-bin/newnode.cgi
- Timestamp:
- 10/18/12 16:53:10 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/htmlform merged eligible
-
Property svn:mergeinfo
set to
-
trunk/cgi-bin/newnode.cgi
r417 r517 13 13 use warnings; 14 14 #use CGI::Carp qw(fatalsToBrowser); 15 use CGI::Simple; 16 use HTML::Template; 15 17 use DBI; 16 use CommonWeb qw(:ALL);17 18 #use POSIX qw(ceil); 18 19 use NetAddr::IP; … … 34 35 } 35 36 36 my %webvar = parse_post(); 37 cleanInput(\%webvar); 37 # Set up the CGI object... 38 my $q = new CGI::Simple; 39 # ... and get query-string params as well as POST params if necessary 40 $q->parse_query_string; 41 42 # Convenience; saves changing all references to %webvar 43 ##fixme: tweak for handling <select multiple='y' size=3> (list with multiple selection) 44 my %webvar = $q->Vars; 38 45 39 46 my ($dbh,$errstr) = connectDB_My; 40 47 my $sth; 41 48 49 $ENV{HTML_TEMPLATE_ROOT} = '../templates'; 50 51 my $page = HTML::Template->new(filename => "newnode.tmpl"); 52 53 if ($webvar{nodename}) { 54 $sth = $dbh->prepare("insert into nodes (node_type,node_name,node_ip) values (?,?,?)"); 55 $sth->execute($webvar{type}, $webvar{nodename}, $webvar{nodeip}); 56 $page->param(nodename => $webvar{nodename}); 57 if ($sth->err) { 58 $page->param(err => $sth->errstr); 59 my $msg = "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr; 60 mailNotify($dbh, 'f:nno', "IPDB node add failure", $msg); 61 syslog "err", $msg; 62 } else { 63 syslog "notice", "$authuser added node '$webvar{nodename}'"; 64 } 65 } 66 42 67 print "Content-type: text/html\n\n"; 43 68 44 $sth = $dbh->prepare("insert into nodes (node_type,node_name,node_ip)". 45 " values ('$webvar{type}','$webvar{nodename}','$webvar{nodeip}')"); 46 $sth->execute; 47 48 if ($sth->err) { 49 print "Error adding node to database: ".$sth->errstr; 50 mailNotify($dbh, 'f:nno', "IPDB node add failure", 51 "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr); 52 syslog "err", "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr; 53 } else { 54 print "Node added. Closing this window should refresh the page."; 55 syslog "notice", "$authuser added node '$webvar{nodename}'"; 56 } 69 print $page->output; 57 70 58 71 finish($dbh);
Note:
See TracChangeset
for help on using the changeset viewer.