Changeset 320 for trunk


Ignore:
Timestamp:
04/04/06 18:25:28 (19 years ago)
Author:
Kris Deugau
Message:

/trunk

Merge all bugfixes, hacks, tweaks, and miscellaneous updates from
/branches/stable necessary to bring code into line. Aside from
CustID verification and notification bits, /trunk and
/branches/stable should now be identical.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/assign.html

    r284 r320  
    2929</td>
    3030</tr><tr class="color2">
    31 <td>Route/allocate from this master:&nbsp;</td><td>$$MASTERLIST$$</td>
     31<td>Route/allocate from this master:&nbsp;</td><td>$$MASTERLIST$$
     32Allow automatic allocation from private IP ranges:<input type=checkbox name=allowpriv>
     33</td>
    3234</tr><tr class="color1">
    3335<td>Circuit ID:&nbsp;</td><td><input name=circid size=40></td>
  • trunk/cgi-bin/IPDB.pm

    r284 r320  
    77# Last update by $Author$
    88###
    9 # Copyright (C) 2004,2005 - Kris Deugau
     9# Copyright (C) 2004-2006 - Kris Deugau
    1010
    1111package IPDB;
  • trunk/cgi-bin/MyIPDB.pm

    r142 r320  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2004,2005 - Kris Deugau
     10# Copyright (C) 2004-2006 - Kris Deugau
    1111
    1212use IPDB 2.0 qw(:ALL);
  • trunk/cgi-bin/admin.cgi

    r295 r320  
    1010# Last update by $Author$
    1111###
    12 # Copyright (C) 2004,2005 - Kris Deugau
     12# Copyright (C) 2004-2006 - Kris Deugau
    1313
    1414use strict;
     
    9292<hr><a href="admin.cgi?action=showusers">Manage users</a> (add/remove users;  change
    9393internal access controls - note that this does NOT include IP-based limits)
     94<hr>Consistency check tools<br>
     95<a href="consistency-check.pl">General</a>:  Check general netblock consistency.<br>
     96<a href="freespace.pl">Free space</a>:  List total and aggregate free space.  Does not
     97include private networks (192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8)
    9498);
    9599} else {
     
    295299  print "Notes:<br>\n".
    296300        "<li>Admin users automatically get all other priviledges.\n".
     301        "<li>Everyone has basic read access.\n".
    297302        "<hr>Add new user:<form action=admin.cgi method=POST>\n".
    298303        "Username: <input name=username><br>\n".
  • trunk/cgi-bin/freespace.pl

    r146 r320  
    88# Last update by $Author$
    99###
    10 # Copyright (C) 2004,2005 - Kris Deugau
     10# Copyright (C) 2004-2006 - Kris Deugau
    1111
    1212use DBI;
     
    2020$tnumfree = $bigrfree = $bigufree = 0;
    2121
     22$sql = 'select * from freeblocks where ';
    2223# General counts first
    2324if ($ARGV[0]) {
    24   $sth = $dbh->prepare("select * from freeblocks where maskbits >= $ARGV[0] order by maskbits desc");
    25 } else {
    26   $sth = $dbh->prepare("select * from freeblocks order by maskbits desc");
     25  $sql .= 'maskbits >= $ARGV[0] and ';
    2726}
     27$sql .= "not (cidr <<= '192.168.0.0/16') ".
     28                "and not (cidr <<= '172.16.0.0/12') ".
     29                "and not (cidr <<= '10.0.0.0/8') ";
     30$sql .= "order by maskbits desc";
     31
     32$sth = $dbh->prepare($sql);
    2833$sth->execute;
    2934while (@data = $sth->fetchrow_array) {
     
    3338}
    3439
     40print "Free block counts:\n";
    3541foreach $size (sort {$a cmp $b} keys %numfree) {
    3642  print "/$size: $numfree{$size}\n";
     
    4450}
    4551
     52print "Aggregate free space:\n";
    4653foreach $size (sort {$a cmp $b} keys %numfree) {
    4754  print "/$size: $numfree{$size}\n";
  • trunk/cgi-bin/main.cgi

    r314 r320  
    103103
    104104    if ($@) {
    105       carp "Transaction aborted because $@";
     105      my $msg = $@;
     106      carp "Transaction aborted because $msg";
    106107      eval { $ip_dbh->rollback; };
    107       syslog "err", "Could not add master block '$webvar{cidr}' to database: '$@'";
    108       printError("Could not add master block $webvar{cidr} to database: $@");
     108      syslog "err", "Could not add master block '$webvar{cidr}' to database: '$msg'";
     109      printError("Could not add master block $webvar{cidr} to database: $msg");
    109110    } else {
    110111      print "<div type=heading align=center>Success!</div>\n";
     
    414415        qq($master ($data[0]):</div></center><br>\n);
    415416
    416   startTable('CIDR allocation','Customer Location','Type','CustID','Description/Name');
     417  startTable('CIDR allocation','Customer Location','Type','CustID','SWIPed?','Description/Name');
    417418
    418419  # Snag the allocations for this block
    419   $sth = $ip_dbh->prepare("select cidr,city,type,custid,description".
     420  $sth = $ip_dbh->prepare("select cidr,city,type,custid,swip,description".
    420421        " from allocations where cidr <<= '$master' order by cidr");
    421422  $sth->execute();
     
    423424  my $count=0;
    424425  while (my @data = $sth->fetchrow_array()) {
    425     # cidr,city,type,custid,description, as per the SELECT
     426    # cidr,city,type,custid,swip,description, as per the SELECT
    426427    my $cidr = new NetAddr::IP $data[0];
    427428
     
    432433    my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : '').
    433434        qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    434         $data[1], $disp_alloctypes{$data[2]}, $data[3], $data[4]);
     435        $data[1], $disp_alloctypes{$data[2]}, $data[3],
     436        ($data[4] eq 'y' ? 'Yes' : 'No'), $data[5]);
    435437    # If the allocation is a pool, allow listing of the IPs in the pool.
    436438    if ($data[2] =~ /^.[pd]$/) {
     
    710712      my $city;
    711713      my $failmsg;
     714      my $extracond = '';
     715      if ($webvar{allocfrom} eq '-') {
     716        $extracond = ($webvar{allowpriv} eq 'on' ? '' :
     717                " and not (cidr <<= '192.168.0.0/16'".
     718                        " or cidr <<= '10.0.0.0/8'".
     719                        " or cidr <<= '172.16.0.0/12')");
     720      }
     721      my $sortorder;
    712722      if ($webvar{alloctype} eq 'rm') {
    713723        if ($webvar{allocfrom} ne '-') {
    714724          $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
    715                 " and cidr <<= '$webvar{allocfrom}' order by maskbits desc";
     725                " and cidr <<= '$webvar{allocfrom}'";
     726          $sortorder = "maskbits desc";
    716727        } else {
    717           $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
    718                 " order by maskbits desc";
     728          $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'";
     729          $sortorder = "maskbits desc";
    719730        }
    720731        $failmsg = "No suitable free block found.<br>\nWe do not have a free".
     
    745756          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    746757                " and cidr <<= '$webvar{allocfrom}' and routed='".
    747                 (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."' order by maskbits desc,cidr";
     758                (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'";
     759          $sortorder = "maskbits desc,cidr";
    748760        } else {
    749761          $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
    750                 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y').
    751                 "' order by maskbits desc,cidr";
     762                " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'";
     763          $sortorder = "maskbits desc,cidr";
    752764        }
    753765      }
     766      $sql = $sql.$extracond." order by ".$sortorder;
    754767      $sth = $ip_dbh->prepare($sql);
    755768      $sth->execute;
     
    914927  } else {
    915928    # New!  Improved!  And now Loaded From The Database!!
    916     $webvar{custid} = $def_custids{$webvar{alloctype}};
     929    if ((!$webvar{custid}) || ($webvar{custid} ne 'STAFF')) {
     930      $webvar{custid} = $def_custids{$webvar{alloctype}};
     931    }
    917932  }
    918933
     
    929944  } else {
    930945    $flag = 'n';
    931     if ($webvar{alloctype} =~ /[wp][cr]|[ds][pi]/) {
     946    if ($webvar{alloctype} =~ /[wp][cr]|d[pi]/) {
    932947      # Set this forcibly rather than messing around elsewhere.  Yes, this *is* a hack.  PTHBTT!!
    933       $webvar{pop} = 'Sudbury';
    934     }
    935     if ($webvar{pop} =~ /^-$/) {
     948      # Match CORE/WAN types (wc, wr, pc, pr), DSL pool and IP (dp, di).
     949      $webvar{pop} = "Sudbury";
     950    } elsif ($webvar{pop} =~ /^-$/) {
    936951      $flag = 'to route the block from/through';
    937952    }
     
    957972  # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data
    958973  if ($webvar{block} =~ /\/32$/) {
    959     $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata from poolips where ip='$webvar{block}'";
     974    $sql = "select ip,custid,type,city,circuitid,description,notes,modifystamp,privdata,oldcustid from poolips where ip='$webvar{block}'";
    960975  } else {
    961     $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata from allocations where cidr='$webvar{block}'"
     976    $sql = "select cidr,custid,type,city,circuitid,description,notes,modifystamp,privdata,oldcustid,swip from allocations where cidr='$webvar{block}'"
    962977  }
    963978
     
    10061021      $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}<input type=hidden name=alloctype value="$data[2]">/g;
    10071022    }
     1023    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
    10081024    $html =~ s/\$\$CITY\$\$/<input type=text name=city value="$data[3]">/g;
    10091025    $html =~ s/\$\$CIRCID\$\$/<input type="text" name="circid" value="$data[4]" maxlength=64 size=64 class="regular">/g;
     
    10121028  } else {
    10131029    $html =~ s/\$\$CUSTID\$\$/$data[1]/g;
     1030    $html =~ s/\$\$OLDCUSTID\$\$/$data[9]/g;
    10141031    $html =~ s/\$\$TYPESELECT\$\$/$disp_alloctypes{$data[2]}/g;
    10151032    $html =~ s/\$\$CITY\$\$/$data[3]/g;
     
    10201037  my ($lastmod,undef) = split /\s+/, $data[7];
    10211038  $html =~ s/\$\$LASTMOD\$\$/$lastmod/g;
     1039
     1040## Hack time!  SWIP isn't going to stay, so I'm not going to integrate it with ACLs.
     1041if ($data[2] =~ /.i/) {
     1042  $html =~ s/\$\$SWIP\$\$/N\/A/;
     1043} else {
     1044  my $tmp = (($data[10] eq 'n') ? '<input type=checkbox name=swip>' :
     1045        '<input type=checkbox name=swip checked=yes>');
     1046  $html =~ s/\$\$SWIP\$\$/$tmp/;
     1047}
    10221048
    10231049  # Allows us to "correctly" colour backgrounds in table
     
    10911117      $sql = "update allocations set custid='$webvar{custid}',".
    10921118        "description='$webvar{desc}',notes='$webvar{notes}',city='$webvar{city}',".
    1093         "type='$webvar{alloctype}',circuitid='$webvar{circid}'$privdata ".
     1119        "type='$webvar{alloctype}',circuitid='$webvar{circid}'$privdata,".
     1120        "swip='".($webvar{swip} eq 'on' ? 'y' : 'n')."' ".
    10941121        "where cidr='$webvar{block}'";
    10951122    }
     
    11151142  my $html = join('', <HTML>);
    11161143
     1144my $swiptmp = ($webvar{swip} eq 'on' ? 'Yes' : 'No');
    11171145  $html =~ s/\$\$BLOCK\$\$/$webvar{block}/g;
    11181146  $webvar{city} = desanitize($webvar{city});
     
    11211149  $html =~ s/\$\$TYPEFULL\$\$/$disp_alloctypes{$webvar{alloctype}}/g;
    11221150  $html =~ s/\$\$CUSTID\$\$/$webvar{custid}/g;
     1151  $html =~ s/\$\$SWIP\$\$/$swiptmp/g;
    11231152  $webvar{circid} = desanitize($webvar{circid});
    11241153  $html =~ s/\$\$CIRCID\$\$/$webvar{circid}/g;
  • trunk/cgi-bin/search.cgi

    r289 r320  
    99# Last update by $Author$
    1010###
    11 # Copyright 2005 Kris Deugau <kdeugau@deepnet.cx>
     11# Copyright 2005,2006 Kris Deugau
    1212
    1313use strict;             
     
    106106  # First chunk of SQL.  Filter on custid, description, and notes as necessary.
    107107  my $sql = "(select $cols from searchme where $webvar{custexclude} custid ilike '%$webvar{custid}%')".
     108        " $sqlconcat $webvar{custexclude} oldcustid ilike '%$webvar{custid}%')".
    108109        " $sqlconcat (select $cols from searchme where $webvar{descexclude} description ilike '%$webvar{desc}%')".
    109110        " $sqlconcat (select $cols from searchme where $webvar{notesexclude} notes ilike '%$webvar{notes}%')";
     
    283284    # Query for a customer ID.  Note that we can't restrict to "numeric-only"
    284285    # as we have non-numeric custIDs in the legacy data.  :/
    285     $sql = "select * from searchme where custid ilike '%$query%'";
     286    $sql = "select * from searchme where custid ilike '%$query%' or oldcustid ilike '%$query%'";
    286287    my $count = countRows($sql);
    287288    $sql .= " order by cidr limit $RESULTS_PER_PAGE offset $offset";
  • trunk/editDisplay.html

    r284 r320  
    1313
    1414<tr class="color2"><td class=heading>CustID:</td><td class="regular">$$CUSTID$$</td></tr>
     15<tr class="color2"><td class=heading>Old CustID:</td><td class="regular">$$OLDCUSTID$$</td></tr>
     16
     17<tr class="color2"><td class=heading>SWIPed?:</td><td class=regular>$$SWIP$$</td></tr>
    1518
    1619<tr class="color1"><td class=heading>Last modified:</td><td class=regular>$$LASTMOD$$</td></tr>
  • trunk/updated.html

    r284 r320  
    66<tr class="color1"><td>Type:</td><td>$$TYPEFULL$$</td></tr>
    77<tr class="color2"><td>Customer ID:</td><td>$$CUSTID$$</td></tr>
     8<tr class="color2"><td>SWIPed?:</td><td>$$SWIP$$</td></tr>
    89<tr class="color1"><td>Circuit ID:</td><td>$$CIRCID$$</td></tr>
    910<tr class="color2"><td valign="top">Description/Name:</td><td>$$DESC$$</td></tr>
Note: See TracChangeset for help on using the changeset viewer.