Changeset 186 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
03/03/05 17:14:54 (19 years ago)
Author:
Kris Deugau
Message:

/trunk

First round of changes for "clean" handling of subblock allocations.
Note that the code will likely malfunction in a number of corner
and not-so-corner cases. Fixing those will require rethinking of
the allocation types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r184 r186  
    331331      $data[2] .= 'i';
    332332    }
    333     my @row = (qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
     333    my @row = ( (($data[2] =~ /^l.$/) ? 'Sub ' : '').
     334        qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    334335        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    335336    # Allow listing of pool if desired/required.
     
    598599#    $data[2] =~ s/\s+//g;
    599600
    600     my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=edit&block=$data[0]\">$data[0]</a>",
     601    my @row = ( (($data[2] =~ /^l.$/) ? 'Sub ' : '').
     602        qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    601603        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    602604    # If the allocation is a pool, allow listing of the IPs in the pool.
     
    634636  # unrouted free blocks, but it's better to let the database do the work if we can.
    635637  $count = 0;
    636   $sth = $ip_dbh->prepare("select cidr from freeblocks where routed='y' and cidr <<= '$master' order by cidr");
     638  $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'".
     639        " order by cidr");
    637640  $sth->execute();
    638641  while (my @data = $sth->fetchrow_array()) {
    639     # cidr,maskbits,city
     642    # cidr,routed
    640643    my $cidr = new NetAddr::IP $data[0];
    641     my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>",
     644    my @row = ((($data[1] eq 'r') ? 'Sub ' : '').
     645        "<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>",
    642646        $cidr->range);
    643647    printRow(\@row, 'color1') if ($count%2 == 0);
     
    869873        if ($webvar{allocfrom} ne '-') {
    870874          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    871                 " and cidr <<= '$webvar{allocfrom}' and routed='y' order by cidr,maskbits desc";
     875                " and cidr <<= '$webvar{allocfrom}' and routed='".
     876                (($webvar{alloctype} =~ /^l.$/) ? 'r' : 'y')."' order by cidr,maskbits desc";
    872877        } else {
    873878          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    874                 " and routed='y' order by cidr,maskbits desc";
     879                " and routed='".(($webvar{alloctype} =~ /^l.$/) ? 'r' : 'y').
     880                "' order by cidr,maskbits desc";
    875881        }
    876882      }
Note: See TracChangeset for help on using the changeset viewer.