source: branches/stable/cgi-bin/checkcusts.pl@ 191

Last change on this file since 191 was 169, checked in by Kris Deugau, 20 years ago

/branches/stable

Updated checkcusts.pl hack to skip new allocation-type-centric
CustIDs.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 1.7 KB
RevLine 
[123]1#!/usr/bin/perl
2# Check all customer IDs to see which are invalid
3###
4# SVN revision info
5# $Date: 2005-02-22 22:00:37 +0000 (Tue, 22 Feb 2005) $
6# SVN revision $Rev: 169 $
7# Last update by $Author: kdeugau $
8###
[169]9# Copyright (C) 2004,2005 Kris Deugau <kdeugau@vianet.ca>
[123]10
11use DBI;
[128]12use IPDB 2.0 qw(:ALL);
[123]13
14# We'll be hosing the server with several thousand queries. We
15# REALLY don't want the overhead and load of opening a new connection
16# for each query.
17#use CustIDCK;
18
19use NetAddr::IP;
20
21$priv1 = new NetAddr::IP '10.0.0.0/8';
22$priv2 = new NetAddr::IP '172.16.0.0/12';
23$priv3 = new NetAddr::IP '192.168.0.0/16';
24
25print "Content-type: text/plain\n\n";
26
[128]27($dbh,$errstr) = connectDB("ipdb", "ipdb", "ipdbpwd");
[156]28$IDH = DBI->connect ("DBI:Pg:host=newbilling;dbname=custids", "cidcheck", "c1dch4ck");
[169]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}
[123]35$sth = $dbh->prepare("select cidr,custid from searchme where not (custid='6750400') ".
36 "and not (custid='STAFF') order by cidr");
37$sth->execute;
38
39$IDS = $IDH->prepare("select custid from custid where custid=?");
40
41$count = $bad = 0;
42while (@data = $sth->fetchrow_array) {
43 $cidr = new NetAddr::IP $data[0];
[169]44 if ($cidr->within($priv1) or $cidr->within($priv2) or $cidr->within($priv3) or
45 (grep /$data[1]/, @def_custids)) {
[123]46 # no-op. we ignore these.
47 } else {
[169]48 $count++;
[123]49 $IDS->execute($data[1]);
50 $hr = $IDS->fetchrow_hashref();
51 if (!$hr->{custid}) {
52 print " $data[0]\thas invalid CustID '$data[1]'\n";
53 $bad++;
54 }
55 $IDS->finish;
56 }
57}
58
59$IDH->disconnect;
60$dbh->disconnect;
61
62print "$count customer blocks, $bad bad.\n";
63exit 0;
64
65
66### Ported subs of sorts from CustIDCK.pm
Note: See TracBrowser for help on using the repository browser.