Changeset 400 for trunk


Ignore:
Timestamp:
05/11/10 17:06:26 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

Merge addition of CustIDCK.pm from r56 - proprietary info this contained
was stripped during repo history conversion and it makes a good base for
providing data validation hooks.
Also merge all updates and related additions since.
See #13.

Location:
trunk/cgi-bin
Files:
2 edited
2 copied

Legend:

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

    r398 r400  
    1818use CommonWeb qw(:ALL);
    1919use MyIPDB;
     20use CustIDCK;
    2021#use POSIX qw(ceil);
    2122use NetAddr::IP;
     
    134135  my $custid = $data[0];
    135136  if ($custid eq '') {
     137    if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) {
     138      # Force uppercase for now...
     139      $webvar{custid} =~ tr/a-z/A-Z/;
     140      # Crosscheck with billing.
     141      my $status = CustIDCK->custid_exist($webvar{custid});
     142      if ($CustIDCK::Error) {
     143        printError("Error verifying customer ID: ".$CustIDCK::ErrMsg);
     144        return;
     145      }
     146      if (!$status) {
     147        printError("Customer ID not valid.  Make sure the Customer ID ".
     148          "is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
     149          "non-customer assignments.");
     150        return;
     151      }
     152    }
    136153    # Type that doesn't have a default custid
    137154    $custid = $webvar{custid};
    138155  }
    139 ##fixme Check billing DB here
    140156
    141157  my $cidr = new NetAddr::IP $webvar{cidr};
     
    506522#
    507523
     524print qq(<hr><a href="/ip/">Back</a> to main interface</a>\n);
    508525
    509526printFooter;
  • trunk/cgi-bin/checkcusts.pl

    r123 r400  
    77# Last update by $Author$
    88###
    9 # Copyright (C) 2004 Kris Deugau <kdeugau@vianet.ca>
     9# Copyright (C) 2004-2006 Kris Deugau
    1010
    1111use DBI;
    12 use IPDB qw(:ALL);
     12use IPDB 2.0 qw(:ALL);
    1313
    1414# We'll be hosing the server with several thousand queries.  We
     
    2525print "Content-type: text/plain\n\n";
    2626
    27 $dbh = connectDB;
     27($dbh,$errstr) = connectDB("ipdb", "ipdb", "ipdbpwd");
    2828$IDH = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck");
     29
     30$sth = $dbh->prepare("select distinct def_custid from alloctypes where listorder >=40");
     31$sth->execute;
     32while (@data = $sth->fetchrow_array) {
     33  push @def_custids, $data[0];
     34}
    2935$sth = $dbh->prepare("select cidr,custid from searchme where not (custid='6750400') ".
    3036        "and not (custid='STAFF') order by cidr");
     37#$sth = $dbh->prepare("select cidr,custid from searchme order by cidr");
    3138$sth->execute;
    3239
     
    3542$count = $bad = 0;
    3643while (@data = $sth->fetchrow_array) {
    37   $count++;
    3844  $cidr = new NetAddr::IP $data[0];
    39   if ($cidr->within($priv1) or $cidr->within($priv2) or $cidr->within($priv3)) {
     45  if ($cidr->within($priv1) or $cidr->within($priv2) or $cidr->within($priv3) or
     46        (grep /$data[1]/, @def_custids)) {
    4047    # no-op.  we ignore these.
    4148  } else {
     49    $count++;
    4250    $IDS->execute($data[1]);
    4351    $hr = $IDS->fetchrow_hashref();
  • trunk/cgi-bin/main.cgi

    r397 r400  
    1515use CommonWeb qw(:ALL);
    1616use MyIPDB;
     17use CustIDCK;
    1718use POSIX qw(ceil);
    1819use NetAddr::IP;
     
    943944      return;
    944945    }
    945     if ($webvar{custid} !~ /^(?:\d{5,10}|STAFF|TEMP)(?:-\d\d?)?$/) {
    946       printError("Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for static IPs for staff.");
    947       return;
    948     }
    949     print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
     946    if ($webvar{custid} !~ /^(?:\d{10}|\d{7}|STAFF)(?:-\d\d?)?$/) {
     947      # Force uppercase for now...
     948      $webvar{custid} =~ tr/a-z/A-Z/;
     949      # Crosscheck with billing.
     950      my $status = CustIDCK->custid_exist($webvar{custid});
     951      if ($CustIDCK::Error) {
     952        printError("Error verifying customer ID: ".$CustIDCK::ErrMsg);
     953        return;
     954      }
     955      if (!$status) {
     956        printError("Customer ID not valid.  Make sure the Customer ID ".
     957          "is correct.<br>\nUse STAFF for staff static IPs, and 6750400 for any other ".
     958          "non-customer assignments.");
     959        return;
     960      }
     961#"Please enter a valid customer ID- this must be a 7- or 10-digit number, or STAFF for
     962#static IPs for staff.");
     963    }
     964#    print "<!-- [ In validateInput().  Insert customer ID cross-check here. ] -->\n";
    950965  } else {
    951966    # New!  Improved!  And now Loaded From The Database!!
     
    967982  } else {
    968983    $flag = 'n';
    969     if ($webvar{alloctype} =~ /[wp][cr]|d[pi]/) {
     984    if ($webvar{alloctype} =~ /[wp][cr]|[ds][pi]/) {
    970985      # Set this forcibly rather than messing around elsewhere.  Yes, this *is* a hack.  PTHBTT!!
    971       # Match CORE/WAN types (wc, wr, pc, pr), DSL pool and IP (dp, di).
    972       $webvar{pop} = "Sudbury";
    973     } elsif ($webvar{pop} =~ /^-$/) {
     986      $webvar{pop} = 'Sudbury';
     987    }
     988    if ($webvar{pop} =~ /^-$/) {
    974989      $flag = 'to route the block from/through';
    975990    }
Note: See TracChangeset for help on using the changeset viewer.