Changeset 157 for trunk


Ignore:
Timestamp:
02/08/05 15:56:33 (19 years ago)
Author:
Kris Deugau
Message:

/trunk

Merge changes from /branches/sql-cleanup into mainline

  • Merge was clean
Location:
trunk/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r146 r157  
    5858
    5959  # Initialize alloctypes hashes
    60   $sth = $dbh->prepare("select * from alloctypes order by listorder");
     60  $sth = $dbh->prepare("select type,listname,dispname,listorder from alloctypes order by listorder");
    6161  $sth->execute;
    6262  while (my @data = $sth->fetchrow_array) {
     
    6868
    6969  # City and POP listings
    70   $sth = $dbh->prepare("select * from cities order by city");
     70  $sth = $dbh->prepare("select city,routing from cities order by city");
    7171  $sth->execute;
    7272  return (undef,$sth->errstr) if $sth->err;
     
    7979
    8080  # Master block list
    81   $sth = $dbh->prepare("select * from masterblocks order by cidr");
     81  $sth = $dbh->prepare("select cidr from masterblocks order by cidr");
    8282  $sth->execute;
    8383  for (my $i=0; my @data = $sth->fetchrow_array(); $i++) {
     
    120120# Return here if we can't select.  Note that this indicates a
    121121# problem executing the select.
    122   my $sth = $dbh->prepare('select cidr from masterblocks');
     122  my $sth = $dbh->prepare("select cidr from masterblocks");
    123123  $sth->execute();
    124124  return (undef,$DBI::errstr) if ($sth->err);
     
    154154  } else {
    155155    # it connects, try a stmt.
    156     my $sth = $dbh->prepare('select cidr from masterblocks');
     156    my $sth = $dbh->prepare("select cidr from masterblocks");
    157157    my $err = $sth->execute();
    158158
     
    189189  local $dbh->{RaiseError} = 1; # step on our toes by accident.
    190190
    191   if ($type =~ /^[cdsmw]i$/) {
     191  if ($type =~ /^.i$/) {
    192192    $msg = "Unable to assign static IP $cidr to $custid";
    193193    eval {
    194       # We'll just have to put up with the oddities caused by SQL (un)sort order
    195       $sth = $dbh->prepare("select * from poolips where pool='$alloc_from'".
    196         " and available='y' order by ip");
    197       $sth->execute;
    198 
     194      # We have to do this in two parts because otherwise we lose
     195      # the ability to return the IP assigned.  Should that change,
     196      # the commented SQL statement below may become usable.
    199197# update poolips set custid='$custid',city='$city',available='n',
    200198#       description='$desc',notes='$notes',circuitid='$circid'
    201199#       where ip=(select ip from poolips where pool='$alloc_from'
    202200#       and available='y' order by ip limit 1);
    203 ##err Need better handling here;  what if there's no free IPs when this sub gets called?
     201
     202      $sth = $dbh->prepare("select ip from poolips where pool='$alloc_from'".
     203        " and available='y' order by ip");
     204      $sth->execute;
     205
    204206      my @data = $sth->fetchrow_array;
    205       $cidr = $data[1];  # $cidr is already declared when we get here!
     207      $cidr = $data[0];  # $cidr is already declared when we get here!
    206208
    207209      $sth = $dbh->prepare("update poolips set custid='$custid',".
     
    234236            " where cidr='$cidr'");
    235237          $sth->execute;
    236           $sth = $dbh->prepare("insert into routed values ('$cidr',".
    237             $cidr->masklen.",'$city')");
     238          $sth = $dbh->prepare("insert into routed (cidr,maskbits,city)".
     239                " values ('$cidr',".$cidr->masklen.",'$city')");
    238240          $sth->execute;
    239241        } else {
     
    242244          $sth->execute;
    243245
    244           $sth = $dbh->prepare("insert into allocations values ('$cidr',".
    245                 "'$custid','$type','$city','$desc','$notes',".
     246          $sth = $dbh->prepare("insert into allocations".
     247                " (cidr,custid,type,city,description,notes,maskbits,circuitid)".
     248                " values ('$cidr','$custid','$type','$city','$desc','$notes',".
    246249                $cidr->masklen.",'$circid')");
    247250          $sth->execute;
    248251
    249252          # And initialize the pool, if necessary
     253          # PPPoE pools (currently dialup, DSL, and WiFi) get all IPs made available
     254          # "DHCP" or "real-subnet" pools have the net, gw, and bcast IPs removed.
    250255          if ($type =~ /^.p$/) {
    251             $msg = "Could not initialize IPs in new $disp_alloctypes{$type} pool $cidr";
    252             initPool($dbh,$cidr,$type,$city,($type eq 'dp' ? "all" : "normal"));
     256            $msg = "Could not initialize IPs in new $disp_alloctypes{$type} $cidr";
     257            my ($code,$rmsg) = initPool($dbh,$cidr,$type,$city,"all");
     258            die $rmsg if $code eq 'FAIL';
     259          } elsif ($type =~ /^.d$/) {
     260            $msg = "Could not initialize IPs in new $disp_alloctypes{$type} $cidr";
     261            my ($code,$rmsg) = initPool($dbh,$cidr,$type,$city,"normal");
     262            die $rmsg if $code eq 'FAIL';
    253263          }
    254264
     
    258268      }; # end of eval
    259269      if ($@) {
    260         $msg = $@;
     270        $msg .= ": ".$@;
    261271        eval { $dbh->rollback; };
    262         return ('FAIL',$@);
     272        return ('FAIL',$msg);
    263273      } else {
    264274        return ('OK',"OK");
     
    297307          # Insert the new freeblocks entries
    298308          # Note that non-routed blocks are assigned to <NULL>
    299           $sth = $dbh->prepare("insert into freeblocks values (?, ?, '<NULL>','n')");
     309          # and use the default value for the routed column ('n')
     310          $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city)".
     311                " values (?, ?, '<NULL>')");
    300312          foreach my $block (@newfreeblocks) {
    301313            $sth->execute("$block", $block->masklen);
     
    303315
    304316          # Insert the entry in the routed table
    305           $sth = $dbh->prepare("insert into routed values ('$cidr',".
    306             $cidr->masklen.",'$city')");
     317          $sth = $dbh->prepare("insert into routed (cidr,maskbits,city)".
     318                " values ('$cidr',".$cidr->masklen.",'$city')");
    307319          $sth->execute;
    308320          # Insert the (almost) same entry in the freeblocks table
    309           $sth = $dbh->prepare("insert into freeblocks values ('$cidr',".
    310             $cidr->masklen.",'$city','y')");
     321          $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
     322                " values ('$cidr',".$cidr->masklen.",'$city','y')");
    311323          $sth->execute;
    312324
     
    314326
    315327          # Insert the new freeblocks entries
    316           $sth = $dbh->prepare("insert into freeblocks values (?, ?, ".
    317                 "(select city from routed where cidr >>= '$cidr'),'y')");
     328          $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
     329                " values (?, ?, (select city from routed where cidr >>= '$cidr'),'y')");
    318330          foreach my $block (@newfreeblocks) {
    319331            $sth->execute("$block", $block->masklen);
     
    321333
    322334          # Insert the allocations entry
    323           $sth = $dbh->prepare("insert into allocations values ('$cidr',".
    324                 "'$custid','$type','$city','$desc','$notes',".$cidr->masklen.
    325                 ",'$circid')");
     335          $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,".
     336                "description,notes,maskbits,circuitid)".
     337                " values ('$cidr','$custid','$type','$city','$desc','$notes',".
     338                $cidr->masklen.",'$circid')");
    326339          $sth->execute;
    327340
    328341          # And initialize the pool, if necessary
     342          # PPPoE pools (currently dialup, DSL, and WiFi) get all IPs made available
     343          # "DHCP" or "real-subnet" pools have the net, gw, and bcast IPs removed.
    329344          if ($type =~ /^.p$/) {
    330345            $msg = "Could not initialize IPs in new $disp_alloctypes{$type} $cidr";
    331             initPool($dbh,$cidr,$type,$city,($type eq 'dp' ? "all" : "normal"));
     346            my ($code,$rmsg) = initPool($dbh,$cidr,$type,$city,"all");
     347            die $rmsg if $code eq 'FAIL';
     348          } elsif ($type =~ /^.d$/) {
     349            $msg = "Could not initialize IPs in new $disp_alloctypes{$type} $cidr";
     350            my ($code,$rmsg) = initPool($dbh,$cidr,$type,$city,"normal");
     351            die $rmsg if $code eq 'FAIL';
    332352          }
    333353
     
    361381  my $pool = new NetAddr::IP $_[1];
    362382
    363   my ($pooltype) = ($type =~ /^(.)p$/);
     383##fixme Need to just replace 2nd char of type with i rather than capturing 1st char of type
     384  $type =~ s/[pd]$/i/;
    364385  my $sth;
    365 
    366   # have to insert all pool IPs into poolips table as "unallocated".
    367   $sth = $dbh->prepare("insert into poolips values ('$pool',".
    368         " ?, '6750400', '$city', '$pooltype', 'y', '', '', '')");
    369   my @poolip_list = $pool->hostenum;
    370   if ($class eq 'all') { # (DSL-ish block - *all* IPs available
    371     $sth->execute($pool->addr);
    372     for (my $i=0; $i<=$#poolip_list; $i++) {
    373       $sth->execute($poolip_list[$i]->addr);
    374     }
    375     $pool--;
    376     $sth->execute($pool->addr);
    377   } else { # (real netblock)
    378     for (my $i=1; $i<=$#poolip_list; $i++) {
    379       $sth->execute($poolip_list[$i]->addr);
    380     }
     386  my $msg;
     387
     388  # Trap errors so we can pass them back to the caller.  Even if the
     389  # caller is only ever supposed to be local, and therefore already
     390  # trapping errors.  >:(
     391  local $dbh->{AutoCommit} = 0; # These need to be local so we don't
     392  local $dbh->{RaiseError} = 1; # step on our toes by accident.
     393
     394  eval {
     395    # have to insert all pool IPs into poolips table as "unallocated".
     396    $sth = $dbh->prepare("insert into poolips (pool,ip,custid,city,type)".
     397        " values ('$pool', ?, '6750400', '$city', '$type')");
     398    my @poolip_list = $pool->hostenum;
     399    if ($class eq 'all') { # (DSL-ish block - *all* IPs available
     400      $sth->execute($pool->addr);
     401      for (my $i=0; $i<=$#poolip_list; $i++) {
     402        $sth->execute($poolip_list[$i]->addr);
     403      }
     404      $pool--;
     405      $sth->execute($pool->addr);
     406    } else { # (real netblock)
     407      for (my $i=1; $i<=$#poolip_list; $i++) {
     408        $sth->execute($poolip_list[$i]->addr);
     409      }
     410    }
     411  };
     412  if ($@) {
     413    $msg = "'".$sth->errstr."'";
     414    eval { $dbh->rollback; };
     415    return ('FAIL',$msg);
     416  } else {
     417    return ('OK',"OK");
    381418  }
    382419} # end initPool()
     
    406443
    407444    eval {
    408       $msg = "Unable to deallocate $type $cidr";
     445      $msg = "Unable to deallocate $disp_alloctypes{$type} $cidr";
    409446      $sth = $dbh->prepare("update poolips set custid='6750400',available='y',".
    410447        "city=(select city from allocations where cidr >>= '$cidr'),".
     
    455492        $sth->execute;
    456493        # Set up query to start compacting free blocks.
    457         $sth = $dbh->prepare("select * from freeblocks where ".
     494        $sth = $dbh->prepare("select cidr from freeblocks where ".
    458495                "maskbits<=".$cidr->masklen." and routed='n' order by maskbits desc");
    459496
     
    463500        $sth->execute;
    464501        # Special case - delete pool IPs
    465         if ($type =~ /^.p$/) {
     502        if ($type =~ /^.[pd]$/) {
    466503          # We have to delete the IPs from the pool listing.
    467504          $sth = $dbh->prepare("delete from poolips where pool='$cidr'");
     
    470507
    471508        # Set up query for compacting free blocks.
    472         $sth = $dbh->prepare("select * from freeblocks where cidr <<= ".
     509        $sth = $dbh->prepare("select cidr from freeblocks where cidr <<= ".
    473510                "(select cidr from routed where cidr >>= '$cidr') ".
    474511                " and maskbits<=".$cidr->masklen." and routed='y' order by maskbits desc");
     
    513550      # insert "new" freeblocks entry
    514551      if ($type eq 'rr') {
    515         $sth = $dbh->prepare("insert into freeblocks values ('$cidr',".$cidr->masklen.
    516                 ",'<NULL>','n')");
     552        $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city)".
     553                " values ('$cidr',".$cidr->masklen.",'<NULL>')");
    517554      } else {
    518         $sth = $dbh->prepare("insert into freeblocks values ('$cidr',".$cidr->masklen.
     555        $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
     556                " values ('$cidr',".$cidr->masklen.
    519557                ",(select city from routed where cidr >>= '$cidr'),'y')");
    520558      }
  • trunk/cgi-bin/main.cgi

    r142 r157  
    5656cleanInput(\%webvar);
    5757
    58 # Stuff that gets loaded from the database
    59 #my @citylist;
    60 #my @poplist;
    61 #my %allocated; # Count for allocated blocks in a master block
    62 #my %free;      # Count for free blocks (routed and unrouted) in a master block
    63 #my %bigfree;   # Tracking largest free block in a master block
    64 #my %routed;    # Number of routed blocks in a master block
    65 
    66 # Slurp up the master block list - we need this several places
    67 # While we're at it, initialize the related hashes.
    68 #$sth = $ip_dbh->prepare("select * from masterblocks order by cidr");
    69 #$sth->execute;
    70 #for (my $i=0; my @data = $sth->fetchrow_array(); $i++) {
    71 #  $masterblocks[$i] = new NetAddr::IP $data[0];
    72 #  $allocated{"$masterblocks[$i]"} = 0;
    73 #  $free{"$masterblocks[$i]"} = 0;
    74 #  $bigfree{"$masterblocks[$i]"} = 128; # Larger number means smaller block.
    75 #                                       # Set to 128 to prepare for IPv6
    76 #  $routed{"$masterblocks[$i]"} = 0;
    77 #}
    78 
    79 
    80 
    8158
    8259#main()
     
    10986# Thus the "routed" flag.
    11087
    111     $sth = $ip_dbh->prepare("insert into freeblocks values ('$webvar{cidr}',".
    112         $cidr->masklen.",'<NULL>','n')");
     88    $sth = $ip_dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
     89        " values ('$webvar{cidr}',".$cidr->masklen.",'<NULL>','n')");
    11390    $sth->execute;
    11491
     
    348325    # Fix up types from pools (which are single-char)
    349326    # Fixing the database would be...  painful.  :(
     327##fixme LEGACY CODE
    350328    if ($data[2] =~ /^[cdsmw]$/) {
    351329      $data[2] .= 'i';
     
    354332        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    355333    # Allow listing of pool if desired/required.
    356     if ($data[2] =~ /^[cdsmw]p$/) {
     334    if ($data[2] =~ /^.[pd]$/) {
    357335      $row[0] .= ' &nbsp; <a href="/ip/cgi-bin/main.cgi?action=listpool'.
    358336        "&pool=$data[0]\">List IPs</a>";
     
    493471
    494472  # Fetch only the blocks relevant to this master
    495   $sth = $ip_dbh->prepare("select * from routed where cidr <<= '$master' order by cidr");
     473  $sth = $ip_dbh->prepare("select cidr,city from routed where cidr <<= '$master' order by cidr");
    496474  $sth->execute();
    497475
     
    504482    $bigfree{"$cidr"} = 128;
    505483    # Retain the routing destination
    506     $routed{"$cidr"} = $data[2];
     484    $routed{"$cidr"} = $data[1];
    507485  }
    508486
     
    596574  my $master = new NetAddr::IP $webvar{block};
    597575
    598   $sth = $ip_dbh->prepare("select * from routed where cidr='$master'");
     576  $sth = $ip_dbh->prepare("select city from routed where cidr='$master'");
    599577  $sth->execute;
    600578  my @data = $sth->fetchrow_array;
    601579
    602580  print qq(<center><div class="heading">Summarizing allocated blocks for ).
    603         qq($master ($data[2]):</div></center><br>\n);
     581        qq($master ($data[0]):</div></center><br>\n);
    604582
    605583  startTable('CIDR allocation','Customer Location','Type','CustID','Description/Name');
    606584
    607585  # Snag the allocations for this block
    608   $sth = $ip_dbh->prepare("select * from allocations where cidr <<= '$master' order by cidr");
     586  $sth = $ip_dbh->prepare("select cidr,city,type,custid,description".
     587        " from allocations where cidr <<= '$master' order by cidr");
    609588  $sth->execute();
    610589
    611590  my $count=0;
    612591  while (my @data = $sth->fetchrow_array()) {
    613     # cidr,custid,type,city,description,notes,maskbits,circuitid
     592    # cidr,city,type,custid,description, as per the SELECT
    614593    my $cidr = new NetAddr::IP $data[0];
    615594
    616595    # Clean up extra spaces that are borking things.
    617     $data[2] =~ s/\s+//g;
     596#    $data[2] =~ s/\s+//g;
    618597
    619598    my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=edit&block=$data[0]\">$data[0]</a>",
    620         $data[3], $disp_alloctypes{$data[2]}, $data[1], $data[4]);
     599        $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
    621600    # If the allocation is a pool, allow listing of the IPs in the pool.
    622     if ($data[2] =~ /^[cdsmw]p$/) {
     601    if ($data[2] =~ /^.[pd]$/) {
    623602      $row[0] .= ' &nbsp; <a href="/ip/cgi-bin/main.cgi?action=listpool'.
    624603        "&pool=$data[0]\">List IPs</a>";
     
    653632  # unrouted free blocks, but it's better to let the database do the work if we can.
    654633  $count = 0;
    655   $sth = $ip_dbh->prepare("select * from freeblocks where routed='y' and cidr <<= '$master' order by cidr");
     634  $sth = $ip_dbh->prepare("select cidr from freeblocks where routed='y' and cidr <<= '$master' order by cidr");
    656635  $sth->execute();
    657636  while (my @data = $sth->fetchrow_array()) {
     
    675654  my $cidr = new NetAddr::IP $webvar{pool};
    676655
     656  my ($pooltype,$poolcity);
     657
    677658  # Snag pool info for heading
    678   $sth = $ip_dbh->prepare("select * from allocations where cidr='$cidr'");
     659  $sth = $ip_dbh->prepare("select type,city from allocations where cidr='$cidr'");
    679660  $sth->execute;
    680   my @data = $sth->fetchrow_array;
    681   my $type = $data[2];  # We'll need this later.
     661  $sth->bind_columns(\$pooltype, \$poolcity);
     662  $sth->fetch() || carp $sth->errstr;
    682663
    683664  print qq(<center><div class="heading">Listing pool IPs for $cidr<br>\n).
    684         qq(($disp_alloctypes{$type} in $data[3])</div></center><br>\n);
    685   print qq(<div class="indent"><b>Reserved IPs:</b><br>\n);
    686   print qq(<div class="indent"><table><tr class=color1><td>Network IP:</td><td>).
     665        qq(($disp_alloctypes{$pooltype} in $poolcity)</div></center><br>\n);
     666  # Only display net/gw/bcast if it's a "real" netblock and not a PPP(oE) lunacy
     667  if ($pooltype =~ /^.d$/) {
     668    print qq(<div class="indent"><b>Reserved IPs:</b><br>\n);
     669    print qq(<div class="indent"><table><tr class=color1><td>Network IP:</td><td>).
    687670        $cidr->addr."</td></tr>\n";
    688   $cidr++;
    689   print "<tr class=color2><td>Gateway:</td><td>".$cidr->addr."</td></tr>\n";
    690   $cidr--;  $cidr--;
    691   print "<tr class=color1><td>Broadcast:</td><td>".$cidr->addr."</td></tr>\n".
     671    $cidr++;
     672    print "<tr class=color2><td>Gateway:</td><td>".$cidr->addr."</td></tr>\n";
     673    $cidr--;  $cidr--;
     674    print "<tr class=color1><td>Broadcast:</td><td>".$cidr->addr."</td></tr>\n".
    692675        "<tr><td>Netmask:</td><td>".$cidr->mask."</td></tr>\n".
    693676        "</table></div></div>\n";
     677  }
    694678
    695679# probably have to add an "edit IP allocation" link here somewhere.
    696680
    697681  startTable('IP','Customer ID','Available?','Description','');
    698   $sth = $ip_dbh->prepare("select * from poolips where pool='$webvar{pool}' order by ip");
     682  $sth = $ip_dbh->prepare("select ip,custid,available,description,type".
     683        " from poolips where pool='$webvar{pool}' order by ip");
    699684  $sth->execute;
    700685  my $count = 0;
    701686  while (my @data = $sth->fetchrow_array) {
    702687    # pool,ip,custid,city,ptype,available,notes,description,circuitid
    703     # If desc is null, make it not null.  <g>
    704     if ($data[7] eq '') {
    705       $data[7] = '&nbsp;';
     688    # ip,custid,available,description,type
     689    # If desc is "null", make it not null.  <g>
     690    if ($data[3] eq '') {
     691      $data[3] = '&nbsp;';
    706692    }
    707693    # Some nice hairy Perl to decide whether to allow unassigning each IP
    708     #   -> if $data[5] (aka poolips.available) == 'n' then we print the unassign link
     694    #   -> if $data[2] (aka poolips.available) == 'n' then we print the unassign link
    709695    #      else we print a blank space
    710     my @row = ( qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[1]">$data[1]</a>),
    711         $data[2],$data[5],$data[7],
    712         ( ($data[5] eq 'n') ?
    713           ("<a href=\"/ip/cgi-bin/main.cgi?action=delete&block=$data[1]&".
    714            "alloctype=$data[4]i\">Unassign this IP</a>") :
     696    my @row = ( qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
     697        $data[1],$data[2],$data[3],
     698        ( ($data[2] eq 'n') ?
     699          ("<a href=\"/ip/cgi-bin/main.cgi?action=delete&block=$data[0]&".
     700           "alloctype=$data[4]\">Unassign this IP</a>") :
    715701          ("&nbsp;") )
    716702        );
     
    802788#  + Different flavours of netblock
    803789
    804   if ($webvar{alloctype} =~ /^[cdsmw]i$/) {
     790  if ($webvar{alloctype} =~ /^.i$/) {
    805791    my ($base,undef) = split //, $webvar{alloctype};    # split into individual chars
    806792    my $sql;
     
    809795    # ... aside from #^%#$%#@#^%^^!!!! legacy data.  GRRR.
    810796    # Note that we want to retain the requested city to relate to customer info.
     797##fixme This needs thought.
     798##SELECT DISTINCT pool, Count(*) FROM poolips where available='y' GROUP BY pool;
    811799    if ($base =~ /^[ds]$/) {
    812800      $sql = "select * from poolips where available='y' and".
     
    862850##fixme
    863851# This section needs serious Pondering.
    864         if ($webvar{alloctype} =~ /^[cdsmw]p$/) {
     852        if ($webvar{alloctype} =~ /^.[pd]$/) {
    865853          if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
    866854            printError("You must chose Sudbury or North Bay for DSL pools.");
     
    878866        }
    879867        if ($webvar{allocfrom} ne '-') {
    880           $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
     868          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    881869                " and cidr <<= '$webvar{allocfrom}' and routed='y' order by cidr,maskbits desc";
    882870        } else {
    883           $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
     871          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    884872                " and routed='y' order by cidr,maskbits desc";
    885873        }
     
    907895      $cidr = $subblocks[0];
    908896    }
    909   } # if ($webvar{alloctype} =~ /^[cdsmw]i$/)
     897  } # if ($webvar{alloctype} =~ /^.i$/)
    910898
    911899  open HTML, "../confirm.html"
     
    973961        "'$webvar{alloctype}' by $authuser failed: '$msg'";
    974962    printError("Allocation of $webvar{fullcidr} as $disp_alloctypes{$webvar{alloctype}}".
    975         " failed: $msg\n");
     963        " failed:<br>\n$msg\n");
    976964  }
    977965
     
    10651053  $data[2] =~ s/\s//;
    10661054
     1055##fixme LEGACY CODE
    10671056  # Postfix "i" on pool IP types
    10681057  if ($data[2] =~ /^[cdsmw]$/) {
     
    11271116    # Relatively simple SQL transaction here.
    11281117    my $sql;
    1129     if (my $pooltype = ($webvar{alloctype} =~ /^([cdsmw])i$/) ) {
     1118    if (my $pooltype = ($webvar{alloctype} =~ /^(.)i$/) ) {
    11301119      # Note the hack ( available='n' ) to work around "update" additions
    11311120      # to static IP space.  Eww.
     
    11381127        "type='$webvar{alloctype}',circuitid='$webvar{circid}' where cidr='$webvar{block}'";
    11391128    }
    1140 syslog "debug", $sql;
     1129    # Log the details of the change.
     1130    syslog "debug", $sql;
    11411131    $sth = $ip_dbh->prepare($sql);
    11421132    $sth->execute;
     
    12161206    $desc = "N/A";
    12171207    $notes = "N/A";
    1218   } elsif ($webvar{alloctype} =~ /^[cdsmw]i$/) { # done with alloctype=rr
     1208  } elsif ($webvar{alloctype} =~ /^.i$/) { # done with alloctype=rr
    12191209
    12201210    # Unassigning a static IP
     
    12291219    $alloctype .="i";
    12301220
    1231   } else { # done with alloctype=[cdsmw]i
     1221  } else { # done with alloctype=~ /^.i$/
    12321222
    12331223    my $sth = $ip_dbh->prepare("select cidr,custid,type,city,circuitid,description,notes from ".
     
    12541244
    12551245  # Set the warning text.
    1256   if ($alloctype =~ /^[cdsmw]p$/) {
     1246  if ($alloctype =~ /^.[pd]$/) {
    12571247    $html =~ s|<!--warn-->|<tr bgcolor="black"><td colspan="2"><div class="red">Warning: clicking confirm will remove this record entirely.<br>Any IPs allocated from this pool will also be removed!</div></td></tr>|;
    12581248  } else {
Note: See TracChangeset for help on using the changeset viewer.