Changeset 186
- Timestamp:
- 03/03/05 17:14:54 (20 years ago)
- Location:
- trunk/cgi-bin
- Files:
-
- 2 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; -
trunk/cgi-bin/main.cgi
r184 r186 331 331 $data[2] .= 'i'; 332 332 } 333 my @row = (qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 333 my @row = ( (($data[2] =~ /^l.$/) ? 'Sub ' : ''). 334 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 334 335 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); 335 336 # Allow listing of pool if desired/required. … … 598 599 # $data[2] =~ s/\s+//g; 599 600 600 my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=edit&block=$data[0]\">$data[0]</a>", 601 my @row = ( (($data[2] =~ /^l.$/) ? 'Sub ' : ''). 602 qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 601 603 $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]); 602 604 # If the allocation is a pool, allow listing of the IPs in the pool. … … 634 636 # unrouted free blocks, but it's better to let the database do the work if we can. 635 637 $count = 0; 636 $sth = $ip_dbh->prepare("select cidr from freeblocks where routed='y' and cidr <<= '$master' order by cidr"); 638 $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'". 639 " order by cidr"); 637 640 $sth->execute(); 638 641 while (my @data = $sth->fetchrow_array()) { 639 # cidr, maskbits,city642 # cidr,routed 640 643 my $cidr = new NetAddr::IP $data[0]; 641 my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>", 644 my @row = ((($data[1] eq 'r') ? 'Sub ' : ''). 645 "<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>", 642 646 $cidr->range); 643 647 printRow(\@row, 'color1') if ($count%2 == 0); … … 869 873 if ($webvar{allocfrom} ne '-') { 870 874 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 871 " and cidr <<= '$webvar{allocfrom}' and routed='y' order by cidr,maskbits desc"; 875 " and cidr <<= '$webvar{allocfrom}' and routed='". 876 (($webvar{alloctype} =~ /^l.$/) ? 'r' : 'y')."' order by cidr,maskbits desc"; 872 877 } else { 873 878 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 874 " and routed='y' order by cidr,maskbits desc"; 879 " and routed='".(($webvar{alloctype} =~ /^l.$/) ? 'r' : 'y'). 880 "' order by cidr,maskbits desc"; 875 881 } 876 882 }
Note:
See TracChangeset
for help on using the changeset viewer.