Changeset 460


Ignore:
Timestamp:
08/04/10 16:49:53 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Convert "new node" miniscript and page to template. See #3.
Update call from assign.tmpl to point to newcity.cgi.
Clean up errors and warnings from newnode.cgi in HTTPD error
log. See #31. (Also note newcity.cgi changes in r459 have
the same cleanups.)

Location:
branches/htmlform
Files:
1 added
2 edited

Legend:

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

    r447 r460  
    1414#use CGI::Carp qw(fatalsToBrowser);
    1515use CGI::Simple;
     16use HTML::Template;
    1617use DBI;
    17 use CommonWeb qw(:ALL);
     18#use CommonWeb qw(:ALL);
    1819#use POSIX qw(ceil);
    1920use NetAddr::IP;
     
    4748my $sth;
    4849
     50$ENV{HTML_TEMPLATE_ROOT} = '../templates';
     51
     52my $page = HTML::Template->new(filename => "newnode.tmpl");
     53
     54if ($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
    4968print "Content-type: text/html\n\n";
    5069
    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 }
     70print $page->output;
    6471
    6572finish($dbh);
  • branches/htmlform/templates/assign.tmpl

    r459 r460  
    6666        <option value="<TMPL_VAR NAME=nid>"><TMPL_VAR NAME=nname></option></TMPL_LOOP>
    6767</select>
    68 &nbsp;<a href="javascript:popNotes('/ip/newnode.html')">Add new location</a>
     68&nbsp;<a href="javascript:popNotes('/ip/cgi-bin/newnode.cgi')">Add new location</a>
    6969</td>
    7070</tr>
Note: See TracChangeset for help on using the changeset viewer.