Changeset 471 for branches/htmlform
- Timestamp:
- 08/17/10 16:33:43 (14 years ago)
- Location:
- branches/htmlform
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/htmlform/cgi-bin/main.cgi
r470 r471 483 483 my $cidr = new NetAddr::IP $webvar{pool}; 484 484 485 my ($pooltype,$poolcity); 485 $page->param(block => $webvar{pool}); 486 $page->param(netip => $cidr->addr); 487 $cidr++; 488 $page->param(gate => $cidr->addr); 489 $cidr--; $cidr--; 490 $page->param(bcast => $cidr->addr); 491 $page->param(mask => $cidr->mask); 486 492 487 493 # Snag pool info for heading 488 $sth = $ip_dbh->prepare("select type,city from allocations where cidr='$cidr'"); 489 $sth->execute; 490 $sth->bind_columns(\$pooltype, \$poolcity); 491 $sth->fetch() || carp $sth->errstr; 492 493 print qq(<center><div class="heading">Listing pool IPs for $cidr<br>\n). 494 qq(($disp_alloctypes{$pooltype} in $poolcity)</div></center><br>\n); 494 $sth = $ip_dbh->prepare("select type,city from allocations where cidr=?"); 495 $sth->execute($webvar{pool}); 496 my ($pooltype, $poolcity) = $sth->fetchrow_array; 497 498 $page->param(disptype => $disp_alloctypes{$pooltype}); 499 $page->param(city => $poolcity); 500 501 # print qq(<center><div class="heading">Listing pool IPs for $cidr<br>\n). 502 # qq(($disp_alloctypes{$pooltype} in $poolcity)</div></center><br>\n); 495 503 # Only display net/gw/bcast if it's a "real" netblock and not a PPP(oE) lunacy 496 if ($pooltype =~ /^.d$/) { 497 print qq(<div class="indent"><b>Reserved IPs:</b><br>\n); 498 print qq(<div class="indent"><table><tr class=color1><td>Network IP:</td><td>). 499 $cidr->addr."</td></tr>\n"; 500 $cidr++; 501 print "<tr class=color2><td>Gateway:</td><td>".$cidr->addr."</td></tr>\n"; 502 $cidr--; $cidr--; 503 print "<tr class=color1><td>Broadcast:</td><td>".$cidr->addr."</td></tr>\n". 504 "<tr><td>Netmask:</td><td>".$cidr->mask."</td></tr>\n". 505 "</table></div></div>\n"; 506 } 504 $page->param(realblock => $pooltype =~ /^.d$/); 507 505 508 506 # probably have to add an "edit IP allocation" link here somewhere. 509 507 510 startTable('IP','Customer ID','Available?','Description','');511 508 $sth = $ip_dbh->prepare("select ip,custid,available,description,type". 512 509 " from poolips where pool='$webvar{pool}' order by ip"); 513 510 $sth->execute; 514 my $count = 0; 515 while (my @data = $sth->fetchrow_array) { 516 # pool,ip,custid,city,ptype,available,notes,description,circuitid 517 # ip,custid,available,description,type 518 # If desc is "null", make it not null. <g> 519 if ($data[3] eq '') { 520 $data[3] = ' '; 521 } 522 # Some nice hairy Perl to decide whether to allow unassigning each IP 523 # -> if $data[2] (aka poolips.available) == 'n' then we print the unassign link 524 # else we print a blank space 525 my @row = ( qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>), 526 $data[1],$data[2],$data[3], 527 ( (($data[2] eq 'n') && ($IPDBacl{$authuser} =~ /d/)) ? 528 ("<a href=\"/ip/cgi-bin/main.cgi?action=delete&block=$data[0]&". 529 "alloctype=$data[4]\">Unassign this IP</a>") : 530 (" ") ) 511 my @poolips; 512 my $rowclass = 0; 513 while (my ($ip,$custid,$available,$desc,$type) = $sth->fetchrow_array) { 514 my %row = ( 515 rowclass => $rowclass++ % 2, 516 ip => $ip, 517 custid => $custid, 518 available => $available, 519 desc => $desc, 520 maydel => $IPDBacl{$authuser} =~ /d/, 521 delme => $available eq 'n' 531 522 ); 532 printRow(\@row, 'color1') if($count%2==0); 533 printRow(\@row, 'color2') if($count%2!=0); 534 $count++; 535 } 536 print "</table>\n"; 523 push @poolips, \%row; 524 } 525 $page->param(poolips => \@poolips); 537 526 538 527 } # end listPool
Note:
See TracChangeset
for help on using the changeset viewer.