Changeset 211 for branches/stable


Ignore:
Timestamp:
04/04/05 17:19:24 (20 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Fixed bug-in-waiting that would create some... odd... results
while assigning a static IP if the poolips data gets a little wonky.

This removes a ##fixme note! w00t!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/cgi-bin/main.cgi

    r209 r211  
    820820  if ($webvar{alloctype} =~ /^.i$/) {
    821821    my ($base,undef) = split //, $webvar{alloctype};    # split into individual chars
    822     my $sql;
    823     # Check for pools in Subury or North Bay if DSL or server pool.  Anywhere else is
    824     # invalid and shouldn't be in the db in the first place.
     822    my ($sql,$city);
     823    # Check for pools in Subury, North Bay, or Toronto if DSL or server pool.
     824    # Anywhere else is invalid and shouldn't be in the db in the first place.
    825825    # ... aside from #^%#$%#@#^%^^!!!! legacy data.  GRRR.
    826826    # Note that we want to retain the requested city to relate to customer info.
    827 ##fixme This needs thought.
    828 ##SELECT DISTINCT pool, Count(*) FROM poolips where available='y' GROUP BY pool;
    829827    if ($base =~ /^[ds]$/) {
    830       $sql = "select * from poolips where available='y' and".
    831         " type='$webvar{alloctype}' and (city='Sudbury' or city='North Bay' or city='Toronto')";
     828      $city = "(allocations.city='Sudbury' or allocations.city='North Bay' or ".
     829        "allocations.city='Toronto')";
    832830    } else {
    833       $sql = "select * from poolips where available='y' and".
    834         " type='$webvar{alloctype}' and city='$webvar{pop}'";
    835     }
    836 
    837     # Now that we know where we're looking, we can list the pools with free IPs.
    838     $sth = $ip_dbh->prepare($sql);
     831      $city = "allocations.city='$webvar{pop}'";
     832    }
     833
     834# Ewww.  But it works.
     835    $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ".
     836        "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ".
     837        "poolips.pool=allocations.cidr AND $city AND poolips.type LIKE '".$base."_' ".
     838        "GROUP BY pool");
    839839    $sth->execute;
    840     my %ipcount;
    841840    my $optionlist;
    842841    while (my @data = $sth->fetchrow_array) {
    843       $ipcount{$data[0]}++;
    844     }
    845     $sth = $ip_dbh->prepare("select city from allocations where cidr=?");
    846     foreach my $key (keys %ipcount) {
    847       $sth->execute($key);
    848       my @data = $sth->fetchrow_array;
    849       $optionlist .= "<option value='$key'>$key [$ipcount{$key} free IP(s)] in $data[0]</option>\n";
     842      # city,pool cidr,free IP count
     843      if ($data[2] > 0) {
     844        $optionlist .= "<option value='$data[1]'>$data[1] [$data[2] free IP(s)] in $data[0]</option>\n";
     845      }
    850846    }
    851847    $cidr = "Single static IP";
     
    880876##fixme
    881877# This section needs serious Pondering.
    882         # Pools of all types get assigned to the POP they're "routed from"
     878        # Pools of most types get assigned to the POP they're "routed from"
    883879        # This includes WAN blocks and other netblock "containers"
    884         if ($webvar{alloctype} =~ /^.[pdc]$/) {
     880        # This does NOT include cable pools.
     881        if ($webvar{alloctype} =~ /^.[pc]$/) {
    885882          if (($webvar{city} !~ /^(Sudbury|North Bay|Toronto)$/) && ($webvar{alloctype} eq 'dp')) {
    886883            printError("You must chose Sudbury, North Bay, or Toronto for DSL pools.");
Note: See TracChangeset for help on using the changeset viewer.