5 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearch qsearchs dbh);
9 use HTML::TableExtract;
12 &untaint_argv; #what it sounds like (eww)
15 my $user = shift or die &usage;
16 my $dbh = adminsuidsetup $user;
18 my $content = get("http://www.localcallingguide.com/lca_listlata.php");
19 my $te = new HTML::TableExtract();
21 my $table = $te->first_table_found;
22 my $sql = 'insert into lata (latanum, description) values ';
24 foreach my $row ( $table->rows ) {
26 next unless $row[0] =~ /\d+/;
28 push @sql, "( ${row[0]}, '${row[1]}')";
30 $sql .= join(',',@sql);
32 my $sth = $dbh->prepare('delete from lata');
33 $sth->execute or die $sth->errstr;
35 $sth = $dbh->prepare($sql);
36 $sth->execute or die $sth->errstr;
45 foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
46 #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
48 $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
54 die "Usage:\n freeside-lata-import user \n";
63 freeside-lata-import - Pull LATA data from and insert into LATA table
67 freeside-lata-import user
71 user - name of an internal Freeside user