Ignore:
Timestamp:
05/14/13 18:10:22 (11 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Merge /trunk r517 (merge /branches/htmlform)
Conflicts all resolved towards /trunk.
Fix a minor syntax error with "while (@data..." -> "while (my @data..."
(may cause merge conflicts later)

Location:
branches/stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable

  • branches/stable/cgi-bin/IPDB.pm

    r592 r593  
    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';
     
    126134  }
    127135
     136##fixme:  initialize HTML::Template env var for template path
     137# something like $self->path().'/templates' ?
     138#  $ENV{HTML_TEMPLATE_ROOT} = 'foo/bar';
     139
    128140  return (1,"OK");
    129141} # end initIPDBGlobals
     
    174186sub finish {
    175187  my $dbh = $_[0];
    176   $dbh->disconnect;
     188  $dbh->disconnect if $dbh;
    177189} # end finish
    178190
     
    360372      }
    361373
    362       $sth = $dbh->prepare("update poolips set custid='$custid',".
    363         "city='$city',available='n',description='$desc',notes='$notes',".
    364         "circuitid='$circid',privdata='$privdata'".
    365         " where ip='$cidr'");
    366       $sth->execute;
     374      $sth = $dbh->prepare("update poolips set custid=?,city=?,".
     375        "available='n',description=?,notes=?,circuitid=?,privdata=?".
     376        " where ip=?");
     377      $sth->execute($custid, $city, $desc, $notes, $circid, $privdata, "$cidr");
    367378# node hack
    368379      if ($nodeid && $nodeid ne '') {
     
    413424          $sth = $dbh->prepare("insert into allocations".
    414425                " (cidr,custid,type,city,description,notes,maskbits,circuitid,privdata)".
    415                 " values ('$cidr','$custid','$type','$city',?,?,".
    416                 $cidr->masklen.",?,?)");
    417           $sth->execute($desc,$notes,$circid,$privdata);
     426                " values (?,?,?,?,?,?,?,?,?)");
     427          $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata);
    418428
    419429          # And initialize the pool, if necessary
     
    527537          $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,".
    528538                "description,notes,maskbits,circuitid,privdata)".
    529                 " values ('$cidr','$custid','$type','$city',?,?,".
    530                 $cidr->masklen.",?,?)");
    531           $sth->execute($desc,$notes,$circid,$privdata);
     539                " values (?,?,?,?,?,?,?,?,?)");
     540          $sth->execute("$cidr", $custid, $type, $city, $desc, $notes, $cidr->masklen, $circid, $privdata);
    532541
    533542          # And initialize the pool, if necessary
     
    653662    eval {
    654663      $msg = "Unable to deallocate $disp_alloctypes{$type} $cidr";
    655       $sth = $dbh->prepare("update poolips set custid='$defcustid',available='y',".
    656         "city=(select city from allocations where cidr >>= '$cidr'".
     664      $sth = $dbh->prepare("update poolips set custid=?,available='y',".
     665        "city=(select city from allocations where cidr >>= ?".
    657666        " order by masklen(cidr) desc limit 1),".
    658         "description='',notes='',circuitid='' where ip='$cidr'");
    659       $sth->execute;
     667        "description='',notes='',circuitid='' where ip=?");
     668      $sth->execute($defcustid, "$cidr", "$cidr");
    660669      $dbh->commit;
    661670    };
Note: See TracChangeset for help on using the changeset viewer.