Changeset 550 for branches/stable/cgi-bin/main.cgi
- Timestamp:
- 11/12/12 17:31:34 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/main.cgi
r549 r550 389 389 while (my @data = $sth->fetchrow_array()) { 390 390 my $cidr = new NetAddr::IP $data[0]; 391 my @row = ("$cidr", $cidr->range); 391 my @row = ( 392 ($IPDBacl{$authuser} =~ /a/ ? 393 qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=n">$cidr</a>) 394 : $cidr), 395 $cidr->range); 392 396 printRow(\@row, 'color1' ) if($count%2==0); 393 397 printRow(\@row, 'color2' ) if($count%2!=0); … … 544 548 # -> if $data[2] (aka poolips.available) == 'n' then we print the unassign link 545 549 # else we print a blank space 546 my @row = ( qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 550 my @row; 551 if ($data[2] eq 'y' && $IPDBacl{$authuser} =~ /a/) { 552 push @row, qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=assign&block=$data[0]&fbtype=i">$data[0]</a>); 553 } else { 554 push @row, qq(<a href="$IPDB::webpath/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>); 555 } 556 push @row, ( 547 557 $data[1],$data[2],$data[3], 548 558 ( (($data[2] eq 'n') && ($IPDBacl{$authuser} =~ /d/)) ? … … 578 588 close HTML; 579 589 my $block = new NetAddr::IP $webvar{block}; 580 $html =~ s|\$\$BLOCK\$\$|$block|g; 581 $html =~ s|\$\$MASKBITS\$\$|$block->masklen|; 590 582 591 my $typelist = ''; 583 592 … … 592 601 # get fbtype='n' (aka a non-routed freeblock). However, should 593 602 # someone manage to get there, they get what they deserve. 594 if ($webvar{fbtype} ne 'y') { 595 # Snag the type of the block from the database. We have no 596 # convenient way to pass this in from the calling location. :/ 597 $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'"); 598 $sth->execute; 599 my @data = $sth->fetchrow_array; 600 $data[0] =~ s/c$/r/; # Munge the type into the correct form 601 $typelist = "$list_alloctypes{$data[0]}<input type=hidden name=alloctype value=$data[0]>\n"; 602 } else { 603 # if ($webvar{fbtype} ne 'y') { 604 # # Snag the type of the block from the database. We have no 605 # # convenient way to pass this in from the calling location. :/ 606 # $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'"); 607 # $sth->execute; 608 # my @data = $sth->fetchrow_array; 609 # $data[0] =~ s/c$/r/; # Munge the type into the correct form 610 # $typelist = "$list_alloctypes{$data[0]}<input type=hidden name=alloctype value=$data[0]>\n"; 611 # } else { 612 if ($webvar{fbtype} eq 'n') { 613 $typelist = "Routed netblock<input type=hidden name=alloctype value=rm>\n"; 614 $html =~ s|\$\$ALLOCBLOCK\$\$|<input name=block size=25 value="$block">|; 615 $html =~ s|\$\$BLOCK\$\$|$block|g; 616 } elsif ($webvar{fbtype} eq 'i') { 617 my ($iptype,$pool) = $ip_dbh->selectrow_array("SELECT type,pool FROM poolips WHERE ip = ?", undef, ($block)); 618 $typelist = "$list_alloctypes{$iptype}<input type=hidden name=alloctype value=$iptype>\n"; 619 $html =~ s|\$\$ALLOCBLOCK\$\$|$block<input type=hidden name=block size=25 value="$block">|; 620 $html =~ s|\$\$BLOCK\$\$|$pool|g; 621 } else { 622 $html =~ s|\$\$ALLOCBLOCK\$\$|<input name=block size=25 value="$block">|; 623 $html =~ s|\$\$BLOCK\$\$|$block|g; 603 624 $typelist .= qq(<select name="alloctype">\n); 604 625 $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 ". 605 "and type not like '_i' and type not like '_r'order by listorder");626 "and type not like '_i' order by listorder"); 606 627 $sth->execute; 607 628 my @data = $sth->fetchrow_array; 608 629 $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n"; 609 while ( my@data = $sth->fetchrow_array) {630 while (@data = $sth->fetchrow_array) { 610 631 $typelist .= "<option value='$data[0]'>$data[1]</option>\n"; 611 632 } … … 700 721 # + Different flavours of netblock 701 722 702 if ($webvar{alloctype} =~ /^.i$/ ) {723 if ($webvar{alloctype} =~ /^.i$/ && $webvar{fbassign} ne 'y') { 703 724 my ($base,undef) = split //, $webvar{alloctype}; # split into individual chars 704 725 … … 722 743 723 744 if ($webvar{fbassign} eq 'y') { 745 $alloc_from = new NetAddr::IP $webvar{allocfrom}; 746 ## possibly messy behaviour: force the _from and block to be the network addr? 747 $alloc_from = qq($alloc_from<input type=hidden name=alloc_from value="$alloc_from">); 724 748 $cidr = new NetAddr::IP $webvar{block}; 725 749 $webvar{maskbits} = $cidr->masklen; … … 790 814 } 791 815 $cidr = new NetAddr::IP $data[0]; 816 817 # this chunk now specific to "guided" allocation; freeblock-select can now slice-n-dice on its own. 818 $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">); 819 # If the block to be allocated is smaller than the one we found, 820 # figure out the "real" block to be allocated. 821 if ($cidr->masklen() ne $webvar{maskbits}) { 822 my $maskbits = $cidr->masklen(); 823 my @subblocks; 824 while ($maskbits++ < $webvar{maskbits}) { 825 @subblocks = $cidr->split($maskbits); 826 } 827 $cidr = $subblocks[0]; 828 } 792 829 } # check for freeblocks assignment or IPDB-controlled assignment 793 830 794 $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">); 795 796 # If the block to be allocated is smaller than the one we found, 797 # figure out the "real" block to be allocated. 798 if ($cidr->masklen() ne $webvar{maskbits}) { 799 my $maskbits = $cidr->masklen(); 800 my @subblocks; 801 while ($maskbits++ < $webvar{maskbits}) { 802 @subblocks = $cidr->split($maskbits); 803 } 804 $cidr = $subblocks[0]; 805 } 831 806 832 } # if ($webvar{alloctype} =~ /^.i$/) 807 833
Note:
See TracChangeset
for help on using the changeset viewer.