Changeset 536 for trunk/cgi-bin
- Timestamp:
- 10/31/12 17:56:03 (12 years ago)
- Location:
- trunk/cgi-bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r535 r536 29 29 &listSummary &listMaster &listRBlock &listFree &listPool 30 30 &getTypeList &getPoolSelect &findAllocateFrom 31 & getParent &getRoutedCity31 &ipParent &subParent &blockParent &getRoutedCity 32 32 &allocateBlock &updateBlock &deleteBlock &getBlockData 33 33 &getNodeList &getNodeName &getNodeInfo … … 43 43 &listSummary &listMaster &listRBlock &listFree &listPool 44 44 &getTypeList &getPoolSelect &findAllocateFrom 45 & getParent &getRoutedCity45 &ipParent &subParent &blockParent &getRoutedCity 46 46 &allocateBlock &updateBlock &deleteBlock &getBlockData 47 47 &getNodeList &getNodeName &getNodeInfo … … 576 576 577 577 578 ## IPDB:: getParent()579 # Get a block's parent's details580 # Takes a database handle and CIDR block581 # Returns a hashref to the parent routed or containerblock, if any582 sub getParent {578 ## IPDB::ipParent() 579 # Get an IP's parent pool's details 580 # Takes a database handle and IP 581 # Returns a hashref to the parent pool block, if any 582 sub ipParent { 583 583 my $dbh = shift; 584 584 my $block = shift; … … 587 587 " WHERE cidr >>= ?", undef, ($block) ); 588 588 return $pinfo; 589 } # end getParent() 589 } # end ipParent() 590 591 592 ## IPDB::subParent() 593 # Get a block's parent's details 594 # Takes a database handle and CIDR block 595 # Returns a hashref to the parent container block, if any 596 sub subParent { 597 my $dbh = shift; 598 my $block = shift; 599 600 my $pinfo = $dbh->selectrow_hashref("SELECT cidr,custid,type,city,description FROM allocations". 601 " WHERE cidr >>= ?", undef, ($block) ); 602 return $pinfo; 603 } # end subParent() 604 605 606 ## IPDB::blockParent() 607 # Get a block's parent's details 608 # Takes a database handle and CIDR block 609 # Returns a hashref to the parent container block, if any 610 sub blockParent { 611 my $dbh = shift; 612 my $block = shift; 613 614 my $pinfo = $dbh->selectrow_hashref("SELECT cidr,city FROM routed". 615 " WHERE cidr >>= ?", undef, ($block) ); 616 return $pinfo; 617 } # end blockParent() 590 618 591 619 -
trunk/cgi-bin/main.cgi
r534 r536 328 328 # Snag the type of the container block from the database. 329 329 ## hmm. need a flag for parent class/type, sort of? 330 my $pblock = getParent($ip_dbh, $webvar{block});330 my $pblock = subParent($ip_dbh, $webvar{block}); 331 331 my $ptype = $pblock->{type}; 332 332 $ptype =~ s/c$/r/; … … 616 616 ##fixme: hook to force-set POP or city on certain alloctypes 617 617 # if ($webvar{alloctype =~ /foo,bar,bz/ { $webvar{pop} = 'blah'; } 618 if ($webvar{pop} =~ /^-$/) {618 if ($webvar{pop} && $webvar{pop} =~ /^-$/) { 619 619 $flag = 'to route the block from/through'; 620 620 } … … 722 722 return if !validateInput; 723 723 724 $webvar{swip} = 'n' if !$webvar{swip}; 725 724 726 my %updargs = ( 725 727 custid => $webvar{custid}, … … 730 732 block => $webvar{block}, 731 733 type => $webvar{alloctype}, 734 swip => $webvar{swip}, 732 735 ); 733 736 … … 760 763 761 764 # Link back to browse-routed or list-pool page on "Update complete" page. 762 my $cblock; # to contain the CIDR of the container block we're retrieving. 763 my $sql; 765 my $cblock; 764 766 if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) { 765 767 $page->param(backpool => 1); 766 $ sql = "select pool from poolips where ip='$webvar{block}'";768 $cblock = ipParent($ip_dbh, $webvar{block}); 767 769 } else { 768 $sql = "select cidr from routed where cidr >>= '$webvar{block}'"; 769 } 770 # I define there to be no errors on this operation... so we don't need to check for them. 771 $sth = $ip_dbh->prepare($sql); 772 $sth->execute; 773 $sth->bind_columns(\$cblock); 774 $sth->fetch(); 775 $sth->finish; 776 $page->param(backblock => $cblock); 770 $cblock = blockParent($ip_dbh, $webvar{block}); 771 } 772 $page->param(backblock => $cblock->{cidr}); 773 774 # Do some HTML fiddling here instead of using ESCAPE=HTML in the template, 775 # because otherwise we can't convert \n to <br>. *sigh* 776 $webvar{notes} = $q->escapeHTML($webvar{notes}); # escape first... 777 $webvar{notes} =~ s/\n/<br>\n/; # ... then convert newlines 778 $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : " "); 779 $webvar{privdata} =~ s/\n/<br>\n/; 777 780 778 781 $page->param(cidr => $webvar{block}); … … 781 784 $page->param(custid => $webvar{custid}); 782 785 $page->param(swip => $webvar{swip} eq 'on' ? 'Yes' : 'No'); 783 $page->param(circid => $q->escapeHTML($webvar{circid})); 784 $page->param(desc => $q->escapeHTML($webvar{desc})); 785 $page->param(notes => $q->escapeHTML($webvar{notes})); 786 $webvar{privdata} = ($webvar{privdata} ? $q->escapeHTML($webvar{privdata}) : " "); 786 $page->param(circid => $webvar{circid}); 787 $page->param(desc => $webvar{desc}); 788 $page->param(notes => $webvar{notes}); 787 789 $page->param(privdata => $webvar{privdata}) 788 790 if $IPDBacl{$authuser} =~ /s/;
Note:
See TracChangeset
for help on using the changeset viewer.