Changeset 528
- Timestamp:
- 10/24/12 16:34:36 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r527 r528 27 27 &initIPDBGlobals &connectDB &finish &checkDBSanity 28 28 &addMaster 29 &listSummary &listMaster &listRBlock &listFree 29 &listSummary &listMaster &listRBlock &listFree &listPool 30 30 &getRoutedCity 31 31 &allocateBlock &deleteBlock &getBlockData … … 40 40 &initIPDBGlobals &connectDB &finish &checkDBSanity 41 41 &addMaster 42 &listSummary &listMaster &listRBlock &listFree 42 &listSummary &listMaster &listRBlock &listFree &listPool 43 43 &getRoutedCity 44 44 &allocateBlock &deleteBlock &getBlockData … … 443 443 return \@flist; 444 444 } # end listFree() 445 446 447 ## IPDB::listPool() 448 # 449 sub listPool { 450 my $dbh = shift; 451 my $pool = shift; 452 453 my $sth = $dbh->prepare("SELECT ip,custid,available,description,type". 454 " FROM poolips WHERE pool = ? ORDER BY ip"); 455 $sth->execute($pool); 456 my @poolips; 457 while (my ($ip,$custid,$available,$desc,$type) = $sth->fetchrow_array) { 458 my %row = ( 459 ip => $ip, 460 custid => $custid, 461 available => $available, 462 desc => $desc, 463 delme => $available eq 'n' 464 ); 465 push @poolips, \%row; 466 } 467 return \@poolips; 468 } # end listPool() 445 469 446 470 … … 972 996 my $block = shift; 973 997 974 my $sth = $dbh->prepare("select cidr,custid,type,city,description from searchme". 975 " where cidr='$block'"); 976 $sth->execute(); 977 return $sth->fetchrow_array(); 998 my $binfo = $dbh->selectrow_hashref("SELECT cidr,custid,type,city,description FROM searchme". 999 " WHERE cidr = ?", undef, ($block) ); 1000 return $binfo; 978 1001 } # end getBlockData() 979 1002 -
trunk/cgi-bin/main.cgi
r527 r528 129 129 } 130 130 elsif($webvar{action} eq 'listpool') { 131 listPool();131 showPool(); 132 132 } 133 133 … … 267 267 268 268 # List the IPs used in a pool 269 sub listPool {269 sub showPool { 270 270 271 271 my $cidr = new NetAddr::IP $webvar{pool}; … … 280 280 281 281 # Snag pool info for heading 282 $sth = $ip_dbh->prepare("select type,city from allocations where cidr=?"); 283 $sth->execute($webvar{pool}); 284 my ($pooltype, $poolcity) = $sth->fetchrow_array; 285 286 $page->param(disptype => $disp_alloctypes{$pooltype}); 287 $page->param(city => $poolcity); 282 my $poolinfo = getBlockData($ip_dbh, $webvar{pool}); 283 284 $page->param(disptype => $disp_alloctypes{$poolinfo->{type}}); 285 $page->param(city => $poolinfo->{city}); 288 286 289 287 # Only display net/gw/bcast if it's a "real" netblock and not a PPP(oE) lunacy 290 $page->param(realblock => $pool type=~ /^.d$/);288 $page->param(realblock => $poolinfo->{type} =~ /^.d$/); 291 289 292 290 # probably have to add an "edit IP allocation" link here somewhere. 293 291 294 $sth = $ip_dbh->prepare("select ip,custid,available,description,type". 295 " from poolips where pool='$webvar{pool}' order by ip"); 296 $sth->execute; 297 my @poolips; 298 my $rowclass = 0; 299 while (my ($ip,$custid,$available,$desc,$type) = $sth->fetchrow_array) { 300 my %row = ( 301 rowclass => $rowclass++ % 2, 302 ip => $ip, 303 custid => $custid, 304 available => $available, 305 desc => $desc, 306 maydel => $IPDBacl{$authuser} =~ /d/, 307 delme => $available eq 'n' 308 ); 309 push @poolips, \%row; 310 } 311 $page->param(poolips => \@poolips); 312 313 } # end listPool 292 my $plist = listPool($ip_dbh, $webvar{pool}); 293 # technically slightly more efficient to check the ACL in an if () once outside the foreach 294 foreach (@{$plist}) { 295 $$_{maydel} = $IPDBacl{$authuser} =~ /d/; 296 } 297 $page->param(poolips => $plist); 298 } # end showPool 314 299 315 300 … … 1038 1023 1039 1024 # need to retrieve block data before deleting so we can notify on that 1040 my ($cidr,$custid,$type,$city,$description)= getBlockData($ip_dbh, $webvar{block});1025 my $blockinfo = getBlockData($ip_dbh, $webvar{block}); 1041 1026 1042 1027 my ($code,$msg) = deleteBlock($ip_dbh, $webvar{block}, $webvar{alloctype}); … … 1044 1029 $page->param(block => $webvar{block}); 1045 1030 if ($code eq 'OK') { 1046 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block} ".1047 " $custid, $city, desc='$description'";1031 syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block} ". 1032 $blockinfo->{custid}.", ".$blockinfo->{city}.", desc='".$blockinfo->{description}."'"; 1048 1033 mailNotify($ip_dbh, 'da', "REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}", 1049 1034 "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n". 1050 "CustID: $custid\nCity: $city\nDescription: $description\n"); 1035 "CustID: ".$blockinfo->{custid}."\nCity: ".$blockinfo->{city}. 1036 "\nDescription: ".$blockinfo->{description}."\n"); 1051 1037 } else { 1052 1038 $page->param(failmsg => $msg); -
trunk/templates/listpool.tmpl
r517 r528 28 28 29 29 <TMPL_LOOP name=poolips> 30 <tr class="row<TMPL_ VAR NAME=rowclass>">30 <tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>"> 31 31 <td><a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&block=<TMPL_VAR NAME=ip>"><TMPL_VAR NAME=ip></a></td> 32 32 <td><TMPL_VAR NAME=custid></td>
Note:
See TracChangeset
for help on using the changeset viewer.