Ignore:
Timestamp:
03/10/05 14:15:19 (20 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Merge updates and changes (and bugfixes to same) from /trunk
r186,187 and r189-191

File:
1 edited

Legend:

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

    r185 r192  
    325325
    326326  while (my @data = $sth->fetchrow_array) {
    327     # cidr,custid,type,city,description,notes
    328     # Fix up types from pools (which are single-char)
    329     # Fixing the database would be...  painful.  :(
    330 ##fixme LEGACY CODE
    331     if ($data[2] =~ /^[cdsmw]$/) {
    332       $data[2] .= 'i';
    333     }
    334     my @row = (qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
     327    # cidr,custid,type,city,description
     328    # Prefix subblocks with "Sub "
     329    my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : '').
     330        qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    335331        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    336332    # Allow listing of pool if desired/required.
     
    599595#    $data[2] =~ s/\s+//g;
    600596
    601     my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=edit&block=$data[0]\">$data[0]</a>",
     597    # Prefix subblocks with "Sub "
     598    my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : '').
     599        qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    602600        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    603601    # If the allocation is a pool, allow listing of the IPs in the pool.
     
    622620        qq(<input type=hidden name=action value="delete">\n).
    623621        qq(<input type=hidden name=block value="$master">\n).
    624         qq(<input type=hidden name=alloctype value="rr">\n).
     622        qq(<input type=hidden name=alloctype value="rm">\n).
    625623        qq(<input type=submit value=" Remove this block ">\n).
    626624        qq(</form>\n);
     
    635633  # unrouted free blocks, but it's better to let the database do the work if we can.
    636634  $count = 0;
    637   $sth = $ip_dbh->prepare("select cidr from freeblocks where routed='y' and cidr <<= '$master' order by cidr");
     635  $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'".
     636        " order by cidr");
    638637  $sth->execute();
    639638  while (my @data = $sth->fetchrow_array()) {
    640     # cidr,maskbits,city
     639    # cidr,routed
    641640    my $cidr = new NetAddr::IP $data[0];
    642     my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>",
     641    # Include some HairyPerl(TM) to prefix subblocks with "Sub "
     642    my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : '').
     643        qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>),
    643644        $cidr->range);
    644645    printRow(\@row, 'color1') if ($count%2 == 0);
     
    730731    $html =~ s|\$\$MASKBITS\$\$|$block->masklen|;
    731732    my $typelist = '';
    732     $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 and type not like '_i' order by listorder");
    733     $sth->execute;
    734     my @data = $sth->fetchrow_array;
    735     $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n";
    736     while (my @data = $sth->fetchrow_array) {
    737       $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
     733
     734    # This is a little dangerous, as it's *theoretically* possible to
     735    # get fbtype='n' (aka a non-routed freeblock).  However, should
     736    # someone manage to get there, they get what they deserve.
     737    if ($webvar{fbtype} ne 'y') {
     738      # Snag the type of the block from the database.  We have no
     739      # convenient way to pass this in from the calling location.  :/
     740      $sth = $ip_dbh->prepare("select type from allocations where cidr >>='$block'");
     741      $sth->execute;
     742      my @data = $sth->fetchrow_array;
     743      $data[0] =~ s/c$/r/;      # Munge the type into the correct form
     744      $typelist = "$list_alloctypes{$data[0]}<input type=hidden name=alloctype value=$data[0]>\n";
     745    } else {
     746      $typelist .= qq(<select name="alloctype">\n);
     747      $sth = $ip_dbh->prepare("select type,listname from alloctypes where listorder < 500 ".
     748        "and type not like '_i' and type not like '_r' order by listorder");
     749      $sth->execute;
     750      my @data = $sth->fetchrow_array;
     751      $typelist .= "<option value='$data[0]' selected>$data[1]</option>\n";
     752      while (my @data = $sth->fetchrow_array) {
     753        $typelist .= "<option value='$data[0]'>$data[1]</option>\n";
     754      }
     755      $typelist .= "</select>\n";
    738756    }
    739757    $html =~ s|\$\$TYPELIST\$\$|$typelist|g;
     
    839857      my $city;
    840858      my $failmsg;
    841       if ($webvar{alloctype} eq 'rr') {
     859      if ($webvar{alloctype} eq 'rm') {
    842860        if ($webvar{allocfrom} ne '-') {
    843861          $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
     
    853871##fixme
    854872# This section needs serious Pondering.
    855         if ($webvar{alloctype} =~ /^.[pd]$/) {
     873        # Pools of all types get assigned to the POP they're "routed from"
     874        # This includes WAN blocks and other netblock "containers"
     875        if ($webvar{alloctype} =~ /^.[pdc]$/) {
    856876          if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
    857877            printError("You must chose Sudbury or North Bay for DSL pools.");
     
    870890        if ($webvar{allocfrom} ne '-') {
    871891          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    872                 " and cidr <<= '$webvar{allocfrom}' and routed='y' order by cidr,maskbits desc";
     892                " and cidr <<= '$webvar{allocfrom}' and routed='".
     893                (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."' order by maskbits desc,cidr";
    873894        } else {
    874895          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    875                 " and routed='y' order by cidr,maskbits desc";
     896                " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y').
     897                "' order by maskbits desc,cidr";
    876898        }
    877899      }
     
    955977    } else {
    956978      print qq(<div class="center"><div class="heading">The block $webvar{fullcidr} was ).
    957         "sucessfully added as type '$webvar{alloctype}' ".
    958         "($disp_alloctypes{$webvar{alloctype}})</div></div>";
     979        "sucessfully added as: $disp_alloctypes{$webvar{alloctype}}</div></div>";
    959980    }
    960981    syslog "notice", "$authuser allocated '$webvar{fullcidr}' to '$webvar{custid}' as ".
     
    963984    syslog "err", "Allocation of '$webvar{fullcidr}' to '$webvar{custid}' as ".
    964985        "'$webvar{alloctype}' by $authuser failed: '$msg'";
    965     printError("Allocation of $webvar{fullcidr} as $disp_alloctypes{$webvar{alloctype}}".
     986    printError("Allocation of $webvar{fullcidr} as '$disp_alloctypes{$webvar{alloctype}}'".
    966987        " failed:<br>\n$msg\n");
    967988  }
     
    10231044  # Check POP location
    10241045  my $flag;
    1025   if ($webvar{alloctype} eq 'rr') {
     1046  if ($webvar{alloctype} eq 'rm') {
    10261047    $flag = 'for a routed netblock';
    10271048    foreach (@poplist) {
     
    10951116# this has now been Requested, so here goes.
    10961117
    1097   if ($data[2] =~ /^d[nyc]|cn|ee|in$/) {
     1118##fixme The check here should be built from the database
     1119  if ($data[2] =~ /^.[ne]$/) {
    10981120    # Block that can be changed
    10991121    my $blockoptions = "<select name=alloctype><option".
    1100         (($data[2] eq 'dn') ? ' selected' : '') ." value='dn'>Dialup netblock</option>\n<option".
    1101         (($data[2] eq 'dy') ? ' selected' : '') ." value='dy'>Dynamic DSL netblock</option>\n<option".
    1102         (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".
     1122        (($data[2] eq 'me') ? ' selected' : '') ." value='me'>Dialup netblock</option>\n<option".
     1123        (($data[2] eq 'de') ? ' selected' : '') ." value='de'>Dynamic DSL netblock</option>\n<option".  (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".
     1124        (($data[2] eq 'ce') ? ' selected' : '') ." value='ce'>Dynamic cable netblock</option>\n<option".        (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".
     1125        (($data[2] eq 'we') ? ' selected' : '') ." value='we'>Dynamic wireless netblock</option>\n<option".     (($data[2] eq 'dc') ? ' selected' : '') ." value='dc'>Dynamic cable netblock</option>\n<option".
    11031126        (($data[2] eq 'cn') ? ' selected' : '') ." value='cn'>Customer netblock</option>\n<option".
    1104         (($data[2] eq 'ee') ? ' selected' : '') ." value='ee'>End-use netblock</option>\n<option".
     1127        (($data[2] eq 'en') ? ' selected' : '') ." value='en'>End-use netblock</option>\n<option".
    11051128        (($data[2] eq 'in') ? ' selected' : '') ." value='in'>Internal netblock</option>\n".
    11061129        "</select>\n";
     
    11991222  my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype);
    12001223
    1201   if ($webvar{alloctype} eq 'rr') {
     1224  if ($webvar{alloctype} eq 'rm') {
    12021225    $sth = $ip_dbh->prepare("select cidr,city from routed where cidr='$webvar{block}'");
    12031226    $sth->execute();
     
    12231246    $desc = "N/A";
    12241247    $notes = "N/A";
    1225   } elsif ($webvar{alloctype} =~ /^.i$/) { # done with alloctype=rr
     1248  } elsif ($webvar{alloctype} =~ /^.i$/) { # done with alloctype=[rm]m
    12261249
    12271250    # Unassigning a static IP
Note: See TracChangeset for help on using the changeset viewer.