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


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

/trunk

Port bugfixes from /branches/stable r203-206 and r209-213 forward.
Clean merge.

File:
1 edited

Legend:

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

    r199 r214  
    171171print qq(<div align=right style="position: absolute; right: 30px;">).
    172172        qq(<a href="/ip/cgi-bin/admin.cgi">Admin tools</a></div><br>\n)
    173         if $authuser =~ /kdeugau|jodyh/;
     173        if $authuser =~ /kdeugau|jodyh|jipp/;
    174174
    175175# We print the footer here, so we don't have to do it elsewhere.
     
    815815  if ($webvar{alloctype} =~ /^.i$/) {
    816816    my ($base,undef) = split //, $webvar{alloctype};    # split into individual chars
    817     my $sql;
    818     # Check for pools in Subury or North Bay if DSL or server pool.  Anywhere else is
    819     # invalid and shouldn't be in the db in the first place.
     817    my ($sql,$city);
     818    # Check for pools in Subury, North Bay, or Toronto if DSL or server pool.
     819    # Anywhere else is invalid and shouldn't be in the db in the first place.
    820820    # ... aside from #^%#$%#@#^%^^!!!! legacy data.  GRRR.
    821821    # Note that we want to retain the requested city to relate to customer info.
    822 ##fixme This needs thought.
    823 ##SELECT DISTINCT pool, Count(*) FROM poolips where available='y' GROUP BY pool;
    824822    if ($base =~ /^[ds]$/) {
    825       $sql = "select * from poolips where available='y' and".
    826         " type='$webvar{alloctype}' and (city='Sudbury' or city='North Bay')";
     823      $city = "(allocations.city='Sudbury' or allocations.city='North Bay' or ".
     824        "allocations.city='Toronto')";
    827825    } else {
    828       $sql = "select * from poolips where available='y' and".
    829         " type='$webvar{alloctype}' and city='$webvar{pop}'";
    830     }
    831 
    832     # Now that we know where we're looking, we can list the pools with free IPs.
    833     $sth = $ip_dbh->prepare($sql);
     826      $city = "allocations.city='$webvar{pop}'";
     827    }
     828
     829# Ewww.  But it works.
     830    $sth = $ip_dbh->prepare("SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool), ".
     831        "poolips.pool, COUNT(*) FROM poolips,allocations WHERE poolips.available='y' AND ".
     832        "poolips.pool=allocations.cidr AND $city AND poolips.type LIKE '".$base."_' ".
     833        "GROUP BY pool");
    834834    $sth->execute;
    835     my %ipcount;
    836835    my $optionlist;
    837836    while (my @data = $sth->fetchrow_array) {
    838       $ipcount{$data[0]}++;
    839     }
    840     $sth = $ip_dbh->prepare("select city from allocations where cidr=?");
    841     foreach my $key (keys %ipcount) {
    842       $sth->execute($key);
    843       my @data = $sth->fetchrow_array;
    844       $optionlist .= "<option value='$key'>$key [$ipcount{$key} free IP(s)] in $data[0]</option>\n";
     837      # city,pool cidr,free IP count
     838      if ($data[2] > 0) {
     839        $optionlist .= "<option value='$data[1]'>$data[1] [$data[2] free IP(s)] in $data[0]</option>\n";
     840      }
    845841    }
    846842    $cidr = "Single static IP";
     
    875871##fixme
    876872# This section needs serious Pondering.
    877         # Pools of all types get assigned to the POP they're "routed from"
     873        # Pools of most types get assigned to the POP they're "routed from"
    878874        # This includes WAN blocks and other netblock "containers"
    879         if ($webvar{alloctype} =~ /^.[pdc]$/) {
    880           if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
    881             printError("You must chose Sudbury or North Bay for DSL pools.");
     875        # This does NOT include cable pools.
     876        if ($webvar{alloctype} =~ /^.[pc]$/) {
     877          if (($webvar{city} !~ /^(Sudbury|North Bay|Toronto)$/) && ($webvar{alloctype} eq 'dp')) {
     878            printError("You must chose Sudbury, North Bay, or Toronto for DSL pools.");
    882879            return;
    883880          }
     
    976973      print qq(<div class="center"><div class="heading">The IP $msg has been allocated to customer $webvar{custid}</div></div>);
    977974      # Notify tech@example.com
    978       mailNotify('tech@example.com',"$disp_alloctypes{$webvar{alloctype}} allocation",
     975      mailNotify('tech@example.com',"ADDED: $disp_alloctypes{$webvar{alloctype}} allocation",
    979976        "$disp_alloctypes{$webvar{alloctype}} $msg allocated to customer $webvar{custid}\n".
    980977        "Description: $webvar{desc}\n\nAllocated by: $authuser\n");
     
    10151012  # CustID check
    10161013  # We have different handling for customer allocations and "internal" or "our" allocations
    1017   if ($webvar{alloctype} =~ /^(cn|.i)$/) {
     1014  if ($def_custids{$webvar{alloctype}} eq '') {
    10181015    if (!$webvar{custid}) {
    10191016      printError("Please enter a customer ID.");
     
    12941291    print "<div class=heading align=center>Success!  $webvar{block} deallocated.</div>\n";
    12951292    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}";
     1293    # Notify tech@ when a block/IP is deallocated
     1294    mailNotify('tech@example.com',"REMOVED: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
     1295        "$disp_alloctypes{$webvar{alloctype}} $webvar{block} deallocated by $authuser\n");
    12961296  } else {
    12971297    if ($webvar{alloctype} =~ /^.i$/) {
Note: See TracChangeset for help on using the changeset viewer.