Changeset 517 for trunk/cgi-bin/IPDB.pm
- Timestamp:
- 10/18/12 16:53:10 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/htmlform merged eligible
-
Property svn:mergeinfo
set to
-
trunk/cgi-bin/IPDB.pm
r486 r517 24 24 @EXPORT_OK = qw( 25 25 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist @masterblocks 26 %allocated %free %routed %bigfree %IPDBacl 26 %allocated %free %routed %bigfree %IPDBacl %aclmsg 27 27 &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock &addMaster 28 28 &deleteBlock &getBlockData &mailNotify … … 32 32 %EXPORT_TAGS = ( ALL => [qw( 33 33 %disp_alloctypes %list_alloctypes %def_custids @citylist @poplist 34 @masterblocks %allocated %free %routed %bigfree %IPDBacl 34 @masterblocks %allocated %free %routed %bigfree %IPDBacl %aclmsg 35 35 &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock 36 36 &addMaster &deleteBlock &getBlockData &mailNotify … … 52 52 our %bigfree; 53 53 our %IPDBacl; 54 55 # mapping table for functional-area => error message 56 our %aclmsg = ( 57 addmaster => 'add a master block', 58 addblock => 'add an allocation', 59 updateblock => 'update a block', 60 delblock => 'delete an allocation', 61 ); 54 62 55 63 our $org_name = 'Example Corp'; … … 122 130 } 123 131 132 ##fixme: initialize HTML::Template env var for template path 133 # something like $self->path().'/templates' ? 134 # $ENV{HTML_TEMPLATE_ROOT} = 'foo/bar'; 135 124 136 return (1,"OK"); 125 137 } # end initIPDBGlobals … … 170 182 sub finish { 171 183 my $dbh = $_[0]; 172 $dbh->disconnect ;184 $dbh->disconnect if $dbh; 173 185 } # end finish 174 186 … … 352 364 $cidr = $data[0]; # $cidr is already declared when we get here! 353 365 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"); 359 370 # node hack 360 371 if ($nodeid && $nodeid ne '') { … … 404 415 $sth = $dbh->prepare("insert into allocations". 405 416 " (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); 409 419 410 420 # And initialize the pool, if necessary … … 514 524 $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,". 515 525 "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); 519 528 520 529 # And initialize the pool, if necessary … … 638 647 eval { 639 648 $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 >>= ?". 642 651 " 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"); 645 654 $dbh->commit; 646 655 };
Note:
See TracChangeset
for help on using the changeset viewer.