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


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

/trunk

Added a CircuitID field on both netblock and static IP
Updated SQL table defs
Fixed nitpicky display bug in delete confirmation HTML

File:
1 edited

Legend:

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

    r73 r74  
    734734  my $count = 0;
    735735  while (my @data = $sth->fetchrow_array) {
    736     # pool,ip,custid,city,ptype,available,notes,description
     736    # pool,ip,custid,city,ptype,available,notes,description,circuitid
    737737    # If desc is null, make it not null.  <g>
    738738    if ($data[7] eq '') {
     
    933933  $html =~ s|\$\$CITY\$\$|$webvar{city}|g;
    934934  $html =~ s|\$\$CUSTID\$\$|$webvar{custid}|g;
     935  $html =~ s|\$\$CIRCID\$\$|$webvar{circid}|g;
    935936  $webvar{desc} = desanitize($webvar{desc});
    936937  $webvar{notes} = desanitize($webvar{notes});
     
    976977
    977978    $sth = $ip_dbh->prepare("update poolips set custid='$webvar{custid}',".
    978         "city='$webvar{city}',available='n',description='$webvar{desc}'".
     979        "city='$webvar{city}',available='n',description='$webvar{desc}',".
     980        "circuitid='$webvar{circid}'".
    979981        " where ip='$cidr'");
    980982    $sth->execute;
     
    10281030          $sth = $ip_dbh->prepare("insert into allocations values ('$webvar{fullcidr}',".
    10291031            "'$webvar{custid}','$webvar{alloctype}','$webvar{city}','$webvar{desc}',".
    1030             "'$webvar{notes}',".$cidr->masklen.")");
     1032            "'$webvar{notes}',".$cidr->masklen.",'$webvar{circid}')");
    10311033          $sth->execute;
    10321034        } # routing vs non-routing netblock
     
    10941096          $sth = $ip_dbh->prepare("insert into allocations values ('$webvar{fullcidr}',".
    10951097            "'$webvar{custid}','$webvar{alloctype}','$webvar{city}',".
    1096             "'$webvar{desc}','$webvar{notes}',".$cidr->masklen.")");
     1098            "'$webvar{desc}','$webvar{notes}',".$cidr->masklen.",'$webvar{circid}')");
    10971099          $sth->execute;
    10981100        } # done with netblock alloctype != rr
     
    11171119        # have to insert all pool IPs into poolips table as "unallocated".
    11181120        $sth = $ip_dbh->prepare("insert into poolips values ('$webvar{fullcidr}',".
    1119           " ?, '6750400', '$webvar{city}', '$pooltype', 'y', '')");
     1121          " ?, '6750400', '$webvar{city}', '$pooltype', 'y', '', '', '')");
    11201122        my @poolip_list = $cidr->hostenum;
    11211123        for (my $i=1; $i<=$#poolip_list; $i++) {
     
    11901192  # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data
    11911193  if ($webvar{block} =~ /\/32$/) {
    1192     $sql = "select ip,custid,ptype,city,description,notes from poolips where ip='$webvar{block}'";
     1194    $sql = "select ip,custid,ptype,city,circuitid,description,notes from poolips where ip='$webvar{block}'";
    11931195  } else {
    1194     $sql = "select cidr,custid,type,city,description,notes from allocations where cidr='$webvar{block}'"
     1196    $sql = "select cidr,custid,type,city,circuitid,description,notes from allocations where cidr='$webvar{block}'"
    11951197  }
    11961198
     
    12431245  # These can be modified, although CustID changes may get ignored.
    12441246  $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
    1245   $html =~ s/\$\$DESC\$\$/$data[4]/g;
    1246   $html =~ s/\$\$NOTES\$\$/$data[5]/g;
     1247  $html =~ s/\$\$TYPE\$\$/$data[2]/g;
     1248  $html =~ s/\$\$CIRCID\$\$/$data[4]/g;
     1249  $html =~ s/\$\$DESC\$\$/$data[5]/g;
     1250  $html =~ s/\$\$NOTES\$\$/$data[6]/g;
    12471251
    12481252  print $html;
     
    12671271      # Note the hack ( available='n' ) to work around "update" additions
    12681272      # to static IP space.  Eww.
    1269       $sql = "update poolips set custid='$webvar{custid}',".
    1270         "notes='$webvar{notes}',description='$webvar{desc}',available='n' ".
     1273      $sql = "update poolips set custid='$webvar{custid}',notes='$webvar{notes}',".
     1274        "circuitid='$webvar{circid}',description='$webvar{desc}',available='n' ".
    12711275        "where ip='$webvar{block}'";
    12721276    } else {
    12731277      $sql = "update allocations set custid='$webvar{custid}',".
    12741278        "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}',".
    1275         "type='$webvar{alloctype}' where cidr='$webvar{block}'";
     1279        "type='$webvar{alloctype}',circuitid='$webvar{circid}' where cidr='$webvar{block}'";
    12761280    }
    12771281syslog "debug", $sql;
     
    12981302  $html =~ s/\$\$TYPEFULL\$\$/$full_alloc_types{$webvar{alloctype}}/g;
    12991303  $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g;
     1304  $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g;
    13001305  $html =~ s/\$\$DESC\$\$/$webvar{desc}/g;
    13011306  $html =~ s/\$\$NOTES\$\$/$webvar{notes}/g;
     
    13221327  }
    13231328
    1324   my ($cidr, $custid, $type, $city, $desc, $notes, $alloctype);
     1329  my ($cidr, $custid, $type, $city, $circid, $desc, $notes, $alloctype);
    13251330
    13261331  if ($webvar{alloctype} eq 'rr') {
     
    13361341    $custid = "N/A";
    13371342    $alloctype = $webvar{alloctype};
     1343    $circid = "N/A";
    13381344    $desc = "N/A";
    13391345    $notes = "N/A";
     
    13441350    $custid = "N/A";
    13451351    $alloctype = $webvar{alloctype};
     1352    $circid = "N/A";
    13461353    $desc = "N/A";
    13471354    $notes = "N/A";
     
    13491356
    13501357    # Unassigning a static IP
    1351     my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes from poolips".
     1358    my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes,circuitid from poolips".
    13521359        " where ip='$webvar{block}'");
    13531360    $sth->execute();
    13541361#  croak $sth->errstr() if($sth->errstr());
    13551362
    1356     $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes);
     1363    $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes, \$circid);
    13571364    $sth->fetch() || croak $sth->errstr;
    13581365
     
    13611368  } else { # done with alloctype=[cdsmw]i
    13621369
    1363     my $sth = $ip_dbh->prepare("select cidr,custid,type,city,description,notes from ".
     1370    my $sth = $ip_dbh->prepare("select cidr,custid,type,city,circuitid,description,notes from ".
    13641371        "allocations where cidr='$webvar{block}'");
    13651372    $sth->execute();
    13661373#       croak $sth->errstr() if($sth->errstr());
    13671374
    1368     $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$desc, \$notes);
    1369     $sth->fetch() || croak $sth->errstr;
     1375    $sth->bind_columns(\$cidr, \$custid, \$alloctype, \$city, \$circid, \$desc, \$notes);
     1376    $sth->fetch() || carp $sth->errstr;
    13701377  } # end cases for different alloctypes
    13711378
     
    13771384  $html =~ s|\$\$CITY\$\$|$city|g;
    13781385  $html =~ s|\$\$CUSTID\$\$|$custid|g;
     1386  $html =~ s|\$\$CIRCID\$\$|$circid|g;
    13791387  $html =~ s|\$\$DESC\$\$|$desc|g;
    13801388  $html =~ s|\$\$NOTES\$\$|$notes|g;
Note: See TracChangeset for help on using the changeset viewer.