[freeside-commits] freeside/FS/bin freeside-lata-import,NONE,1.1
Erik Levinson
levinse at wavetail.420.am
Sat Feb 12 23:19:47 PST 2011
- Previous message: [freeside-commits] freeside/httemplate/elements tr-select-state.html, NONE, 1.1 menu.html, 1.109, 1.110
- Next message: [freeside-commits] freeside/FS/t did_order.t, NONE, 1.1 did_vendor.t, NONE, 1.1 lata.t, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv15255/FS/bin
Added Files:
freeside-lata-import
Log Message:
bulk DID orders and inventory, RT11291
--- NEW FILE: freeside-lata-import ---
#!/usr/bin/perl -w
use strict;
use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Conf;
use FS::Record qw(qsearch qsearchs dbh);
use LWP::Simple;
use HTML::TableExtract;
use Data::Dumper;
&untaint_argv; #what it sounds like (eww)
use vars qw(%opt);
my $user = shift or die &usage;
my $dbh = adminsuidsetup $user;
my $content = get("http://www.localcallingguide.com/lca_listlata.php");
my $te = new HTML::TableExtract();
$te->parse($content);
my $table = $te->first_table_found;
my $sql = 'insert into lata (latanum, description) values ';
my @sql;
foreach my $row ( $table->rows ) {
my @row = @$row;
next unless $row[0] =~ /\d+/;
$row[1] =~ s/'//g;
push @sql, "( ${row[0]}, '${row[1]}')";
}
$sql .= join(',', at sql);
my $sth = $dbh->prepare('delete from lata');
$sth->execute or die $sth->errstr;
$sth = $dbh->prepare($sql);
$sth->execute or die $sth->errstr;
$dbh->commit;
###
# subroutines
###
sub untaint_argv {
foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
#$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
# Date::Parse
$ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
$ARGV[$_]=$1;
}
}
sub usage {
die "Usage:\n freeside-lata-import user \n";
}
###
# documentation
###
=head1 NAME
freeside-lata-import - Pull LATA data from and insert into LATA table
=head1 SYNOPSIS
freeside-lata-import user
=head1 DESCRIPTION
user - name of an internal Freeside user
=head1 BUGS
=head1 SEE ALSO
L<FS::lata>
=cut
- Previous message: [freeside-commits] freeside/httemplate/elements tr-select-state.html, NONE, 1.1 menu.html, 1.109, 1.110
- Next message: [freeside-commits] freeside/FS/t did_order.t, NONE, 1.1 did_vendor.t, NONE, 1.1 lata.t, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list