Changeset 460
- Timestamp:
- 08/04/10 16:49:53 (14 years ago)
- Location:
- branches/htmlform
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/newnode.cgi
r447 r460 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; … … 47 48 my $sth; 48 49 50 $ENV{HTML_TEMPLATE_ROOT} = '../templates'; 51 52 my $page = HTML::Template->new(filename => "newnode.tmpl"); 53 54 if ($webvar{nodename}) { 55 $sth = $dbh->prepare("insert into nodes (node_type,node_name,node_ip) values (?,?,?)"); 56 $sth->execute($webvar{type}, $webvar{nodename}, $webvar{nodeip}); 57 $page->param(nodename => $webvar{nodename}); 58 if ($sth->err) { 59 $page->param(err => $sth->errstr); 60 my $msg = "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr; 61 mailNotify($dbh, 'f:nno', "IPDB node add failure", $msg); 62 syslog "err", $msg; 63 } else { 64 syslog "notice", "$authuser added node '$webvar{nodename}'"; 65 } 66 } 67 49 68 print "Content-type: text/html\n\n"; 50 69 51 $sth = $dbh->prepare("insert into nodes (node_type,node_name,node_ip)". 52 " values ('$webvar{type}','$webvar{nodename}','$webvar{nodeip}')"); 53 $sth->execute; 54 55 if ($sth->err) { 56 print "Error adding node to database: ".$sth->errstr; 57 mailNotify($dbh, 'f:nno', "IPDB node add failure", 58 "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr); 59 syslog "err", "$authuser could not add node '$webvar{nodename}','$webvar{type}' to database: ".$sth->errstr; 60 } else { 61 print "Node added. Closing this window should refresh the page."; 62 syslog "notice", "$authuser added node '$webvar{nodename}'"; 63 } 70 print $page->output; 64 71 65 72 finish($dbh); -
branches/htmlform/templates/assign.tmpl
r459 r460 66 66 <option value="<TMPL_VAR NAME=nid>"><TMPL_VAR NAME=nname></option></TMPL_LOOP> 67 67 </select> 68 <a href="javascript:popNotes('/ip/ newnode.html')">Add new location</a>68 <a href="javascript:popNotes('/ip/cgi-bin/newnode.cgi')">Add new location</a> 69 69 </td> 70 70 </tr>
Note:
See TracChangeset
for help on using the changeset viewer.