Changeset 517 for trunk/cgi-bin/IPDB.pm


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/IPDB.pm

    r486 r517  
    2424@EXPORT_OK    = qw(
    2525        %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist @masterblocks
    26         %allocated %free %routed %bigfree %IPDBacl
     26        %allocated %free %routed %bigfree %IPDBacl %aclmsg
    2727        &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock &addMaster
    2828        &deleteBlock &getBlockData &mailNotify
     
    3232%EXPORT_TAGS    = ( ALL => [qw(
    3333                %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist
    34                 @masterblocks %allocated %free %routed %bigfree %IPDBacl
     34                @masterblocks %allocated %free %routed %bigfree %IPDBacl %aclmsg
    3535                &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock
    3636                &addMaster &deleteBlock &getBlockData &mailNotify
     
    5252our %bigfree;
    5353our %IPDBacl;
     54
     55# mapping table for functional-area => error message
     56our %aclmsg = (
     57        addmaster       => 'add a master block',
     58        addblock        => 'add an allocation',
     59        updateblock     => 'update a block',
     60        delblock        => 'delete an allocation',
     61        );
    5462
    5563our $org_name = 'Example Corp';
     
    122130  }
    123131
     132##fixme:  initialize HTML::Template env var for template path
     133# something like $self->path().'/templates' ?
     134#  $ENV{HTML_TEMPLATE_ROOT} = 'foo/bar';
     135
    124136  return (1,"OK");
    125137} # end initIPDBGlobals
     
    170182sub finish {
    171183  my $dbh = $_[0];
    172   $dbh->disconnect;
     184  $dbh->disconnect if $dbh;
    173185} # end finish
    174186
     
    352364      $cidr = $data[0];  # $cidr is already declared when we get here!
    353365
    354       $sth = $dbh->prepare("update poolips set custid='$custid',".
    355         "city='$city',available='n',description='$desc',notes='$notes',".
    356         "circuitid='$circid',privdata='$privdata'".
    357         " where ip='$cidr'");
    358       $sth->execute;
     366      $sth = $dbh->prepare("update poolips set custid=?,city=?,".
     367        "available='n',description=?,notes=?,circuitid=?,privdata=?".
     368        " where ip=?");
     369      $sth->execute($custid, $city, $desc, $notes, $circid, $privdata, "$cidr");
    359370# node hack
    360371      if ($nodeid && $nodeid ne '') {
     
    404415          $sth = $dbh->prepare("insert into allocations".
    405416                " (cidr,custid,type,city,description,notes,maskbits,circuitid,privdata)".
    406                 " values ('$cidr','$custid','$type','$city','$desc','$notes',".
    407                 $cidr->masklen.",'$circid','$privdata')");
    408           $sth->execute;
     417                " values (?,?,?,?,?,?,?,?,?)");
     418          $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata);
    409419
    410420          # And initialize the pool, if necessary
     
    514524          $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,".
    515525                "description,notes,maskbits,circuitid,privdata)".
    516                 " values ('$cidr','$custid','$type','$city','$desc','$notes',".
    517                 $cidr->masklen.",'$circid','$privdata')");
    518           $sth->execute;
     526                " values (?,?,?,?,?,?,?,?,?)");
     527          $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata);
    519528
    520529          # And initialize the pool, if necessary
     
    638647    eval {
    639648      $msg = "Unable to deallocate $disp_alloctypes{$type} $cidr";
    640       $sth = $dbh->prepare("update poolips set custid='$defcustid',available='y',".
    641         "city=(select city from allocations where cidr >>= '$cidr'".
     649      $sth = $dbh->prepare("update poolips set custid=?,available='y',".
     650        "city=(select city from allocations where cidr >>= ?".
    642651        " order by masklen(cidr) desc limit 1),".
    643         "description='',notes='',circuitid='' where ip='$cidr'");
    644       $sth->execute;
     652        "description='',notes='',circuitid='' where ip=?");
     653      $sth->execute($defcustid, "$cidr", "$cidr");
    645654      $dbh->commit;
    646655    };
Note: See TracChangeset for help on using the changeset viewer.