Ignore:
Timestamp:
11/16/04 15:24:12 (20 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Backports from /trunk r74:

  • Addition of CircuitID field WARNING: This REQUIRES changes to the allocations and poolips tables!!
  • New SQL schema definition
  • Display bugfix
File:
1 edited

Legend:

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

    r71 r75  
    735735  my $count = 0;
    736736  while (my @data = $sth->fetchrow_array) {
    737     # pool,ip,custid,city,ptype,available,notes,description
     737    # pool,ip,custid,city,ptype,available,notes,description,circuitid
    738738    # If desc is null, make it not null.  <g>
    739739    if ($data[7] eq '') {
     
    934934  $html =~ s|\$\$CITY\$\$|$webvar{city}|g;
    935935  $html =~ s|\$\$CUSTID\$\$|$webvar{custid}|g;
     936  $html =~ s|\$\$CIRCID\$\$|$webvar{circid}|g;
    936937  $webvar{desc} = desanitize($webvar{desc});
    937938  $webvar{notes} = desanitize($webvar{notes});
     
    977978
    978979    $sth = $ip_dbh->prepare("update poolips set custid='$webvar{custid}',".
    979         "city='$webvar{city}',available='n',description='$webvar{desc}'".
     980        "city='$webvar{city}',available='n',description='$webvar{desc}',".
     981        "circuitid='$webvar{circid}'".
    980982        " where ip='$cidr'");
    981983    $sth->execute;
     
    10291031          $sth = $ip_dbh->prepare("insert into allocations values ('$webvar{fullcidr}',".
    10301032            "'$webvar{custid}','$webvar{alloctype}','$webvar{city}','$webvar{desc}',".
    1031             "'$webvar{notes}',".$cidr->masklen.")");
     1033            "'$webvar{notes}',".$cidr->masklen.",'$webvar{circid}')");
    10321034          $sth->execute;
    10331035        } # routing vs non-routing netblock
     
    10951097          $sth = $ip_dbh->prepare("insert into allocations values ('$webvar{fullcidr}',".
    10961098            "'$webvar{custid}','$webvar{alloctype}','$webvar{city}',".
    1097             "'$webvar{desc}','$webvar{notes}',".$cidr->masklen.")");
     1099            "'$webvar{desc}','$webvar{notes}',".$cidr->masklen.",'$webvar{circid}')");
    10981100          $sth->execute;
    10991101        } # done with netblock alloctype != rr
     
    11181120        # have to insert all pool IPs into poolips table as "unallocated".
    11191121        $sth = $ip_dbh->prepare("insert into poolips values ('$webvar{fullcidr}',".
    1120           " ?, '6750400', '$webvar{city}', '$pooltype', 'y', '')");
     1122          " ?, '6750400', '$webvar{city}', '$pooltype', 'y', '', '', '')");
    11211123        my @poolip_list = $cidr->hostenum;
    11221124        for (my $i=1; $i<=$#poolip_list; $i++) {
     
    12051207  # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data
    12061208  if ($webvar{block} =~ /\/32$/) {
    1207     $sql = "select ip,custid,ptype,city,description,notes from poolips where ip='$webvar{block}'";
     1209    $sql = "select ip,custid,ptype,city,circuitid,description,notes from poolips where ip='$webvar{block}'";
    12081210  } else {
    1209     $sql = "select cidr,custid,type,city,description,notes from allocations where cidr='$webvar{block}'"
     1211    $sql = "select cidr,custid,type,city,circuitid,description,notes from allocations where cidr='$webvar{block}'"
    12101212  }
    12111213
     
    12581260  # These can be modified, although CustID changes may get ignored.
    12591261  $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
    1260   $html =~ s/\$\$DESC\$\$/$data[4]/g;
    1261   $html =~ s/\$\$NOTES\$\$/$data[5]/g;
     1262  $html =~ s/\$\$TYPE\$\$/$data[2]/g;
     1263  $html =~ s/\$\$CIRCID\$\$/$data[4]/g;
     1264  $html =~ s/\$\$DESC\$\$/$data[5]/g;
     1265  $html =~ s/\$\$NOTES\$\$/$data[6]/g;
    12621266
    12631267  print $html;
     
    12801284    my $sql;
    12811285    if (my $pooltype = ($webvar{alloctype} =~ /^([cdms])i$/) ) {
    1282       $sql = "update poolips set custid='$webvar{custid}',".
    1283         "notes='$webvar{notes}',description='$webvar{desc}' ".
     1286      $sql = "update poolips set custid='$webvar{custid}',notes='$webvar{notes}',".
     1287        "circuitid='$webvar{circid}',description='$webvar{desc}' ".
    12841288        "where ip='$webvar{block}'";
    12851289    } else {
    12861290      $sql = "update allocations set custid='$webvar{custid}',".
    12871291        "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}',".
    1288         "type='$webvar{alloctype}' where cidr='$webvar{block}'";
     1292        "type='$webvar{alloctype}',circuitid='$webvar{circid}' where cidr='$webvar{block}'";
    12891293    }
    12901294syslog "debug", $sql;
     
    13111315  $html =~ s/\$\$TYPEFULL\$\$/$full_alloc_types{$webvar{alloctype}}/g;
    13121316  $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g;
     1317  $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g;
    13131318  $html =~ s/\$\$DESC\$\$/$webvar{desc}/g;
    13141319  $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g;
     
    13351340  }
    13361341
    1337   my ($cidr, $custid, $type, $city, $desc, $notes, $alloctype);
     1342  my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype);
    13381343
    13391344  if ($webvar{alloctype} eq 'rr') {
     
    13491354    $custid = "N/A";
    13501355    $alloctype = $webvar{alloctype};
     1356    $circid = "N/A";
    13511357    $desc = "N/A";
    13521358    $notes = "N/A";
     
    13571363    $custid = "N/A";
    13581364    $alloctype = $webvar{alloctype};
     1365    $circid = "N/A";
    13591366    $desc = "N/A";
    13601367    $notes = "N/A";
     
    13621369
    13631370    # Unassigning a static IP
    1364     my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes from poolips".
     1371    my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes,circuitid from poolips".
    13651372        " where ip='$webvar{block}'");
    13661373    $sth->execute();
    13671374#  croak $sth->errstr() if($sth->errstr());
    13681375
    1369     $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes);
     1376    $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes, \$circid);
    13701377    $sth->fetch() || croak $sth->errstr;
    13711378
     
    13741381  } else { # done with alloctype=[sdcmw]i
    13751382
    1376     my $sth = $ip_dbh->prepare("select cidr,custid,type,city,description,notes from ".
     1383    my $sth = $ip_dbh->prepare("select cidr,custid,type,city,circuitid,description,notes from ".
    13771384        "allocations where cidr='$webvar{block}'");
    13781385    $sth->execute();
    13791386#       croak $sth->errstr() if($sth->errstr());
    13801387
    1381     $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$desc, \$notes);
    1382     $sth->fetch() || croak $sth->errstr;
     1388    $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$circid, \$desc, \$notes);
     1389    $sth->fetch() || carp $sth->errstr;
    13831390  } # end cases for different alloctypes
    13841391
     
    13901397  $html =~ s|\$\$CITY\$\$|$city|g;
    13911398  $html =~ s|\$\$CUSTID\$\$|$custid|g;
     1399  $html =~ s|\$\$CIRCID\$\$|$circid|g;
    13921400  $html =~ s|\$\$DESC\$\$|$desc|g;
    13931401  $html =~ s|\$\$NOTES\$\$|$notes|g;
Note: See TracChangeset for help on using the changeset viewer.