Ignore:
Timestamp:
10/18/12 16:53:10 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Finally merge conversion to HTML::Template from /branches/htmlform

  • Node "hack" showed conflict due to having been added to all branches in parallel
  • editDisplay.html was apparently changed enough that the merged delete caused an irrelevant conflict

Closes #3.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/cgi-bin/newnode.cgi

    r417 r517  
    1313use warnings;
    1414#use CGI::Carp qw(fatalsToBrowser);
     15use CGI::Simple;
     16use HTML::Template;
    1517use DBI;
    16 use CommonWeb qw(:ALL);
    1718#use POSIX qw(ceil);
    1819use NetAddr::IP;
     
    3435}
    3536
    36 my %webvar = parse_post();
    37 cleanInput(\%webvar);
     37# Set up the CGI object...
     38my $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)
     44my %webvar = $q->Vars;
    3845
    3946my ($dbh,$errstr) = connectDB_My;
    4047my $sth;
    4148
     49$ENV{HTML_TEMPLATE_ROOT} = '../templates';
     50
     51my $page = HTML::Template->new(filename => "newnode.tmpl");
     52
     53if ($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
    4267print "Content-type: text/html\n\n";
    4368
    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 }
     69print $page->output;
    5770
    5871finish($dbh);
Note: See TracChangeset for help on using the changeset viewer.