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

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

/branches/stable

Updated CustIDCK.pm and checkcusts.pl with new billing server
due to old machine being rather unstable.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 1.5 KB
Line 
1#!/usr/bin/perl
2# Check all customer IDs to see which are invalid
3###
4# SVN revision info
5# $Date: 2005-02-07 17:00:47 +0000 (Mon, 07 Feb 2005) $
6# SVN revision $Rev: 156 $
7# Last update by $Author: kdeugau $
8###
9# Copyright (C) 2004 Kris Deugau <kdeugau@vianet.ca>
10
11use DBI;
12use IPDB 2.0 qw(:ALL);
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
27($dbh,$errstr) = connectDB("ipdb", "ipdb", "ipdbpwd");
28$IDH = DBI->connect ("DBI:Pg:host=newbilling;dbname=custids", "cidcheck", "c1dch4ck");
29$sth = $dbh->prepare("select cidr,custid from searchme where not (custid='6750400') ".
30 "and not (custid='STAFF') order by cidr");
31$sth->execute;
32
33$IDS = $IDH->prepare("select custid from custid where custid=?");
34
35$count = $bad = 0;
36while (@data = $sth->fetchrow_array) {
37 $count++;
38 $cidr = new NetAddr::IP $data[0];
39 if ($cidr->within($priv1) or $cidr->within($priv2) or $cidr->within($priv3)) {
40 # no-op. we ignore these.
41 } else {
42 $IDS->execute($data[1]);
43 $hr = $IDS->fetchrow_hashref();
44 if (!$hr->{custid}) {
45 print " $data[0]\thas invalid CustID '$data[1]'\n";
46 $bad++;
47 }
48 $IDS->finish;
49 }
50}
51
52$IDH->disconnect;
53$dbh->disconnect;
54
55print "$count customer blocks, $bad bad.\n";
56exit 0;
57
58
59### Ported subs of sorts from CustIDCK.pm
Note: See TracBrowser for help on using the repository browser.