Changeset 186 for trunk/cgi-bin/IPDB.pm
- Timestamp:
- 03/03/05 17:14:54 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r184 r186 243 243 } else { 244 244 # common stuff for end-use, dialup, dynDSL, pools, etc, etc. 245 $sth = $dbh->prepare("delete from freeblocks where cidr='$cidr'"); 246 $sth->execute; 247 245 246 # special case - block is a container/"reserve" block - alloctype begins with 'r' 247 if ($type =~ /^r.$/) { 248 $sth = $dbh->prepare("update freeblocks set routed='r' where cidr='$cidr'"); 249 $sth->execute; 250 } else { 251 # "normal" case 252 $sth = $dbh->prepare("delete from freeblocks where cidr='$cidr'"); 253 $sth->execute; 254 } 248 255 $sth = $dbh->prepare("insert into allocations". 249 256 " (cidr,custid,type,city,description,notes,maskbits,circuitid)". … … 328 335 329 336 # Insert the new freeblocks entries 337 # Along with some more HairyPerl(TM) in case we're inserting a 338 # subblock (l.) allocation 330 339 $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 331 " values (?, ?, (select city from routed where cidr >>= '$cidr'),'y')"); 340 " values (?, ?, (select city from routed where cidr >>= '$cidr'),'". 341 (($type =~ /^l.$/) ? 'r' : 'y')."')"); 332 342 foreach my $block (@newfreeblocks) { 333 343 $sth->execute("$block", $block->masklen); 334 344 } 335 345 # special-case for reserve/"container" blocks 346 if ($type =~ /^r.$/) { 347 $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 348 " values ('$cidr',".$cidr->masklen.",'$city','r')"); 349 $sth->execute; 350 } 336 351 # Insert the allocations entry 337 352 $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,". … … 499 514 } else { # end alloctype routing case 500 515 501 $sth = $dbh->prepare("delete from allocations where cidr='$cidr'"); 516 # Delete all allocations within the block being deleted. This is 517 # deliberate and correct, and removes the need to special-case 518 # removal of "container" blocks. 519 $sth = $dbh->prepare("delete from allocations where cidr <<='$cidr'"); 502 520 $sth->execute; 521 503 522 # Special case - delete pool IPs 504 523 if ($type =~ /^.[pd]$/) { … … 511 530 $sth = $dbh->prepare("select cidr from freeblocks where cidr <<= ". 512 531 "(select cidr from routed where cidr >>= '$cidr') ". 513 " and maskbits<=".$cidr->masklen." and routed='y' order by maskbits desc"); 532 " and maskbits<=".$cidr->masklen. 533 " and routed='".(($type =~ /^l.$/) ? 'r' : 'y'). 534 "' order by maskbits desc"); 514 535 515 536 } # end alloctype general case … … 542 563 } 543 564 544 # Clear old freeblocks entries - if any. $i==0 if not. 545 if ($i>0) { 546 $sth = $dbh->prepare("delete from freeblocks where cidr=?"); 547 foreach my $block (@combinelist) { 548 $sth->execute("$block"); 549 } 550 } 565 # Clear old freeblocks entries - if any. They should all be within 566 # the $cidr determined above. 567 $sth = $dbh->prepare("delete from freeblocks where cidr <<='$cidr'"); 568 $sth->execute; 551 569 552 570 # insert "new" freeblocks entry … … 557 575 $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)". 558 576 " values ('$cidr',".$cidr->masklen. 559 ",(select city from routed where cidr >>= '$cidr'),'y')"); 577 ",(select city from routed where cidr >>= '$cidr'),'". 578 (($type =~ /^l.$/) ? 'r' : 'y')."')"); 560 579 } 561 580 $sth->execute;
Note:
See TracChangeset
for help on using the changeset viewer.