Changeset 24


Ignore:
Timestamp:
10/26/04 11:26:11 (20 years ago)
Author:
Kris Deugau
Message:

Merge bugfixes and updates in r18:23 from /trunk to /branches/stable

Location:
branches/stable
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/stable/assign.html

    r4 r24  
    4141<option>Timmins</option>
    4242<option>Thessalon</option>
     43<option>Thunder Bay</option>
    4344<option>Toronto</option>
    4445<option>Wawa</option>
     
    8081<option>Sudbury</option>
    8182<option>Timmins</option>
     83<option>Thunder Bay</option>
    8284<option>Toronto</option>
    8385</select>
  • branches/stable/cgi-bin/main.cgi

    r17 r24  
    694694    my $cidr = new NetAddr::IP $data[0];
    695695    if ($master->contains($cidr)) {
    696       my @row = ("$cidr", $cidr->range);
     696      my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>",
     697        $cidr->range);
    697698      printRow(\@row, 'color1') if ($count%2 == 0);
    698699      printRow(\@row, 'color2') if ($count%2 != 0);
     
    766767  printHeader('');
    767768
    768   open HTML, "../assign.html"
     769  my $html;
     770
     771  # New special case- block to assign is specified
     772  if ($webvar{block} ne '') {
     773    open HTML, "../fb-assign.html"
     774        or croak "Could not open fb-assign.html: $!";
     775    $html = join('',<HTML>);
     776    close HTML;
     777    my $block = new NetAddr::IP $webvar{block};
     778    $html =~ s|\$\$BLOCK\$\$|$block|g;
     779    $html =~ s|\$\$MASKBITS\$\$|$block->masklen|;
     780  } else {
     781    open HTML, "../assign.html"
    769782        or croak "Could not open assign.html: $!";
    770   my $html = join('',<HTML>);
    771   close(HTML);
     783    $html = join('',<HTML>);
     784    close HTML;
     785  }
    772786
    773787  print $html;
     
    830844
    831845  } else { # end show pool options
    832     if (!$webvar{maskbits}) {
    833       printAndExit("Please specify a CIDR mask length.");
    834     }
    835     my $sql;
    836     my $city;
    837     my $failmsg;
    838     if ($webvar{alloctype} eq 'rr') {
    839       $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
    840         " order by maskbits desc";
    841       $failmsg = "No suitable free block found.<br>\nWe do not have a free".
    842         " routeable block of that size.<br>\nYou will have to either route".
    843         " a set of smaller netblocks or a single smaller netblock.";
    844     } else {
    845       if ($webvar{alloctype} =~ /^[sd]p$/) {
    846         if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
    847           printAndExit("You must chose Sudbury or North Bay for DSL pools."); }
    848         if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; }
    849         $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    850           " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller".
    851           " block size for the pool.";
     846
     847    if ($webvar{fbassign} eq 'y') {
     848      $cidr = new NetAddr::IP $webvar{block};
     849      $webvar{maskbits} = $cidr->masklen;
     850    } else { # done with direct freeblocks assignment
     851
     852      if (!$webvar{maskbits}) {
     853        printAndExit("Please specify a CIDR mask length.");
     854      }
     855      my $sql;
     856      my $city;
     857      my $failmsg;
     858      if ($webvar{alloctype} eq 'rr') {
     859        $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
     860          " order by maskbits desc";
     861        $failmsg = "No suitable free block found.<br>\nWe do not have a free".
     862          " routeable block of that size.<br>\nYou will have to either route".
     863          " a set of smaller netblocks or a single smaller netblock.";
    852864      } else {
    853         $city = $webvar{pop};
    854         $failmsg = "No suitable free block found.<br>\nYou will have to route another".
    855           " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or".
    856           " chose a smaller blocksize.";
    857       }
    858       $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    859         " and routed='y' order by cidr,maskbits desc";
    860     }
    861     $sth = $ip_dbh->prepare($sql);
    862     $sth->execute;
    863     my @data = $sth->fetchrow_array();
    864     if ($data[0] eq "") {
    865       printAndExit($failmsg);
    866     }
    867 
    868     $cidr = new NetAddr::IP $data[0];
     865        if ($webvar{alloctype} =~ /^[sd]p$/) {
     866          if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
     867            printAndExit("You must chose Sudbury or North Bay for DSL pools."); }
     868          if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; }
     869          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
     870            " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller".
     871            " block size for the pool.";
     872        } else {
     873          $city = $webvar{pop};
     874          $failmsg = "No suitable free block found.<br>\nYou will have to route another".
     875            " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or".
     876            " chose a smaller blocksize.";
     877        }
     878        $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
     879          " and routed='y' order by cidr,maskbits desc";
     880      }
     881      $sth = $ip_dbh->prepare($sql);
     882      $sth->execute;
     883      my @data = $sth->fetchrow_array();
     884      if ($data[0] eq "") {
     885        printAndExit($failmsg);
     886      }
     887      $cidr = new NetAddr::IP $data[0];
     888    } # check for freeblocks assignment or IPDB-controlled assignment
     889
    869890    $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">);
    870891
     
    11201141      printAndExit("Please enter a customer ID.");
    11211142    }
    1122     if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)$/) {
     1143    if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) {
    11231144      printAndExit("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff.");
    11241145    }
     
    12211242    } else {
    12221243      $sql = "update allocations set custid='$webvar{custid}',".
    1223         "description='$webvar{desc}',notes='$webvar{notes}' ".
     1244        "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}' ".
    12241245        "where cidr='$webvar{block}'";
    12251246    }
     
    14891510    }
    14901511    print "<div class=heading align=center>Success!  $webvar{block} deleted.</div>\n";
    1491     syslog "notice", "$authuser deallocated netblock $webvar{block}";
     1512    syslog "notice", "$authuser deallocated '$webvar{alloctype}'-type netblock $webvar{block}";
    14921513
    14931514  } # end alloctype != netblock
  • branches/stable/editDisplay.html

    r4 r24  
    88<tr class="color1"><td class=heading>IP block:</td><td colspan=2 class="regular">$$BLOCK$$</td></tr>
    99
    10 <tr class="color2"><td class=heading>City:</td><td colspan=2 class="regular">$$CITY$$<input type=hidden name=city value="$$CITY$$"></td></tr>
     10<tr class="color2"><td class=heading>City:</td><td colspan=2 class="regular">
     11<input type=text name=city value="$$CITY$$"></td></tr>
    1112
    1213<tr class="color1"><td class=heading>Type:</td><td colspan=2 class=regular>$$FULLTYPE$$
Note: See TracChangeset for help on using the changeset viewer.