docs updates and added new bin script to divide leads by timezone

git-svn-id: svn://192.168.202.10@707 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2007-11-06 08:23:43 +00:00
parent 549b05f7c5
commit bb77c6a404
3 changed files with 162 additions and 16 deletions
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/perl
#
# AST_DB_tz_divide.pl version 2.0.4 *DBI-version*
#
# DESCRIPTION:
# OPTIONAL!!! CUSTOMIZE THIS SCRIPT FIRST!!!
# separates leads into two different lists
#
# It is recommended that you run this program on the local Asterisk machine
#
# Copyright (C) 2007 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 71106-0250 - first build
#
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
@conf = <conf>;
close(conf);
$i=0;
foreach(@conf)
{
$line = $conf[$i];
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
$i++;
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($isdst) {$TZmove = "'-6.00','-7.00','-8.00','-9.00','-10.00'";}
else {$TZmove = "'-7.00','-8.00','-9.00','-10.00','-11.00'";}
$stmtA = "UPDATE vicidial_list set list_id='222' where list_id='111' and gmt_offset_now IN($TZmove);";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) {
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
$stmtA = "UPDATE vicidial_list set list_id='12021' where list_id='11315' and gmt_offset_now IN($TZmove);";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) {
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
$secX = time();
$XDtarget = ($secX - 2678400);
($Xsec,$Xmin,$Xhour,$Xmday,$Xmon,$Xyear,$Xwday,$Xyday,$Xisdst) = localtime($XDtarget);
$Xyear = ($Xyear + 1900);
$Xmon++;
if ($Xmon < 10) {$Xmon = "0$Xmon";}
if ($Xmday < 10) {$Xmday = "0$Xmday";}
if ($Xhour < 10) {$Xhour = "0$Xhour";}
if ($Xmin < 10) {$Xmin = "0$Xmin";}
if ($Xsec < 10) {$Xsec = "0$Xsec";}
$XDSQLdate = "$Xyear-$Xmon-$Xmday $Xhour:$Xmin:$Xsec";
$TDtarget = ($secX - 5356800);
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
$Tyear = ($Tyear + 1900);
$Tmon++;
if ($Tmon < 10) {$Tmon = "0$Tmon";}
if ($Tmday < 10) {$Tmday = "0$Tmday";}
if ($Thour < 10) {$Thour = "0$Thour";}
if ($Tmin < 10) {$Tmin = "0$Tmin";}
if ($Tsec < 10) {$Tsec = "0$Tsec";}
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$stmtA = "UPDATE vicidial_list set list_id='999999' where list_id IN('11315','12021','111','222') and entry_date < \"$XDSQLdate\";";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) {
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
$stmtA = "DELETE from vicidial_list WHERE list_id='999999' and entry_date < \"$TDSQLdate\";";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) {
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
$dbhA->disconnect();
exit;
+8 -8
View File
@@ -138,20 +138,20 @@ cd zlib-1.2.3
make
make install
cd /usr/local
wget http://gulus.usherbrooke.ca/pub/appl/ssh/OpenSSH/portable/openssh-4.6p1.tar.gz
gunzip openssh-4.6p1.tar.gz
tar xvf openssh-4.6p1.tar
cd openssh-4.6p1
wget http://gulus.usherbrooke.ca/pub/appl/ssh/OpenSSH/portable/openssh-4.7p1.tar.gz
gunzip openssh-4.7p1.tar.gz
tar xvf openssh-4.7p1.tar
cd openssh-4.7p1
./configure
make
make install
cd /usr/local
wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz
gunzip openssl-0.9.8e.tar.gz
tar xvf openssl-0.9.8e.tar
cd openssl-0.9.8e
wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz
gunzip openssl-0.9.8g.tar.gz
tar xvf openssl-0.9.8g.tar
cd openssl-0.9.8g
./config
make
make install
+12 -8
View File
@@ -390,6 +390,10 @@ NOTE: a minimum of MySQL server 4.0.X is required
- cp /usr/local/mysql-5.0.27/libmysql/.libs/libmysqlclient.so.15 /usr/lib/
- you are done
** INSTALLATION NOTE **
If you are having Linuxthreads problems upon onfigure, just execute the following command:
echo '/* Linuxthreads */' >> /usr/include/pthread.h
***** NOTE: if you will be using any of the DBI perl scripts: *****
Every machine that you will be using the newer BDI perl scripts on will need
to have the perl modules DBI and DBD::mysql installed on them. To do this
@@ -632,10 +636,10 @@ updated on your system, so we're going to install a new version now.
- make
- make install
- cd /usr/local
- wget http://gulus.usherbrooke.ca/pub/appl/ssh/OpenSSH/portable/openssh-4.6p1.tar.gz
- gunzip openssh-4.6p1.tar.gz
- tar xvf openssh-4.6p1.tar
- cd openssh-4.6p1
- wget http://gulus.usherbrooke.ca/pub/appl/ssh/OpenSSH/portable/openssh-4.7p1.tar.gz
- gunzip openssh-4.7p1.tar.gz
- tar xvf openssh-4.7p1.tar
- cd openssh-4.7p1
- ./configure
- make
- make install
@@ -650,10 +654,10 @@ your locally installed copy of Apache web server)
9. Go to http://www.openssl.org/ and download the linux source for openssl
- to install this directly on the command line type:
- cd /usr/local
- wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz
- gunzip openssl-0.9.8e.tar.gz
- tar xvf openssl-0.9.8e.tar
- cd openssl-0.9.8e
- wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz
- gunzip openssl-0.9.8g.tar.gz
- tar xvf openssl-0.9.8g.tar
- cd openssl-0.9.8g
- ./config
- make
- make install