Ignore:
Timestamp:
02/03/05 14:23:34 (20 years ago)
Author:
Kris Deugau
Message:

/branches/sql-cleanup

Fixed a bunch of general problems with pool allocations, and
rearranged some code, alloctypes, and the poolips table (ugh)
to more cleanly support different types of IP pool.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sql-cleanup/cgi-bin/main.cgi

    r142 r149  
    354354        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    355355    # Allow listing of pool if desired/required.
    356     if ($data[2] =~ /^[cdsmw]p$/) {
     356    if ($data[2] =~ /^.[pd]$/) {
    357357      $row[0] .= ' &nbsp; <a href="/ip/cgi-bin/main.cgi?action=listpool'.
    358358        "&pool=$data[0]\">List IPs</a>";
     
    620620        $data[3], $disp_alloctypes{$data[2]}, $data[1], $data[4]);
    621621    # If the allocation is a pool, allow listing of the IPs in the pool.
    622     if ($data[2] =~ /^[cdsmw]p$/) {
     622    if ($data[2] =~ /^.[pd]$/) {
    623623      $row[0] .= ' &nbsp; <a href="/ip/cgi-bin/main.cgi?action=listpool'.
    624624        "&pool=$data[0]\">List IPs</a>";
     
    675675  my $cidr = new NetAddr::IP $webvar{pool};
    676676
     677  my ($pooltype,$poolcity);
     678
    677679  # Snag pool info for heading
    678   $sth = $ip_dbh->prepare("select * from allocations where cidr='$cidr'");
     680  $sth = $ip_dbh->prepare("select type,city from allocations where cidr='$cidr'");
    679681  $sth->execute;
    680   my @data = $sth->fetchrow_array;
    681   my $type = $data[2];  # We'll need this later.
     682  $sth->bind_columns(\$pooltype, \$poolcity);
     683  $sth->fetch() || carp $sth->errstr;
    682684
    683685  print qq(<center><div class="heading">Listing pool IPs for $cidr<br>\n).
    684         qq(($disp_alloctypes{$type} in $data[3])</div></center><br>\n);
    685   print qq(<div class="indent"><b>Reserved IPs:</b><br>\n);
    686   print qq(<div class="indent"><table><tr class=color1><td>Network IP:</td><td>).
     686        qq(($disp_alloctypes{$pooltype} in $poolcity)</div></center><br>\n);
     687  # Only display net/gw/bcast if it's a "real" netblock and not a PPP(oE) lunacy
     688  if ($pooltype =~ /^.d$/) {
     689    print qq(<div class="indent"><b>Reserved IPs:</b><br>\n);
     690    print qq(<div class="indent"><table><tr class=color1><td>Network IP:</td><td>).
    687691        $cidr->addr."</td></tr>\n";
    688   $cidr++;
    689   print "<tr class=color2><td>Gateway:</td><td>".$cidr->addr."</td></tr>\n";
    690   $cidr--;  $cidr--;
    691   print "<tr class=color1><td>Broadcast:</td><td>".$cidr->addr."</td></tr>\n".
     692    $cidr++;
     693    print "<tr class=color2><td>Gateway:</td><td>".$cidr->addr."</td></tr>\n";
     694    $cidr--;  $cidr--;
     695    print "<tr class=color1><td>Broadcast:</td><td>".$cidr->addr."</td></tr>\n".
    692696        "<tr><td>Netmask:</td><td>".$cidr->mask."</td></tr>\n".
    693697        "</table></div></div>\n";
     698  }
    694699
    695700# probably have to add an "edit IP allocation" link here somewhere.
     
    973978        "'$webvar{alloctype}' by $authuser failed: '$msg'";
    974979    printError("Allocation of $webvar{fullcidr} as $disp_alloctypes{$webvar{alloctype}}".
    975         " failed: $msg\n");
     980        " failed:<br>\n$msg\n");
    976981  }
    977982
Note: See TracChangeset for help on using the changeset viewer.