From 7da0e193a7abec68e06aebe2a0c5fd64089f079c Mon Sep 17 00:00:00 2001 From: mattf Date: Sun, 21 Jun 2009 11:14:21 +0000 Subject: [PATCH] Code cleanup in several bin scripts Added new output options with audio file transfer to AST_VDsales_export.pl git-svn-id: svn://192.168.202.10@1160 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/ADMIN_backup.pl | 202 ++--- bin/AST_CRON_audio_3_ftp.pl | 6 +- bin/AST_VDadapt.pl | 20 +- bin/AST_VDauto_dial.pl | 616 +++++++------ bin/AST_VDsales_export.pl | 708 ++++++++++----- bin/AST_sourceID_summary_export.pl | 137 +-- docs/REQUIRED_APPS_INSTALL.txt | 2 +- docs/SCRATCH_INSTALL.txt | 6 +- extras/first_server_install.sql | 1 + install.pl | 1296 ++++++++++++++-------------- 10 files changed, 1633 insertions(+), 1361 deletions(-) diff --git a/bin/ADMIN_backup.pl b/bin/ADMIN_backup.pl index b6a541bf..89ca8b55 100644 --- a/bin/ADMIN_backup.pl +++ b/bin/ADMIN_backup.pl @@ -1,11 +1,11 @@ #!/usr/bin/perl # -# ADMIN_backup.pl version 2.0.5 +# ADMIN_backup.pl version 2.2.0 # # DESCRIPTION: # Backs-up the asterisk database, conf/agi/sounds/bin files # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # @@ -13,9 +13,9 @@ # 80317-1609 - Added Sangoma conf file backup and changed FTP settings # 80328-0135 - Do not attempt to archive /etc/my.cnf is --without-db flag is set # 80611-0549 - Added DB option to backup all tables except for log tables +# 90620-1851 - Moved mysqldump bin lookup to database backup section # - $secT = time(); $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -32,93 +32,93 @@ $VDL_date = "$year-$mon-$mday 00:00:01"; ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "allowed run time options:\n"; - print " [--db-only] = only backup the database\n"; - print " [--db-without-logs] = do not backup the log tables in the database\n"; - print " [--conf-only] = only backup the asterisk conf files\n"; - print " [--without-db] = do not backup the database\n"; - print " [--without-conf] = do not backup the conf files\n"; - print " [--without-web] = do not backup web files\n"; - print " [--without-sounds] = do not backup asterisk sounds\n"; - print " [--ftp-transfer] = Transfer backup to FTP server\n"; - print " [--debugX] = super debug\n"; - print " [--debug] = debug\n"; - print " [-t] = test\n"; - exit; - } + { + print "allowed run time options:\n"; + print " [--db-only] = only backup the database\n"; + print " [--db-without-logs] = do not backup the log tables in the database\n"; + print " [--conf-only] = only backup the asterisk conf files\n"; + print " [--without-db] = do not backup the database\n"; + print " [--without-conf] = do not backup the conf files\n"; + print " [--without-web] = do not backup web files\n"; + print " [--without-sounds] = do not backup asterisk sounds\n"; + print " [--ftp-transfer] = Transfer backup to FTP server\n"; + print " [--debugX] = super debug\n"; + print " [--debug] = debug\n"; + print " [-t] = test\n"; + exit; + } else - { - if ($args =~ /--debug/i) { - $DB=1; $FTPdebug=1; - print "\n----- DEBUG -----\n\n"; - } - if ($args =~ /--debugX/i) - { - $DBX=1; - print "\n----- SUPER DEBUG -----\n\n"; - } - if ($args =~ /-t/i) - { - $T=1; $TEST=1; - print "\n-----TESTING -----\n\n"; - } - if ($args =~ /--db-only/i) - { - $db_only=1; - print "\n----- Backup Database Only -----\n\n"; - } - if ($args =~ /--db-without-logs/i) - { - $db_without_logs=1; - print "\n----- Backup Database Without Logs -----\n\n"; - } - if ($args =~ /--conf-only/i) - { - $conf_only=1; - print "\n----- Conf Files Backup Only -----\n\n"; - } - if ($args =~ /--without-db/i) - { - $without_db=1; - print "\n----- No Database Backup -----\n\n"; - } - if ($args =~ /--without-conf/i) - { - $without_conf=1; - print "\n----- No Conf Files Backup -----\n\n"; - } - if ($args =~ /--without-sounds/i) - { - $without_sounds=1; - print "\n----- No Sounds Backup -----\n\n"; - } - if ($args =~ /--without-web/i) - { - $without_web=1; - print "\n----- No web files Backup -----\n\n"; - } - if ($args =~ /--ftp-transfer/i) - { - $ftp_transfer=1; - print "\n----- FTP transfer -----\n\n"; + if ($args =~ /--debug/i) + { + $DB=1; $FTPdebug=1; + print "\n----- DEBUG -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER DEBUG -----\n\n"; + } + if ($args =~ /-t/i) + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } + if ($args =~ /--db-only/i) + { + $db_only=1; + print "\n----- Backup Database Only -----\n\n"; + } + if ($args =~ /--db-without-logs/i) + { + $db_without_logs=1; + print "\n----- Backup Database Without Logs -----\n\n"; + } + if ($args =~ /--conf-only/i) + { + $conf_only=1; + print "\n----- Conf Files Backup Only -----\n\n"; + } + if ($args =~ /--without-db/i) + { + $without_db=1; + print "\n----- No Database Backup -----\n\n"; + } + if ($args =~ /--without-conf/i) + { + $without_conf=1; + print "\n----- No Conf Files Backup -----\n\n"; + } + if ($args =~ /--without-sounds/i) + { + $without_sounds=1; + print "\n----- No Sounds Backup -----\n\n"; + } + if ($args =~ /--without-web/i) + { + $without_web=1; + print "\n----- No web files Backup -----\n\n"; + } + if ($args =~ /--ftp-transfer/i) + { + $ftp_transfer=1; + print "\n----- FTP transfer -----\n\n"; + } } } -} else -{ -print "no command line options set\n"; -} + { + print "no command line options set\n"; + } # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -207,22 +207,6 @@ else } } -### find mysqldump binary to do the database dump -$mysqldumpbin = ''; -if ( -e ('/usr/bin/mysqldump')) {$mysqldumpbin = '/usr/bin/mysqldump';} -else - { - if ( -e ('/usr/local/mysql/bin/mysqldump')) {$mysqldumpbin = '/usr/local/mysql/bin/mysqldump';} - else - { - if ( -e ('/bin/mysqldump')) {$mysqldumpbin = '/bin/mysqldump';} - else - { - print "Can't find mysqldump binary! MySQL backups will not work...\n"; - } - } - } - $conf='_CONF_'; $sangoma='_SANGOMA_'; $linux='_LINUX_'; @@ -239,6 +223,22 @@ $sgSTRING=''; if ( ($without_db < 1) && ($conf_only < 1) ) { + ### find mysqldump binary to do the database dump + $mysqldumpbin = ''; + if ( -e ('/usr/bin/mysqldump')) {$mysqldumpbin = '/usr/bin/mysqldump';} + else + { + if ( -e ('/usr/local/mysql/bin/mysqldump')) {$mysqldumpbin = '/usr/local/mysql/bin/mysqldump';} + else + { + if ( -e ('/bin/mysqldump')) {$mysqldumpbin = '/bin/mysqldump';} + else + { + print "Can't find mysqldump binary! MySQL backups will not work...\n"; + } + } + } + ### BACKUP THE MYSQL FILES ON THE DB SERVER ### if ($db_without_logs) { @@ -257,16 +257,16 @@ if ( ($without_db < 1) && ($conf_only < 1) ) $archive_tables=''; while ($sthArows > $rec_count) { - @aryA = $sthA->fetchrow_array; - if ($aryA[0] =~ /_log|server_performance|vicidial_ivr|vicidial_hopper|vicidial_manager|web_client_sessions|imm_outcomes/) + @aryA = $sthA->fetchrow_array; + if ($aryA[0] =~ /_log|server_performance|vicidial_ivr|vicidial_hopper|vicidial_manager|web_client_sessions|imm_outcomes/) { $log_tables .= " $aryA[0]"; } - else + else { $archive_tables .= " $aryA[0]"; } - $rec_count++; + $rec_count++; } $sthA->finish(); diff --git a/bin/AST_CRON_audio_3_ftp.pl b/bin/AST_CRON_audio_3_ftp.pl index 31f14a79..cb280d58 100644 --- a/bin/AST_CRON_audio_3_ftp.pl +++ b/bin/AST_CRON_audio_3_ftp.pl @@ -218,7 +218,7 @@ sleep(5); ### Loop through files a second time to gather filesizes again 5 seconds later $i=0; foreach(@FILES) - { + { $FILEsize2[$i] = 0; if ( (length($FILES[$i]) > 4) && (!-d "$dir1/$FILES[$i]") ) @@ -283,6 +283,10 @@ foreach(@FILES) `mv -f "$dir2/$ALLfile" "$PATHDONEmonitor/FTP/$ALLfile"`; } } + else + { + print "ERROR: Could not ping server $VARFTP_host\n"; + } ### END Remote file transfer ### sleep for twenty hundredths of a second to not flood the server with disk activity diff --git a/bin/AST_VDadapt.pl b/bin/AST_VDadapt.pl index bd87b5ad..f4101ba1 100644 --- a/bin/AST_VDadapt.pl +++ b/bin/AST_VDadapt.pl @@ -421,15 +421,7 @@ while ($master_loop<$CLIloops) $differential_onemin[$i]=0; $agents_average_onemin[$i]=0; - # ### Grab the count of agents and lines - # if ($campaign_id[$i] !~ /(CLOSER|BLEND|INBND|_C$|_B$|_I$)/) - # { - &count_agents_lines; - # } - # else - # { - # if ($DB) {print " CLOSER CAMPAIGN\n";} - # } + &count_agents_lines; if ($total_agents_avg[$i] > 0) { @@ -595,7 +587,7 @@ sub get_time_now $current_hourmin = "$hour$min"; ### get date-time of one hour ago ### - $VDL_hour = ($secX - (60 * 60)); + $VDL_hour = ($secX - (60 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_hour); $Vyear = ($Vyear + 1900); $Vmon++; @@ -604,7 +596,7 @@ sub get_time_now $VDL_hour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### get date-time of half hour ago ### - $VDL_halfhour = ($secX - (30 * 60)); + $VDL_halfhour = ($secX - (30 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_halfhour); $Vyear = ($Vyear + 1900); $Vmon++; @@ -613,7 +605,7 @@ sub get_time_now $VDL_halfhour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### get date-time of five minutes ago ### - $VDL_five = ($secX - (5 * 60)); + $VDL_five = ($secX - (5 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_five); $Vyear = ($Vyear + 1900); $Vmon++; @@ -622,10 +614,10 @@ sub get_time_now $VDL_five = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; ### get epoch of ninty seconds ago ### - $VDL_ninty = ($secX - (1 * 90)); + $VDL_ninty = ($secX - (1 * 90)); ### get date-time of one minute ago ### - $VDL_one = ($secX - (1 * 60)); + $VDL_one = ($secX - (1 * 60)); ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_one); $Vyear = ($Vyear + 1900); $Vmon++; diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index 3df8f54c..1ab35cc8 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_VDauto_dial.pl version 2.0.5 *DBI-version* +# AST_VDauto_dial.pl version 2.2.0 *DBI-version* # # DESCRIPTION: # Places auto_dial calls on the VICIDIAL dialer system @@ -76,53 +76,54 @@ # 90202-0203 - Added outbound_autodial_active option to halt all dialing # 90306-1845 - Added configurable calls-per-second option # 90611-0554 - Bug fix for Manual dial calls and logging +# 90619-1948 - format fixing # ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n\n"; - } - else - { - if ($args =~ /--delay=/i) { - @data_in = split(/--delay=/,$args); + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n\n"; + } + else + { + if ($args =~ /--delay=/i) + { + @data_in = split(/--delay=/,$args); $loop_delay = $data_in[1]; print " LOOP DELAY OVERRIDE!!!!! = $loop_delay seconds\n\n"; $loop_delay = ($loop_delay * 1000); - } + } else - { - $loop_delay = '2500'; - } + { + $loop_delay = '2500'; + } if ($args =~ /-debug/i) - { - $DB=1; # Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute - } + { + $DB=1; # Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute + } if ($args =~ /-t/i) - { - $TEST=1; - $T=1; + { + $TEST=1; + $T=1; + } } } -} else -{ -print "no command line options set\n"; + { + print "no command line options set\n"; $loop_delay = '2500'; $DB=1; -} + } ### end parsing run-time options ### @@ -185,9 +186,9 @@ if (!$JAMdebugFILE) {$JAMdebugFILE = "$PATHlogs/vdad-JAM.$year-$mon-$mday";} use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second use DBI; - ### connect to MySQL database defined in the conf file - $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; +### connect to MySQL database defined in the conf file +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") +or die "Couldn't connect to database: " . DBI->errstr; ### Grab Server values from the database $stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs FROM servers where server_ip = '$server_ip';"; @@ -197,33 +198,33 @@ $sthArows=$sthA->rows; $rec_count=0; while ($sthArows > $rec_count) { - @aryA = $sthA->fetchrow_array; - $DBtelnet_host = "$aryA[0]"; - $DBtelnet_port = "$aryA[1]"; - $DBASTmgrUSERNAME = "$aryA[2]"; - $DBASTmgrSECRET = "$aryA[3]"; - $DBASTmgrUSERNAMEupdate = "$aryA[4]"; - $DBASTmgrUSERNAMElisten = "$aryA[5]"; - $DBASTmgrUSERNAMEsend = "$aryA[6]"; - $DBmax_vicidial_trunks = "$aryA[7]"; - $DBanswer_transfer_agent= "$aryA[8]"; - $DBSERVER_GMT = "$aryA[9]"; - $DBext_context = "$aryA[10]"; - $DBvd_server_logs = "$aryA[11]"; - if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;} - if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;} - if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;} - if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;} - if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;} - if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;} - if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;} - $max_vicidial_trunks = $DBmax_vicidial_trunks; - if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} - if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} - if ($DBext_context) {$ext_context = $DBext_context;} - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - else {$SYSLOG = '0';} - $rec_count++; + @aryA = $sthA->fetchrow_array; + $DBtelnet_host = "$aryA[0]"; + $DBtelnet_port = "$aryA[1]"; + $DBASTmgrUSERNAME = "$aryA[2]"; + $DBASTmgrSECRET = "$aryA[3]"; + $DBASTmgrUSERNAMEupdate = "$aryA[4]"; + $DBASTmgrUSERNAMElisten = "$aryA[5]"; + $DBASTmgrUSERNAMEsend = "$aryA[6]"; + $DBmax_vicidial_trunks = "$aryA[7]"; + $DBanswer_transfer_agent= "$aryA[8]"; + $DBSERVER_GMT = "$aryA[9]"; + $DBext_context = "$aryA[10]"; + $DBvd_server_logs = "$aryA[11]"; + if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;} + if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;} + if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;} + if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;} + if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;} + if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;} + if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;} + $max_vicidial_trunks = $DBmax_vicidial_trunks; + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + $rec_count++; } $sthA->finish(); @@ -256,13 +257,12 @@ $sthA->finish(); $one_day_interval = 12; # 1 month loops for one year while($one_day_interval > 0) -{ - + { $endless_loop=5760000; # 30 days minutes at XXX seconds per loop $stat_count=1; while($endless_loop > 0) - { + { &get_time_now; $VDADLOGfile = "$PATHlogs/vdautodial.$year-$mon-$mday"; @@ -358,28 +358,28 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBlive_user[$user_counter] = "$aryA[0]"; - $DBlive_server_ip[$user_counter] = "$aryA[1]"; - $DBlive_campaign[$user_counter] = "$aryA[2]"; - $DBlive_conf_exten[$user_counter] = "$aryA[3]"; - $DBlive_status[$user_counter] = "$aryA[4]"; - - if ($user_campaigns !~ /\|$DBlive_campaign[$user_counter]\|/i) - { - if ($campaigns_update !~ /'$DBlive_campaign[$user_counter]'/) {$campaigns_update .= "'$DBlive_campaign[$user_counter]',"; $CPcount++;} - $user_campaigns .= "$DBlive_campaign[$user_counter]|"; - $user_campaignsSQL .= ",'$DBlive_campaign[$user_counter]'"; - $DBcampaigns[$user_campaigns_counter] = $DBlive_campaign[$user_counter]; - $user_campaigns_counter++; - } - if ($user_campaignIP !~ /\|$DBlive_campaign[$user_counter]__$DBlive_server_ip[$user_counter]\|/i) - { - $user_campaignIP .= "$DBlive_campaign[$user_counter]__$DBlive_server_ip[$user_counter]|"; - $DBIPcampaign[$user_CIPct] = "$DBlive_campaign[$user_counter]"; - $DBIPaddress[$user_CIPct] = "$DBlive_server_ip[$user_counter]"; - $user_CIPct++; - } - $user_counter++; + $DBlive_user[$user_counter] = "$aryA[0]"; + $DBlive_server_ip[$user_counter] = "$aryA[1]"; + $DBlive_campaign[$user_counter] = "$aryA[2]"; + $DBlive_conf_exten[$user_counter] = "$aryA[3]"; + $DBlive_status[$user_counter] = "$aryA[4]"; + + if ($user_campaigns !~ /\|$DBlive_campaign[$user_counter]\|/i) + { + if ($campaigns_update !~ /'$DBlive_campaign[$user_counter]'/) {$campaigns_update .= "'$DBlive_campaign[$user_counter]',"; $CPcount++;} + $user_campaigns .= "$DBlive_campaign[$user_counter]|"; + $user_campaignsSQL .= ",'$DBlive_campaign[$user_counter]'"; + $DBcampaigns[$user_campaigns_counter] = $DBlive_campaign[$user_counter]; + $user_campaigns_counter++; + } + if ($user_campaignIP !~ /\|$DBlive_campaign[$user_counter]__$DBlive_server_ip[$user_counter]\|/i) + { + $user_campaignIP .= "$DBlive_campaign[$user_counter]__$DBlive_server_ip[$user_counter]|"; + $DBIPcampaign[$user_CIPct] = "$DBlive_campaign[$user_counter]"; + $DBIPaddress[$user_CIPct] = "$DBlive_server_ip[$user_counter]"; + $user_CIPct++; + } + $user_counter++; $rec_count++; } $sthA->finish(); @@ -393,7 +393,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $active_line_counter = "$aryA[0]"; + $active_line_counter = "$aryA[0]"; $rec_count++; } $sthA->finish(); @@ -440,7 +440,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBIPold_trunk_shortage[$user_CIPct] = "$aryA[0]"; + $DBIPold_trunk_shortage[$user_CIPct] = "$aryA[0]"; $rec_count++; } if ($rec_count < 1) @@ -466,7 +466,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBIPserver_trunks_limit[$user_CIPct] = "$aryA[0]"; + $DBIPserver_trunks_limit[$user_CIPct] = "$aryA[0]"; $rec_count++; } $stmtA = "SELECT sum(dedicated_trunks) FROM vicidial_server_trunks where campaign_id NOT IN('$DBIPcampaign[$user_CIPct]') and server_ip='$server_ip';"; @@ -477,7 +477,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBIPserver_trunks_other[$user_CIPct] = "$aryA[0]"; + $DBIPserver_trunks_other[$user_CIPct] = "$aryA[0]"; $rec_count++; } @@ -495,27 +495,27 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBIPadlevel[$user_CIPct] = "$aryA[0]"; - $DBIPcalltime[$user_CIPct] = "$aryA[1]"; - $DBIPdialtimeout[$user_CIPct] = "$aryA[2]"; - $DBIPdialprefix[$user_CIPct] = "$aryA[3]"; - $DBIPcampaigncid[$user_CIPct] = "$aryA[4]"; - $DBIPactive[$user_CIPct] = "$aryA[5]"; - $DBIPvdadexten[$user_CIPct] = "$aryA[6]"; - $DBIPclosercamp[$user_CIPct] = "$aryA[7]"; - $omit_phone_code = "$aryA[8]"; - if ($omit_phone_code =~ /Y/) {$DBIPomitcode[$user_CIPct] = 1;} - else {$DBIPomitcode[$user_CIPct] = 0;} - $available_only_ratio_tally = "$aryA[9]"; - if ($available_only_ratio_tally =~ /Y/) - { - $DBIPcount[$user_CIPct] = $DBIPACTIVEcount[$user_CIPct]; - $active_only=1; - } - $DBIPautoaltdial[$user_CIPct] = "$aryA[10]"; - $DBIPcampaign_allow_inbound[$user_CIPct] = "$aryA[11]"; - $DBIPqueue_priority[$user_CIPct] = "$aryA[12]"; - $DBIPdial_method[$user_CIPct] = "$aryA[13]"; + $DBIPadlevel[$user_CIPct] = "$aryA[0]"; + $DBIPcalltime[$user_CIPct] = "$aryA[1]"; + $DBIPdialtimeout[$user_CIPct] = "$aryA[2]"; + $DBIPdialprefix[$user_CIPct] = "$aryA[3]"; + $DBIPcampaigncid[$user_CIPct] = "$aryA[4]"; + $DBIPactive[$user_CIPct] = "$aryA[5]"; + $DBIPvdadexten[$user_CIPct] = "$aryA[6]"; + $DBIPclosercamp[$user_CIPct] = "$aryA[7]"; + $omit_phone_code = "$aryA[8]"; + if ($omit_phone_code =~ /Y/) {$DBIPomitcode[$user_CIPct] = 1;} + else {$DBIPomitcode[$user_CIPct] = 0;} + $available_only_ratio_tally = "$aryA[9]"; + if ($available_only_ratio_tally =~ /Y/) + { + $DBIPcount[$user_CIPct] = $DBIPACTIVEcount[$user_CIPct]; + $active_only=1; + } + $DBIPautoaltdial[$user_CIPct] = "$aryA[10]"; + $DBIPcampaign_allow_inbound[$user_CIPct] = "$aryA[11]"; + $DBIPqueue_priority[$user_CIPct] = "$aryA[12]"; + $DBIPdial_method[$user_CIPct] = "$aryA[13]"; $rec_count++; } $sthA->finish(); @@ -533,7 +533,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $tally_xfer_line_counter = "$aryA[0]"; + $tally_xfer_line_counter = "$aryA[0]"; $rec_count++; } $sthA->finish(); @@ -551,15 +551,15 @@ while($one_day_interval > 0) ### subtract that number from goalcalls to determine how many new ### calls need to be placed in this loop if ($DBIPcampaign_allow_inbound[$user_CIPct] =~ /Y/) - { + { if (length($DBIPclosercamp[$user_CIPct]) > 2) - { + { $DBIPclosercamp[$user_CIPct] =~ s/^ | -$//gi; $DBIPclosercamp[$user_CIPct] =~ s/ /','/gi; $DBIPclosercamp[$user_CIPct] = "'$DBIPclosercamp[$user_CIPct]'"; - } - else {$DBIPclosercamp[$user_CIPct]="''";} - + } + else {$DBIPclosercamp[$user_CIPct]="''";} + $campaign_query = "( (call_type='IN' and campaign_id IN($DBIPclosercamp[$user_CIPct])) or (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type IN('OUT','OUTBALANCE')) )"; } else {$campaign_query = "(campaign_id='$DBIPcampaign[$user_CIPct]' and call_type IN('OUT','OUTBALANCE'))";} @@ -571,7 +571,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBIPexistcalls[$user_CIPct] = "$aryA[0]"; + $DBIPexistcalls[$user_CIPct] = "$aryA[0]"; $rec_count++; } $sthA->finish(); @@ -657,7 +657,7 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $waiting_calls = "$aryA[0]"; + $waiting_calls = "$aryA[0]"; $rec_count++; } $sthA->finish(); @@ -752,26 +752,26 @@ while($one_day_interval > 0) { $stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$server_ip' where campaign_id='$DBIPcampaign[$user_CIPct]' and status='READY' order by priority desc,hopper_id LIMIT $DBIPmakecalls[$user_CIPct]"; print "|$stmtA|\n"; - $UDaffected_rows = $dbhA->do($stmtA); + $UDaffected_rows = $dbhA->do($stmtA); print "hopper rows updated to QUEUE: |$UDaffected_rows|\n"; if ($UDaffected_rows) - { - $lead_id=''; $phone_code=''; $phone_number=''; $called_count=''; - while ($call_CMPIPct < $UDaffected_rows) { - $stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBIPcampaign[$user_CIPct]' and status='QUEUE' and user='VDAD_$server_ip' order by priority desc,hopper_id LIMIT 1"; - print "|$stmtA|\n"; + $lead_id=''; $phone_code=''; $phone_number=''; $called_count=''; + while ($call_CMPIPct < $UDaffected_rows) + { + $stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBIPcampaign[$user_CIPct]' and status='QUEUE' and user='VDAD_$server_ip' order by priority desc,hopper_id LIMIT 1"; + print "|$stmtA|\n"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; + $rec_countCUSTDATA=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $lead_id = "$aryA[0]"; - $alt_dial = "$aryA[1]"; + $lead_id = "$aryA[0]"; + $alt_dial = "$aryA[1]"; $rec_count++; } $sthA->finish(); @@ -791,7 +791,7 @@ while($one_day_interval > 0) { $stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'"; print "|$stmtA|\n"; - $UQaffected_rows = $dbhA->do($stmtA); + $UQaffected_rows = $dbhA->do($stmtA); print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n"; $stmtA = "SELECT * FROM vicidial_list where lead_id='$lead_id';"; @@ -799,20 +799,20 @@ while($one_day_interval > 0) $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; + $rec_countCUSTDATA=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $list_id = "$aryA[7]"; - $gmt_offset_now = "$aryA[8]"; - $called_since_last_reset = "$aryA[9]"; - $phone_code = "$aryA[10]"; - $phone_number = "$aryA[11]"; - $address3 = "$aryA[18]"; - $alt_phone = "$aryA[26]"; - $called_count = "$aryA[30]"; + $list_id = "$aryA[7]"; + $gmt_offset_now = "$aryA[8]"; + $called_since_last_reset = "$aryA[9]"; + $phone_code = "$aryA[10]"; + $phone_number = "$aryA[11]"; + $address3 = "$aryA[18]"; + $alt_phone = "$aryA[26]"; + $called_count = "$aryA[30]"; - $rec_countCUSTDATA++; + $rec_countCUSTDATA++; $rec_count++; } $sthA->finish(); @@ -898,14 +898,14 @@ while($one_day_interval > 0) $local_AMP = '@'; $Local_out_prefix = '9'; $Local_dial_timeout = '60'; - if ($DBIPdialtimeout[$user_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$user_CIPct];} + if ($DBIPdialtimeout[$user_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$user_CIPct];} $Local_dial_timeout = ($Local_dial_timeout * 1000); - if (length($DBIPdialprefix[$user_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$user_CIPct]";} - if (length($DBIPvdadexten[$user_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$user_CIPct]";} - else {$VDAD_dial_exten = "$answer_transfer_agent";} - - if (length($DBIPcampaigncid[$user_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$user_CIPct]"; $CCID_on++;} - if ($DBIPdialprefix[$user_CIPct] =~ /x/i) {$Local_out_prefix = '';} + if (length($DBIPdialprefix[$user_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$user_CIPct]";} + if (length($DBIPvdadexten[$user_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$user_CIPct]";} + else {$VDAD_dial_exten = "$answer_transfer_agent";} + + if (length($DBIPcampaigncid[$user_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$user_CIPct]"; $CCID_on++;} + if ($DBIPdialprefix[$user_CIPct] =~ /x/i) {$Local_out_prefix = '';} if ($RECcount) { @@ -916,7 +916,7 @@ while($one_day_interval > 0) if ($lists_update !~ /'$list_id'/) {$lists_update .= "'$list_id',"; $LUcount++;} - $lead_id_call_list .= "$lead_id|"; + $lead_id_call_list .= "$lead_id|"; if (length($alt_dial)<1) {$alt_dial='MAIN';} @@ -942,20 +942,18 @@ while($one_day_interval > 0) $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type,alt_dial,queue_priority) values('$DBIPaddress[$user_CIPct]','$DBIPcampaign[$user_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT','$alt_dial','$DBIPqueue_priority[$user_CIPct]')"; $affected_rows = $dbhA->do($stmtA); - ### sleep for a five hundredths of a second to not flood the server with new calls - # usleep(1*50*1000); - usleep(1*$per_call_delay*1000); + ### sleep for a five hundredths of a second to not flood the server with new calls + # usleep(1*50*1000); + usleep(1*$per_call_delay*1000); + } } + $call_CMPIPct++; } - $call_CMPIPct++; } } } + $user_CIPct++; } - $user_CIPct++; - } - - @@ -979,16 +977,16 @@ while($one_day_interval > 0) $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; - $kill_vac=0; + $rec_countCUSTDATA=0; + $kill_vac=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $KLcallerid[$kill_vac] = "$aryA[0]"; - $KLserver_ip[$kill_vac] = "$aryA[1]"; - $KLchannel[$kill_vac] = "$aryA[2]"; - $KLuniqueid[$kill_vac] = "$aryA[3]"; - $KLstatus[$kill_vac] = "$aryA[4]"; + $KLcallerid[$kill_vac] = "$aryA[0]"; + $KLserver_ip[$kill_vac] = "$aryA[1]"; + $KLchannel[$kill_vac] = "$aryA[2]"; + $KLuniqueid[$kill_vac] = "$aryA[3]"; + $KLstatus[$kill_vac] = "$aryA[4]"; $kill_vac++; $rec_count++; } @@ -1010,13 +1008,13 @@ while($one_day_interval > 0) $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; + $rec_countCUSTDATA=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $end_epoch = "$aryA[0]"; - $CLuniqueid = "$aryA[1]"; - $start_epoch = "$aryA[2]"; + $end_epoch = "$aryA[0]"; + $CLuniqueid = "$aryA[1]"; + $start_epoch = "$aryA[2]"; $rec_count++; } $sthA->finish(); @@ -1029,13 +1027,13 @@ while($one_day_interval > 0) $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; + $rec_countCUSTDATA=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $end_epoch = "$aryA[0]"; - $CLuniqueid = "$aryA[1]"; - $start_epoch = "$aryA[2]"; + $end_epoch = "$aryA[0]"; + $CLuniqueid = "$aryA[1]"; + $start_epoch = "$aryA[2]"; $rec_count++; } $sthA->finish(); @@ -1048,7 +1046,7 @@ while($one_day_interval > 0) $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; + $rec_countCUSTDATA=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; @@ -1237,7 +1235,7 @@ while($one_day_interval > 0) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; + $epc_countCAMPDATA=0; while ($sthArows > $epc_countCAMPDATA) { @aryA = $sthA->fetchrow_array; @@ -1246,7 +1244,7 @@ while($one_day_interval > 0) $VD_gmt_offset_now = "$aryA[1]"; $VD_state = "$aryA[2]"; $VD_list_id = "$aryA[3]"; - $epc_countCAMPDATA++; + $epc_countCAMPDATA++; } $sthA->finish(); if (length($VD_alt_phone)>5) @@ -1303,7 +1301,7 @@ while($one_day_interval > 0) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; + $epc_countCAMPDATA=0; while ($sthArows > $epc_countCAMPDATA) { @aryA = $sthA->fetchrow_array; @@ -1312,7 +1310,7 @@ while($one_day_interval > 0) $VD_gmt_offset_now = "$aryA[1]"; $VD_state = "$aryA[2]"; $VD_list_id = "$aryA[3]"; - $epc_countCAMPDATA++; + $epc_countCAMPDATA++; } $sthA->finish(); if (length($VD_address3)>5) @@ -1374,14 +1372,14 @@ while($one_day_interval > 0) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; + $epc_countCAMPDATA=0; while ($sthArows > $epc_countCAMPDATA) { @aryA = $sthA->fetchrow_array; $VD_gmt_offset_now = "$aryA[1]"; $VD_state = "$aryA[2]"; $VD_list_id = "$aryA[3]"; - $epc_countCAMPDATA++; + $epc_countCAMPDATA++; } $sthA->finish(); $alt_dial_phones_count=0; @@ -1514,34 +1512,34 @@ while($one_day_interval > 0) $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $rec_count=0; - $rec_countCUSTDATA=0; + $rec_countCUSTDATA=0; while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VALOuser[$logcount] = "$aryA[0]"; - $VALOcampaign[$logcount] = "$aryA[1]"; - $VALOtimelog[$logcount] = "$aryA[2]"; - $VALOextension[$logcount] = "$aryA[3]"; - $logcount++; + $VALOuser[$logcount] = "$aryA[0]"; + $VALOcampaign[$logcount] = "$aryA[1]"; + $VALOtimelog[$logcount] = "$aryA[2]"; + $VALOextension[$logcount] = "$aryA[3]"; + $logcount++; $rec_count++; } $sthA->finish(); $logrun=0; foreach(@VALOuser) { - $VALOuser_group=''; - $stmtA = "SELECT user_group FROM vicidial_users where user='$VALOuser[$logrun]';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $UGrec_count=0; - while ($sthArows > $UGrec_count) - { - @aryA = $sthA->fetchrow_array; - $VALOuser_group = "$aryA[0]"; - $UGrec_count++; - } - $sthA->finish(); + $VALOuser_group=''; + $stmtA = "SELECT user_group FROM vicidial_users where user='$VALOuser[$logrun]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $UGrec_count=0; + while ($sthArows > $UGrec_count) + { + @aryA = $sthA->fetchrow_array; + $VALOuser_group = "$aryA[0]"; + $UGrec_count++; + } + $sthA->finish(); $stmtA = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VALOuser[$logrun]','LOGOUT','$VALOcampaign[$logrun]','$SQLdate','$now_date_epoch','$VALOuser_group');"; $affected_rows = $dbhA->do($stmtA); @@ -1589,16 +1587,16 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $auto_call_id = "$aryA[0]"; - $CLlead_id = "$aryA[1]"; - $CLphone_number = "$aryA[2]"; - $CLstatus = "$aryA[3]"; - $CLcampaign_id = "$aryA[4]"; - $CLphone_code = "$aryA[5]"; - $CLalt_dial = "$aryA[6]"; - $CLstage = "$aryA[7]"; - $CLcallerid = "$aryA[8]"; - $CLuniqueid = "$aryA[9]"; + $auto_call_id = "$aryA[0]"; + $CLlead_id = "$aryA[1]"; + $CLphone_number = "$aryA[2]"; + $CLstatus = "$aryA[3]"; + $CLcampaign_id = "$aryA[4]"; + $CLphone_code = "$aryA[5]"; + $CLalt_dial = "$aryA[6]"; + $CLstage = "$aryA[7]"; + $CLcallerid = "$aryA[8]"; + $CLuniqueid = "$aryA[9]"; $rec_count++; } $sthA->finish(); @@ -1675,7 +1673,7 @@ while($one_day_interval > 0) ### sleep for 2 and a half seconds before beginning the loop again usleep(1*$loop_delay*1000); - $endless_loop--; + $endless_loop--; if($DB){print STDERR "\nloop counter: |$endless_loop|\n";} ### putting a blank file called "VDAD.kill" in the directory will automatically safely kill this program @@ -1696,11 +1694,11 @@ while($one_day_interval > 0) $rec_count=0; while ($sthArows > $rec_count) { - @aryA = $sthA->fetchrow_array; - $DBvd_server_logs = "$aryA[0]"; - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - else {$SYSLOG = '0';} - $rec_count++; + @aryA = $sthA->fetchrow_array; + $DBvd_server_logs = "$aryA[0]"; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + $rec_count++; } $sthA->finish(); @@ -1713,14 +1711,14 @@ while($one_day_interval > 0) $rec_count=0; while ($sthArows > $rec_count) { - @aryA = $sthA->fetchrow_array; - $enable_queuemetrics_logging = "$aryA[0]"; - $queuemetrics_server_ip = "$aryA[1]"; - $queuemetrics_dbname = "$aryA[2]"; - $queuemetrics_login= "$aryA[3]"; - $queuemetrics_pass = "$aryA[4]"; - $queuemetrics_log_id = "$aryA[5]"; - $rec_count++; + @aryA = $sthA->fetchrow_array; + $enable_queuemetrics_logging = "$aryA[0]"; + $queuemetrics_server_ip = "$aryA[1]"; + $queuemetrics_dbname = "$aryA[2]"; + $queuemetrics_login= "$aryA[3]"; + $queuemetrics_pass = "$aryA[4]"; + $queuemetrics_log_id = "$aryA[5]"; + $rec_count++; } $sthA->finish(); ##### END QUEUEMETRICS LOGGING LOOKUP ##### @@ -1742,20 +1740,20 @@ while($one_day_interval > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $DBmax_vicidial_trunks = "$aryA[0]"; - $DBanswer_transfer_agent= "$aryA[1]"; - $DBSERVER_GMT = "$aryA[2]"; - $DBext_context = "$aryA[3]"; - $max_vicidial_trunks = $DBmax_vicidial_trunks; - if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} - if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} - if ($DBext_context) {$ext_context = $DBext_context;} + $DBmax_vicidial_trunks = "$aryA[0]"; + $DBanswer_transfer_agent= "$aryA[1]"; + $DBSERVER_GMT = "$aryA[2]"; + $DBext_context = "$aryA[3]"; + $max_vicidial_trunks = $DBmax_vicidial_trunks; + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBext_context) {$ext_context = $DBext_context;} $rec_count++; } $sthA->finish(); $event_string = "| updating server parameters $max_vicidial_trunks|$answer_transfer_agent|$SERVER_GMT|$ext_context|"; - &event_logger; + &event_logger; &get_time_now; @@ -1767,7 +1765,7 @@ while($one_day_interval > 0) $i=0; foreach (@psoutput) { - chomp($psoutput[$i]); + chomp($psoutput[$i]); @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); @@ -1788,27 +1786,27 @@ while($one_day_interval > 0) $bad_grabber_counter=0; - $stat_count++; - } + $stat_count++; + } - if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} + if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} - $event_string='HANGING UP|'; - &event_logger; + $event_string='HANGING UP|'; + &event_logger; $one_day_interval--; -} + } - $event_string='CLOSING DB CONNECTION|'; - &event_logger; +$event_string='CLOSING DB CONNECTION|'; +&event_logger; - $dbhA->disconnect(); +$dbhA->disconnect(); - if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} +if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} exit; @@ -1826,113 +1824,109 @@ exit; sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes -{ -$secX = time(); + { + $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); $LOCAL_GMT_OFF = $SERVER_GMT; $LOCAL_GMT_OFF_STD = $SERVER_GMT; if ($isdst) {$LOCAL_GMT_OFF++;} -$GMT_now = ($secX - ($LOCAL_GMT_OFF * 3600)); + $GMT_now = ($secX - ($LOCAL_GMT_OFF * 3600)); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now); if ($hour < 10) {$hour = "0$hour";} if ($min < 10) {$min = "0$min";} if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} -($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); -$year = ($year + 1900); -$mon++; -if ($mon < 10) {$mon = "0$mon";} -if ($mday < 10) {$mday = "0$mday";} -if ($hour < 10) {$hour = "0$hour";} -if ($min < 10) {$min = "0$min";} -if ($sec < 10) {$sec = "0$sec";} + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year = ($year + 1900); + $mon++; + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + if ($hour < 10) {$hour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} -$now_date_epoch = time(); -$now_date = "$year-$mon-$mday $hour:$min:$sec"; -$file_date = "$year-$mon-$mday"; + $now_date_epoch = time(); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + $file_date = "$year-$mon-$mday"; $CIDdate = "$mon$mday$hour$min$sec"; $tsSQLdate = "$year$mon$mday$hour$min$sec"; $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; -$BDtarget = ($secX - 10); -($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget); -$Byear = ($Byear + 1900); -$Bmon++; -if ($Bmon < 10) {$Bmon = "0$Bmon";} -if ($Bmday < 10) {$Bmday = "0$Bmday";} -if ($Bhour < 10) {$Bhour = "0$Bhour";} -if ($Bmin < 10) {$Bmin = "0$Bmin";} -if ($Bsec < 10) {$Bsec = "0$Bsec";} + $BDtarget = ($secX - 10); + ($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget); + $Byear = ($Byear + 1900); + $Bmon++; + if ($Bmon < 10) {$Bmon = "0$Bmon";} + if ($Bmday < 10) {$Bmday = "0$Bmday";} + if ($Bhour < 10) {$Bhour = "0$Bhour";} + if ($Bmin < 10) {$Bmin = "0$Bmin";} + if ($Bsec < 10) {$Bsec = "0$Bsec";} $BDtsSQLdate = "$Byear$Bmon$Bmday$Bhour$Bmin$Bsec"; -$PDtarget = ($secX - 30); -($Psec,$Pmin,$Phour,$Pmday,$Pmon,$Pyear,$Pwday,$Pyday,$Pisdst) = localtime($PDtarget); -$Pyear = ($Pyear + 1900); -$Pmon++; -if ($Pmon < 10) {$Pmon = "0$Pmon";} -if ($Pmday < 10) {$Pmday = "0$Pmday";} -if ($Phour < 10) {$Phour = "0$Phour";} -if ($Pmin < 10) {$Pmin = "0$Pmin";} -if ($Psec < 10) {$Psec = "0$Psec";} + $PDtarget = ($secX - 30); + ($Psec,$Pmin,$Phour,$Pmday,$Pmon,$Pyear,$Pwday,$Pyday,$Pisdst) = localtime($PDtarget); + $Pyear = ($Pyear + 1900); + $Pmon++; + if ($Pmon < 10) {$Pmon = "0$Pmon";} + if ($Pmday < 10) {$Pmday = "0$Pmday";} + if ($Phour < 10) {$Phour = "0$Phour";} + if ($Pmin < 10) {$Pmin = "0$Pmin";} + if ($Psec < 10) {$Psec = "0$Psec";} $PDtsSQLdate = "$Pyear$Pmon$Pmday$Phour$Pmin$Psec"; $halfminSQLdate = "$Pyear-$Pmon-$Pmday $Phour:$Pmin:$Psec"; -$XDtarget = ($secX - 120); -($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";} + $XDtarget = ($secX - 120); + ($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 - 6000); -($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";} + $TDtarget = ($secX - 6000); + ($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"; - -} - - + } sub event_logger -{ -if ($DB) {print "$now_date|$event_string|\n";} -if ($SYSLOG) { - ### open the log file for writing ### - open(Lout, ">>$VDADLOGfile") - || die "Can't open $VDADLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); + if ($DB) {print "$now_date|$event_string|\n";} + if ($SYSLOG) + { + ### open the log file for writing ### + open(Lout, ">>$VDADLOGfile") + || die "Can't open $VDADLOGfile: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; } -$event_string=''; -} sub jam_event_logger -{ -if ($DB) {print "$now_date|$jam_string|\n";} -if ($useJAMdebugFILE) { - ### open the log file for writing ### - open(Jout, ">>$JAMdebugFILE") - || die "Can't open $JAMdebugFILE: $!\n"; - print Jout "$now_date|$jam_string|\n"; - close(Jout); + if ($DB) {print "$now_date|$jam_string|\n";} + if ($useJAMdebugFILE) + { + ### open the log file for writing ### + open(Jout, ">>$JAMdebugFILE") + || die "Can't open $JAMdebugFILE: $!\n"; + print Jout "$now_date|$jam_string|\n"; + close(Jout); + } + $jam_string=''; } -$jam_string=''; -} - diff --git a/bin/AST_VDsales_export.pl b/bin/AST_VDsales_export.pl index b4c99111..6ca61a22 100644 --- a/bin/AST_VDsales_export.pl +++ b/bin/AST_VDsales_export.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_VDsales_export.pl version: 2.0.5 +# AST_VDsales_export.pl version: 2.2.0 # # This script is designed to gather sales for a VICIDIAL Outbound-only campaign and # post them to a directory @@ -17,11 +17,14 @@ # 71005-0054 - Altered script to use astguiclient.conf for settings # 90105-1155 - Added AS400 export formats and changed around date override # 90106-2309 - Added email sending -# +# 90620-0900 - Formatting fixes +# $txt = '.txt'; $US = '_'; $MT[0] = ''; +$Q=0; +$DB=0; # Default FTP account variables $VARREPORT_host = '10.0.0.4'; @@ -50,6 +53,7 @@ $timestamp = "$year-$mon-$mday $hour:$min:$sec"; $filedate = "$year$mon$mday"; $ABIfiledate = "$mon-$mday-$year$us$hour$min$sec"; $shipdate = "$year-$mon-$mday"; +$start_date = "$year$mon$mday"; $datestamp = "$year/$mon/$mday $hour:$min"; @@ -91,10 +95,13 @@ if (length($ARGV[0])>1) print " [--output-format=XXX] = Format of file. Default \"pipe-standard\"\n"; print " [--with-inbound=XXX-XXY] = include the following inbound groups\n"; print " [--ftp-transfer] = Send results file by FTP to another server\n"; + print " [--ftp-audio-transfer] = Send associated audio files to FTP server, dated directories\n"; + print " [--with-transfer-audio] = Different method for finding audio, also grabs transfer audio filenames\n"; + print " [--with-did-lookup] = Looks up the DID pattern and name the call came in on if possible\n"; print " [--email-list=test@test.com:test2@test.com] = send email results to these addresses\n"; print " [--email-sender=vicidial@localhost] = sender for the email results\n"; - print " [-q] = quiet\n"; - print " [-t] = test\n"; + print " [--quiet] = quiet\n"; + print " [--test] = test\n"; print " [--debug] = debugging messages\n"; print " [--debugX] = Super debugging messages\n"; print "\n"; @@ -113,7 +120,7 @@ if (length($ARGV[0])>1) $DBX=1; print "\n----- SUPER DEBUG MODE -----\n\n"; } - if ($args =~ /-q/i) + if ($args =~ /-quiet/i) { $q=1; $Q=1; } @@ -173,32 +180,32 @@ if (length($ARGV[0])>1) { # print "\n|$ARGS|\n\n"; @data_in = split(/--filename=/,$args); - $filename = $data_in[1]; - $filename =~ s/ .*$//gi; - $filename =~ s/YYYY/$year/gi; - $filename =~ s/MM/$mon/gi; - $filename =~ s/DD/$mday/gi; + $filename = $data_in[1]; + $filename =~ s/ .*$//gi; + $filename =~ s/YYYY/$year/gi; + $filename =~ s/MM/$mon/gi; + $filename =~ s/DD/$mday/gi; $filename_override=1; } if ($args =~ /--sale-statuses=/i) { @data_in = split(/--sale-statuses=/,$args); - $sale_statuses = $data_in[1]; - $sale_statuses =~ s/ .*$//gi; - if ($sale_statuses =~ /---ALL---/) - {if (!$Q) {print "\n----- EXPORT ALL STATUSES -----\n\n";} } + $sale_statuses = $data_in[1]; + $sale_statuses =~ s/ .*$//gi; + if ($sale_statuses =~ /---ALL---/) + {if (!$Q) {print "\n----- EXPORT ALL STATUSES -----\n\n";} } } if ($args =~ /--output-format=/i) { @data_in = split(/--output-format=/,$args); - $output_format = $data_in[1]; - $output_format =~ s/ .*$//gi; + $output_format = $data_in[1]; + $output_format =~ s/ .*$//gi; } if ($args =~ /--with-inbound=/i) { @data_in = split(/--with-inbound=/,$args); - $with_inbound = $data_in[1]; - $with_inbound =~ s/ .*$//gi; + $with_inbound = $data_in[1]; + $with_inbound =~ s/ .*$//gi; } if ($args =~ /-ftp-transfer/i) { @@ -206,6 +213,62 @@ if (length($ARGV[0])>1) {print "\n----- FTP TRANSFER MODE -----\n\n";} $ftp_transfer=1; } + if ($args =~ /-ftp-audio-transfer/i) + { + if (!$Q) + {print "\n----- FTP AUDIO TRANSFER MODE -----\n\n";} + $ftp_audio_transfer=1; + + ### find wget binary + $wgetbin = ''; + if ( -e ('/bin/wget')) {$wgetbin = '/bin/wget';} + else + { + if ( -e ('/usr/bin/wget')) {$wgetbin = '/usr/bin/wget';} + else + { + if ( -e ('/usr/local/bin/wget')) {$wgetbin = '/usr/local/bin/wget';} + else + { + print "Can't find wget binary! Exiting...\n"; + exit + } + } + } + ### find find binary + $findbin = ''; + if ( -e ('/bin/find')) {$findbin = '/bin/find';} + else + { + if ( -e ('/usr/bin/find')) {$findbin = '/usr/bin/find';} + else + { + if ( -e ('/usr/local/bin/find')) {$findbin = '/usr/local/bin/find';} + else + { + print "Can't find find binary! Exiting...\n"; + exit + } + } + } + $tempdir = '/root/tempaudioexport'; + if (!-e "$tempdir") + {`mkdir -p $tempdir`;} + ## remove old audio files from directory + `$findbin $tempdir/ -maxdepth 1 -type f -mtime +0 -print | xargs rm -f`; + } + if ($args =~ /-with-transfer-audio/i) + { + if (!$Q) + {print "\n----- AUDIO TRANSFER LOOKUP MODE -----\n\n";} + $with_transfer_audio=1; + } + if ($args =~ /-with-did-lookup/i) + { + if (!$Q) + {print "\n----- DID LOOKUP ENABLED -----\n\n";} + $with_did_lookup=1; + } if ($args =~ /--test/i) { $T=1; $TEST=1; @@ -214,9 +277,9 @@ if (length($ARGV[0])>1) if ($args =~ /--email-list=/i) { @data_in = split(/--email-list=/,$args); - $email_list = $data_in[1]; - $email_list =~ s/ .*//gi; - $email_list =~ s/:/,/gi; + $email_list = $data_in[1]; + $email_list =~ s/ .*//gi; + $email_list =~ s/:/,/gi; print "\n----- EMAIL NOTIFICATION: $email_list -----\n\n"; } else @@ -225,9 +288,9 @@ if (length($ARGV[0])>1) if ($args =~ /--email-sender=/i) { @data_in = split(/--email-sender=/,$args); - $email_sender = $data_in[1]; - $email_sender =~ s/ .*//gi; - $email_sender =~ s/:/,/gi; + $email_sender = $data_in[1]; + $email_sender =~ s/ .*//gi; + $email_sender =~ s/:/,/gi; print "\n----- EMAIL NOTIFICATION SENDER: $email_sender -----\n\n"; } else @@ -235,9 +298,9 @@ if (length($ARGV[0])>1) } } else -{ -print "no command line options set, using defaults.\n"; -} + { + print "no command line options set, using defaults.\n"; + } ### end parsing run-time options ### # default path to astguiclient configuration file: @@ -306,24 +369,24 @@ if ($output_format =~ /^html-rec$/) if ($output_format =~ /^fixed-as400$/) {$DLT = ''; $txt='.txt'; print "---- fixed-as400 ----\n";} - if ($sale_statuses =~ /---ALL---/) - { - $sale_statusesSQL=''; - $close_statusesSQL=''; - } - else - { - $sale_statusesSQL = $sale_statuses; - $sale_statusesSQL =~ s/-/','/gi; - $sale_statusesSQL = "'$sale_statusesSQL'"; - $close_statusesSQL = $sale_statusesSQL; - $sale_statusesSQL = " and vicidial_log.status IN($sale_statusesSQL)"; - $close_statusesSQL = " and vicidial_closer_log.status IN($close_statusesSQL)"; - } +if ($sale_statuses =~ /---ALL---/) + { + $sale_statusesSQL=''; + $close_statusesSQL=''; + } +else + { + $sale_statusesSQL = $sale_statuses; + $sale_statusesSQL =~ s/-/','/gi; + $sale_statusesSQL = "'$sale_statusesSQL'"; + $close_statusesSQL = $sale_statusesSQL; + $sale_statusesSQL = " and vicidial_log.status IN($sale_statusesSQL)"; + $close_statusesSQL = " and vicidial_closer_log.status IN($close_statusesSQL)"; + } - $with_inboundSQL = $with_inbound; - $with_inboundSQL =~ s/-/','/gi; - $with_inboundSQL = "'$with_inboundSQL'"; +$with_inboundSQL = $with_inbound; +$with_inboundSQL =~ s/-/','/gi; +$with_inboundSQL = "'$with_inboundSQL'"; if (!$Q) { @@ -362,7 +425,7 @@ $TOTAL_SALES=0; ########################################################################### ########### CURRENT DAY SALES GATHERING outbound-only: vicidial_log ###### ########################################################################### -$stmtA = "select vicidial_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_log.list_id,title,address3,last_local_call_time from vicidial_list,vicidial_log,vicidial_users where campaign_id IN($campaignSQL) $sale_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_log.user;"; +$stmtA = "select vicidial_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_log.list_id,title,address3,last_local_call_time,uniqueid,length_in_sec from vicidial_list,vicidial_log,vicidial_users where campaign_id IN($campaignSQL) $sale_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_log.user;"; #$stmtA = "select vicidial_users.user,first_name,last_name,address1,address2,city,state,postal_code,phone_number,email,security_phrase,comments,last_local_call_time,lead_id,vicidial_users.full_name,status,vendor_lead_code,source_id,list_id,title,address3,last_local_call_time from vicidial_list,vicidial_users where list_id NOT IN('999','998') $sale_statusesSQL and called_count > 0 and vicidial_users.user=vicidial_list.user;"; if ($DB) {print "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -394,6 +457,12 @@ while ($sthArows > $rec_count) $title = $aryA[19]; $address3 = $aryA[20]; $last_local_call_time = $aryA[21]; + $vicidial_id = $aryA[22]; + $uniqueid = $aryA[22]; + $length_in_sec = $aryA[23]; + + $queue_seconds = '0'; + $closer=''; &select_format_loop; @@ -406,7 +475,7 @@ if (length($with_inboundSQL)>3) ########################################################################### ########### CURRENT DAY SALES GATHERING inbound-only: vicidial_closer_log ###### ########################################################################### - $stmtA = "select vicidial_closer_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_closer_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_closer_log.list_id,campaign_id,title,address3,last_local_call_time from vicidial_list,vicidial_closer_log,vicidial_users where campaign_id IN($with_inboundSQL) $close_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_closer_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_closer_log.user;"; + $stmtA = "select vicidial_closer_log.user,first_name,last_name,address1,address2,city,state,postal_code,vicidial_list.phone_number,vicidial_list.email,security_phrase,vicidial_list.comments,call_date,vicidial_list.lead_id,vicidial_users.full_name,vicidial_closer_log.status,vicidial_list.vendor_lead_code,vicidial_list.source_id,vicidial_closer_log.list_id,campaign_id,title,address3,last_local_call_time,xfercallid,closecallid,uniqueid,length_in_sec,queue_seconds from vicidial_list,vicidial_closer_log,vicidial_users where campaign_id IN($with_inboundSQL) $close_statusesSQL and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_closer_log.lead_id=vicidial_list.lead_id and vicidial_users.user=vicidial_closer_log.user;"; if ($DB) {print "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -438,21 +507,24 @@ if (length($with_inboundSQL)>3) $title = $aryA[20]; $address3 = $aryA[21]; $last_local_call_time = $aryA[22]; + $xfercallid = $aryA[23]; + $vicidial_id = $aryA[24]; + $uniqueid = $aryA[25]; + $length_in_sec = $aryA[26]; + $queue_seconds = $aryA[27]; $user = ''; $agent_name=''; - $stmtB = "select vicidial_xfer_log.user,full_name from vicidial_xfer_log,vicidial_users where lead_id='$lead_id' and closer='$closer' and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_users.user=vicidial_xfer_log.user order by call_date desc limit 1;"; + $stmtB = "select vicidial_xfer_log.user,full_name from vicidial_xfer_log,vicidial_users where lead_id='$lead_id' and closer='$closer' and xfercallid='$xfercallid' and call_date > '$shipdate 00:00:01' and call_date < '$shipdate 23:59:59' and vicidial_users.user=vicidial_xfer_log.user order by call_date desc limit 1;"; $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; $sthBrows=$sthB->rows; - $rec_countB=0; - while ($sthBrows > $rec_countB) + if ($sthBrows > 0) { @aryB = $sthB->fetchrow_array; - $user = $aryB[0]; - $agent_name = $aryB[1]; - $rec_countB++; + $user = $aryB[0]; + $agent_name = $aryB[1]; } $sthB->finish(); @@ -463,7 +535,6 @@ if (length($with_inboundSQL)>3) $sthA->finish(); } - close(out); @@ -479,43 +550,53 @@ if ( (length($Ealert)>5) && (length($email_list) > 3) ) $mailsubject = "VICIDIAL Lead Export $outfile"; - %mail = ( To => "$email_list", - From => "$email_sender", - Subject => "$mailsubject", - ); - $boundary = "====" . time() . "===="; - $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; + %mail = ( To => "$email_list", + From => "$email_sender", + Subject => "$mailsubject", + ); + $boundary = "====" . time() . "===="; + $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; - $message = encode_qp( "VICIDIAL Lead Export:\n\n Attachment: $outfile\n Total Records: $TOTAL_SALES\n" ); + $message = encode_qp( "VICIDIAL Lead Export:\n\n Attachment: $outfile\n Total Records: $TOTAL_SALES\n" ); - $Zfile = "$PATHoutfile"; + $Zfile = "$PATHoutfile"; - open (F, $Zfile) or die "Cannot read $Zfile: $!"; - binmode F; undef $/; - $attachment = encode_base64(); - close F; + open (F, $Zfile) or die "Cannot read $Zfile: $!"; + binmode F; undef $/; + $attachment = encode_base64(); + close F; - $boundary = '--'.$boundary; - $mail{body} .= "$boundary\n"; - $mail{body} .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; - $mail{body} .= "Content-Transfer-Encoding: quoted-printable\n\n"; - $mail{body} .= "$message\n"; - $mail{body} .= "$boundary\n"; - $mail{body} .= "Content-Type: application/octet-stream; name=\"$outfile\"\n"; - $mail{body} .= "Content-Transfer-Encoding: base64\n"; - $mail{body} .= "Content-Disposition: attachment; filename=\"$outfile\"\n\n"; - $mail{body} .= "$attachment\n"; - $mail{body} .= "$boundary"; - $mail{body} .= "--\n"; + $boundary = '--'.$boundary; + $mail{body} .= "$boundary\n"; + $mail{body} .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; + $mail{body} .= "Content-Transfer-Encoding: quoted-printable\n\n"; + $mail{body} .= "$message\n"; + $mail{body} .= "$boundary\n"; + $mail{body} .= "Content-Type: application/octet-stream; name=\"$outfile\"\n"; + $mail{body} .= "Content-Transfer-Encoding: base64\n"; + $mail{body} .= "Content-Disposition: attachment; filename=\"$outfile\"\n\n"; + $mail{body} .= "$attachment\n"; + $mail{body} .= "$boundary"; + $mail{body} .= "--\n"; - sendmail(%mail) or die $mail::Sendmail::error; - print "ok. log says:\n", $mail::sendmail::log; ### print mail log for status + sendmail(%mail) or die $mail::Sendmail::error; + print "ok. log says:\n", $mail::sendmail::log; ### print mail log for status } + +# FTP overrides- +# $VARREPORT_host = '10.0.0.4'; +# $VARREPORT_port = '21'; +# $VARREPORT_user = 'cron'; +# $VARREPORT_pass = 'test'; +# $VARREPORT_dir = ''; +$NODATEDIR = 0; # Don't use dated directories for audio +$YEARDIR = 1; # put dated directories in a year directory first + if ($ftp_transfer > 0) -{ + { use Net::FTP; if (!$Q) {print "Sending File Over FTP: $outfile\n";} @@ -524,7 +605,44 @@ if ($ftp_transfer > 0) $ftp->cwd("$VARREPORT_dir"); $ftp->put("$PATHweb/vicidial/server_reports/$outfile", "$outfile"); $ftp->quit; -} + } + +if ($ftp_audio_transfer > 0) + { + use Net::FTP; + if (!$Q) {print "Sending File Over FTP: $outfile\n";} + + opendir(FILE, "$tempdir/"); + @FILES = readdir(FILE); + + $i=0; + foreach(@FILES) + { + if ( (length($FILES[$i]) > 4) && (!-d "$tempdir/$FILES[$i]") ) + { + $ftp = Net::FTP->new("$VARREPORT_host", Port => "$VARREPORT_port", Debug => "$DB", Passive => "1"); + $ftp->login("$VARREPORT_user","$VARREPORT_pass"); + if (length($VARREPORT_dir) > 0) + {$ftp->cwd("$VARREPORT_dir");} + if ($NODATEDIR < 1) + { + if ($YEARDIR > 0) + { + $ftp->mkdir("$year"); + $ftp->cwd("$year"); + } + $ftp->mkdir("$start_date"); + $ftp->cwd("$start_date"); + } + $start_date_PATH = "$start_date/"; + $ftp->binary(); + $ftp->put("$tempdir/$FILES[$i]", "$FILES[$i]"); + $ftp->quit; + } + $i++; + } + } + ### calculate time to run script ### $secY = time(); @@ -543,57 +661,26 @@ exit; ### Subroutine for formatting of the output ### sub select_format_loop -{ - -if ($T) { -# $user = '1234'; - $agent_name = 'Joe Agent'; -# $closer = '4321'; - $closer_name = 'Jane Closer'; - $security = '4111111111111111'; - $comments = 'VISA'; - $phone_number =~ s/^\d\d\d\d\d/23456/gi; - $address1 =~ s/^..../1234 /gi - } -$ivr_id = '0'; -$ivr_filename = ''; - - -$stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by length_in_sec desc limit 1;"; -$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; -$sthB->execute or die "executing: $stmtB ", $dbhB->errstr; -$sthBrows=$sthB->rows; -$rec_countB=0; -while ($sthBrows > $rec_countB) - { - @aryB = $sthB->fetchrow_array; - $ivr_id = $aryB[0]; - $ivr_filename = $aryB[1]; - $ivr_location = $aryB[2]; - $rec_countB++; - } -$sthB->finish(); - -if (length($ivr_id)<3) - { - $stmtB = "select recording_id,filename from recording_log where lead_id='$lead_id' order by length_in_sec desc limit 1;"; - $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; - $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; - $sthBrows=$sthB->rows; - $rec_countB=0; - while ($sthBrows > $rec_countB) + if ($T) { - @aryB = $sthB->fetchrow_array; - $ivr_id = $aryB[0]; - $ivr_filename = $aryB[1]; - $rec_countB++; + # $user = '1234'; + $agent_name = 'Joe Agent'; + # $closer = '4321'; + $closer_name = 'Jane Closer'; + $security = '4111111111111111'; + $comments = 'VISA'; + $phone_number =~ s/^\d\d\d\d\d/23456/gi; + $address1 =~ s/^..../1234 /gi } - $sthB->finish(); - if (length($ivr_id)<3) + ##### BEGIN standard audio lookup ##### + if ($with_transfer_audio < 1) { - $stmtB = "select recording_id,filename from recording_log where filename LIKE \"%$phone_number%\" order by length_in_sec desc limit 1;"; + $ivr_id = '0'; + $ivr_filename = ''; + + $stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by length_in_sec desc limit 1;"; $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; $sthBrows=$sthB->rows; @@ -601,103 +688,286 @@ if (length($ivr_id)<3) while ($sthBrows > $rec_countB) { @aryB = $sthB->fetchrow_array; - $ivr_id = $aryB[0]; + $ivr_id = $aryB[0]; $ivr_filename = $aryB[1]; + $ivr_location = $aryB[2]; $rec_countB++; } $sthB->finish(); + + if (length($ivr_id)<3) + { + $stmtB = "select recording_id,filename,location from recording_log where lead_id='$lead_id' order by length_in_sec desc limit 1;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + $rec_countB=0; + while ($sthBrows > $rec_countB) + { + @aryB = $sthB->fetchrow_array; + $ivr_id = $aryB[0]; + $ivr_filename = $aryB[1]; + $ivr_location = $aryB[2]; + $rec_countB++; + } + $sthB->finish(); + + if (length($ivr_id)<3) + { + $stmtB = "select recording_id,filename,location from recording_log where filename LIKE \"%$phone_number%\" order by length_in_sec desc limit 1;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + $rec_countB=0; + while ($sthBrows > $rec_countB) + { + @aryB = $sthB->fetchrow_array; + $ivr_id = $aryB[0]; + $ivr_filename = $aryB[1]; + $ivr_location = $aryB[2]; + $rec_countB++; + } + $sthB->finish(); + } + } + + if ( ($ftp_audio_transfer > 0) && (length($ivr_filename) > 3) && (length($ivr_location) > 5) ) + { + @ivr_path = split(/\//,$ivr_location); + $path_file = $ivr_path[$#ivr_path]; + `$wgetbin --output-document=$tempdir/$path_file $ivr_location `; + } } - } -if ($status =~ /UPSELL/) {$UPSELL='L5';} -else {$UPSELL='N';} + ##### END standard audio lookup ##### + + ##### BEGIN transfer audio lookup ##### + else + { + $ivr_id = '0'; + $ivr_filename = ''; + + $stmtB = "select recording_id,filename,location from recording_log where vicidial_id='$vicidial_id' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by start_time limit 10;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + $rec_countB=0; + while ($sthBrows > $rec_countB) + { + @aryB = $sthB->fetchrow_array; + if ($rec_countB > 0) + { + $ivr_id .= "|"; + $ivr_filename .= "|"; + $ivr_location .= "|"; + } + $ivr_id .= "$aryB[0]"; + $ivr_filename .= "$aryB[1]"; + $ivr_location .= "$aryB[2]"; + @ivr_path = split(/\//,$ivr_location); + $path_file = $ivr_path[$#ivr_path]; + $rec_countB++; + if ($ftp_audio_transfer > 0) + { + `$wgetbin --output-document=$tempdir/$path_file $aryB[2] `; + } + } + $sthB->finish(); + + ### Look for other closer calls after this call + $more_calls[0]=''; + $stmtB = "select closecallid from vicidial_closer_log where lead_id='$lead_id' and call_date > '$call_date' and call_date < '$shipdate 23:59:59' order by call_date limit 10;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + $rec_countB=0; + while ($sthBrows > $rec_countB) + { + @aryB = $sthB->fetchrow_array; + $more_calls[$rec_countB] = "$aryB[0]"; + $rec_countB++; + } + $sthB->finish(); + + $u=0; + while ($sthBrows > $u) + { + $closecallid = $more_calls[$u]; + + $stmtB = "select recording_id,filename,location from recording_log where vicidial_id='$closecallid' and start_time > '$shipdate 00:00:01' and start_time < '$shipdate 23:59:59' order by start_time limit 10;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + $rec_countB=0; + while ($sthBrows > $rec_countB) + { + @aryB = $sthB->fetchrow_array; + if (length($ivr_id) > 1) + { + $ivr_id .= "|"; + $ivr_filename .= "|"; + $ivr_location .= "|"; + } + $ivr_id .= "$aryB[0]"; + $ivr_filename .= "$aryB[1]"; + $ivr_location .= "$aryB[2]"; + @ivr_path = split(/\//,$ivr_location); + $path_file = $ivr_path[$#ivr_path]; + $rec_countB++; + if ($ftp_audio_transfer > 0) + { + `$wgetbin --output-document=$tempdir/$path_file $aryB[2] `; + } + } + $sthB->finish(); + + $u++; + } + } + ##### END transfer audio lookup ##### + + ##### BEGIN DID lookup ##### + if ($with_did_lookup > 0) + { + $did_pattern = ''; + $did_name = ''; + $did_date = ''; + + $stmtB = "select did_pattern,did_description,call_date from vicidial_inbound_dids vid,vicidial_did_log vdl where uniqueid='$uniqueid' and call_date > '$shipdate 00:00:01' and call_date <= '$call_date' and vid.did_id=vdl.did_id order by call_date desc limit 1;"; + if ($DB > 0) {print "$stmtB\n";} + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + if ($sthBrows > 0) + { + @aryB = $sthB->fetchrow_array; + $did_pattern = "$aryB[0]"; + $did_name = "$aryB[1]"; + $did_date = "$aryB[2]"; + } + $sthB->finish(); + } + ##### BEGIN DID lookup ##### + + if ($status =~ /UPSELL/) {$UPSELL='L5';} + else {$UPSELL='N';} + + if ($output_format =~ /^pipe-standard$/) + { + $str = "$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$email|$security|$comments|$call_date|$lead_id|$list_id|$user|$agent_name|$status|$vendor_id|$source_id|$campaign|$campaign_id|$ivr_id|$closer|$closer_name|\n"; + } + + if ($output_format =~ /^csv-standard$/) + { + $str = "\"$first_name\",\"$last_name\",\"$address1\",\"$address2\",\"$city\",\"$state\",\"$postal_code\",\"$phone_number\",\"$email\",\"$security\",\"$comments\",\"$call_date\",\"$lead_id\",\"$list_id\",\"$user\",\"$agent_name\",\"$status\",\"$vendor_id\",\"$source_id\",\"$campaign\",\"$campaign_id\",\"$ivr_id\",\"$closer\",\"$closer_name\"\r\n"; + } + + if ($output_format =~ /^tab-standard$/) + { + $str = "$first_name\t$last_name\t$address1\t$address2\t$city\t$state\t$postal_code\t$phone_number\t$email\t$security\t$comments\t$call_date\t$lead_id\t$list_id\t$user\t$agent_name\t$status\t$vendor_id\t$source_id\t$campaign\t$campaign_id\t$ivr_id\t$closer\t$closer_name\t\n"; + } + + if ($output_format =~ /^pipe-triplep$/) + { + $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n"; + } + + if ($output_format =~ /^pipe-vici$/) + { + $str = "VDAD|$agent_name|$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$ivr_id|DU|$UPSELL|N|||$security|$comments||||||$call_date|CBDISC|$email\r\n"; + } + + if ($output_format =~ /^html-rec$/) + { + $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n"; + } + + if ($output_format =~ /^fixed-as400$/) + { + # 16884259 MRS. JEAN BROWN RISALPUR BROMSBERROW HEATYH LEDBURY HEREFORDSHIRE ENGLAND HR8 1PQ 01531650052 1209200809:52NI 3205UK + $vendor_id = sprintf("%-10s",$vendor_id); while(length($vendor_id)>10) {$vendor_id =~ s/.$//gi;} + $title = sprintf("%-10s",$title); while(length($title)>10) {$title =~ s/.$//gi;} + $first_name = sprintf("%-15s",$first_name); while(length($first_name)>15) {$first_name =~ s/.$//gi;} + $last_name = sprintf("%-20s",$last_name); while(length($last_name)>20) {$last_name =~ s/.$//gi;} + $address1 = sprintf("%-30s",$address1); while(length($address1)>30) {$address1 =~ s/.$//gi;} + $address2 = sprintf("%-30s",$address2); while(length($address2)>30) {$address2 =~ s/.$//gi;} + $address3 = sprintf("%-30s",$address3); while(length($address3)>30) {$address3 =~ s/.$//gi;} + $city = sprintf("%-50s",$city); while(length($city)>50) {$city =~ s/.$//gi;} + $postal_code = sprintf("%-9s",$postal_code); while(length($postal_code)>9) {$postal_code =~ s/.$//gi;} + $phone_number = sprintf("%-20s",$phone_number); while(length($phone_number)>20) {$phone_number =~ s/.$//gi;} + @dtsplit = split(" ",$last_local_call_time); + @datesplit = split("-",$dtsplit[0]); + $timesplit = substr($dtsplit[1], 0, 5); + $formatted_date = "$datesplit[1]$datesplit[2]$datesplit[0]$timesplit"; + $user = sprintf("%-4s",$user); + if ($status =~ /^AA$/) {$status = 'A';} + if ($status =~ /^A$/) {$status = 'A';} + if ($status =~ /^B$/) {$status = 'B';} + if ($status =~ /^N$/) {$status = 'N';} + if ($status =~ /^NA$/) {$status = 'N';} + if ($status =~ /^NP$/) {$status = 'N';} + if ($status =~ /^PU$/) {$status = 'N';} + if ($status =~ /^DROP$/) {$status = 'N';} + if ($status =~ /^SALE$/) {$status = 'AP';} + if ($status =~ /^A6$/) {$status = 'A6';} + if ($status =~ /^DC$/) {$status = 'D';} + if ($status =~ /^DNC$/) {$status = 'DC';} + if ($status =~ /^DNCL$/) {$status = 'DC';} + if ($status =~ /^DIED$/) {$status = 'DD';} + if ($status =~ /^COMP$/) {$status = 'DD';} + if ($status =~ /^DEC$/) {$status = 'DD';} + if ($status =~ /^ERI$/) {$status = 'DD';} + if ($status =~ /^INCALL$/) {$status = 'DD';} + if ($status =~ /^SP$/) {$status = 'DD';} + if ($status =~ /^WRON$/) {$status = 'DD';} + if ($status =~ /^HBED$/) {$status = 'DD';} + if ($status =~ /^CALLBK$/) {$status = 'A6';} + if ($status =~ /^HAP1$/) {$status = 'NI';} + if ($status =~ /^HAP2$/) {$status = 'NI';} + if ($status =~ /^NI$/) {$status = 'NI';} + + $status = sprintf("%-16s",$status); while(length($status)>16) {$status =~ s/.$//gi;} + $user =~ s/VDAD/ /gi; + $UK = 'UK'; + + $str = "$vendor_id$title$first_name$last_name$address1$address2$address3$city$postal_code$phone_number$formatted_date$status$user$UK\r\n"; + } + + if ($output_format =~ /^tab-QMcustomUSA$/) + { + # 1245328655100219 2009-06-18 05:37:35 937 9375551212 8185551223 8106 35 255 0 DSAW - q8187-20090618-053939-1245328655.100219.WAV|q8186-20090618-053735-1245328655.100219.WAV + # 1- unique number (digits only) + # 2- date + # 3- time + # 4- CID arecode + # 5- CID full + # 6- DID + # 7- user + # 8- hold time (seconds) + # 9- talk time (seconds) + # 10- after call work time (seconds) + # 11- application name, 4 characters + # 12- order number (just a dash for now '-') + # 13- call recording filenames + + $uniqueid =~ s/\D//gi; + @call_date_array = split(/ /,$call_date); + $phone_areacode = substr($phone_number, 0, 3); + if (length($closer) < 1) {$closer = $user;} + $application = substr($did_name, 0, 4); + $talk_seconds = ($length_in_sec - $queue_seconds); + $queue_seconds =~ s/\..*//gi; + $dispo_time = 0; + + $str = "$uniqueid\t$call_date_array[0]\t$call_date_array[1]\t$phone_areacode\t$phone_number\t$did_pattern\t$closer\t$queue_seconds\t$talk_seconds\t$dispo_time\t$application\t-\t$ivr_filename\t\n"; + + } + + $Ealert .= "$str"; + + print out "$str"; + if ($DBX) {print "$str\n";} + + $rec_count++; -if ($output_format =~ /^pipe-standard$/) - { - $str = "$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$email|$security|$comments|$call_date|$lead_id|$list_id|$user|$agent_name|$status|$vendor_id|$source_id|$campaign|$campaign_id|$ivr_id|$closer|$closer_name|\n"; } -if ($output_format =~ /^csv-standard$/) - { - $str = "\"$first_name\",\"$last_name\",\"$address1\",\"$address2\",\"$city\",\"$state\",\"$postal_code\",\"$phone_number\",\"$email\",\"$security\",\"$comments\",\"$call_date\",\"$lead_id\",\"$list_id\",\"$user\",\"$agent_name\",\"$status\",\"$vendor_id\",\"$source_id\",\"$campaign\",\"$campaign_id\",\"$ivr_id\",\"$closer\",\"$closer_name\"\r\n"; - } - -if ($output_format =~ /^tab-standard$/) - { - $str = "$first_name\t$last_name\t$address1\t$address2\t$city\t$state\t$postal_code\t$phone_number\t$email\t$security\t$comments\t$call_date\t$lead_id\t$list_id\t$user\t$agent_name\t$status\t$vendor_id\t$source_id\t$campaign\t$campaign_id\t$ivr_id\t$closer\t$closer_name\t\n"; - } - -if ($output_format =~ /^pipe-triplep$/) - { - $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n"; - } - -if ($output_format =~ /^pipe-vici$/) - { - $str = "VDAD|$agent_name|$first_name|$last_name|$address1|$address2|$city|$state|$postal_code|$phone_number|$ivr_id|DU|$UPSELL|N|||$security|$comments||||||$call_date|CBDISC|$email\r\n"; - } -if ($output_format =~ /^html-rec$/) - { - $str = "$user|$agent_name|$closer|$closer_name|$call_date|$status|$first_name|$last_name|$phone_number|$address1|$address2|$city|$state|$postal_code|$comments|$security|$email|$vendor_id|$source_id|$lead_id|$list_id|$campaign|$campaign_id|$ivr_id|\n"; - } - -if ($output_format =~ /^fixed-as400$/) - { - # 16884259 MRS. JEAN BROWN RISALPUR BROMSBERROW HEATYH LEDBURY HEREFORDSHIRE ENGLAND HR8 1PQ 01531650052 1209200809:52NI 3205UK - $vendor_id = sprintf("%-10s",$vendor_id); while(length($vendor_id)>10) {$vendor_id =~ s/.$//gi;} - $title = sprintf("%-10s",$title); while(length($title)>10) {$title =~ s/.$//gi;} - $first_name = sprintf("%-15s",$first_name); while(length($first_name)>15) {$first_name =~ s/.$//gi;} - $last_name = sprintf("%-20s",$last_name); while(length($last_name)>20) {$last_name =~ s/.$//gi;} - $address1 = sprintf("%-30s",$address1); while(length($address1)>30) {$address1 =~ s/.$//gi;} - $address2 = sprintf("%-30s",$address2); while(length($address2)>30) {$address2 =~ s/.$//gi;} - $address3 = sprintf("%-30s",$address3); while(length($address3)>30) {$address3 =~ s/.$//gi;} - $city = sprintf("%-50s",$city); while(length($city)>50) {$city =~ s/.$//gi;} - $postal_code = sprintf("%-9s",$postal_code); while(length($postal_code)>9) {$postal_code =~ s/.$//gi;} - $phone_number = sprintf("%-20s",$phone_number); while(length($phone_number)>20) {$phone_number =~ s/.$//gi;} - @dtsplit = split(" ",$last_local_call_time); - @datesplit = split("-",$dtsplit[0]); - $timesplit = substr($dtsplit[1], 0, 5); - $formatted_date = "$datesplit[1]$datesplit[2]$datesplit[0]$timesplit"; - $user = sprintf("%-4s",$user); - if ($status =~ /^AA$/) {$status = 'A';} - if ($status =~ /^A$/) {$status = 'A';} - if ($status =~ /^B$/) {$status = 'B';} - if ($status =~ /^N$/) {$status = 'N';} - if ($status =~ /^NA$/) {$status = 'N';} - if ($status =~ /^NP$/) {$status = 'N';} - if ($status =~ /^PU$/) {$status = 'N';} - if ($status =~ /^DROP$/) {$status = 'N';} - if ($status =~ /^SALE$/) {$status = 'AP';} - if ($status =~ /^A6$/) {$status = 'A6';} - if ($status =~ /^DC$/) {$status = 'D';} - if ($status =~ /^DNC$/) {$status = 'DC';} - if ($status =~ /^DNCL$/) {$status = 'DC';} - if ($status =~ /^DIED$/) {$status = 'DD';} - if ($status =~ /^COMP$/) {$status = 'DD';} - if ($status =~ /^DEC$/) {$status = 'DD';} - if ($status =~ /^ERI$/) {$status = 'DD';} - if ($status =~ /^INCALL$/) {$status = 'DD';} - if ($status =~ /^SP$/) {$status = 'DD';} - if ($status =~ /^WRON$/) {$status = 'DD';} - if ($status =~ /^HBED$/) {$status = 'DD';} - if ($status =~ /^CALLBK$/) {$status = 'A6';} - if ($status =~ /^HAP1$/) {$status = 'NI';} - if ($status =~ /^HAP2$/) {$status = 'NI';} - if ($status =~ /^NI$/) {$status = 'NI';} - - $status = sprintf("%-16s",$status); while(length($status)>16) {$status =~ s/.$//gi;} - $user =~ s/VDAD/ /gi; - $UK = 'UK'; - - $str = "$vendor_id$title$first_name$last_name$address1$address2$address3$city$postal_code$phone_number$formatted_date$status$user$UK\r\n"; - } - - -$Ealert .= "$str"; - -print out "$str"; -if ($DBX) {print "$str\n";} - -$rec_count++; - -} - diff --git a/bin/AST_sourceID_summary_export.pl b/bin/AST_sourceID_summary_export.pl index c66e0c97..d1dafa3f 100644 --- a/bin/AST_sourceID_summary_export.pl +++ b/bin/AST_sourceID_summary_export.pl @@ -1,16 +1,17 @@ #!/usr/bin/perl # -# AST_sourceID_summary_export.pl version: 2.0.5 +# AST_sourceID_summary_export.pl version: 2.2.0 # # This script is designed to gather stats for all leads by source_id and # post them to a directory # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # CHANGES # 70905-1409 - First version # 71005-0054 - Altered script to use astguiclient.conf for settings -# +# 90620-0856 - Formatting fixes +# $txt = '.txt'; $US = '_'; @@ -30,70 +31,70 @@ $np_statuses = 'NP'; ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "allowed run time options:\n"; - print " [--sale-statuses=XXX-XXY] = Statuses that are deemed to be \"Sales\". Default SALE\n"; - print " [--NI-statuses=XXX-XXY] = Statuses that are deemed to be \"Not Interested\". Default NI\n"; - print " [--NP-statuses=XXX-XXY] = Statuses that are deemed to be \"No Pitch\". Default NP\n"; - print " [--ignore-lists=XXX-XXY] = lists that should be ignored in summary\n"; - print " [--ftp-transfer] = Send results file by FTP to another server\n"; - print " [-q] = quiet\n"; - print " [-t] = test\n"; - print " [--debug] = debugging messages\n"; - print " [--debugX] = Super debugging messages\n"; - print "\n"; + { + print "allowed run time options:\n"; + print " [--sale-statuses=XXX-XXY] = Statuses that are deemed to be \"Sales\". Default SALE\n"; + print " [--NI-statuses=XXX-XXY] = Statuses that are deemed to be \"Not Interested\". Default NI\n"; + print " [--NP-statuses=XXX-XXY] = Statuses that are deemed to be \"No Pitch\". Default NP\n"; + print " [--ignore-lists=XXX-XXY] = lists that should be ignored in summary\n"; + print " [--ftp-transfer] = Send results file by FTP to another server\n"; + print " [-q] = quiet\n"; + print " [-t] = test\n"; + print " [--debug] = debugging messages\n"; + print " [--debugX] = Super debugging messages\n"; + print "\n"; - exit; - } + exit; + } else - { + { if ($args =~ /--debug/i) - { - $DB=1; - print "\n----- DEBUG MODE -----\n\n"; - } + { + $DB=1; + print "\n----- DEBUG MODE -----\n\n"; + } if ($args =~ /--debugX/i) - { - $DBX=1; - print "\n----- SUPER DEBUG MODE -----\n\n"; - } + { + $DBX=1; + print "\n----- SUPER DEBUG MODE -----\n\n"; + } if ($args =~ /-q/i) - { - $q=1; $Q=1; - } + { + $q=1; $Q=1; + } if ($args =~ /--sale-statuses=/i) - { - @data_in = split(/--sale-statuses=/,$args); + { + @data_in = split(/--sale-statuses=/,$args); $sale_statuses = $data_in[1]; $sale_statuses =~ s/ .*$//gi; - } + } if ($args =~ /--NI-statuses=/) - { - @data_in = split(/--NI-statuses=/,$args); + { + @data_in = split(/--NI-statuses=/,$args); $ni_statuses = $data_in[1]; $ni_statuses =~ s/ .*$//gi; - } + } if ($args =~ /--NP-statuses=/) - { - @data_in = split(/--NP-statuses=/,$args); + { + @data_in = split(/--NP-statuses=/,$args); $np_statuses = $data_in[1]; $np_statuses =~ s/ .*$//gi; - } + } if ($args =~ /--ignore-lists=/) - { - @data_in = split(/--ignore-lists=/,$args); + { + @data_in = split(/--ignore-lists=/,$args); $ignore_lists = $data_in[1]; $ignore_lists =~ s/ .*$//gi; - } + } if ($args =~ /-ftp-transfer/i) { if (!$Q) @@ -101,39 +102,39 @@ if (length($ARGV[0])>1) $ftp_transfer=1; } if ($args =~ /--test/i) - { - $T=1; $TEST=1; - print "\n----- TESTING -----\n\n"; + { + $T=1; $TEST=1; + print "\n----- TESTING -----\n\n"; + } } } -} else -{ -print "no command line options set, using defaults.\n"; -} + { + print "no command line options set, using defaults.\n"; + } ### end parsing run-time options ### $secX = time(); - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); - $year = ($year + 1900); - $mon++; +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; # # rerun override - Use this to override the day manually # $year='2007'; # $mon='5'; # $mday='18'; - if ($mon < 10) {$mon = "0$mon";} - if ($mday < 10) {$mday = "0$mday";} - if ($hour < 10) {$hour = "0$hour";} - if ($min < 10) {$min = "0$min";} - if ($sec < 10) {$sec = "0$sec";} - $timestamp = "$year-$mon-$mday $hour:$min:$sec"; - $filedate = "$year$mon$mday"; - $ABIfiledate = "$mon-$mday-$year$us$hour$min$sec"; - $shipdate = "$year-$mon-$mday"; - $datestamp = "$year/$mon/$mday $hour:$min"; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$timestamp = "$year-$mon-$mday $hour:$min:$sec"; +$filedate = "$year$mon$mday"; +$ABIfiledate = "$mon-$mday-$year$us$hour$min$sec"; +$shipdate = "$year-$mon-$mday"; +$datestamp = "$year/$mon/$mday $hour:$min"; # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -323,7 +324,7 @@ close(out); if ($ftp_transfer > 0) -{ + { use Net::FTP; if (!$Q) {print "Sending File Over FTP: $outfile\n";} @@ -332,7 +333,7 @@ if ($ftp_transfer > 0) $ftp->cwd("$VARREPORT_dir"); $ftp->put("$PATHweb/vicidial/server_reports/$outfile", "$outfile"); $ftp->quit; -} + } ### calculate time to run script ### $secY = time(); diff --git a/docs/REQUIRED_APPS_INSTALL.txt b/docs/REQUIRED_APPS_INSTALL.txt index 9e77ade9..94bc3562 100644 --- a/docs/REQUIRED_APPS_INSTALL.txt +++ b/docs/REQUIRED_APPS_INSTALL.txt @@ -122,7 +122,7 @@ cd ntp-4.2.2p3 ./configure make make install -/usr/local/bin/ntpdate -u ntp.myfloridacity.us +/usr/local/bin/ntpdate -u pool.ntp.org cd /usr/local diff --git a/docs/SCRATCH_INSTALL.txt b/docs/SCRATCH_INSTALL.txt index 704fd038..01b32c45 100644 --- a/docs/SCRATCH_INSTALL.txt +++ b/docs/SCRATCH_INSTALL.txt @@ -589,7 +589,7 @@ the time is the same on our client computers and our servers. - make install - vi /etc/ntp.conf (change to just 1 line: "server ntp.myfloridacity.us") - cp /etc/ntp.conf /etc/ntpd.conf # just to be sure - - /usr/local/bin/ntpdate -u ntp.myfloridacity.us # initial sync + - /usr/local/bin/ntpdate -u pool.ntp.org # initial sync - /usr/sbin/ntpd # run it - you are done @@ -2604,7 +2604,7 @@ SUBPHASE 6.4: setting up asterisk and helper applications for startup /usr/bin/setterm -powerdown ### start time server -/usr/local/bin/ntpdate -u ntp.myfloridacity.us +/usr/local/bin/ntpdate -u pool.ntp.org /usr/sbin/ntpd ### start up the MySQL server @@ -2686,7 +2686,7 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running 3 1 * * * /usr/share/astguiclient/AST_DB_optimize.pl ## adjust time on the server with ntp -30 * * * * /usr/local/bin/ntpdate -u ntp.myfloridacity.us 2>/dev/null 1>&2 +30 * * * * /usr/local/bin/ntpdate -u pool.ntp.org 2>/dev/null 1>&2 ### VICIDIAL agent time log weekly and daily summary report generation 2 0 * * 0 /usr/share/astguiclient/AST_agent_week.pl diff --git a/extras/first_server_install.sql b/extras/first_server_install.sql index ada0987d..09734696 100644 --- a/extras/first_server_install.sql +++ b/extras/first_server_install.sql @@ -7,6 +7,7 @@ INSERT INTO phones (extension, dialplan_number, voicemail_id, phone_ip, computer INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,load_leads,campaign_detail,ast_admin_access,modify_users) values('6666','1234','Admin','9','ADMIN','1','1','1','1'); INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,active) values('VDAD','donotedit','Outbound Auto Dial','1','ADMIN','N'); +INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,active) values('VDCL','donotedit','Inbound No Agent','1','ADMIN','N'); INSERT INTO conferences values('8600001','10.10.10.15',''); INSERT INTO conferences values('8600002','10.10.10.15',''); diff --git a/install.pl b/install.pl index 1be99cd1..30f67fed 100644 --- a/install.pl +++ b/install.pl @@ -1,8 +1,8 @@ #!/usr/bin/perl -# install.pl version 2.0.5 +# install.pl version 2.2.0 # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # CHANGES @@ -17,6 +17,7 @@ # 80526-1345 - Added Timeclock auto-logout option 9 # 90210-0319 - Added option to prompt for Asterisk version # 90312-1256 - Added CLI flag for automatic configuration +# 90620-1910 - Added check before creating directories and formatting changes # ############################################ @@ -125,78 +126,78 @@ $MT[0]=''; ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "install.pl - installs astGUIclient server files in the proper places, this\n"; - print "script will look for an /etc/astguiclient.conf file for existing settings, and\n"; - print "if not present will prompt for proper information then copy files.\n"; - print "\n"; - print "installation options:\n"; - print " [--help] = this help screen\n"; - print " [--test] = test (will not copy files)\n"; - print " [--debug] = verbose debug messages\n"; - print " [--no-prompt] = do not ask questions, just install\n"; - print " [--web-only] = only copy files/directories for web server install\n"; - print " [--without-web] = do not copy web files/directories\n\n"; - print "configuration options:\n"; - print " [--home=/path/from/root] = define home path from root at runtime\n"; - print " [--logs=/path/from/root] = define logs path from root at runtime\n"; - print " [--agi=/path/from/root] = define agi-bin path from root at runtime\n"; - print " [--web=/path/from/root] = define webroot path from root at runtime\n"; - print " [--sounds=/path/from/root] = define sounds path from root at runtime\n"; - print " [--monitor=/path/from/root] = define monitor path from root at runtime\n"; - print " [--DONEmonitor=/path/from/root] = define monitor DONE path from root at runtime\n"; - print " [--server_ip=192.168.0.1] = define server IP address at runtime\n"; - print " [--DB_server=localhost] = define database server IP address at runtime\n"; - print " [--DB_database=asterisk] = define database name at runtime\n"; - print " [--DB_user=cron] = define database user login at runtime\n"; - print " [--DB_pass=1234] = define database user password at runtime\n"; - print " [--DB_port=3306] = define database connection port at runtime\n"; - print " [--active_keepalives=123456] = define processes to keepalive\n"; - print " X - NO KEEPALIVE PROCESSES (use only if you want none to be keepalive)\n"; - print " 1 - AST_update\n"; - print " 2 - AST_send_listen\n"; - print " 3 - AST_VDauto_dial\n"; - print " 4 - AST_VDremote_agents\n"; - print " 5 - AST_VDadapt (If multi-server system, this must only be on one server)\n"; - print " 6 - FastAGI_log\n"; - print " 7 - AST_VDauto_dial_FILL (only for multi-server, this must only be on one server)\n"; - print " 8 - ip_relay (used for blind agent monitoring)\n"; - print " 9 - Timeclock auto-logout\n"; - print " [--asterisk_version] = set the asterisk version you want to install for\n"; - print " [--copy_sample_conf_files] = copies the sample conf files to /etc/asterisk/\n"; - print " [--FTP_host=192.168.0.2] = define recording archive server IP address at runtime\n"; - print " [--FTP_user=cron] = define archive server name at runtime\n"; - print " [--FTP_pass=test] = define archive server user login at runtime\n"; - print " [--FTP_port=21] = define archive server user password at runtime\n"; - print " [--FTP_dir=RECORDINGS] = define archive server connection port at runtime\n"; - print " [--HTTP_path=http://192.168.0.2] = define archive web root at runtime\n"; - print " [--REPORT_host=192.168.0.2] = define report server IP address at runtime\n"; - print " [--REPORT_user=cron] = define report server name at runtime\n"; - print " [--REPORT_pass=test] = define report server user login at runtime\n"; - print " [--REPORT_port=21] = define report server user password at runtime\n"; - print " [--REPORT_dir=REPORTS] = define report server connection port at runtime\n"; - print " [--fastagi_log_min_servers=3] = define FastAGI log min servers\n"; - print " [--fastagi_log_max_servers=16] = define FastAGI log max servers\n"; - print " [--fastagi_log_min_spare_servers=2] = define FastAGI log min spare servers\n"; - print " [--fastagi_log_max_spare_servers=8] = define FastAGI log max spare servers\n"; - print " [--fastagi_log_max_requests=1000] = define FastAGI log max requests\n"; - print " [--fastagi_log_checkfordead=30] = define FastAGI log check-for-dead seconds\n"; - print " [--fastagi_log_checkforwait=60] = define FastAGI log check-for-wait seconds\n"; - print " [--build_multiserver_conf] = generates conf file examples for extensions.conf and iax.conf\n"; - print " [--build_phones_conf] = generates conf file examples for extensions.conf, sip.conf and iax.conf\n"; - print "\n"; + { + print "install.pl - installs astGUIclient server files in the proper places, this\n"; + print "script will look for an /etc/astguiclient.conf file for existing settings, and\n"; + print "if not present will prompt for proper information then copy files.\n"; + print "\n"; + print "installation options:\n"; + print " [--help] = this help screen\n"; + print " [--test] = test (will not copy files)\n"; + print " [--debug] = verbose debug messages\n"; + print " [--no-prompt] = do not ask questions, just install\n"; + print " [--web-only] = only copy files/directories for web server install\n"; + print " [--without-web] = do not copy web files/directories\n\n"; + print "configuration options:\n"; + print " [--home=/path/from/root] = define home path from root at runtime\n"; + print " [--logs=/path/from/root] = define logs path from root at runtime\n"; + print " [--agi=/path/from/root] = define agi-bin path from root at runtime\n"; + print " [--web=/path/from/root] = define webroot path from root at runtime\n"; + print " [--sounds=/path/from/root] = define sounds path from root at runtime\n"; + print " [--monitor=/path/from/root] = define monitor path from root at runtime\n"; + print " [--DONEmonitor=/path/from/root] = define monitor DONE path from root at runtime\n"; + print " [--server_ip=192.168.0.1] = define server IP address at runtime\n"; + print " [--DB_server=localhost] = define database server IP address at runtime\n"; + print " [--DB_database=asterisk] = define database name at runtime\n"; + print " [--DB_user=cron] = define database user login at runtime\n"; + print " [--DB_pass=1234] = define database user password at runtime\n"; + print " [--DB_port=3306] = define database connection port at runtime\n"; + print " [--active_keepalives=123456] = define processes to keepalive\n"; + print " X - NO KEEPALIVE PROCESSES (use only if you want none to be keepalive)\n"; + print " 1 - AST_update\n"; + print " 2 - AST_send_listen\n"; + print " 3 - AST_VDauto_dial\n"; + print " 4 - AST_VDremote_agents\n"; + print " 5 - AST_VDadapt (If multi-server system, this must only be on one server)\n"; + print " 6 - FastAGI_log\n"; + print " 7 - AST_VDauto_dial_FILL (only for multi-server, this must only be on one server)\n"; + print " 8 - ip_relay (used for blind agent monitoring)\n"; + print " 9 - Timeclock auto-logout\n"; + print " [--asterisk_version] = set the asterisk version you want to install for\n"; + print " [--copy_sample_conf_files] = copies the sample conf files to /etc/asterisk/\n"; + print " [--FTP_host=192.168.0.2] = define recording archive server IP address at runtime\n"; + print " [--FTP_user=cron] = define archive server name at runtime\n"; + print " [--FTP_pass=test] = define archive server user login at runtime\n"; + print " [--FTP_port=21] = define archive server user password at runtime\n"; + print " [--FTP_dir=RECORDINGS] = define archive server connection port at runtime\n"; + print " [--HTTP_path=http://192.168.0.2] = define archive web root at runtime\n"; + print " [--REPORT_host=192.168.0.2] = define report server IP address at runtime\n"; + print " [--REPORT_user=cron] = define report server name at runtime\n"; + print " [--REPORT_pass=test] = define report server user login at runtime\n"; + print " [--REPORT_port=21] = define report server user password at runtime\n"; + print " [--REPORT_dir=REPORTS] = define report server connection port at runtime\n"; + print " [--fastagi_log_min_servers=3] = define FastAGI log min servers\n"; + print " [--fastagi_log_max_servers=16] = define FastAGI log max servers\n"; + print " [--fastagi_log_min_spare_servers=2] = define FastAGI log min spare servers\n"; + print " [--fastagi_log_max_spare_servers=8] = define FastAGI log max spare servers\n"; + print " [--fastagi_log_max_requests=1000] = define FastAGI log max requests\n"; + print " [--fastagi_log_checkfordead=30] = define FastAGI log check-for-dead seconds\n"; + print " [--fastagi_log_checkforwait=60] = define FastAGI log check-for-wait seconds\n"; + print " [--build_multiserver_conf] = generates conf file examples for extensions.conf and iax.conf\n"; + print " [--build_phones_conf] = generates conf file examples for extensions.conf, sip.conf and iax.conf\n"; + print "\n"; - exit; - } + exit; + } else { if ($args =~ /--debug/i) # Debug flag @@ -212,536 +213,458 @@ if (length($ARGV[0])>1) if ($args =~ /--no-prompt/i) # do not ask questions {$NOPROMPT=1;} if ($args =~ /--home=/i) # CLI defined home path - { - @CLIhomeARY = split(/--home=/,$args); - @CLIhomeARX = split(/ /,$CLIhomeARY[1]); - if (length($CLIhomeARX[0])>2) { - $PATHhome = $CLIhomeARX[0]; - $PATHhome =~ s/\/$| |\r|\n|\t//gi; - $CLIhome=1; - print " CLI defined home path: $PATHhome\n"; + @CLIhomeARY = split(/--home=/,$args); + @CLIhomeARX = split(/ /,$CLIhomeARY[1]); + if (length($CLIhomeARX[0])>2) + { + $PATHhome = $CLIhomeARX[0]; + $PATHhome =~ s/\/$| |\r|\n|\t//gi; + $CLIhome=1; + print " CLI defined home path: $PATHhome\n"; + } } - } if ($args =~ /--logs=/i) # CLI defined logs path - { - @CLIlogsARY = split(/--logs=/,$args); - @CLIlogsARX = split(/ /,$CLIlogsARY[1]); - if (length($CLIlogsARX[0])>2) { - $PATHlogs = $CLIlogsARX[0]; - $PATHlogs =~ s/\/$| |\r|\n|\t//gi; - $CLIlogs=1; - print " CLI defined logs path: $PATHlogs\n"; + @CLIlogsARY = split(/--logs=/,$args); + @CLIlogsARX = split(/ /,$CLIlogsARY[1]); + if (length($CLIlogsARX[0])>2) + { + $PATHlogs = $CLIlogsARX[0]; + $PATHlogs =~ s/\/$| |\r|\n|\t//gi; + $CLIlogs=1; + print " CLI defined logs path: $PATHlogs\n"; + } } - } if ($args =~ /--agi=/i) # CLI defined agi-bin path - { - @CLIagiARY = split(/--agi=/,$args); - @CLIagiARX = split(/ /,$CLIagiARY[1]); - if (length($CLIagiARX[0])>2) { - $PATHagi = $CLIagiARX[0]; - $PATHagi =~ s/\/$| |\r|\n|\t//gi; - $CLIagi=1; - print " CLI defined agi-bin path: $PATHagi\n"; + @CLIagiARY = split(/--agi=/,$args); + @CLIagiARX = split(/ /,$CLIagiARY[1]); + if (length($CLIagiARX[0])>2) + { + $PATHagi = $CLIagiARX[0]; + $PATHagi =~ s/\/$| |\r|\n|\t//gi; + $CLIagi=1; + print " CLI defined agi-bin path: $PATHagi\n"; + } } - } if ($args =~ /--web=/i) # CLI defined webroot path - { - @CLIwebARY = split(/--web=/,$args); - @CLIwebARX = split(/ /,$CLIwebARY[1]); - if (length($CLIwebARX[0])>2) { - $PATHweb = $CLIwebARX[0]; - $PATHweb =~ s/\/$| |\r|\n|\t//gi; - $CLIweb=1; - print " CLI defined webroot path: $PATHweb\n"; + @CLIwebARY = split(/--web=/,$args); + @CLIwebARX = split(/ /,$CLIwebARY[1]); + if (length($CLIwebARX[0])>2) + { + $PATHweb = $CLIwebARX[0]; + $PATHweb =~ s/\/$| |\r|\n|\t//gi; + $CLIweb=1; + print " CLI defined webroot path: $PATHweb\n"; + } } - } if ($args =~ /--sounds=/i) # CLI defined sounds path - { - @CLIsoundsARY = split(/--sounds=/,$args); - @CLIsoundsARX = split(/ /,$CLIsoundsARY[1]); - if (length($CLIsoundsARX[0])>2) { - $PATHsounds = $CLIsoundsARX[0]; - $PATHsounds =~ s/\/$| |\r|\n|\t//gi; - $CLIsounds=1; - print " CLI defined sounds path: $PATHsounds\n"; + @CLIsoundsARY = split(/--sounds=/,$args); + @CLIsoundsARX = split(/ /,$CLIsoundsARY[1]); + if (length($CLIsoundsARX[0])>2) + { + $PATHsounds = $CLIsoundsARX[0]; + $PATHsounds =~ s/\/$| |\r|\n|\t//gi; + $CLIsounds=1; + print " CLI defined sounds path: $PATHsounds\n"; + } } - } if ($args =~ /--monitor=/i) # CLI defined monitor path - { - @CLImonitorARY = split(/--monitor=/,$args); - @CLImonitorARX = split(/ /,$CLImonitorARY[1]); - if (length($CLImonitorARX[0])>2) { - $PATHmonitor = $CLImonitorARX[0]; - $PATHmonitor =~ s/\/$| |\r|\n|\t//gi; - $CLImonitor=1; - print " CLI defined monitor path: $PATHmonitor\n"; + @CLImonitorARY = split(/--monitor=/,$args); + @CLImonitorARX = split(/ /,$CLImonitorARY[1]); + if (length($CLImonitorARX[0])>2) + { + $PATHmonitor = $CLImonitorARX[0]; + $PATHmonitor =~ s/\/$| |\r|\n|\t//gi; + $CLImonitor=1; + print " CLI defined monitor path: $PATHmonitor\n"; + } } - } if ($args =~ /--DONEmonitor=/i) # CLI defined DONEmonitor path - { - @CLIDONEmonitorARY = split(/--DONEmonitor=/,$args); - @CLIDONEmonitorARX = split(/ /,$CLIDONEmonitorARY[1]); - if (length($CLIDONEmonitorARX[0])>2) { - $PATHDONEmonitor = $CLIDONEmonitorARX[0]; - $PATHDONEmonitor =~ s/\/$| |\r|\n|\t//gi; - $CLIDONEmonitor=1; - print " CLI defined DONEmonitor: $PATHDONEmonitor\n"; + @CLIDONEmonitorARY = split(/--DONEmonitor=/,$args); + @CLIDONEmonitorARX = split(/ /,$CLIDONEmonitorARY[1]); + if (length($CLIDONEmonitorARX[0])>2) + { + $PATHDONEmonitor = $CLIDONEmonitorARX[0]; + $PATHDONEmonitor =~ s/\/$| |\r|\n|\t//gi; + $CLIDONEmonitor=1; + print " CLI defined DONEmonitor: $PATHDONEmonitor\n"; + } } - } if ($args =~ /--server_ip=/i) # CLI defined server IP address - { - @CLIserver_ipARY = split(/--server_ip=/,$args); - @CLIserver_ipARX = split(/ /,$CLIserver_ipARY[1]); - if (length($CLIserver_ipARX[0])>2) { - $VARserver_ip = $CLIserver_ipARX[0]; - $VARserver_ip =~ s/\/$| |\r|\n|\t//gi; - $CLIserver_ip=1; - print " CLI defined server IP: $VARserver_ip\n"; + @CLIserver_ipARY = split(/--server_ip=/,$args); + @CLIserver_ipARX = split(/ /,$CLIserver_ipARY[1]); + if (length($CLIserver_ipARX[0])>2) + { + $VARserver_ip = $CLIserver_ipARX[0]; + $VARserver_ip =~ s/\/$| |\r|\n|\t//gi; + $CLIserver_ip=1; + print " CLI defined server IP: $VARserver_ip\n"; + } } - } if ($args =~ /--DB_server=/i) # CLI defined Database server address - { - @CLIDB_serverARY = split(/--DB_server=/,$args); - @CLIDB_serverARX = split(/ /,$CLIDB_serverARY[1]); - if (length($CLIDB_serverARX[0])>2) { - $VARDB_server = $CLIDB_serverARX[0]; - $VARDB_server =~ s/\/$| |\r|\n|\t//gi; - $CLIDB_server=1; - print " CLI defined DB server: $VARDB_server\n"; + @CLIDB_serverARY = split(/--DB_server=/,$args); + @CLIDB_serverARX = split(/ /,$CLIDB_serverARY[1]); + if (length($CLIDB_serverARX[0])>2) + { + $VARDB_server = $CLIDB_serverARX[0]; + $VARDB_server =~ s/\/$| |\r|\n|\t//gi; + $CLIDB_server=1; + print " CLI defined DB server: $VARDB_server\n"; + } } - } if ($args =~ /--DB_database=/i) # CLI defined Database name - { - @CLIDB_databaseARY = split(/--DB_database=/,$args); - @CLIDB_databaseARX = split(/ /,$CLIDB_databaseARY[1]); - if (length($CLIDB_databaseARX[0])>1) { - $VARDB_database = $CLIDB_databaseARX[0]; - $VARDB_database =~ s/ |\r|\n|\t//gi; - $CLIDB_database=1; - print " CLI defined DB database: $VARDB_database\n"; + @CLIDB_databaseARY = split(/--DB_database=/,$args); + @CLIDB_databaseARX = split(/ /,$CLIDB_databaseARY[1]); + if (length($CLIDB_databaseARX[0])>1) + { + $VARDB_database = $CLIDB_databaseARX[0]; + $VARDB_database =~ s/ |\r|\n|\t//gi; + $CLIDB_database=1; + print " CLI defined DB database: $VARDB_database\n"; + } } - } if ($args =~ /--DB_user=/i) # CLI defined Database user login - { - @CLIDB_userARY = split(/--DB_user=/,$args); - @CLIDB_userARX = split(/ /,$CLIDB_userARY[1]); - if (length($CLIDB_userARX[0])>1) { - $VARDB_user = $CLIDB_userARX[0]; - $VARDB_user =~ s/ |\r|\n|\t//gi; - $CLIDB_user=1; - print " CLI defined DB user: $VARDB_user\n"; + @CLIDB_userARY = split(/--DB_user=/,$args); + @CLIDB_userARX = split(/ /,$CLIDB_userARY[1]); + if (length($CLIDB_userARX[0])>1) + { + $VARDB_user = $CLIDB_userARX[0]; + $VARDB_user =~ s/ |\r|\n|\t//gi; + $CLIDB_user=1; + print " CLI defined DB user: $VARDB_user\n"; + } } - } if ($args =~ /--DB_pass=/i) # CLI defined Database user password - { - @CLIDB_passARY = split(/--DB_pass=/,$args); - @CLIDB_passARX = split(/ /,$CLIDB_passARY[1]); - if (length($CLIDB_passARX[0])>1) { - $VARDB_pass = $CLIDB_passARX[0]; - $VARDB_pass =~ s/ |\r|\n|\t//gi; - $CLIDB_pass=1; - print " CLI defined DB password: $VARDB_pass\n"; + @CLIDB_passARY = split(/--DB_pass=/,$args); + @CLIDB_passARX = split(/ /,$CLIDB_passARY[1]); + if (length($CLIDB_passARX[0])>1) + { + $VARDB_pass = $CLIDB_passARX[0]; + $VARDB_pass =~ s/ |\r|\n|\t//gi; + $CLIDB_pass=1; + print " CLI defined DB password: $VARDB_pass\n"; + } } - } if ($args =~ /--DB_port=/i) # CLI defined Database connection port - { - @CLIDB_portARY = split(/--DB_port=/,$args); - @CLIDB_portARX = split(/ /,$CLIDB_portARY[1]); - if (length($CLIDB_portARX[0])>1) { - $VARDB_port = $CLIDB_portARX[0]; - $VARDB_port =~ s/ |\r|\n|\t//gi; - $CLIDB_port=1; - print " CLI defined DB port: $VARDB_port\n"; + @CLIDB_portARY = split(/--DB_port=/,$args); + @CLIDB_portARX = split(/ /,$CLIDB_portARY[1]); + if (length($CLIDB_portARX[0])>1) + { + $VARDB_port = $CLIDB_portARX[0]; + $VARDB_port =~ s/ |\r|\n|\t//gi; + $CLIDB_port=1; + print " CLI defined DB port: $VARDB_port\n"; + } } - } if ($args =~ /--active_keepalives=/i) # CLI defined keepalive processes - { - @CLIkeepaliveARY = split(/--active_keepalives=/,$args); - @CLIkeepaliveARX = split(/ /,$CLIkeepaliveARY[1]); - if (length($CLIkeepaliveARX[0])>1) { - $VARactive_keepalives = $CLIkeepaliveARX[0]; - $VARactive_keepalives =~ s/ |\r|\n|\t//gi; - $CLIactive_keepalives=1; - print " CLI active keepalive procs: $VARactive_keepalives\n"; + @CLIkeepaliveARY = split(/--active_keepalives=/,$args); + @CLIkeepaliveARX = split(/ /,$CLIkeepaliveARY[1]); + if (length($CLIkeepaliveARX[0])>1) + { + $VARactive_keepalives = $CLIkeepaliveARX[0]; + $VARactive_keepalives =~ s/ |\r|\n|\t//gi; + $CLIactive_keepalives=1; + print " CLI active keepalive procs: $VARactive_keepalives\n"; + } } - } if ($args =~ /--asterisk_version=/i) # CLI defined asterisk version - { - @CLIastversionARY = split(/--asterisk_version=/,$args); - @CLIastversionARX = split(/ /,$CLIastversionARY[1]); - if (length($CLIastversionARX[0])>1) { - $VARasterisk_version = $CLIastversionARX[0]; - $VARasterisk_version =~ s/ |\r|\n|\t//gi; - $CLIasterisk_version=1; - print " CLI asterisk version: $VARasterisk_version\n"; + @CLIastversionARY = split(/--asterisk_version=/,$args); + @CLIastversionARX = split(/ /,$CLIastversionARY[1]); + if (length($CLIastversionARX[0])>1) + { + $VARasterisk_version = $CLIastversionARX[0]; + $VARasterisk_version =~ s/ |\r|\n|\t//gi; + $CLIasterisk_version=1; + print " CLI asterisk version: $VARasterisk_version\n"; + } } - } if ($args =~ /--FTP_host=/i) # CLI defined archive server address - { - @CLIFTP_hostARY = split(/--FTP_host=/,$args); - @CLIFTP_hostARX = split(/ /,$CLIFTP_hostARY[1]); - if (length($CLIFTP_hostARX[0])>2) { - $VARFTP_host = $CLIFTP_hostARX[0]; - $VARFTP_host =~ s/\/$| |\r|\n|\t//gi; - $CLIFTP_host=1; - print " CLI defined FTP host: $VARFTP_host\n"; + @CLIFTP_hostARY = split(/--FTP_host=/,$args); + @CLIFTP_hostARX = split(/ /,$CLIFTP_hostARY[1]); + if (length($CLIFTP_hostARX[0])>2) + { + $VARFTP_host = $CLIFTP_hostARX[0]; + $VARFTP_host =~ s/\/$| |\r|\n|\t//gi; + $CLIFTP_host=1; + print " CLI defined FTP host: $VARFTP_host\n"; + } } - } if ($args =~ /--FTP_user=/i) # CLI defined archive FTP user - { - @CLIFTP_userARY = split(/--FTP_user=/,$args); - @CLIFTP_userARX = split(/ /,$CLIFTP_userARY[1]); - if (length($CLIFTP_userARX[0])>2) { - $VARFTP_user = $CLIFTP_userARX[0]; - $VARFTP_user =~ s/\/$| |\r|\n|\t//gi; - $CLIFTP_user=1; - print " CLI defined FTP user: $VARFTP_user\n"; + @CLIFTP_userARY = split(/--FTP_user=/,$args); + @CLIFTP_userARX = split(/ /,$CLIFTP_userARY[1]); + if (length($CLIFTP_userARX[0])>2) + { + $VARFTP_user = $CLIFTP_userARX[0]; + $VARFTP_user =~ s/\/$| |\r|\n|\t//gi; + $CLIFTP_user=1; + print " CLI defined FTP user: $VARFTP_user\n"; + } } - } if ($args =~ /--FTP_pass=/i) # CLI defined archive FTP pass - { - @CLIFTP_passARY = split(/--FTP_pass=/,$args); - @CLIFTP_passARX = split(/ /,$CLIFTP_passARY[1]); - if (length($CLIFTP_passARX[0])>2) { - $VARFTP_pass = $CLIFTP_passARX[0]; - $VARFTP_pass =~ s/\/$| |\r|\n|\t//gi; - $CLIFTP_pass=1; - print " CLI defined FTP pass: $VARFTP_pass\n"; + @CLIFTP_passARY = split(/--FTP_pass=/,$args); + @CLIFTP_passARX = split(/ /,$CLIFTP_passARY[1]); + if (length($CLIFTP_passARX[0])>2) + { + $VARFTP_pass = $CLIFTP_passARX[0]; + $VARFTP_pass =~ s/\/$| |\r|\n|\t//gi; + $CLIFTP_pass=1; + print " CLI defined FTP pass: $VARFTP_pass\n"; + } } - } if ($args =~ /--FTP_port=/i) # CLI defined archive FTP port - { - @CLIFTP_portARY = split(/--FTP_port=/,$args); - @CLIFTP_portARX = split(/ /,$CLIFTP_portARY[1]); - if (length($CLIFTP_portARX[0])>2) { - $VARFTP_port = $CLIFTP_portARX[0]; - $VARFTP_port =~ s/\/$| |\r|\n|\t//gi; - $CLIFTP_port=1; - print " CLI defined FTP port: $VARFTP_port\n"; + @CLIFTP_portARY = split(/--FTP_port=/,$args); + @CLIFTP_portARX = split(/ /,$CLIFTP_portARY[1]); + if (length($CLIFTP_portARX[0])>2) + { + $VARFTP_port = $CLIFTP_portARX[0]; + $VARFTP_port =~ s/\/$| |\r|\n|\t//gi; + $CLIFTP_port=1; + print " CLI defined FTP port: $VARFTP_port\n"; + } } - } if ($args =~ /--FTP_dir=/i) # CLI defined archive FTP directory - { - @CLIFTP_dirARY = split(/--FTP_dir=/,$args); - @CLIFTP_dirARX = split(/ /,$CLIFTP_dirARY[1]); - if (length($CLIFTP_dirARX[0])>2) { - $VARFTP_dir = $CLIFTP_dirARX[0]; - $VARFTP_dir =~ s/\/$| |\r|\n|\t//gi; - $CLIFTP_dir=1; - print " CLI defined FTP dir: $VARFTP_dir\n"; + @CLIFTP_dirARY = split(/--FTP_dir=/,$args); + @CLIFTP_dirARX = split(/ /,$CLIFTP_dirARY[1]); + if (length($CLIFTP_dirARX[0])>2) + { + $VARFTP_dir = $CLIFTP_dirARX[0]; + $VARFTP_dir =~ s/\/$| |\r|\n|\t//gi; + $CLIFTP_dir=1; + print " CLI defined FTP dir: $VARFTP_dir\n"; + } } - } if ($args =~ /--HTTP_path=/i) # CLI defined archive HTTP path - { - @CLIHTTP_pathARY = split(/--HTTP_path=/,$args); - @CLIHTTP_pathARX = split(/ /,$CLIHTTP_pathARY[1]); - if (length($CLIHTTP_pathARX[0])>2) { - $VARHTTP_path = $CLIHTTP_pathARX[0]; - $VARHTTP_path =~ s/\/$| |\r|\n|\t//gi; - $CLIHTTP_path=1; - print " CLI defined HTTP path: $VARHTTP_path\n"; + @CLIHTTP_pathARY = split(/--HTTP_path=/,$args); + @CLIHTTP_pathARX = split(/ /,$CLIHTTP_pathARY[1]); + if (length($CLIHTTP_pathARX[0])>2) + { + $VARHTTP_path = $CLIHTTP_pathARX[0]; + $VARHTTP_path =~ s/\/$| |\r|\n|\t//gi; + $CLIHTTP_path=1; + print " CLI defined HTTP path: $VARHTTP_path\n"; + } } - } if ($args =~ /--REPORT_host=/i) # CLI defined archive server address - { - @CLIREPORT_hostARY = split(/--REPORT_host=/,$args); - @CLIREPORT_hostARX = split(/ /,$CLIREPORT_hostARY[1]); - if (length($CLIREPORT_hostARX[0])>2) { - $VARREPORT_host = $CLIREPORT_hostARX[0]; - $VARREPORT_host =~ s/\/$| |\r|\n|\t//gi; - $CLIREPORT_host=1; - print " CLI defined REPORT host: $VARREPORT_host\n"; + @CLIREPORT_hostARY = split(/--REPORT_host=/,$args); + @CLIREPORT_hostARX = split(/ /,$CLIREPORT_hostARY[1]); + if (length($CLIREPORT_hostARX[0])>2) + { + $VARREPORT_host = $CLIREPORT_hostARX[0]; + $VARREPORT_host =~ s/\/$| |\r|\n|\t//gi; + $CLIREPORT_host=1; + print " CLI defined REPORT host: $VARREPORT_host\n"; + } } - } if ($args =~ /--REPORT_user=/i) # CLI defined archive REPORT user - { - @CLIREPORT_userARY = split(/--REPORT_user=/,$args); - @CLIREPORT_userARX = split(/ /,$CLIREPORT_userARY[1]); - if (length($CLIREPORT_userARX[0])>2) { - $VARREPORT_user = $CLIREPORT_userARX[0]; - $VARREPORT_user =~ s/\/$| |\r|\n|\t//gi; - $CLIREPORT_user=1; - print " CLI defined REPORT user: $VARREPORT_user\n"; + @CLIREPORT_userARY = split(/--REPORT_user=/,$args); + @CLIREPORT_userARX = split(/ /,$CLIREPORT_userARY[1]); + if (length($CLIREPORT_userARX[0])>2) + { + $VARREPORT_user = $CLIREPORT_userARX[0]; + $VARREPORT_user =~ s/\/$| |\r|\n|\t//gi; + $CLIREPORT_user=1; + print " CLI defined REPORT user: $VARREPORT_user\n"; + } } - } if ($args =~ /--REPORT_pass=/i) # CLI defined archive REPORT pass - { - @CLIREPORT_passARY = split(/--REPORT_pass=/,$args); - @CLIREPORT_passARX = split(/ /,$CLIREPORT_passARY[1]); - if (length($CLIREPORT_passARX[0])>2) { - $VARREPORT_pass = $CLIREPORT_passARX[0]; - $VARREPORT_pass =~ s/\/$| |\r|\n|\t//gi; - $CLIREPORT_pass=1; - print " CLI defined REPORT pass: $VARREPORT_pass\n"; + @CLIREPORT_passARY = split(/--REPORT_pass=/,$args); + @CLIREPORT_passARX = split(/ /,$CLIREPORT_passARY[1]); + if (length($CLIREPORT_passARX[0])>2) + { + $VARREPORT_pass = $CLIREPORT_passARX[0]; + $VARREPORT_pass =~ s/\/$| |\r|\n|\t//gi; + $CLIREPORT_pass=1; + print " CLI defined REPORT pass: $VARREPORT_pass\n"; + } } - } if ($args =~ /--REPORT_port=/i) # CLI defined archive REPORT port - { - @CLIREPORT_portARY = split(/--REPORT_port=/,$args); - @CLIREPORT_portARX = split(/ /,$CLIREPORT_portARY[1]); - if (length($CLIREPORT_portARX[0])>2) { - $VARREPORT_port = $CLIREPORT_portARX[0]; - $VARREPORT_port =~ s/\/$| |\r|\n|\t//gi; - $CLIREPORT_port=1; - print " CLI defined REPORT port: $VARREPORT_port\n"; + @CLIREPORT_portARY = split(/--REPORT_port=/,$args); + @CLIREPORT_portARX = split(/ /,$CLIREPORT_portARY[1]); + if (length($CLIREPORT_portARX[0])>2) + { + $VARREPORT_port = $CLIREPORT_portARX[0]; + $VARREPORT_port =~ s/\/$| |\r|\n|\t//gi; + $CLIREPORT_port=1; + print " CLI defined REPORT port: $VARREPORT_port\n"; + } } - } if ($args =~ /--REPORT_dir=/i) # CLI defined archive REPORT directory - { - @CLIREPORT_dirARY = split(/--REPORT_dir=/,$args); - @CLIREPORT_dirARX = split(/ /,$CLIREPORT_dirARY[1]); - if (length($CLIREPORT_dirARX[0])>2) { - $VARREPORT_dir = $CLIREPORT_dirARX[0]; - $VARREPORT_dir =~ s/\/$| |\r|\n|\t//gi; - $CLIREPORT_dir=1; - print " CLI defined REPORT dir: $VARREPORT_dir\n"; + @CLIREPORT_dirARY = split(/--REPORT_dir=/,$args); + @CLIREPORT_dirARX = split(/ /,$CLIREPORT_dirARY[1]); + if (length($CLIREPORT_dirARX[0])>2) + { + $VARREPORT_dir = $CLIREPORT_dirARX[0]; + $VARREPORT_dir =~ s/\/$| |\r|\n|\t//gi; + $CLIREPORT_dir=1; + print " CLI defined REPORT dir: $VARREPORT_dir\n"; + } } - } if ($args =~ /--copy_sample_conf_files/i) # CLI defined conf files - { - $CLIcopy_conf_files='y'; - print " CLI copy conf files: YES\n"; - } + { + $CLIcopy_conf_files='y'; + print " CLI copy conf files: YES\n"; + } else - { - $CLIcopy_conf_files='n'; - } + { + $CLIcopy_conf_files='n'; + } if ($args =~ /--fastagi_log_min_servers=/i) # CLI defined fastagi min servers - { - @CLIDB_minserARY = split(/--fastagi_log_min_servers=/,$args); - @CLIDB_minserARX = split(/ /,$CLIDB_minserARY[1]); - if (length($CLIDB_minserARX[0])>1) { - $VARfastagi_log_min_servers = $CLIDB_minserARX[0]; - $VARfastagi_log_min_servers =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_min_servers=1; - print " CLI defined log min server: $VARfastagi_log_min_servers\n"; + @CLIDB_minserARY = split(/--fastagi_log_min_servers=/,$args); + @CLIDB_minserARX = split(/ /,$CLIDB_minserARY[1]); + if (length($CLIDB_minserARX[0])>1) + { + $VARfastagi_log_min_servers = $CLIDB_minserARX[0]; + $VARfastagi_log_min_servers =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_min_servers=1; + print " CLI defined log min server: $VARfastagi_log_min_servers\n"; + } } - } if ($args =~ /--fastagi_log_max_servers=/i) # CLI defined fastagi max servers - { - @CLIDB_maxserARY = split(/--fastagi_log_max_servers=/,$args); - @CLIDB_maxserARX = split(/ /,$CLIDB_maxserARY[1]); - if (length($CLIDB_maxserARX[0])>1) { - $VARfastagi_log_max_servers = $CLIDB_maxserARX[0]; - $VARfastagi_log_max_servers =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_max_servers=1; - print " CLI defined log max server: $VARfastagi_log_max_servers\n"; + @CLIDB_maxserARY = split(/--fastagi_log_max_servers=/,$args); + @CLIDB_maxserARX = split(/ /,$CLIDB_maxserARY[1]); + if (length($CLIDB_maxserARX[0])>1) + { + $VARfastagi_log_max_servers = $CLIDB_maxserARX[0]; + $VARfastagi_log_max_servers =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_max_servers=1; + print " CLI defined log max server: $VARfastagi_log_max_servers\n"; + } } - } if ($args =~ /--fastagi_log_min_spare_servers=/i) # CLI defined fastagi min spare servers - { - @CLIDB_minspaARY = split(/--fastagi_log_min_spare_servers=/,$args); - @CLIDB_minspaARX = split(/ /,$CLIDB_minspaARY[1]); - if (length($CLIDB_minspaARX[0])>1) { - $VARfastagi_log_min_spare_servers = $CLIDB_minspaARX[0]; - $VARfastagi_log_min_spare_servers =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_min_spare_servers=1; - print " CLI defined log min spare: $VARfastagi_log_min_spare_servers\n"; + @CLIDB_minspaARY = split(/--fastagi_log_min_spare_servers=/,$args); + @CLIDB_minspaARX = split(/ /,$CLIDB_minspaARY[1]); + if (length($CLIDB_minspaARX[0])>1) + { + $VARfastagi_log_min_spare_servers = $CLIDB_minspaARX[0]; + $VARfastagi_log_min_spare_servers =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_min_spare_servers=1; + print " CLI defined log min spare: $VARfastagi_log_min_spare_servers\n"; + } } - } if ($args =~ /--fastagi_log_max_spare_servers=/i) # CLI defined fastagi max spare servers - { - @CLIDB_maxspaARY = split(/--fastagi_log_max_spare_servers=/,$args); - @CLIDB_maxspaARX = split(/ /,$CLIDB_maxspaARY[1]); - if (length($CLIDB_maxspaARX[0])>1) { - $VARfastagi_log_max_spare_servers = $CLIDB_maxspaARX[0]; - $VARfastagi_log_max_spare_servers =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_max_spare_servers=1; - print " CLI defined log max spare: $VARfastagi_log_max_spare_servers\n"; + @CLIDB_maxspaARY = split(/--fastagi_log_max_spare_servers=/,$args); + @CLIDB_maxspaARX = split(/ /,$CLIDB_maxspaARY[1]); + if (length($CLIDB_maxspaARX[0])>1) + { + $VARfastagi_log_max_spare_servers = $CLIDB_maxspaARX[0]; + $VARfastagi_log_max_spare_servers =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_max_spare_servers=1; + print " CLI defined log max spare: $VARfastagi_log_max_spare_servers\n"; + } } - } if ($args =~ /--fastagi_log_max_requests=/i) # CLI defined fastagi max requests - { - @CLIDB_maxreqARY = split(/--fastagi_log_max_requests=/,$args); - @CLIDB_maxreqARX = split(/ /,$CLIDB_maxreqARY[1]); - if (length($CLIDB_maxreqARX[0])>1) { - $VARfastagi_log_max_requests = $CLIDB_maxreqARX[0]; - $VARfastagi_log_max_requests =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_max_requests=1; - print " CLI defined log max request:$VARfastagi_log_max_requests\n"; + @CLIDB_maxreqARY = split(/--fastagi_log_max_requests=/,$args); + @CLIDB_maxreqARX = split(/ /,$CLIDB_maxreqARY[1]); + if (length($CLIDB_maxreqARX[0])>1) + { + $VARfastagi_log_max_requests = $CLIDB_maxreqARX[0]; + $VARfastagi_log_max_requests =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_max_requests=1; + print " CLI defined log max request:$VARfastagi_log_max_requests\n"; + } } - } if ($args =~ /--fastagi_log_checkfordead=/i) # CLI defined fastagi check-for-dead seconds - { - @CLIDB_ckdeadARY = split(/--fastagi_log_checkfordead=/,$args); - @CLIDB_ckdeadARX = split(/ /,$CLIDB_ckdeadARY[1]); - if (length($CLIDB_ckdeadARX[0])>1) { - $VARfastagi_log_checkfordead = $CLIDB_ckdeadARX[0]; - $VARfastagi_log_checkfordead =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_checkfordead=1; - print " CLI defined log ckdead sec: $VARfastagi_log_checkfordead\n"; + @CLIDB_ckdeadARY = split(/--fastagi_log_checkfordead=/,$args); + @CLIDB_ckdeadARX = split(/ /,$CLIDB_ckdeadARY[1]); + if (length($CLIDB_ckdeadARX[0])>1) + { + $VARfastagi_log_checkfordead = $CLIDB_ckdeadARX[0]; + $VARfastagi_log_checkfordead =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_checkfordead=1; + print " CLI defined log ckdead sec: $VARfastagi_log_checkfordead\n"; + } } - } if ($args =~ /--fastagi_log_checkforwait=/i) # CLI defined fastagi check-for-wait seconds - { - @CLIDB_ckwaitARY = split(/--fastagi_log_checkforwait=/,$args); - @CLIDB_ckwaitARX = split(/ /,$CLIDB_ckwaitARY[1]); - if (length($CLIDB_ckwaitARX[0])>1) { - $VARfastagi_log_checkforwait = $CLIDB_ckwaitARX[0]; - $VARfastagi_log_checkforwait =~ s/ |\r|\n|\t//gi; - $CLIfastagi_log_checkforwait=1; - print " CLI defined log ckwait sec: $VARfastagi_log_checkforwait\n"; + @CLIDB_ckwaitARY = split(/--fastagi_log_checkforwait=/,$args); + @CLIDB_ckwaitARX = split(/ /,$CLIDB_ckwaitARY[1]); + if (length($CLIDB_ckwaitARX[0])>1) + { + $VARfastagi_log_checkforwait = $CLIDB_ckwaitARX[0]; + $VARfastagi_log_checkforwait =~ s/ |\r|\n|\t//gi; + $CLIfastagi_log_checkforwait=1; + print " CLI defined log ckwait sec: $VARfastagi_log_checkforwait\n"; + } } - } if ($args =~ /--build_multiserver_conf/i) # CLI defined conf files - { - $build_multiserver_conf='y'; - print " CLI multiserver conf gen: YES\n"; - - # default path to astguiclient configuration file: - $PATHconf = '/etc/astguiclient.conf'; - - open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; - @conf = ; - close(conf); - $i=0; - foreach(@conf) { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ 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++; - } + $build_multiserver_conf='y'; + print " CLI multiserver conf gen: YES\n"; - # Customized Variables - $server_ip = $VARserver_ip; # Asterisk server IP - if (!$VARDB_port) {$VARDB_port='3306';} + # default path to astguiclient configuration file: + $PATHconf = '/etc/astguiclient.conf'; - use DBI; + open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; + @conf = ; + close(conf); + $i=0; + foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ 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++; + } - $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; + # Customized Variables + $server_ip = $VARserver_ip; # Asterisk server IP + if (!$VARDB_port) {$VARDB_port='3306';} - ### format the new server_ip dialstring for example to use with extensions.conf - $S='*'; - if( $VARserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) - { - $a = leading_zero($1); - $b = leading_zero($2); - $c = leading_zero($3); - $d = leading_zero($4); - $VARremDIALstr = "$a$S$b$S$c$S$d"; - } + use DBI; - $ext = "\nAdd the following lines to your extensions.conf file:\n"; - $ext .= "TRUNKloop = IAX2/ASTloop:test\@127.0.0.1:40569\n"; - $ext .= "TRUNKblind = IAX2/ASTblind:test\@127.0.0.1:41569\n"; + $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; - $iax = "\nAdd the following lines to your iax.conf file:\n"; - $iax .= "register => ASTloop:test\@127.0.0.1:40569\n"; - $iax .= "register => ASTblind:test\@127.0.0.1:41569\n"; - - $Lext = "\n"; - $Lext .= "; Local Server: $server_ip\n"; - $Lext .= "exten => _$VARremDIALstr*.,1,Goto(default,\${EXTEN:16},1)\n"; - $Lext .= "exten => _8600XXX*.,1,AGI(agi-VDADfixCXFER.agi)\n"; - $Lext .= "exten => _78600XXX*.,1,AGI(agi-VDADfixCXFER.agi)\n"; - $Lext .= "; Local blind monitoring\n"; - $Lext .= "exten => _08600XXX,1,Dial(\${TRUNKblind}/6\${EXTEN:1},55,o)\n"; - - $Liax .= "\n"; - $Liax .= "[ASTloop]\n"; - $Liax .= "type=friend\n"; - $Liax .= "accountcode=IAXASTloop\n"; - $Liax .= "context=default\n"; - $Liax .= "auth=plaintext\n"; - $Liax .= "host=dynamic\n"; - $Liax .= "permit=0.0.0.0/0.0.0.0\n"; - $Liax .= "secret=test\n"; - $Liax .= "disallow=all\n"; - $Liax .= "allow=ulaw\n"; - $Liax .= "qualify=yes\n"; - - $Liax .= "\n"; - $Liax .= "[ASTblind]\n"; - $Liax .= "type=friend\n"; - $Liax .= "accountcode=IAXASTblind\n"; - $Liax .= "context=default\n"; - $Liax .= "auth=plaintext\n"; - $Liax .= "host=dynamic\n"; - $Liax .= "permit=0.0.0.0/0.0.0.0\n"; - $Liax .= "secret=test\n"; - $Liax .= "disallow=all\n"; - $Liax .= "allow=ulaw\n"; - $Liax .= "qualify=yes\n"; - - ##### Get the server_id for this server's server_ip ##### - $stmtA = "SELECT server_id FROM servers where server_ip='$server_ip';"; - print "$stmtA\n"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $server_id = "$aryA[0]"; - $i++; - } - $sthA->finish(); - - ##### Get the server_ips and server_ids of all VICIDIAL servers on the network ##### - $stmtA = "SELECT server_ip,server_id FROM servers where server_ip!='$server_ip';"; - print "$stmtA\n"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $i=0; - while ($sthArows > $i) - { - @aryA = $sthA->fetchrow_array; - $server_ip[$i] = "$aryA[0]"; - $server_id[$i] = "$aryA[1]"; - - if( $server_ip[$i] =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + ### format the new server_ip dialstring for example to use with extensions.conf + $S='*'; + if( $VARserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) { $a = leading_zero($1); $b = leading_zero($2); @@ -749,17 +672,27 @@ if (length($ARGV[0])>1) $d = leading_zero($4); $VARremDIALstr = "$a$S$b$S$c$S$d"; } - $ext .= "TRUNK$server_id[$i] = IAX2/$server_id:test\@$server_ip[$i]:4569\n"; - $iax .= "register => $server_id:test\@$server_ip[$i]:4569\n"; + $ext = "\nAdd the following lines to your extensions.conf file:\n"; + $ext .= "TRUNKloop = IAX2/ASTloop:test\@127.0.0.1:40569\n"; + $ext .= "TRUNKblind = IAX2/ASTblind:test\@127.0.0.1:41569\n"; - $Lext .= "; Remote Server VDAD extens: $server_id[$i] $server_ip[$i]\n"; - $Lext .= "exten => _$VARremDIALstr*.,1,Dial(\${TRUNK$server_id[$i]}/\${EXTEN:16},55,o)\n"; + $iax = "\nAdd the following lines to your iax.conf file:\n"; + $iax .= "register => ASTloop:test\@127.0.0.1:40569\n"; + $iax .= "register => ASTblind:test\@127.0.0.1:41569\n"; + + $Lext = "\n"; + $Lext .= "; Local Server: $server_ip\n"; + $Lext .= "exten => _$VARremDIALstr*.,1,Goto(default,\${EXTEN:16},1)\n"; + $Lext .= "exten => _8600XXX*.,1,AGI(agi-VDADfixCXFER.agi)\n"; + $Lext .= "exten => _78600XXX*.,1,AGI(agi-VDADfixCXFER.agi)\n"; + $Lext .= "; Local blind monitoring\n"; + $Lext .= "exten => _08600XXX,1,Dial(\${TRUNKblind}/6\${EXTEN:1},55,o)\n"; $Liax .= "\n"; - $Liax .= "[$server_id[$i]]\n"; + $Liax .= "[ASTloop]\n"; $Liax .= "type=friend\n"; - $Liax .= "accountcode=IAX$server_id[$i]\n"; + $Liax .= "accountcode=IAXASTloop\n"; $Liax .= "context=default\n"; $Liax .= "auth=plaintext\n"; $Liax .= "host=dynamic\n"; @@ -769,149 +702,216 @@ if (length($ARGV[0])>1) $Liax .= "allow=ulaw\n"; $Liax .= "qualify=yes\n"; - $i++; + $Liax .= "\n"; + $Liax .= "[ASTblind]\n"; + $Liax .= "type=friend\n"; + $Liax .= "accountcode=IAXASTblind\n"; + $Liax .= "context=default\n"; + $Liax .= "auth=plaintext\n"; + $Liax .= "host=dynamic\n"; + $Liax .= "permit=0.0.0.0/0.0.0.0\n"; + $Liax .= "secret=test\n"; + $Liax .= "disallow=all\n"; + $Liax .= "allow=ulaw\n"; + $Liax .= "qualify=yes\n"; + + ##### Get the server_id for this server's server_ip ##### + $stmtA = "SELECT server_id FROM servers where server_ip='$server_ip';"; + print "$stmtA\n"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $server_id = "$aryA[0]"; + $i++; + } + $sthA->finish(); + + ##### Get the server_ips and server_ids of all VICIDIAL servers on the network ##### + $stmtA = "SELECT server_ip,server_id FROM servers where server_ip!='$server_ip';"; + print "$stmtA\n"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $i=0; + while ($sthArows > $i) + { + @aryA = $sthA->fetchrow_array; + $server_ip[$i] = "$aryA[0]"; + $server_id[$i] = "$aryA[1]"; + + if( $server_ip[$i] =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VARremDIALstr = "$a$S$b$S$c$S$d"; + } + $ext .= "TRUNK$server_id[$i] = IAX2/$server_id:test\@$server_ip[$i]:4569\n"; + + $iax .= "register => $server_id:test\@$server_ip[$i]:4569\n"; + + $Lext .= "; Remote Server VDAD extens: $server_id[$i] $server_ip[$i]\n"; + $Lext .= "exten => _$VARremDIALstr*.,1,Dial(\${TRUNK$server_id[$i]}/\${EXTEN:16},55,o)\n"; + + $Liax .= "\n"; + $Liax .= "[$server_id[$i]]\n"; + $Liax .= "type=friend\n"; + $Liax .= "accountcode=IAX$server_id[$i]\n"; + $Liax .= "context=default\n"; + $Liax .= "auth=plaintext\n"; + $Liax .= "host=dynamic\n"; + $Liax .= "permit=0.0.0.0/0.0.0.0\n"; + $Liax .= "secret=test\n"; + $Liax .= "disallow=all\n"; + $Liax .= "allow=ulaw\n"; + $Liax .= "qualify=yes\n"; + + $i++; + } + $sthA->finish(); + + + print "$ext$Lext\n$iax$Liax\n"; + exit; } - $sthA->finish(); - - - print "$ext$Lext\n$iax$Liax\n"; - exit; - } if ($args =~ /--build_phones_conf/i) # CLI defined conf files - { - $build_phones_conf='y'; - print " CLI phones conf gen: YES\n"; - - # default path to astguiclient configuration file: - $PATHconf = '/etc/astguiclient.conf'; - - open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; - @conf = ; - close(conf); - $i=0; - foreach(@conf) { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ 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++; - } + $build_phones_conf='y'; + print " CLI phones conf gen: YES\n"; - # Customized Variables - $server_ip = $VARserver_ip; # Asterisk server IP - if (!$VARDB_port) {$VARDB_port='3306';} + # default path to astguiclient configuration file: + $PATHconf = '/etc/astguiclient.conf'; - use DBI; + open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; + @conf = ; + close(conf); + $i=0; + foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ 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++; + } - $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; + # Customized Variables + $server_ip = $VARserver_ip; # Asterisk server IP + if (!$VARDB_port) {$VARDB_port='3306';} - $ext = "\nAdd the following lines to your extensions.conf file:\n"; + use DBI; - $sip = "\nAdd the following lines to your sip.conf file:\n"; + $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; - $iax = "\nAdd the following lines to your iax.conf file:\n"; + $ext = "\nAdd the following lines to your extensions.conf file:\n"; - $vm = "\nAdd the following lines to your voicemail.conf file:\n"; + $sip = "\nAdd the following lines to your sip.conf file:\n"; - ##### Get the SIP phone entries ##### - $stmtA = "SELECT extension,dialplan_number,voicemail_id,pass FROM phones where server_ip='$server_ip' and protocol='SIP';"; - print "$stmtA\n"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $i=0; - while ($sthArows > $i) - { - @aryA = $sthA->fetchrow_array; + $iax = "\nAdd the following lines to your iax.conf file:\n"; + + $vm = "\nAdd the following lines to your voicemail.conf file:\n"; + + ##### Get the SIP phone entries ##### + $stmtA = "SELECT extension,dialplan_number,voicemail_id,pass FROM phones where server_ip='$server_ip' and protocol='SIP';"; + print "$stmtA\n"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $i=0; + while ($sthArows > $i) + { + @aryA = $sthA->fetchrow_array; $extension[$i] = "$aryA[0]"; $dialplan[$i] = "$aryA[1]"; $voicemail[$i] = "$aryA[2]"; $pass[$i] = "$aryA[3]"; - $ext .= "exten => $dialplan[$i],1,Dial(SIP/$extension[$i])\n"; - $ext .= "exten => $dialplan[$i],2,Voicemail,u$voicemail[$i]\n"; + $ext .= "exten => $dialplan[$i],1,Dial(SIP/$extension[$i])\n"; + $ext .= "exten => $dialplan[$i],2,Voicemail,u$voicemail[$i]\n"; - $sip .= "\[$extension[$i]\]\n"; - $sip .= "disallow=all\n"; - $sip .= "allow=ulaw\n"; - $sip .= "type=friend\n"; - $sip .= "username=$extension[$i]\n"; - $sip .= "secret=$pass[$i]\n"; - $sip .= "host=dynamic\n"; - $sip .= "dtmfmode=rfc2833\n"; - $sip .= "qualify=1000\n"; - $sip .= "mailbox=$voicemail[$i]\n\n"; + $sip .= "\[$extension[$i]\]\n"; + $sip .= "disallow=all\n"; + $sip .= "allow=ulaw\n"; + $sip .= "type=friend\n"; + $sip .= "username=$extension[$i]\n"; + $sip .= "secret=$pass[$i]\n"; + $sip .= "host=dynamic\n"; + $sip .= "dtmfmode=rfc2833\n"; + $sip .= "qualify=1000\n"; + $sip .= "mailbox=$voicemail[$i]\n\n"; - $vm .= "$voicemail[$i] => $voicemail[$i],$extension[$i] Mailbox\n"; + $vm .= "$voicemail[$i] => $voicemail[$i],$extension[$i] Mailbox\n"; - $i++; - } - $sthA->finish(); + $i++; + } + $sthA->finish(); - ##### Get the IAX phone entries ##### - $stmtA = "SELECT extension,dialplan_number,voicemail_id,pass FROM phones where server_ip='$server_ip' and protocol='IAX2';"; - print "$stmtA\n"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $i=0; - while ($sthArows > $i) - { - @aryA = $sthA->fetchrow_array; + ##### Get the IAX phone entries ##### + $stmtA = "SELECT extension,dialplan_number,voicemail_id,pass FROM phones where server_ip='$server_ip' and protocol='IAX2';"; + print "$stmtA\n"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $i=0; + while ($sthArows > $i) + { + @aryA = $sthA->fetchrow_array; $extension[$i] = "$aryA[0]"; $dialplan[$i] = "$aryA[1]"; $voicemail[$i] = "$aryA[2]"; $pass[$i] = "$aryA[3]"; - $ext .= "exten => $dialplan[$i],1,Dial(IAX2/$extension[$i])\n"; - $ext .= "exten => $dialplan[$i],2,Voicemail,u$voicemail[$i]\n"; + $ext .= "exten => $dialplan[$i],1,Dial(IAX2/$extension[$i])\n"; + $ext .= "exten => $dialplan[$i],2,Voicemail,u$voicemail[$i]\n"; - $iax .= "\[$extension[$i]\]\n"; - $iax .= "disallow=all\n"; - $iax .= "allow=ulaw\n"; - $iax .= "context=default\n"; - $iax .= "type=friend\n"; - $iax .= "accountcode=$extension[$i]\n"; - $iax .= "secret=$pass[$i]\n"; - $iax .= "auth=md5\n"; - $iax .= "host=dynamic\n"; - $iax .= "permit=0.0.0.0/0.0.0.0\n"; - $iax .= "qualify=1000\n"; - $iax .= "mailbox=$voicemail[$i]\n\n"; + $iax .= "\[$extension[$i]\]\n"; + $iax .= "disallow=all\n"; + $iax .= "allow=ulaw\n"; + $iax .= "context=default\n"; + $iax .= "type=friend\n"; + $iax .= "accountcode=$extension[$i]\n"; + $iax .= "secret=$pass[$i]\n"; + $iax .= "auth=md5\n"; + $iax .= "host=dynamic\n"; + $iax .= "permit=0.0.0.0/0.0.0.0\n"; + $iax .= "qualify=1000\n"; + $iax .= "mailbox=$voicemail[$i]\n\n"; - $vm .= "$voicemail[$i] => $voicemail[$i],$extension[$i] Mailbox\n"; + $vm .= "$voicemail[$i] => $voicemail[$i],$extension[$i] Mailbox\n"; - $i++; + $i++; + } + $sthA->finish(); + + print "$ext\n$sip\n$iax\n$vm\n"; + exit; } - $sthA->finish(); - - - print "$ext\n$sip\n$iax\n$vm\n"; - exit; } } -} else -{ -# print "no command line options set\n"; -$CLIcopy_conf_files='n'; -} + { + # print "no command line options set\n"; + $CLIcopy_conf_files='n'; + } ### end parsing run-time options ### if (-e "$PATHconf") @@ -1033,7 +1033,7 @@ else else { `mkdir -p $PROMPThome`; - print " $PROMPThome directory created\n"; + print " $PROMPThome directory created\n"; $PATHhome=$PROMPThome; $continue='YES'; } @@ -1058,7 +1058,7 @@ else else { `mkdir -p $PATHhome`; - print " $PATHhome directory created\n"; + print " $PATHhome directory created\n"; $continue='YES'; } } @@ -1092,7 +1092,7 @@ else else { `mkdir -p $PROMPTlogs`; - print " $PROMPTlogs directory created\n"; + print " $PROMPTlogs directory created\n"; $PATHlogs=$PROMPTlogs; $continue='YES'; } @@ -1151,7 +1151,7 @@ else else { `mkdir -p $PROMPTagi`; - print " $PROMPTagi directory created\n"; + print " $PROMPTagi directory created\n"; $PATHagi=$PROMPTagi; $continue='YES'; } @@ -1210,7 +1210,7 @@ else else { `mkdir -p $PROMPTweb`; - print " $PROMPTweb directory created\n"; + print " $PROMPTweb directory created\n"; $PATHweb=$PROMPTweb; $continue='YES'; } @@ -1269,7 +1269,7 @@ else else { `mkdir -p $PROMPTsounds`; - print " $PROMPTsounds directory created\n"; + print " $PROMPTsounds directory created\n"; $PATHsounds=$PROMPTsounds; $continue='YES'; } @@ -1328,7 +1328,7 @@ else else { `mkdir -p $PROMPTmonitor`; - print " $PROMPTmonitor directory created\n"; + print " $PROMPTmonitor directory created\n"; $PATHmonitor=$PROMPTmonitor; $continue='YES'; } @@ -1387,7 +1387,7 @@ else else { `mkdir -p $PROMPTDONEmonitor`; - print " $PROMPTDONEmonitor directory created\n"; + print " $PROMPTDONEmonitor directory created\n"; $PATHDONEmonitor=$PROMPTDONEmonitor; $continue='YES'; } @@ -1642,7 +1642,7 @@ else else { `mkdir -p /etc/asterisk`; - print " /etc/asterisk directory created\n"; + print " /etc/asterisk directory created\n"; $continue='YES'; } } @@ -2147,29 +2147,38 @@ print "\nSTARTING ASTGUICLIENT INSTALLATION PHASE...\n"; if ($WEBONLY < 1) { - print "Creating $PATHhome/LEADS_IN/DONE directories...\n"; - `mkdir -p $PATHhome/libs`; - `mkdir -p $PATHhome/libs/Asterisk`; - `mkdir -p $PATHhome/LEADS_IN`; - `mkdir -p $PATHhome/LEADS_IN/DONE`; - `chmod -R 0766 $PATHhome/LEADS_IN`; - `mkdir -p $PATHhome/VTIGER_IN`; - `mkdir -p $PATHhome/VTIGER_IN/DONE`; - `chmod -R 0766 $PATHhome/VTIGER_IN`; + print "Creating $PATHhome/LEADS_IN directories...\n"; + if (!-e "$PATHhome/libs/Asterisk") {`mkdir -p $PATHhome/libs/Asterisk`;} + if (!-e "$PATHhome/LEADS_IN/DONE") + { + `mkdir -p $PATHhome/LEADS_IN/DONE`; + `chmod -R 0766 $PATHhome/LEADS_IN`; + } + if (!-e "$PATHhome/VTIGER_IN/DONE") + { + `mkdir -p $PATHhome/VTIGER_IN/DONE`; + `chmod -R 0766 $PATHhome/VTIGER_IN`; + } print "Creating $PATHmonitor directories...\n"; - `mkdir -p $PATHmonitor`; - `mkdir -p $PATHDONEmonitor`; - `mkdir -p $PATHDONEmonitor/ORIG`; - `mkdir -p $PATHDONEmonitor/GSM`; - `mkdir -p $PATHDONEmonitor/MP3`; - `mkdir -p $PATHDONEmonitor/OGG`; - `mkdir -p $PATHDONEmonitor/FTP`; - `chmod -R 0766 $PATHmonitor`; - `chmod -R 0766 $PATHDONEmonitor`; + if (!-e "$PATHmonitor") + { + `mkdir -p $PATHmonitor`; + `chmod -R 0766 $PATHmonitor`; + } + if (!-e "$PATHDONEmonitor") + { + `mkdir -p $PATHDONEmonitor`; + `chmod -R 0766 $PATHDONEmonitor`; + } + if (!-e "$PATHDONEmonitor/ORIG") {`mkdir -p $PATHDONEmonitor/ORIG`;} + if (!-e "$PATHDONEmonitor/GSM") {`mkdir -p $PATHDONEmonitor/GSM`;} + if (!-e "$PATHDONEmonitor/MP3") {`mkdir -p $PATHDONEmonitor/MP3`;} + if (!-e "$PATHDONEmonitor/OGG") {`mkdir -p $PATHDONEmonitor/OGG`;} + if (!-e "$PATHDONEmonitor/FTP") {`mkdir -p $PATHDONEmonitor/FTP`;} print "Creating $PATHlogs/archive directory for backups...\n"; - `mkdir -p $PATHlogs/archive`; + if (!-e "$PATHlogs/archive") {`mkdir -p $PATHlogs/archive`;} print "Copying bin scripts to $PATHhome ...\n"; `cp -f ./bin/* $PATHhome/`; @@ -2212,12 +2221,13 @@ if ($WEBONLY < 1) if ($NOWEB < 1) { print "Creating $PATHweb web directories...\n"; - `mkdir -p $PATHweb/agc/`; - `mkdir -p $PATHweb/astguiclient/`; - `mkdir -p $PATHweb/vicidial/`; - `mkdir -p $PATHweb/vicidial/ploticus/`; - `mkdir -p $PATHweb/vicidial/agent_reports/`; - `mkdir -p $PATHweb/vicidial/server_reports/`; + + if (!-e "$PATHweb/agc/") {`mkdir -p $PATHweb/agc/`;} + if (!-e "$PATHweb/astguiclient/") {`mkdir -p $PATHweb/astguiclient/`;} + if (!-e "$PATHweb/vicidial/") {`mkdir -p $PATHweb/vicidial/`;} + if (!-e "$PATHweb/vicidial/ploticus/") {`mkdir -p $PATHweb/vicidial/ploticus/`;} + if (!-e "$PATHweb/vicidial/agent_reports/") {`mkdir -p $PATHweb/vicidial/agent_reports/`;} + if (!-e "$PATHweb/vicidial/server_reports/") {`mkdir -p $PATHweb/vicidial/server_reports/`;} print "Copying web files...\n"; `cp -f -R ./www/* $PATHweb/`; @@ -2294,9 +2304,9 @@ exit; sub leading_zero($) -{ - $_ = $_[0]; - s/^(\d)$/0$1/; - s/^(\d\d)$/0$1/; - return $_; -} # End of the leading_zero() routine. + { + $_ = $_[0]; + s/^(\d)$/0$1/; + s/^(\d\d)$/0$1/; + return $_; + } # End of the leading_zero() routine.