diff --git a/agc_2-X/trunk/ADMIN_adjust_GMTnow_on_leads.pl b/agc_2-X/trunk/ADMIN_adjust_GMTnow_on_leads.pl new file mode 100644 index 00000000..ab4ed81d --- /dev/null +++ b/agc_2-X/trunk/ADMIN_adjust_GMTnow_on_leads.pl @@ -0,0 +1,688 @@ +#!/usr/bin/perl + +# ADMIN_adjust_GMTnow_on_leads.pl +# +# program goes throught the vicidial_list table and adjusts the gmt_offset_now +# field to change it to today's offset if needed because of Daylight Saving Time +# +# run every time you load leads into the vicidial_list table +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 50810-1540 - Added database server variable definitions lookup +# 60615-1717 - Added definition GMT lookup from database not flat text file +# + +$MT[0]=''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [--debug] = debugging messages\n\n"; + } + else + { + if ($args =~ /-q/i) + { + $q=1; $Q=1; + } + if ($args =~ /--debug/i) + { + $DB=1; + print "\n-----DEBUGGING -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t|--test/i) + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } + } +} +else +{ +print "no command line options set\n"; +} + +if ($DB) {print "STARTING TIME ZONE DAYLIGHT SAVING TIME CALCULATION SCRIPT\n\n\n\n";} + +### end parsing run-time options ### + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$secX = time(); +# $secX = '1079989363'; # epoch for March 22, 2993 +# $secX = '1097989363'; # epoch for October 17, 2004 + + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); + $mon++; + $year = ($year + 1900); + 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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +use Net::MySQL; + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + ### 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 FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEupdate = "$record->[4]"; + $DBASTmgrUSERNAMElisten = "$record->[5]"; + $DBASTmgrUSERNAMEsend = "$record->[6]"; + $DBmax_vicidial_trunks = "$record->[7]"; + $DBanswer_transfer_agent= "$record->[8]"; + $DBSERVER_GMT = "$record->[9]"; + $DBext_context = "$record->[10]"; + 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;} + if ($DBmax_vicidial_trunks) {$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;} + } + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + $stmtA = "select distinct phone_code from vicidial_list;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countY=0; + @phone_codes=@MT; + $phone_codes_list='|'; + while ($recordA = $iterA->each) + { + $phone_codes[$rec_countY] = $recordA->[0]; + $phone_codes_ORIG[$rec_countY] = $recordA->[0]; + $phone_codes[$rec_countY] =~ s/011|0011| |\t|\r|\n//gi; + + # if ( ($phone_codes_list !~ /\|$phone_codes[$rec_countY]\|/) && (length($phone_codes[$rec_countY]) > 0) ) + # { + # $phone_codes_list .= "$phone_codes[$rec_countY]|"; + # } + + if ($DBX) {print "|",$recordA->[0],"|","\n";} + $rec_countY++; + } + } + + if ($DB) {print " - Unique Country dial codes found: $rec_countY\n";} + + + $stmtA = "select * from vicidial_phone_codes;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countZ=0; + @codefile=@MT; + while ($recordA = $iterA->each) + { + $codefile[$rec_countZ] = "$recordA->[0]\t$recordA->[1]\t$recordA->[2]\t$recordA->[3]\t$recordA->[4]\t$recordA->[5]\t$recordA->[6]\t$recordA->[7]\n"; + $rec_countZ++; + } + } + + if ($DB) {print " - GMT phone codes records: $rec_countZ\n";} + +# open(codefile, "/home/cron/phone_codes_GMT.txt") || die "can't open /home/cron/phone_codes_GMT.txt: $!\n"; +# @codefile = ; +# close(codefile); + +$ep=0; $ei=0; $ee=0; +$d=0; +foreach (@phone_codes) + { + $match_code = $phone_codes[$d]; + $match_code_ORIG = $phone_codes_ORIG[$d]; + + if ($DB) {print "\nRUNNING LOOP FOR COUNTRY CODE: $match_code\n";} + + $e=0; + foreach (@codefile) + { + chomp($codefile[$e]); + if ($codefile[$e] =~ /^$match_code\t/) + { + @m = split(/\t/, $codefile[$e]); + $area_code = $m[2]; + $area_state = $m[3]; + $area_GMT = $m[4]; $area_GMT =~ s/\+//gi; $area_GMT = ($area_GMT + 0); + $area_GMT_method = $m[6]; + if ($area_code =~ /S/) # look for state override flag in areacode field + { + $area_code =~ s/\D//gi; + $AC_match = " and phone_number LIKE \"$area_code%\" and state='$area_state'"; + if ($DB) {print " AREA CODE STATE OVERRIDE: $codefile[$e]\n";} + } + else + { + if ($area_code =~ /\*/) {$AC_match = '';} + else {$AC_match = " and phone_number LIKE \"$area_code%\"";} + } + if ($DBX) {print "PROCESSING THIS LINE: $codefile[$e]\n";} + $stmtA = "select count(*) from vicidial_list where phone_code='$match_code_ORIG' $AC_match;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countZ=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $rec_countZ = $recordA->[0]; + } + } + if (!$rec_countZ) + { + if ($DB) {print " IGNORING: $codefile[$e]\n";} + $ei++; + } + else + { + $AC_GMT_diff = ($area_GMT - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) && ($area_GMT_method =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &USA_dstcalc; + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$area_GMT++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($area_GMT_method =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$area_GMT++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($AC_processed) + { + $stmtA = "select count(*) from vicidial_list where phone_code='$match_code_ORIG' $AC_match and gmt_offset_now != '$area_GMT';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $rec_countW = $recordA->[0]; + } + } + if (!$rec_countW) + { + if ($DB) {print " ALL GMT ALREADY CORRECT FOR : $match_code_ORIG $area_code $area_GMT\n";} + $ei++; + } + else + { + $stmtA = "update vicidial_list set gmt_offset_now='$area_GMT' where phone_code='$match_code_ORIG' $AC_match and gmt_offset_now != '$area_GMT';"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + $Prec_countW = sprintf("%8s", $rec_countW); + if ($DB) {print " $Prec_countW records in $match_code_ORIG $area_code updated to $area_GMT\n";} + $ee++; + # sleep(1); + } + } + } + + $ep++; + } + else + { + if ($DBX) {print " IGNORING: $codefile[$e]\n";} + $ei++; + } + $e++; + } + + $d++; + } + + + + $dbhA->close; + +if($DB){print "\nDONE\n";} + +exit; + + + + +sub USA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +#********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $USA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } + } else { + $USA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $USA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } + } else { + $USA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/ADMIN_area_code_populate.pl b/agc_2-X/trunk/ADMIN_area_code_populate.pl new file mode 100644 index 00000000..1bbc129c --- /dev/null +++ b/agc_2-X/trunk/ADMIN_area_code_populate.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +# ADMIN_area_code_populate.pl version 1.1.12 for Perl +# +# Copyright (C) 2006 Joe Johnson,Matt Florell LICENSE: GPLv2 +# +# Description: +# server application that allows load areacodes into to asterisk list database +# +# +# CHANGES +# 60615-1514 - Changed to ignore the header row +# + +use lib ".\\",".\\libs", './', './libs', '../libs', '/usr/local/perl_TK/libs', 'C:\\AST_VICI\\libs'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # needed to have perl sleep in increments of less than one second +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbh = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$slash_star = '\*'; + + open(codefile, "/home/cron/phone_codes_GMT.txt") || die "can't open /home/cron/phone_codes_GMT.txt: $!\n"; + @codefile = ; + close(codefile); + $pc=0; + $ins_stmt="insert into vicidial_phone_codes VALUES "; + foreach (@codefile) + { + @row=split(/\t/, $codefile[$pc]); + if ($codefile[$pc] !~ /GEOGRAPHIC DESCRIPTION/) + { + $pc++; + $row[7] =~ s/\r|\n|\t| $//gi; + $row[6] =~ s/\r|\n|\t| $//gi; + $row[5] =~ s/\r|\n|\t| $//gi; + $row[4] =~ s/\r|\n|\t| $//gi; + $row[3] =~ s/\r|\n|\t| $//gi; + $row[2] =~ s/\r|\n|\t| $//gi; + $row[1] =~ s/\r|\n|\t| $//gi; + $row[0] =~ s/\r|\n|\t| $//gi; + $ins_stmt.="('$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '$row[5]', '$row[6]', '$row[7]'), "; + if ($pc =~ /00$/) + { + chop($ins_stmt); + chop($ins_stmt); + $dbh->query($ins_stmt) || die "can't execute query: |$ins_stmt| $!\n"; + $ins_stmt="insert into vicidial_phone_codes VALUES "; + print STDERR "$pc\n"; + } + } + else {$pc++;} + } + + chop($ins_stmt); + chop($ins_stmt); + $dbh->query($ins_stmt); + $ins_stmt="insert into vicidial_phone_codes VALUES "; + print STDERR "$pc\n"; + +exit; \ No newline at end of file diff --git a/agc_2-X/trunk/ADMIN_keepalive_AST_VDautodial.pl b/agc_2-X/trunk/ADMIN_keepalive_AST_VDautodial.pl new file mode 100644 index 00000000..b40027f7 --- /dev/null +++ b/agc_2-X/trunk/ADMIN_keepalive_AST_VDautodial.pl @@ -0,0 +1,120 @@ +#!/usr/bin/perl +# +# ADMIN_keepalive_AST_VDauto_dial.pl version 0.3 +# +# designed to keep the AST_update processes aline and check every minute +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 50810-1452 - removed '-L' flag for screen logging of output (optimization) +# 50823-1454 - Added commandline debug options with debug printouts +# + +$DB=0; # Debug flag +$MT[0]=''; $MT[1]=''; +@psline=@MT; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$running_VDAD = 0; + +$i=0; +foreach (@psoutput) +{ + chomp($psoutput[$i]); +if ($DBX) {print "$i|$psoutput[$i]| \n";} +@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + +if ($psline[1] =~ /\/home\/cron\/AST_VDauto_dial\.pl/) + { + $running_VDAD++; + if ($DB) {print "VDAD RUNNING: |$psline[1]|\n";} + } + +$i++; +} + + +if (!$running_VDAD) +{ +# print "double check that VDAD is not running\n"; + + sleep(4); + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; +$i=0; +foreach (@psoutput2) + { + chomp($psoutput2[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + + if ($psline[1] =~ /\/home\/cron\/AST_VDauto_dial\.pl/) + { + $running_VDAD++; + if ($DB) {print "VDAD RUNNING: |$psline[1]|\n";} + } + + $i++; + } + +if (!$running_VDAD) + { + if ($DB) {print "starting AST_VDauto_dial...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTVDauto /home/cron/AST_VDauto_dial.pl`; + } +} + + + + + if ($DB) {print "DONE\n";} + +exit; diff --git a/agc_2-X/trunk/ADMIN_keepalive_AST_VDremote_agents.pl b/agc_2-X/trunk/ADMIN_keepalive_AST_VDremote_agents.pl new file mode 100644 index 00000000..5b834222 --- /dev/null +++ b/agc_2-X/trunk/ADMIN_keepalive_AST_VDremote_agents.pl @@ -0,0 +1,119 @@ +#!/usr/bin/perl +# +# ADMIN_keepalive_AST_VDremote_agents.pl version 0.3 +# +# designed to keep the AST_update processes aline and check every minute +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 50810-1453 - removed '-L' flag for screen logging of output (optimization) +# 50823-1459 - Added commandline debug options with debug printouts +# + +$DB=0; # Debug flag +$MT[0]=''; $MT[1]=''; +@psline=@MT; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$running_VDra = 0; + +$i=0; +foreach (@psoutput) +{ + chomp($psoutput[$i]); +if ($DBX) {print "$i|$psoutput[$i]| \n";} +@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + +if ($psline[1] =~ /\/home\/cron\/AST_VDremote_agents\.pl/) + { + $running_VDra++; + if ($DB) {print "VDra RUNNING: |$psline[1]|\n";} + } + +$i++; +} + + +if (!$running_VDra) +{ +# print "double check that update is not running\n"; + + sleep(5); + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; +$i=0; +foreach (@psoutput2) + { + chomp($psoutput2[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + + if ($psline[1] =~ /\/home\/cron\/AST_VDremote_agents\.pl/) + { + $running_VDra++; + if ($DB) {print "VDra RUNNING: |$psline[1]|\n";} + } + + $i++; + } + +if (!$running_VDra) + { + if ($DB) {print "starting AST_VDremote_agents...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTVDremote /home/cron/AST_VDremote_agents.pl`; + } +} + + + + + if ($DB) {print "DONE\n";} + +exit; diff --git a/agc_2-X/trunk/ADMIN_keepalive_AST_send_listen.pl b/agc_2-X/trunk/ADMIN_keepalive_AST_send_listen.pl new file mode 100644 index 00000000..bdf94ead --- /dev/null +++ b/agc_2-X/trunk/ADMIN_keepalive_AST_send_listen.pl @@ -0,0 +1,169 @@ +#!/usr/bin/perl +# +# ADMIN_keepalive_AST_send_listen.pl version 0.3 +# +# designed to keep the AST_manager_listen and manager_send processes alive and check every minute +# +# if you are on an older system you may need to change the @psoutput lines to fit your ps version +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 50810-1450 - removed '-L' flag for screen logging of output (optimization) +# 50823-1440 - Added commandline debug options with debug printouts +# + +$DB=0; # Debug flag +$MT[0]=''; $MT[1]=''; +@psline=@MT; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + sleep(1); + + +#@psoutput = `ps -f -C AST_manager --no-headers`; +#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$running_listen = 0; +$running_send = 0; + +$i=0; +foreach (@psoutput) +{ + chomp($psoutput[$i]); +if ($DBX) {print "$i|$psoutput[$i]| \n";} +@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + +if ($psline[1] =~ /AST_manager_li/) + { + $running_listen++; + if ($DB) {print "LISTEN RUNNING: |$psline[1]|\n";} + } +if ($psline[1] =~ /AST_manager_se/) + { + $running_send++; + if ($DB) {print "SEND RUNNING: |$psline[1]|\n";} + } + +$i++; +} + + + +if (!$running_listen) +{ + # print "double check that update_11 is not running\n"; + + sleep(1); + +#@psoutput = `ps -f -C AST_manager --no-headers`; +#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$i=0; +foreach (@psoutput2) + { + chomp($psoutput2[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + + if ($psline[1] =~ /AST_manager_li/) + { + $running_listen++; + if ($DB) {print "LISTEN RUNNING: |$psline[1]|\n";} + } + + $i++; + } + +if (!$running_listen) + { + if ($DB) {print "starting AST_manager_listen...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTlisten /home/cron/AST_manager_listen.pl`; + } +} + + + + +if (!$running_send) +{ + # print "double check that update_12 is not running\n"; + + sleep(1); + +#@psoutput = `ps -f -C AST_manager --no-headers`; +#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; +$i=0; +foreach (@psoutput) + { + chomp($psoutput[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + + if ($psline[1] =~ /AST_manager_se/) + { + $running_send++; + if ($DB) {print "SEND RUNNING: |$psline[1]|";} + } + + $i++; + } + +if (!$running_send) + { + if ($DB) {print "starting AST_manager_send...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTsend /home/cron/AST_manager_send.pl`; + } +} + + + + + if ($DB) {print "DONE\n";} + +exit; diff --git a/agc_2-X/trunk/ADMIN_keepalive_AST_update.pl b/agc_2-X/trunk/ADMIN_keepalive_AST_update.pl new file mode 100644 index 00000000..4a713e30 --- /dev/null +++ b/agc_2-X/trunk/ADMIN_keepalive_AST_update.pl @@ -0,0 +1,121 @@ +#!/usr/bin/perl +# +# ADMIN_keepalive_AST_update.pl version 0.4 +# +# designed to keep the AST_update processes aline and check every minute +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 50810-1451 - removed '-L' flag for screen logging of output (optimization) +# 50823-1446 - Added commandline debug options with debug printouts +# 51229-1027 - fixed typo of array name +# + +$DB=0; # Debug flag +$MT[0]=''; $MT[1]=''; +@psline=@MT; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$running_update = 0; + +$i=0; +foreach (@psoutput) +{ + chomp($psoutput[$i]); +if ($DBX) {print "$i|$psoutput[$i]| \n";} +@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + +if ($psline[1] =~ /\/home\/cron\/AST_update\.pl/) + { + $running_update++; + if ($DB) {print "UPDATE RUNNING: |$psline[1]|\n";} + } + +$i++; +} + + +if (!$running_update) +{ +# print "double check that update is not running\n"; + + sleep(5); + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput2 = `/bin/ps -o "%p %a" --no-headers -A`; +$i=0; +foreach (@psoutput2) + { + chomp($psoutput2[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + + if ($psline[1] =~ /\/home\/cron\/AST_update\.pl/) + { + $running_update++; + if ($DB) {print "UPDATE RUNNING: |$psline[1]|\n";} + } + + $i++; + } + +if (!$running_update) + { + if ($DB) {print "starting AST_update...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTupdate /home/cron/AST_update.pl`; + } +} + + + + + if ($DB) {print "DONE\n";} + +exit; diff --git a/agc_2-X/trunk/ADMIN_keepalive_send_listen.at b/agc_2-X/trunk/ADMIN_keepalive_send_listen.at new file mode 100644 index 00000000..652c1bc0 --- /dev/null +++ b/agc_2-X/trunk/ADMIN_keepalive_send_listen.at @@ -0,0 +1,6 @@ +#!/bin/sh + +/home/cron/ADMIN_keepalive_AST_send_listen.pl + +exit + diff --git a/agc_2-X/trunk/ADMIN_restart_roll_logs.pl b/agc_2-X/trunk/ADMIN_restart_roll_logs.pl new file mode 100644 index 00000000..a617e3da --- /dev/null +++ b/agc_2-X/trunk/ADMIN_restart_roll_logs.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl +# ADMIN_restart_roll_logs.pl - script to roll the Asterisk logs on machine restart +# have this run on the astersik server +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +($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) {$Fhour = "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"; + + +print "rolling AST_update log...\n"; +`mv -f /home/cron/LOG_AST_update.log /home/cron/LOGS/LOG_AST_update.log.$now_date`; + +print "rolling MSAST_update log...\n"; +`mv -f /home/cron/MSLOG_AST_update.log /home/cron/LOGS/MSLOG_AST_update.log.$now_date`; + +print "rolling LIAST_update log...\n"; +`mv -f /home/cron/LILOG_AST_update.log /home/cron/LOGS/LILOG_AST_update.log.$now_date`; + +print "rolling VDAST_update log...\n"; +`mv -f /home/cron/VDLOG_AST_update.log /home/cron/LOGS/VDLOG_AST_update.log.$now_date`; + +print "rolling Asterisk messages log...\n"; +`mv -f /var/log/asterisk/messages /var/log/asterisk/messages.$now_date`; + +print "rolling Asterisk event log...\n"; +`mv -f /var/log/asterisk/event_log /var/log/asterisk/event_log.$now_date`; + +print "rolling Asterisk cdr logs...\n"; +`mv -f /var/log/asterisk/cdr-csv/Master.csv /var/log/asterisk/cdr-csv/Master.csv.$now_date`; +`mv -f /var/log/asterisk/cdr-custom/Master.csv /var/log/asterisk/cdr-custom/Master.csv.$now_date`; + +print "rolling Asterisk screen log...\n"; +`mv -f /screenlog.0 /screenlog.0.$now_date`; + +print "rolling Asterisk root screen log...\n"; +`mv -f /root/screenlog.0 /root/screenlog.0.$now_date`; + + +print "FINISHED... EXITING\n"; + +exit; diff --git a/agc_2-X/trunk/AST_CRON_mix_recordings.pl b/agc_2-X/trunk/AST_CRON_mix_recordings.pl new file mode 100644 index 00000000..f14198e3 --- /dev/null +++ b/agc_2-X/trunk/AST_CRON_mix_recordings.pl @@ -0,0 +1,124 @@ +#!/usr/bin/perl +# +# AST_CRON_mix_recordings.pl +# runs every 5 minutes and mixes the call recordings in the monitor together +# and puts the resulting ALL file into the DONE directory in the "monitor" dir +# +# soxmix is REQUIRED to use this script, soxmix is available only as part of +# the sox audio package, and only in newer versions. Make sure you have soxmix +# installed properly and in your path +# +# put an entry into the cron of of your asterisk machine to run this script +# every 5 minutes or however often you desire +# +# make sure that the following directories exist: +# /var/spool/asterisk/monitor # default Asterisk recording directory +# /var/spool/asterisk/monitor/DONE # where the combined files are put +# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put +# +# This program assumes that recordings are saved as .wav +# should be easy to change this code if you use .gsm instead +# +# This program also sends the ALL combined file to an FTP server for archival +# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the +# file transfer section of the code to deactivate remote copying of the +# recording files +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 51021-1058 Added quotes around CLI executed commands +# 51122-1458 Added soxmix binary path check +# 60318-0921 Added ability to mix gsm audio files +# + + +#$v=1; + +# Customize variables for FTP +$FTP_host = '10.0.0.4'; +$FTP_user = 'cron'; +$FTP_pass = 'test'; +$FTP_dir = 'RECORDINGS'; + +### directory where in/out recordings are saved to by Asterisk +$dir1 = '/var/spool/asterisk/monitor'; + +$soxmixbin = ''; +if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} +else + { + if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} + else + { + print "Can't find soxmix binary! Exiting...\n"; + exit; + } + } + +use Net::Ping; +use Net::FTP; + + + opendir(FILE, "$dir1/"); + @FILES = readdir(FILE); + +$i=0; +foreach(@FILES) + { + $size1 = 0; + $size2 = 0; + + if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) + { + + $size1 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size1\n";} + sleep(1); + $size2 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size2\n\n";} + + if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) + { + $INfile = $FILES[$i]; + $OUTfile = $FILES[$i]; + $OUTfile =~ s/-in\.wav/-out.wav/gi; + $OUTfile =~ s/-in\.gsm/-out.gsm/gi; + $ALLfile = $FILES[$i]; + $ALLfile =~ s/-in\.wav/-all.wav/gi; + $ALLfile =~ s/-in\.gsm/-all.gsm/gi; + + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + + `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`; + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + if (!$T) + { + `mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`; + `mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`; + `mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; + } + + ### BEGIN Remote file transfer + $p = Net::Ping->new(); + $ping_good = $p->ping("$FTP_host"); + + if ($ping_good) + { + $ftp = Net::FTP->new("$FTP_host", Port => 21); + $ftp->login("$FTP_user","$FTP_pass"); + $ftp->cwd("$FTP_dir"); + $ftp->binary(); + $ftp->put("$dir1/DONE/$ALLfile", "$ALLfile"); + $ftp->quit; + } + ### END Remote file transfer + + } + } + $i++; + } + +if ($v) {print "DONE... EXITING\n\n";} + +exit; diff --git a/agc_2-X/trunk/AST_CRON_mix_recordings_BASIC.pl b/agc_2-X/trunk/AST_CRON_mix_recordings_BASIC.pl new file mode 100644 index 00000000..87dce180 --- /dev/null +++ b/agc_2-X/trunk/AST_CRON_mix_recordings_BASIC.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl +# +# AST_CRON_mix_recordings_BASIC.pl +# runs every 5 minutes and mixes the call recordings in the monitor together +# and puts the resulting ALL file into the DONE directory in the "monitor" dir +# +# soxmix is REQUIRED to use this script, soxmix is available only as part of +# the sox audio package, and only in newer versions. Make sure you have soxmix +# installed properly and in your path +# +# put an entry into the cron of of your asterisk machine to run this script +# every 5 minutes or however often you desire +# +# make sure that the following directories exist: +# /var/spool/asterisk/monitor # default Asterisk recording directory +# /var/spool/asterisk/monitor/DONE # where the combined files are put +# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put +# +# This program assumes that recordings are saved as .wav +# should be easy to change this code if you use .gsm instead +# +# This program also sends the ALL combined file to an FTP server for archival +# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the +# file transfer section of the code to deactivate remote copying of the +# recording files +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 51021-1058 Added quotes around CLI executed commands +# 51122-1456 Added soxmix binary path check +# 60318-0921 Added ability to mix gsm audio files +# + + +#$v=1; + + +### directory where in/out recordings are saved to by Asterisk +$dir1 = '/var/spool/asterisk/monitor'; + +$soxmixbin = ''; +if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} +else + { + if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} + else + { + print "Can't find soxmix binary! Exiting...\n"; + exit; + } + } + + opendir(FILE, "$dir1/"); + @FILES = readdir(FILE); + +$i=0; +foreach(@FILES) + { + $size1 = 0; + $size2 = 0; + + if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) + { + + $size1 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size1\n";} + sleep(1); + $size2 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size2\n\n";} + + + if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) + { + $INfile = $FILES[$i]; + $OUTfile = $FILES[$i]; + $OUTfile =~ s/-in\.wav/-out.wav/gi; + $OUTfile =~ s/-in\.gsm/-out.gsm/gi; + $ALLfile = $FILES[$i]; + $ALLfile =~ s/-in\.wav/-all.wav/gi; + $ALLfile =~ s/-in\.gsm/-all.gsm/gi; + + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + + `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`; + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + if (!$T) + { + `mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`; + `mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`; + `mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; + } + } + } + $i++; + } + +if ($v) {print "DONE... EXITING\n\n";} + +exit; diff --git a/agc_2-X/trunk/AST_CRON_mix_recordings_GSM.pl b/agc_2-X/trunk/AST_CRON_mix_recordings_GSM.pl new file mode 100644 index 00000000..02c5ef63 --- /dev/null +++ b/agc_2-X/trunk/AST_CRON_mix_recordings_GSM.pl @@ -0,0 +1,151 @@ +#!/usr/bin/perl +# +# AST_CRON_mix_recordings_GSM.pl +# runs every 5 minutes and mixes the call recordings in the monitor together +# and puts the resulting ALL file into the DONE directory in the "monitor" dir +# and converts the ALL file to GSM format to save space. +# +# soxmix is REQUIRED to use this script, soxmix is available only as part of +# the sox audio package, and only in newer versions. Make sure you have soxmix +# installed properly and in your path +# +# put an entry into the cron of of your asterisk machine to run this script +# every 5 minutes or however often you desire +# +# make sure that the following directories exist: +# /var/spool/asterisk/monitor # default Asterisk recording directory +# /var/spool/asterisk/monitor/DONE # where the combined files are put +# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put +# +# This program assumes that recordings are saved as .wav +# should be easy to change this code if you use .gsm instead +# +# This program also sends the ALL combined file to an FTP server for archival +# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the +# file transfer section of the code to deactivate remote copying of the +# recording files +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 51021-1058 Added quotes around CLI executed commands +# 51122-1455 Added soxmix and sox binary path check +# + + +#$v=1; + +# Customize variables for FTP +$FTP_host = '10.0.0.4'; +$FTP_user = 'cron'; +$FTP_pass = 'test'; +$FTP_dir = 'RECORDINGS'; +$FTP_port = '21'; + +### directory where in/out recordings are saved to by Asterisk +$dir1 = '/var/spool/asterisk/monitor'; + +$soxmixbin = ''; +if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} +else + { + if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} + else + { + print "Can't find soxmix binary! Exiting...\n"; + exit; + } + } +$soxbin = ''; +if ( -e ('/usr/bin/sox')) {$soxbin = '/usr/bin/sox';} +else + { + if ( -e ('/usr/local/bin/sox')) {$soxbin = '/usr/local/bin/sox';} + else + { + print "Can't find sox binary! Exiting...\n"; + exit; + } + } + +use Net::Ping; +use Net::FTP; + + + opendir(FILE, "$dir1/"); + @FILES = readdir(FILE); + +$i=0; +foreach(@FILES) + { + $size1 = 0; + $size2 = 0; + + if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) + { + + $size1 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size1\n";} + sleep(1); + $size2 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size2\n\n";} + + + if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) + { + $INfile = $FILES[$i]; + $OUTfile = $FILES[$i]; + $OUTfile =~ s/-in\.wav/-out.wav/gi; + $ALLfile = $FILES[$i]; + $ALLfile =~ s/-in\.wav/-all.wav/gi; + $GSMfile = $ALLfile; + $GSMfile =~ s/-all\.wav/-all.gsm/gi; + + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + + `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`; + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + if (!$T) + { + `mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`; + `mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`; + `mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; + } + else + { + `cp -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; + } + + `$soxbin "$dir1/DONE/$ALLfile" "$dir1/DONE/$GSMfile"`; + + if (!$T) + { + `rm -f "$dir1/DONE/$ALLfile"`; + } + + if($DB){print STDERR "\n|/usr/bin/sox $live_folder/$filename[$k]$WAV $arch_folder/$filename[$k]$GSM|\n";} + chmod 0755, "$dir1/DONE/$GSMfile"; + + ### BEGIN Remote file transfer + # $p = Net::Ping->new(); + # $ping_good = $p->ping("$FTP_host"); + + # if ($ping_good) + # { + $ftp = Net::FTP->new("$FTP_host", Port => $FTP_port, Debug => 0, Passive => 1); + $ftp->login("$FTP_user","$FTP_pass"); + $ftp->cwd("$FTP_dir"); + $ftp->binary(); + $ftp->put("$dir1/DONE/$GSMfile", "$GSMfile"); + $ftp->quit; + # } + ### END Remote file transfer + + } + } + $i++; + } + +if ($v) {print "DONE... EXITING\n\n";} + +exit; diff --git a/agc_2-X/trunk/AST_CRON_mix_recordings_MP3.pl b/agc_2-X/trunk/AST_CRON_mix_recordings_MP3.pl new file mode 100644 index 00000000..2133f485 --- /dev/null +++ b/agc_2-X/trunk/AST_CRON_mix_recordings_MP3.pl @@ -0,0 +1,152 @@ +#!/usr/bin/perl +# +# AST_CRON_mix_recordings_MP3.pl +# runs every 5 minutes and mixes the call recordings in the monitor together +# and puts the resulting ALL file into the DONE directory in the "monitor" dir +# and converts the ALL file to GSM format to save space. +# +# soxmix is REQUIRED to use this script, soxmix is available only as part of +# the sox audio package, and only in newer versions. Make sure you have soxmix +# installed properly and in your path +# +# put an entry into the cron of of your asterisk machine to run this script +# every 5 minutes or however often you desire +# +# make sure that the following directories exist: +# /var/spool/asterisk/monitor # default Asterisk recording directory +# /var/spool/asterisk/monitor/DONE # where the combined files are put +# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put +# +# This program assumes that recordings are saved as .wav +# should be easy to change this code if you use .gsm instead +# +# This program also sends the ALL combined file to an FTP server for archival +# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the +# file transfer section of the code to deactivate remote copying of the +# recording files +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# Contributions by Mike Lord +# +# 51021-1058 - Added quotes around CLI executed commands +# 51122-1455 - Added soxmix and sox binary path check +# 60616-1027 - Modified to convert to MP3 format +# + + +#$v=1; + +# Customize variables for FTP +$FTP_host = '10.0.0.4'; +$FTP_user = 'cron'; +$FTP_pass = 'test'; +$FTP_dir = 'recordings'; +$FTP_port = '21'; + +### directory where in/out recordings are saved to by Asterisk +$dir1 = '/var/spool/asterisk/monitor'; + +$soxmixbin = ''; +if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} +else + { + if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} + else + { + print "Can't find soxmix binary! Exiting...\n"; + exit; + } + } +$lamebin = ''; +if ( -e ('/usr/bin/lame')) {$lamebin = '/usr/bin/lame';} +else + { + if ( -e ('/usr/local/bin/lame')) {$lamebin = '/usr/local/bin/lame';} + else + { + print "Can't find lame binary! Exiting...\n"; + exit; + } + } + +use Net::Ping; +use Net::FTP; + + + opendir(FILE, "$dir1/"); + @FILES = readdir(FILE); + +$i=0; +foreach(@FILES) + { + $size1 = 0; + $size2 = 0; + + if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) + { + + $size1 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size1\n";} + sleep(1); + $size2 = (-s "$dir1/$FILES[$i]"); + if ($v) {print "$FILES[$i] $size2\n\n";} + + + if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) + { + $INfile = $FILES[$i]; + $OUTfile = $FILES[$i]; + $OUTfile =~ s/-in\.wav/-out.wav/gi; + $ALLfile = $FILES[$i]; + $ALLfile =~ s/-in\.wav/-all.wav/gi; + $MP3file = $ALLfile; + $MP3file =~ s/-all\.wav/-all.mp3/gi; + + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + + `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`; + if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} + if (!$T) + { + `mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`; + `mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`; + `mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; + } + else + { + `cp -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; + } + + `$lamebin -b 16 -m m --silent "$dir1/DONE/$ALLfile" "$dir1/DONE/$MP3file"`; + + if (!$T) + { + `rm -f "$dir1/DONE/$ALLfile"`; + } + + if($DB){print STDERR "\n|/usr/bin/sox $live_folder/$filename[$k]$WAV $arch_folder/$filename[$k]$GSM|\n";} + chmod 0755, "$dir1/DONE/$MP3file"; + + ### BEGIN Remote file transfer + # $p = Net::Ping->new(); + # $ping_good = $p->ping("$FTP_host"); + + # if ($ping_good) + # { + $ftp = Net::FTP->new("$FTP_host", Port => $FTP_port, Debug => 0, Passive => 1); + $ftp->login("$FTP_user","$FTP_pass"); + $ftp->cwd("$FTP_dir"); + $ftp->binary(); + $ftp->put("$dir1/DONE/$MP3file", "$MP3file"); + $ftp->quit; + # } + ### END Remote file transfer + + } + } + $i++; + } + +if ($v) {print "DONE... EXITING\n\n";} + +exit; diff --git a/agc_2-X/trunk/AST_DB_optimize.pl b/agc_2-X/trunk/AST_DB_optimize.pl new file mode 100644 index 00000000..2c1aabf2 --- /dev/null +++ b/agc_2-X/trunk/AST_DB_optimize.pl @@ -0,0 +1,153 @@ +#!/usr/bin/perl +# +# AST_DB_optimize.pl version 0.1 +# +# DESCRIPTION: +# optimizes the tables used in the asterisk MySQL database +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use Net::MySQL; + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + + + $stmtA = "optimize table call_log;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table park_log;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_log;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_closer_log;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_xfer_log;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_list;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_manager;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_auto_calls;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + $stmtA = "optimize table vicidial_live_agents;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + if ($DB) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + + + $dbhA->close; + + +exit; + + + + + + diff --git a/agc_2-X/trunk/AST_SERVER_conf.pl b/agc_2-X/trunk/AST_SERVER_conf.pl new file mode 100644 index 00000000..ba87cee3 --- /dev/null +++ b/agc_2-X/trunk/AST_SERVER_conf.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl + +# AST_SERVER_conf.pl +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +# Customized Variables +$server_ip = '10.10.10.15'; # Asterisk server IP +$DB_server = 'localhost'; # MySQL server IP +$DB_database = 'asterisk'; # MySQL database name +$DB_user = 'cron'; # MySQL user +$DB_pass = '1234'; # MySQL pass +$DB_port = '3306'; # MySQL connection port + +$LOGfile = '/home/cron/LOG_AST_update.log'; +$telnetlog = '/home/cron/telnetlog.log'; +$MSLOGfile = '/home/cron/MSLOG_AST_update.log'; +$MStelnetlog = '/home/cron/MStelnetlog.log'; +$LILOGfile = '/home/cron/LILOG_AST_update.log'; +$LItelnetlog = '/home/cron/LItelnetlog.log'; +$KHLOGfile = '/home/cron/KHLOG_AST_update.log'; +$VDADLOGfile = '/home/cron/VDLOG_AST_update.log'; + +return 1; diff --git a/agc_2-X/trunk/AST_VDauto_dial.pl b/agc_2-X/trunk/AST_VDauto_dial.pl new file mode 100644 index 00000000..aeec29e0 --- /dev/null +++ b/agc_2-X/trunk/AST_VDauto_dial.pl @@ -0,0 +1,887 @@ +#!/usr/bin/perl +# +# AST_VDauto_dial.pl version 0.11 +# +# DESCRIPTION: +# uses Net::MySQL to place auto_dial calls on the VICIDIAL dialer system +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with VICIDIAL +# +# For the client to use VICIDIAL, this program must be in the cron constantly +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# It is recommended that you run this program on the local Asterisk machine +# +# This script is to run perpetually querying every second to place new phone +# calls from the vicidial_hopper based upon how many available agents there are +# and the value of the auto_dial_level setting in the campaign screen of the +# admin web page +# +# It is good practice to keep this program running by placing the associated +# KEEPALIVE script running every minute to ensure this program is always running +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 50125-1201 - Changed dial timeout to 120 seconds from 180 seconds +# 50317-0954 - Added duplicate check per cycle to account for DB lockups +# 50322-1302 - Added campaign custom callerid feature +# 50324-1353 - Added optional variable to record ring time thru separate diap prefix +# 50606-2308 - Added code to ensure no calls placed out on inactive campaign +# 50617-1248 - Added code to place LOGOUT entry in auto-paused user logs +# 50620-1349 - Added custom vdad transfer AGI extension per campaign +# 50810-1610 - Added database server variable definitions lookup +# 50810-1630 - Added max_vicidial_trunks server limiter on active lines +# 50812-0957 - corrected max_trunks logic, added update of server every 25 sec +# 60120-1522 - corrected time error for hour variable, caused agi problems +# 60427-1223 - Fixed Blended in/out CLOSER campaign issue +# 60608-1134 - Altered vac table field of call_type for IN OUT distinction +# 60612-1324 - Altered dead call section to accept BUSY detection from VD_hangup +# - Altered dead call section to accept DISCONNECT detection from VD_hangup +# 60614-1142 - Added code to work with recycled leads, multi called_since_last_reset values +# - Removed gmt lead validation because it is already done by VDhopper +# + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $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); + $loop_delay = $data_in[1]; + print " LOOP DELAY OVERRIDE!!!!! = $loop_delay seconds\n\n"; + $loop_delay = ($loop_delay * 1000); + } + else + { + $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 + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +print "no command line options set\n"; + $loop_delay = '2500'; + $DB=1; +} +### end parsing run-time options ### + + +# constants +$US='__'; +$MT[0]=''; +$RECcount=''; ### leave blank for no REC count +$RECprefix='7'; ### leave blank for no REC prefix + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + + &get_time_now; # update time/date variables + + $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; + &event_logger; # writes to the log and if debug flag is set prints to STDOUT + +use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; + + ### connect to MySQL database defined in the AST_SERVER_conf.pl file + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### 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 FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEupdate = "$record->[4]"; + $DBASTmgrUSERNAMElisten = "$record->[5]"; + $DBASTmgrUSERNAMEsend = "$record->[6]"; + $DBmax_vicidial_trunks = "$record->[7]"; + $DBanswer_transfer_agent= "$record->[8]"; + $DBSERVER_GMT = "$record->[9]"; + $DBext_context = "$record->[10]"; + 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;} + if ($DBmax_vicidial_trunks) {$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;} + } + } + + + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + +$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 + + while($endless_loop > 0) + { + &get_time_now; + + ############################################################################### + ###### first figure out how many calls should be placed for each campaign per server + ############################################################################### + @DBlive_user=@MT; + @DBlive_server_ip=@MT; + @DBlive_campaign=@MT; + @DBlive_conf_exten=@MT; + @DBcampaigns=@MT; + @DBIPaddress=@MT; + @DBIPcampaign=@MT; + @DBIPactive=@MT; + @DBIPvdadexten=@MT; + @DBIPcount=@MT; + @DBIPadlevel=@MT; + @DBIPdialtimeout=@MT; + @DBIPdialprefix=@MT; + @DBIPcampaigncid=@MT; + @DBIPexistcalls=@MT; + @DBIPgoalcalls=@MT; + @DBIPmakecalls=@MT; + @DBIPclosercamp=@MT; + + $active_line_counter=0; + $user_counter=0; + $user_campaigns = '|'; + $user_campaigns_counter = 0; + $user_campaignIP = '|'; + $user_CIPct = 0; + + ##### Get a listing of the users that are active and ready to take calls + ##### Also get a listing of the campaigns and campaigns/serverIP that will be used + $dbhA->query("SELECT user,server_ip,campaign_id,conf_exten FROM vicidial_live_agents where status IN('READY','QUEUE','INCALL','DONE') and server_ip='$server_ip' and last_update_time > '$BDtsSQLdate' order by last_call_time"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBlive_user[$user_counter] = "$record->[0]"; + $DBlive_server_ip[$user_counter] = "$record->[1]"; + $DBlive_campaign[$user_counter] = "$record->[2]"; + $DBlive_conf_exten[$user_counter] = "$record->[3]"; + + if ($user_campaigns !~ /\|$DBlive_campaign[$user_counter]\|/i) + { + $user_campaigns .= "$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++; + } + } + + $event_string="LIVE AGENTS LOGGED IN: $user_counter"; + &event_logger; + + $user_CIPct = 0; + foreach(@DBIPcampaign) + { + $user_counter=0; + foreach(@DBlive_campaign) + { + if ( ($DBlive_campaign[$user_counter] =~ /$DBIPcampaign[$user_CIPct]/i) && ($DBlive_server_ip[$user_counter] =~ /$DBIPaddress[$user_CIPct]/i) ) + { + $DBIPcount[$user_CIPct]++ + } + $user_counter++; + } + + ### grab the dial_level and multiply by active agents to get your goalcalls + $DBIPadlevel[$user_CIPct]=0; + $dbhA->query("SELECT auto_dial_level,local_call_time,dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,closer_campaigns FROM vicidial_campaigns where campaign_id='$DBIPcampaign[$user_CIPct]'"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBIPadlevel[$user_CIPct] = "$record->[0]"; + $DBIPcalltime[$user_CIPct] = "$record->[1]"; + $DBIPdialtimeout[$user_CIPct] = "$record->[2]"; + $DBIPdialprefix[$user_CIPct] = "$record->[3]"; + $DBIPcampaigncid[$user_CIPct] = "$record->[4]"; + $DBIPactive[$user_CIPct] = "$record->[5]"; + $DBIPvdadexten[$user_CIPct] = "$record->[6]"; + $DBIPclosercamp[$user_CIPct] = "$record->[7]"; + } + } + + $DBIPgoalcalls[$user_CIPct] = ($DBIPadlevel[$user_CIPct] * $DBIPcount[$user_CIPct]); + if ($DBIPactive[$user_CIPct] =~ /N/) {$DBIPgoalcalls[$user_CIPct] = 0;} + $DBIPgoalcalls[$user_CIPct] = sprintf("%.0f", $DBIPgoalcalls[$user_CIPct]); + + $event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: agents: $DBIPcount[$user_CIPct] dial_level: $DBIPadlevel[$user_CIPct]"; + &event_logger; + + $active_line_counter=0; + $active_line_goal=0; + ### see how many total VDAD calls are going on right now for max limiter + $dbhA->query("SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER');"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $active_line_counter = "$record->[0]"; + } + } + + ### see how many calls are alrady active per campaign per server and + ### subtract that number from goalcalls to determine how many new + ### calls need to be placed in this loop + if ($DBIPcampaign[$user_CIPct] =~ /CLOSER/) + { + 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]=''} + + $campaign_query = "( (call_type='IN' and campaign_id IN($DBIPclosercamp[$user_CIPct])) or (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type='OUT') )"; + } + else {$campaign_query = "(campaign_id='$DBIPcampaign[$user_CIPct]' and call_type='OUT')";} + $dbhA->query("SELECT count(*) FROM vicidial_auto_calls where $campaign_query and server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER','CLOSER');"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBIPexistcalls[$user_CIPct] = "$record->[0]"; + } + } + + $DBIPmakecalls[$user_CIPct] = ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]); + $MVT_msg = ''; + $active_line_goal = ($active_line_counter + $DBIPmakecalls[$user_CIPct]); + if ($active_line_goal > $max_vicidial_trunks) + { + $MVT_msg = "MVT override: $max_vicidial_trunks"; + $DBIPmakecalls[$user_CIPct] = ($max_vicidial_trunks - $active_line_counter); + } + $event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]) $MVT_msg"; + &event_logger; + + $user_CIPct++; + } + + ############################################################################### + ###### second lookup leads and place calls for each campaign/server_ip + ###### go one lead at a time and place the call by inserting a record into vicidial_manager + ############################################################################### + + $user_CIPct = 0; + foreach(@DBIPcampaign) + { + $event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: CALLING"; + &event_logger; + $call_CMPIPct=0; + $lead_id_call_list='|'; + my $UDaffected_rows=0; + if ($call_CMPIPct < $DBIPmakecalls[$user_CIPct]) + { + $stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$server_ip' where campaign_id='$DBIPcampaign[$user_CIPct]' and status='READY' order by hopper_id LIMIT $DBIPmakecalls[$user_CIPct]"; + print "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $UDaffected_rows = $dbhA->get_affected_rows_length; + 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 FROM vicidial_hopper where campaign_id='$DBIPcampaign[$user_CIPct]' and status='QUEUE' and user='VDAD_$server_ip' LIMIT 1"; + print "|$stmtA|\n"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $lead_id = "$record->[0]"; + } + } + + if ($lead_id_call_list =~ /\|$lead_id\|/) + { + print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n"; + open(DUPout, ">>/home/cron/VDAD_DUPLICATE.$file_date") + || die "Can't open /home/cron/VDAD_DUPLICATE.$file_date: $!\n"; + print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n"; + close(DUPout); + } + else + { + $stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'"; + print "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $UQaffected_rows = $dbhA->get_affected_rows_length; + print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n"; + + $stmtA = "SELECT * FROM vicidial_list where lead_id='$lead_id';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $gmt_offset_now = "$record->[8]"; + $called_since_last_reset = "$record->[9]"; + $phone_code = "$record->[10]"; + $phone_number = "$record->[11]"; + $called_count = "$record->[30]"; + + $rec_countCUSTDATA++; + } + } + + if ($rec_countCUSTDATA) + { + ### update called_count + $called_count++; + if ($called_since_last_reset =~ /^Y/) + { + if ($called_since_last_reset =~ /^Y$/) {$CSLR = 'Y1';} + else + { + $called_since_last_reset =~ s/^Y//gi; + $called_since_last_reset++; + $CSLR = "Y$called_since_last_reset"; + } + } + else {$CSLR = 'Y';} + + $stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD' where lead_id='$lead_id'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + 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 ($RECcount) + { + if ( (length($RECprefix)>0) && ($called_count < $RECcount) ) + {$Local_out_prefix .= "$RECprefix";} + } + $PADlead_id = sprintf("%09s", $lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + + $lead_id_call_list .= "$lead_id|"; + + ### use manager middleware-app to connect the next call to the meetme room + # VmmddhhmmssLLLLLLLLL + $VqueryCID = "V$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";} + else {$CIDstring = "$VqueryCID";} + + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DBIPaddress[$user_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')"; + $dbhA->query($stmtA); + + $event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|"; + &event_logger; + + ### insert a SENT record to the vicidial_auto_calls table + $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$DBIPaddress[$user_CIPct]','$DBIPcampaign[$user_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT')"; + $dbhA->query($stmtA); + + ### sleep for a tenth of a second to not flood the server with new calls + usleep(1*100*1000); + + } + } + $call_CMPIPct++; + } + } + + } + + $user_CIPct++; + } + + + + + + + + &get_time_now; + + ############################################################################### + ###### third we will grab the callerids of the vicidial_auto_calls records and check for dead calls + ###### we also check to make sure that it isn't a call that has been transferred, + ###### if it has been we need to leave the vicidial_list status alone + ############################################################################### + + @KLcallerid = @MT; + @KLserver_ip = @MT; + @KLchannel = @MT; + $kill_vac=0; + + $stmtA = "SELECT callerid,server_ip,channel,uniqueid FROM vicidial_auto_calls where server_ip='$server_ip' order by call_time;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $KLcallerid[$kill_vac] = "$record->[0]"; + $KLserver_ip[$kill_vac] = "$record->[1]"; + $KLchannel[$kill_vac] = "$record->[2]"; + $KLuniqueid[$kill_vac] = "$record->[3]"; + + $kill_vac++; + } + } + + $kill_vac=0; + foreach(@KLcallerid) + { + if (length($KLserver_ip[$kill_vac]) > 7) + { + $end_epoch=0; $CLuniqueid=''; + + $stmtA = "SELECT end_epoch,uniqueid FROM call_log where caller_code='$KLcallerid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, start_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $end_epoch = "$record->[0]"; + $CLuniqueid = "$record->[1]"; + } + } + + if ( (length($KLuniqueid[$kill_vac]) > 15) && (length($CLuniqueid) < 15) ) + { + $stmtA = "SELECT end_epoch,uniqueid FROM call_log where uniqueid='$KLuniqueid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, start_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $end_epoch = "$record->[0]"; + $CLuniqueid = "$record->[1]"; + } + } + } + if ($end_epoch > 1000) + { + $CLlead_id=''; $auto_call_id=''; $CLstatus=''; $CLcampaign_id=''; $CLphone_number=''; $CLphone_code=''; + + $stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]'"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $auto_call_id = "$record->[0]"; + $CLlead_id = "$record->[1]"; + $CLphone_number = "$record->[2]"; + $CLstatus = "$record->[3]"; + $CLcampaign_id = "$record->[4]"; + $CLphone_code = "$record->[5]"; + } + } + $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; + # $stmtA = "UPDATE vicidial_auto_calls set status='PAUSED' where callerid='$KLcallerid[$kill_vac]'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|"; + &event_logger; + + if ($CLstatus !~ /XFER|CLOSER/) + { + if ($CLstatus =~ /BUSY/) {$CLnew_status = 'B';} + else + { + if ($CLstatus =~ /DISCONNECT/) {$CLnew_status = 'DC';} + else {$CLnew_status = 'NA';} + } + if ($CLstatus =~ /LIVE/) {$CLnew_status = 'DROP';} + else + { + $end_epoch = ($now_date_epoch + 1); + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','1','$end_epoch')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + $event_string = "| dead NA call added to log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|"; + &event_logger; + + } + + $stmtA = "UPDATE vicidial_list set status='$CLnew_status' where lead_id='$CLlead_id'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| dead call vac lead marked $CLnew_status|$CLlead_id|$CLphone_number|$CLstatus|"; + &event_logger; + + $stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where callerid='$KLcallerid[$kill_vac]';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| dead call vla agent PAUSED $affected_rows|$CLlead_id|$CLphone_number|$CLstatus|"; + &event_logger; + } + else + { + $event_string = "| dead call vac XFERd do nothing|$CLlead_id|$CLphone_number|$CLstatus|"; + &event_logger; + } + } + } + $kill_vac++; + } + + + + ### pause agents that have disconnected or closed their apps over 30 seconds ago + $stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where server_ip='$server_ip' and last_update_time < '$PDtsSQLdate' and status NOT IN('PAUSED')"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| lagged call vla agent PAUSED $affected_rows|$PDtsSQLdate|$BDtsSQLdate|$tsSQLdate|"; + &event_logger; + + if ($affected_rows > 0) + { + @VALOuser=@MT; @VALOcampaign=@MT; @VALOtimelog=@MT; @VALOextension=@MT; + $logcount=0; + $stmtA = "SELECT user,campaign_id,last_update_time,extension FROM vicidial_live_agents where server_ip='$server_ip' and status = 'PAUSED' and random_id='10' order by last_update_time desc limit $affected_rows"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VALOuser[$logcount] = "$record->[0]"; + $VALOcampaign[$logcount] = "$record->[1]"; + $VALOtimelog[$logcount] = "$record->[2]"; + $VALOextension[$logcount] = "$record->[3]"; + $logcount++; + } + } + $logrun=0; + foreach(@VALOuser) + { + $stmtA = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch) values('$VALOuser[$logrun]','LOGOUT','$VALOcampaign[$logrun]','$SQLdate','$now_date_epoch');"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| lagged agent LOGOUT entry inserted $VALOuser[$logrun]|$VALOcampaign[$logrun]|$VALOextension[$logcount]|"; + &event_logger; + + $logrun++; + } + + } + + + ### delete call records that are SENT for over 3 minutes + $stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$XDSQLdate' and status NOT IN('XFER','CLOSER','LIVE')"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| lagged call vac agent DELETED $affected_rows|$XDSQLdate|"; + &event_logger; + + + + + + ############################################################################### + ###### last, wait for a little bit and repeat the loop + ############################################################################### + + ### sleep for 2 and a half seconds before beginning the loop again + usleep(1*$loop_delay*1000); + + $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 + if (-e '/home/cron/VDAD.kill') + { + unlink('/home/cron/VDAD.kill'); + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n" + } + if ($endless_loop =~ /0$/) # run every ten cycles (about 25 seconds) + { + ### delete call records that are LIVE for over 10 minutes + $stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$TDSQLdate' and status NOT IN('XFER','CLOSER')"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| lagged call vac agent DELETED $affected_rows|$TDSQLdate|LIVE|"; + &event_logger; + + ### Grab Server values from the database in case they've changed + $stmtA = "SELECT max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBmax_vicidial_trunks = "$record->[0]"; + $DBanswer_transfer_agent= "$record->[1]"; + $DBSERVER_GMT = "$record->[2]"; + $DBext_context = "$record->[3]"; + if ($DBmax_vicidial_trunks) {$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;} + } + } + + $event_string = "| updating server parameters $max_vicidial_trunks|$answer_transfer_agent|$SERVER_GMT|$ext_context|"; + &event_logger; + + &get_time_now; + + #@psoutput = `/bin/ps -f --no-headers -A`; + @psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + + $running_listen = 0; + + $i=0; + foreach (@psoutput) + { + chomp($psoutput[$i]); + + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + + if ($psline[1] =~ /AST_manager_li/) {$running_listen++;} + + $i++; + } + + if (!$running_listen) + { + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED NO LISTENER RUNNING... EXITING\n\n"; + } + + if($DB){print "checking to see if listener is dead |$running_listen|\n";} + } + + $bad_grabber_counter=0; + + + } + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} + + $event_string='HANGING UP|'; + &event_logger; + + $one_day_interval--; + +} + + $event_string='CLOSING DB CONNECTION|'; + &event_logger; + + + $dbhA->close; + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} + + +exit; + + + + + + + + + + + + + +sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes +{ +$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)); + ($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";} + +$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";} + $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";} + $PDtsSQLdate = "$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";} + $XDSQLdate = "$Xyear-$Xmon-$Xmday $Xhour:$Xmin:$Xsec"; + +$TDtarget = ($secX - 600); +($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";} + ### 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=''; +} diff --git a/agc_2-X/trunk/AST_VDhopper.pl b/agc_2-X/trunk/AST_VDhopper.pl new file mode 100644 index 00000000..ab55395c --- /dev/null +++ b/agc_2-X/trunk/AST_VDhopper.pl @@ -0,0 +1,1192 @@ +#!/usr/bin/perl +# +# AST_VDhopper.pl version 0.9 +# +# DESCRIPTION: +# uses Net::MySQL to update the VICIDIAL leads hopper for the new streamlined +# approach of allocating leads to client machines. +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with VICIDIAL +# +# For the client to use VICIDIAL, this program must be in the cron running +# every minute +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# It is recommended that you run this program on the local Asterisk machine +# +# If this script is run ever minute and you are getting close to no leads after +# a minute, you may want to play with the variables below to streamline for +# your usage +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50810-1613 - Added database server variable definitions lookup +# 60215-1106 - Added Scheduled Callback release functionality +# 60228-1623 - Change Callback activation to set the called_since_last_reset=N +# 60228-1735 - Added hopper gmt validation to remove gmt outside of time range +# 60320-0932 - Added inactive lead list hopper deletion (Thanks Vic Jolin) +# 60322-1030 - Added super debug output +# 60418-0947 - Added lead filter per campaign +# 60509-1416 - Rewrite of local_call_time functions +# 60511-1150 - Added inserts into vicidial_campaign_stats table +# 60609-1451 - Added ability to filter by DNC list vicidial_dnc +# 60614-1159 - Added campaign lead recycling ability +# + +# constants +$DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute +$US='__'; +$MT[0]=''; +#$vicidial_hopper='TEST_vicidial_hopper'; # for testing +$vicidial_hopper='vicidial_hopper'; + +# options +$insert_auto_CB_to_hopper = 1; # set to 1 to automatically insert ANYONE callbacks into the hopper + + +($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) {$Fhour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$now_date = "$year-$mon-$mday $hour:$min:$sec"; +$VDL_date = "$year-$mon-$mday 00:00:01"; + +if (!$VDHLOGfile) {$VDHLOGfile = "/home/cron/hopper.$year-$mon-$mday";} + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [--dbgmt] = show GMT offset of records as they are inserted into hopper\n [-t] = test\n [--level=XXX] = force a hopper_level of XXX\n [--campaign=XXX] = run for campaign XXX only\n\n"; + } + else + { + if ($args =~ /--campaign=/i) + { + # print "\n|$ARGS|\n\n"; + @data_in = split(/--campaign=/,$args); + $CLIcampaign = $data_in[1]; + } + else + {$CLIcampaign = '';} + if ($args =~ /--level=/i) + { + @data_in = split(/--level=/,$args); + $CLIlevel = $data_in[1]; + $CLIlevel =~ s/ .*$//gi; + $CLIlevel =~ s/\D//gi; + print "\n-----HOPPER LEVEL OVERRIDE: $CLIlevel -----\n\n"; + } + else + {$CLIlevel = '';} + if ($args =~ /--debug/i) + { + $DB=1; + print "\n----- DEBUG -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER DEBUG -----\n\n"; + } + if ($args =~ /--dbgmt/i) + { + $DB_show_offset=1; + print "\n-----DEBUG GMT -----\n\n"; + } + if ($args =~ /-t/i) + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } + if ($args =~ /--wipe-hopper-clean/i) + { + $wipe_hopper_clean=1; + } + } +} +else +{ +print "no command line options set\n"; +} + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +sleep(1); ### sleep for 5 seconds to stagger cron script load + +#use lib './lib', '../lib'; +use Net::MySQL; + + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + +$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)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now); + $mon++; + $year = ($year + 1900); + 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";} + + + if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} + +if ($wipe_hopper_clean) + { + $stmtA = "DELETE from $vicidial_hopper;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print "Hopper Wiped Clean: $affected_rows\n";} + $event_string = "|HOPPER WIPE CLEAN|"; + &event_logger; + + exit; + } + +### Delete leads from inactive lists if there are any +$stmtA = "SELECT * FROM vicidial_lists where active='N';"; +if ($DB) {print $stmtA;} +$inactive_lists=''; +$inactive_lists_count=0; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $inactive_list = $record->[0]; + $inactive_lists .= "'$inactive_list',"; + $inactive_lists_count++; + } + } +if ($DB) {print "Inactive Lists: $inactive_lists_count\n";} + +if ($inactive_lists_count > 0) + { + chop($inactive_lists); + $stmtA = "DELETE from $vicidial_hopper where list_id IN($inactive_lists);"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print "Inactive List Leads Deleted: $affected_rows |$stmtA|\n";} + $event_string = "|INACTIVE LIST DEL|$affected_rows|"; + &event_logger; + } + + +### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed +$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $CBHOLD_count = "$record->[0]"; + } + } + + if ($DB) {print "CALLBACK HOLD: $CBHOLD_count|$stmtA|\n";} + +if ($CBHOLD_count > 0) + { + $update_leads=''; + $stmtA = "SELECT vicidial_callbacks.lead_id,recipient,campaign_id,vicidial_callbacks.list_id,gmt_offset_now FROM vicidial_callbacks,vicidial_list where callback_time <= '$now_date' and vicidial_callbacks.status='ACTIVE' and vicidial_callbacks.lead_id=vicidial_list.lead_id;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $cbc=0; + $cba=0; + while ( $record = $iter->each) + { + $lead_ids[$cbc] = $record->[0]; + $recipient = $record->[1]; + $update_leads .= "'$lead_ids[$cbc]',"; + if ($recipient == 'ANYONE') + { + $CA_lead_id[$cba] = $record->[0]; + $CA_campaign_id[$cba] = $record->[2]; + $CA_list_id[$cba] = $record->[3]; + $CA_gmt_offset_now[$cba] = $record->[4]; + $cba++; + } + $cbc++; + } + } + if ($cbc > 0) + { + chop($update_leads); + + $stmtA = "UPDATE vicidial_list set status='CALLBK', called_since_last_reset='N' where lead_id IN($update_leads);"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print "Scheduled Callbacks Activated: $affected_rows\n";} + $event_string = "|CALLBACKS LISTACT|$affected_rows|"; + &event_logger; + + $stmtA = "UPDATE vicidial_callbacks set status='LIVE' where lead_id IN($update_leads);"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print "Scheduled Callbacks Activated: $affected_rows\n";} + $event_string = "|CALLBACKS CB ACT |$affected_rows|"; + &event_logger; + + } + ### INSERT ANYONE CALLBACKS INTO HOPPER DIRECTLY ### + if ( ($cba > 0) && ($insert_auto_CB_to_hopper) ) + { + if ($DB) {print "ANYONE Scheduled Callbacks Inserted into hopper: $cba\n";} + $event_string = "|ANYONE CB HOPPER |$cba|"; + &event_logger; + $CAu=0; + foreach(@CA_lead_id) + { + $stmtA = "INSERT INTO $vicidial_hopper SET lead_id='$CA_lead_id[$CAu]',campaign_id='$CA_campaign_id[$CAu]',list_id='$CA_list_id[$CAu]',gmt_offset_now='$CA_gmt_offset_now[$CAu]';"; + $dbhA->query("$stmtA"); + $CAu++; + } + } + } +### END Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed + + + +@campaign_id=@MT; + +if ($CLIcampaign) + { + $stmtA = "SELECT * from vicidial_campaigns where campaign_id='$CLIcampaign'"; + } +else + { + $stmtA = "SELECT * from vicidial_campaigns where active='Y'"; + } + +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $campaign_id[$rec_count] = "$record->[0]"; + $dial_status_a[$rec_count] = "$record->[3]"; + $dial_status_b[$rec_count] = "$record->[4]"; + $dial_status_c[$rec_count] = "$record->[5]"; + $dial_status_d[$rec_count] = "$record->[6]"; + $dial_status_e[$rec_count] = "$record->[7]"; + $lead_order[$rec_count] = "$record->[8]"; + if (!$CLIlevel) + {$hopper_level[$rec_count] = "$record->[13]";} + else + {$hopper_level[$rec_count] = "$CLIlevel";} + $local_call_time[$rec_count] = "$record->[16]"; + $lead_filter_id[$rec_count] = "$record->[35]"; + $use_internal_dnc[$rec_count] = "$record->[43]"; + $rec_count++; + } + } + +$i=0; +foreach(@campaign_id) + { + ### close out MySQL connection and re-connect to start new connection ### +# $dbhA->close(); +# my $dbhA = ''; + + ### Make sure this file is in a libs path or put the absolute path to it +# require("/home/cron/AST_SERVER_conf.pl"); # local configuration file +# if (!$DB_port) {$DB_port='3306';} +# use Net::MySQL; + +# my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") +# or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + $VCSdialable_leads=0; + $VCScalls_today=0; + $VCSdrops_today=0; + $VCSdrops_today_pct=0; + $vicidial_log = 'vicidial_log'; + + $stmtA = "SELECT dialable_leads from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $VCSdialable_leads = "$record->[0]"; + } + } + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $VCScalls_today = "$record->[0]"; + } + } + if ($VCScalls_today > 0) + { + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $VCSdrops_today = "$record->[0]"; + if ($VCSdrops_today > 0) + { + $VCSdrops_today_pct = ( ($VCSdrops_today / $VCScalls_today) * 100 ); + $VCSdrops_today_pct = sprintf("%.2f", $VCSdrops_today_pct); + } + } + } + } + + $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today',drops_today='$VCSdrops_today',drops_today_pct='$VCSdrops_today_pct' where campaign_id='$campaign_id[$i]';"; + $dbhA->query("$stmtA"); + + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + if ($DBX) {print "\n |GMT-DAY-HOUR| ";} + while ($p > -13) + { + $pzone = ($GMT_now + ($p * 3600)); + ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); + $phour=($phour * 100); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} + $g++; + } + if ($DBX) {print "\n";} + + $stmtA = "SELECT * FROM vicidial_call_times where call_time_id='$local_call_time[$i]';"; + if ($DBX) {print " |$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $Gct_default_start = "$record->[3]"; + $Gct_default_stop = "$record->[4]"; + $Gct_sunday_start = "$record->[5]"; + $Gct_sunday_stop = "$record->[6]"; + $Gct_monday_start = "$record->[7]"; + $Gct_monday_stop = "$record->[8]"; + $Gct_tuesday_start = "$record->[9]"; + $Gct_tuesday_stop = "$record->[10]"; + $Gct_wednesday_start = "$record->[11]"; + $Gct_wednesday_stop = "$record->[12]"; + $Gct_thursday_start = "$record->[13]"; + $Gct_thursday_stop = "$record->[14]"; + $Gct_friday_start = "$record->[15]"; + $Gct_friday_stop = "$record->[16]"; + $Gct_saturday_start = "$record->[17]"; + $Gct_saturday_stop = "$record->[18]"; + $Gct_state_call_times = "$record->[19]"; + } + } + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $del_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (length($Gct_state_call_times)>2) + { + @state_rules = split(/\|/,$Gct_state_call_times); + $ct_srs = ($#state_rules - 2); + } + while($ct_srs >= $b) + { + if (length($state_rules[$b])>1) + { + $stmtA = "SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + if ($DBX) {print " |$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $Gstate_call_time_id = "$record->[0]"; + $Gstate_call_time_state = "$record->[1]"; + $Gsct_default_start = "$record->[4]"; + $Gsct_default_stop = "$record->[5]"; + $Gsct_sunday_start = "$record->[6]"; + $Gsct_sunday_stop = "$record->[7]"; + $Gsct_monday_start = "$record->[8]"; + $Gsct_monday_stop = "$record->[9]"; + $Gsct_tuesday_start = "$record->[10]"; + $Gsct_tuesday_stop = "$record->[11]"; + $Gsct_wednesday_start = "$record->[12]"; + $Gsct_wednesday_stop = "$record->[13]"; + $Gsct_thursday_start = "$record->[14]"; + $Gsct_thursday_stop = "$record->[15]"; + $Gsct_friday_start = "$record->[16]"; + $Gsct_friday_stop = "$record->[17]"; + $Gsct_saturday_start = "$record->[18]"; + $Gsct_saturday_stop = "$record->[19]"; + $ct_states .="'$Gstate_call_time_state',"; + } + } + + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $del_state_gmt = "$del_state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($del_state_gmt)) "; + } + + $b++; + } + if (length($ct_states)>2) + { + $ct_states =~ s/,$//gi; + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + $del_default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $del_default_gmt = "$del_default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + $del_gmtSQL = "(gmt_offset_now IN($del_default_gmt) $ct_statesSQL) $del_state_gmt_SQL"; + + ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### + + ##### BEGIN lead recycling parsing and prep ### + + $stmtA = "SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id[$i]' and active='Y';"; + $dbhA->query("$stmtA"); + $rec_ct=0; + if ($dbhA->has_selected_record) + { + @recycle_status=@MT; + @recycle_delay=@MT; + @recycle_maximum=@MT; + @RSQLdate=@MT; + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $recycle_status[$rec_ct] = $record->[2]; + $recycle_delay[$rec_ct] = $record->[3]; + $recycle_maximum[$rec_ct] = $record->[4]; + $rec_ct++; + } + } + + if ($rec_ct > 0) + { + $rc=0; + $recycle_SQL = "( "; + while($rc < $rec_ct) + { + $secX = time(); + $Rtarget = ($secX - $recycle_delay[$rc]); + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + $Y=1; + $recycle_Y = "'Y'"; + while ($Y < $recycle_maximum[$rc]) + { + $recycle_Y .= ",'Y$Y'"; + $Y++; + } + + if ($rc > 0) {$recycle_SQL .= " or ";} + + $recycle_SQL .= "( (called_since_last_reset IN($recycle_Y)) and (status='$recycle_status[$rc]') and (modify_date < \"$RSQLdate[$rc]\") )"; + + if ($DBX) {print "RECYCLE: |$campaign_id[$i]|$recycle_status[$rc]|$recycle_delay[$rc]|$recycle_maximum[$rc]|$RSQLdate[$rc]|\n";} + $rc++; + } + + $recycle_SQL .= " )"; + + if ($DBX) {print "RECYCLE SQL: |$recycle_SQL|\n";} + } + ##### END lead recycling parsing and prep ### + + if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$i] HOPPER: $hopper_level[$i] \n";} + + ### Delete the DONE leads if there are any + $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status IN('DONE');"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print " hopper DONE cleared: $affected_rows\n";} + if ($DBX) {print " |$stmtA|\n";} + + ### Delete the leads that are out of GMT time range if there are any + $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and ($del_gmtSQL);"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print " hopper GMT BAD cleared: $affected_rows\n";} + if ($DBX) {print " |$stmtA|\n";} + + ### Find out how many leads are in the hopper from a specific campaign + $hopper_ready_count=0; + $stmtA = "SELECT count(*) from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countA=0; + while ( $record = $iter->each) + { + $hopper_ready_count = $record->[0]; + if ($DB) {print " hopper READY count: $hopper_ready_count\n";} + if ($DBX) {print " |$stmtA|\n";} + $rec_countA++; + } + } + $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]||"; + &event_logger; + + ##### IF hopper level is below set minimum, then try to add more leads ##### + if ($hopper_ready_count < $hopper_level[$i]) + { + if ($DB) {print " hopper too low ($hopper_ready_count|$hopper_level[$i]) starting hopper dump\n";} + + ### Get list of the lists in the campaign ### + $stmtA = "SELECT list_id FROM vicidial_lists where campaign_id='$campaign_id[$i]' and active='Y';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countLISTS=0; + $camp_lists = ''; + while ( $record = $iter->each) + { + $camp_lists .= "'$record->[0]',"; + $rec_countLISTS++; + } + chop($camp_lists); + } + if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";} + if ($DBX) {print " |$stmtA|\n";} + + if ( ($lead_filter_id[$i] !~ /NONE/) && (length($lead_filter_id[$i])>0) ) + { + ### Get SQL of lead filter for the campaign ### + $stmtA = "SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id[$i]';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $lead_filter_sql[$i] = "$record->[0]"; + } + } + $lead_filter_sql[$i] =~ s/^and|and$|^or|or$|^ and|and $|^ or|or $//gi; + $lead_filter_sql[$i] = "and $lead_filter_sql[$i]"; + if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";} + if ($DB) {print " lead filter $lead_filter_id[$i] defined for $campaign_id[$i]\n";} + if ($DBX) {print " |$lead_filter_sql[$i]|\n";} + } + else + { + $lead_filter_sql[$i] = ''; + if ($DB) {print " no lead filter defined for campaign: $campaign_id[$i]\n";} + if ($DBX) {print " |$lead_filter_id[$i]|\n";} + } + + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and ($all_gmtSQL) $lead_filter_sql[$i];"; + if ($DBX) {print " |$stmtA|\n";} + $dbhA->query("$stmtA"); + $campaign_leads_to_call=0; + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $campaign_leads_to_call = "$record->[0]"; + if ($DB) {print " leads to call count: $campaign_leads_to_call\n";} + if ($DBX) {print " |$stmtA|\n";} + } + } + if ($lead_order[$i] =~ /DOWN COUNT 2nd NEW|DOWN COUNT 3rd NEW|DOWN COUNT 4th NEW/) + { + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and ($all_gmtSQL) $lead_filter_sql[$i];"; + $dbhA->query("$stmtA"); + $NEW_campaign_leads_to_call=0; + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $NEW_campaign_leads_to_call = "$record->[0]"; + if ($DB) {print " NEW leads to call count: $NEW_campaign_leads_to_call\n";} + if ($DBX) {print " |$stmtA|\n";} + } + } + } + + ##### IF no NEW leads to be called, error out of this campaign ##### + if ( ($lead_order[$i] =~ /DOWN COUNT 2nd NEW|DOWN COUNT 3rd NEW|DOWN COUNT 4th NEW/) && ($NEW_campaign_leads_to_call > 0) ) {$GOOD=1;} + else + { + if ($DB) {print " ERROR CANNOT ADD ANY NEW LEADS TO HOPPER\n";} + } + + ##### IF no leads to be called, error out of this campaign ##### + if ($campaign_leads_to_call < 1) + { + if ($DB) {print " ERROR CANNOT ADD ANY LEADS TO HOPPER\n";} + if ($VCSdialable_leads > 0) + { + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0' where campaign_id='$campaign_id[$i]';"; + $dbhA->query("$stmtA"); + } + } + else + { + if ($VCSdialable_leads != $campaign_leads_to_call) + { + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='$campaign_leads_to_call' where campaign_id='$campaign_id[$i]';"; + $dbhA->query("$stmtA"); + } + if ($DB) {print " Getting Leads to add to hopper\n";} + ### grab leads already in hopper so we don't duplicate + $stmtA = "SELECT lead_id FROM $vicidial_hopper where campaign_id='$campaign_id[$i]';"; + if ($DBX) {print " |$stmtA|\n";} + $dbhA->query("$stmtA"); + $rec_countLISTS=0; + $lead_id_lists = ''; + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $lead_id_lists .= "'$record->[0]',"; + $rec_countLISTS++; + } + $lead_id_lists .= "'0'"; + } + + $order_stmt=''; + $NEW_count = 0; + $NEW_level = 0; + $OTHER_level = $hopper_level[$i]; + if ($lead_order[$i] eq "DOWN") {$order_stmt = 'order by lead_id asc';} + if ($lead_order[$i] eq "UP") {$order_stmt = 'order by lead_id desc';} + if ($lead_order[$i] eq "UP LAST NAME") {$order_stmt = 'order by last_name desc, lead_id asc';} + if ($lead_order[$i] eq "DOWN LAST NAME") {$order_stmt = 'order by last_name, lead_id asc';} + if ($lead_order[$i] eq "UP PHONE") {$order_stmt = 'order by phone_number desc, lead_id asc';} + if ($lead_order[$i] eq "DOWN PHONE") {$order_stmt = 'order by phone_number, lead_id asc';} + if ($lead_order[$i] eq "UP COUNT") {$order_stmt = 'order by called_count desc, lead_id asc';} + if ($lead_order[$i] eq "DOWN COUNT") {$order_stmt = 'order by called_count, lead_id asc';} + if ($lead_order[$i] eq "DOWN COUNT 2nd NEW") {$NEW_count = 2;} + if ($lead_order[$i] eq "DOWN COUNT 3rd NEW") {$NEW_count = 3;} + if ($lead_order[$i] eq "DOWN COUNT 4th NEW") {$NEW_count = 4;} + + ### BEGIN recycle grab leads ### + if ($rec_ct > 0) + { + if ($DB) {print " looking for RECYCLE leads, maximum of 100\n";} + + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where $recycle_SQL and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] limit 100;"; + if ($DBX) {print " |$stmtA|\n";} + $REC_rec_countLEADS=0; + @REC_leads_to_hopper=@MT; + @REC_lists_to_hopper=@MT; + @REC_phone_to_hopper=@MT; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $REC_leads_to_hopper[$REC_rec_countLEADS] = "$record->[0]"; + $REC_lists_to_hopper[$REC_rec_countLEADS] = "$record->[1]"; + $REC_gmt_to_hopper[$REC_rec_countLEADS] = "$record->[2]"; + $REC_phone_to_hopper[$REC_rec_countLEADS] = "$record->[3]"; + $REC_state_to_hopper[$REC_rec_countLEADS] = "$record->[4]"; + if ($DB_show_offset) {print "LEAD_ADD: $record->[2] $record->[3] $record->[4]\n";} + $REC_rec_countLEADS++; + } + } + if ($DB) {print " RECYCLE leads to call count: $REC_rec_countLEADS\n";} + if ($DBX) {print " |$stmtA|\n";} + } + ### END recycle grab leads ### + + if ($NEW_count > 0) + { + $NEW_level = int($hopper_level[$i] / $NEW_count); + $OTHER_level = ($hopper_level[$i] - $NEW_level); + $order_stmt = 'order by called_count, lead_id asc'; + if ($DB) {print " looking for $NEW_level NEW leads mixed in with $OTHER_level other leads\n";} + + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] $order_stmt limit $NEW_level;"; + if ($DBX) {print " |$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $NEW_rec_countLEADS=0; + @NEW_leads_to_hopper=@MT; + @NEW_lists_to_hopper=@MT; + @NEW_phone_to_hopper=@MT; + while ( $record = $iter->each) + { + $NEW_leads_to_hopper[$NEW_rec_countLEADS] = "$record->[0]"; + $NEW_lists_to_hopper[$NEW_rec_countLEADS] = "$record->[1]"; + $NEW_gmt_to_hopper[$NEW_rec_countLEADS] = "$record->[2]"; + $NEW_phone_to_hopper[$NEW_rec_countLEADS] = "$record->[3]"; + $NEW_state_to_hopper[$NEW_rec_countLEADS] = "$record->[4]"; + if ($DB_show_offset) {print "LEAD_ADD: $record->[2] $record->[3] $record->[4]\n";} + $NEW_rec_countLEADS++; + } + } + + } + + if ($DB) {print " lead call order: $order_stmt\n";} + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] $order_stmt limit $OTHER_level;"; + if ($DBX) {print " |$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countLEADS=0; $NEW_dec=99; $NEW_in=0; + @leads_to_hopper=@MT; + @lists_to_hopper=@MT; + @gmt_to_hopper=@MT; + @state_to_hopper=@MT; + @phone_to_hopper=@MT; + while ( $record = $iter->each) + { + if ( ($NEW_count > 0) && ($NEW_rec_countLEADS > $NEW_in) ) + { + if ($DB_show_offset) {print "NEW_COUNT: $NEW_count|$NEW_dec|$NEW_in|$NEW_rec_countLEADS\n";} + if ($NEW_count > $NEW_dec) + { + $NEW_dec++; + } + else + { + $leads_to_hopper[$rec_countLEADS] = "$NEW_leads_to_hopper[$NEW_in]"; + $lists_to_hopper[$rec_countLEADS] = "$NEW_lists_to_hopper[$NEW_in]"; + $gmt_to_hopper[$rec_countLEADS] = "$NEW_gmt_to_hopper[$NEW_in]"; + $state_to_hopper[$rec_countLEADS] = "$NEW_state_to_hopper[$NEW_in]"; + $phone_to_hopper[$rec_countLEADS] = "$NEW_phone_to_hopper[$NEW_in]"; + if ($DB_show_offset) {print "LEAD_ADD: $NEW_leads_to_hopper[$NEW_in] $NEW_phone_to_hopper[$NEW_in]\n";} + $rec_countLEADS++; + $NEW_in++; + $NEW_dec=2; + } + } + if ($REC_rec_countLEADS > $REC_insert_count) + { + $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; + $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; + $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; + $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; + $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; + $rec_countLEADS++; + $REC_insert_count++; + } + $leads_to_hopper[$rec_countLEADS] = "$record->[0]"; + $lists_to_hopper[$rec_countLEADS] = "$record->[1]"; + $gmt_to_hopper[$rec_countLEADS] = "$record->[2]"; + $state_to_hopper[$rec_countLEADS] = "$record->[4]"; + $phone_to_hopper[$rec_countLEADS] = "$record->[3]"; + if ($DB_show_offset) {print "LEAD_ADD: $record->[2] $record->[3] $record->[4]\n";} + $rec_countLEADS++; + } + } + + if ($DB) {print " Adding to hopper: $rec_countLEADS\n";} + $event_string = "|$campaign_id[$i]|Added to hopper $rec_countLEADS|"; + &event_logger; + + $h=0; + foreach(@leads_to_hopper) + { + if ($leads_to_hopper[$h] != '0') + { + $DNClead=0; + if ($use_internal_dnc[$i] =~ /Y/) + { + if ($DB) {print " Doinbg DNC Check: $phone_to_hopper[$h]\n";} + $stmtA = "SELECT count(*) from vicidial_dnc where phone_number='$phone_to_hopper[$h]';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $DNClead = "$record->[0]"; + } + } + if ($DNClead != '0') + { + $stmtA = "UPDATE vicidial_list SET status='DNCL' where lead_id='$leads_to_hopper[$h]';"; + $dbhA->query("$stmtA"); + if ($DB) {print "Flagging DNC lead: $leads_to_hopper[$h] $phone_to_hopper[$h]\n";} + } + } + if ($DNClead == '0') + { + $stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]');"; + $dbhA->query("$stmtA"); + } + } + $h++; + } + if ($DB) {print " DONE with this campaign\n";} + + } + } + + + $i++; + } + + +$dbhA->close; + +if($DB){print "DONE... Exiting... Goodbye... See you later... Really, I mean it :)\n";} + +exit; + + + +sub event_logger { + ### open the log file for writing ### + open(Lout, ">>$VDHLOGfile") + || die "Can't open $VDHLOGfile: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} + + diff --git a/agc_2-X/trunk/AST_VDremote_agents.pl b/agc_2-X/trunk/AST_VDremote_agents.pl new file mode 100644 index 00000000..a042effa --- /dev/null +++ b/agc_2-X/trunk/AST_VDremote_agents.pl @@ -0,0 +1,493 @@ +#!/usr/bin/perl +# +# AST_VDremote_agents.pl version 0.1 +# +# DESCRIPTION: +# uses Net::MySQL to keep remote agents logged in to the VICIDIAL system +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with VICIDIAL +# +# For the client to use VICIDIAL with remote agents, this must always be running +# +# It is recommended that you run this program on the local Asterisk machine +# +# This script is to run perpetually querying every second to update the remote +# agents that should appear to be logged in so that the calls can be transferred +# out to them properly. +# +# It is good practice to keep this program running by placing the associated +# KEEPALIVE script running every minute to ensure this program is always running +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 50215-0954 - First version of script +# 50810-1615 - Added database server variable definitions lookup +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-v] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2 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 = '2000'; + } + if ($args =~ /-v/i) + { + $V=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; + } + } +} +else +{ +print "no command line options set\n"; + $loop_delay = '2000'; + $V=1; +} +### end parsing run-time options ### + + +# constants +$US='__'; +$MT[0]=''; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; + + ### connect to MySQL database defined in the AST_SERVER_conf.pl file + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + + &get_time_now; # update time/date variables + + $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; + &event_logger; # writes to the log and if debug flag is set prints to STDOUT + + + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + +$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 + + while($endless_loop > 0) + { + &get_time_now; + + if ($endless_loop =~ /0$|5$/) + { + ### delete call records that are LIVE for over 10 minutes and last_update_time < '$PDtsSQLdate' + $stmtA = "DELETE FROM vicidial_live_agents where server_ip='$server_ip' and status IN('PAUSED') and extension LIKE \"R/%\""; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| lagged call vla agent DELETED $affected_rows"; + &event_logger; + + + $stmtA = "UPDATE vicidial_live_agents set status='INCALL', last_call_time='$SQLdate' where server_ip='$server_ip' and status IN('QUEUE') and extension LIKE \"R/%\""; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + + $event_string = "| QUEUEd call listing vla UPDATEd $affected_rows"; + &event_logger; + + #@psoutput = `/bin/ps -f --no-headers -A`; + @psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + + $running_listen = 0; + + $i=0; + foreach (@psoutput) + { + chomp($psoutput[$i]); + + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + + if ($psline[1] =~ /AST_manager_li/) {$running_listen++;} + + $i++; + } + + if (!$running_listen) + { + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED NO LISTENER RUNNING... EXITING\n\n"; + } + + if($DB){print "checking to see if listener is dead |$running_listen|\n";} + } + + + + $user_counter=0; + @DBremote_user=@MT; + @DBremote_server_ip=@MT; + @DBremote_campaign=@MT; + @DBremote_conf_exten=@MT; + @DBremote_closer=@MT; + @DBremote_random=@MT; + @loginexistsRANDOM=@MT; + @loginexistsALL=@MT; + @VD_user=@MT; + @VD_extension=@MT; + @VD_status=@MT; + @VD_uniqueid=@MT; + @VD_callerid=@MT; + @VD_random=@MT; + ############################################################################### + ###### first grab all of the ACTIVE remote agents information from the database + ############################################################################### + $dbhA->query("SELECT * FROM vicidial_remote_agents where status IN('ACTIVE') and server_ip='$server_ip' order by user_start"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $user_start = "$record->[1]"; + $number_of_lines = "$record->[2]"; + $conf_exten = "$record->[4]"; + $campaign_id = "$record->[6]"; + $closer_campaigns = "$record->[7]"; + + $y=0; + while ($y < $number_of_lines) + { + $random = int( rand(9999999)) + 10000000; + $user_id = ($user_start + $y); + $DBremote_user[$user_counter] = "$user_id"; + $DBremote_server_ip[$user_counter] = "$server_ip"; + $DBremote_campaign[$user_counter] = "$campaign_id"; + $DBremote_conf_exten[$user_counter] = "$conf_exten"; + $DBremote_closer[$user_counter] = "$closer_campaigns"; + $DBremote_random[$user_counter] = "$random"; + + $y++; + $user_counter++; + } + + } + if ($V) {print STDERR "$user_counter live remote agents ACTIVE\n";} + } + + + ############################################################################### + ###### second traverse array of remote agents to be active and insert or update + ###### in vicidial_live_agents table + ############################################################################### + $h=0; + foreach(@DBremote_user) + { + if (length($DBremote_user[$h])>1) + { + + ### check to see if the record exists and only needs random number update + $dbhA->query("SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]'"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $loginexistsRANDOM[$h] = "$record->[0]"; + } + } + if ($loginexistsRANDOM[$h] > 0) + { + $stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]' where user='$DBremote_user[$h]' and server_ip='$server_ip' and campaign_id='$DBremote_campaign[$h]' and conf_exten='$DBremote_conf_exten[$h]' and closer_campaigns='$DBremote_closer[$h]'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($V) {print STDERR "$DBremote_user[$h] $DBremote_campaign[$h] ONLY RANDOM ID UPDATE: $affected_rows\n";} + } + ### check if record for user on server exists at all in vicidial_live_agents + else + { + $dbhA->query("SELECT count(*) FROM vicidial_live_agents where user='$DBremote_user[$h]' and server_ip='$server_ip'"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $loginexistsALL[$h] = "$record->[0]"; + } + } + if ($loginexistsALL[$h] > 0) + { + $stmtA = "UPDATE vicidial_live_agents set random_id='$DBremote_random[$h]',campaign_id='$DBremote_campaign[$h]',conf_exten='$DBremote_conf_exten[$h]',closer_campaigns='$DBremote_closer[$h]', status='READY' where user='$DBremote_user[$h]' and server_ip='$server_ip'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($V) {print STDERR "$DBremote_user[$h] ALL UPDATE: $affected_rows\n";} + } + ### no records exist so insert a new one + else + { + $stmtA = "INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,campaign_id,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,channel,uniqueid,callerid) values('$DBremote_user[$h]','$server_ip','$DBremote_conf_exten[$h]','R/$DBremote_user[$h]','READY','$DBremote_campaign[$h]','$DBremote_random[$h]','$SQLdate','$tsSQLdate','$SQLdate','$DBremote_closer[$h]','','','')"; + $dbhA->query("$stmtA"); + if ($V) {print STDERR "$DBremote_user[$h] NEW INSERT\n";} + } + } + } + $h++; + } + + + ############################################################################### + ###### third validate that the calls that the vicidial_live_agents are on are not dead + ###### and if they are wipe out the values and set the agent record back to READY + ############################################################################### + $dbhA->query("SELECT user,extension,status,uniqueid,callerid FROM vicidial_live_agents where extension LIKE \"R/%\" and server_ip='$server_ip' and uniqueid > 10"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $z=0; + while ( $record = $iter->each) + { + $VDuser = "$record->[0]"; + $VDextension = "$record->[1]"; + $VDstatus = "$record->[2]"; + $VDuniqueid = "$record->[3]"; + $VDcallerid = "$record->[4]"; + $VDrandom = int( rand(9999999)) + 10000000; + + $VD_user[$z] = "$VDuser"; + $VD_extension[$z] = "$VDextension"; + $VD_status[$z] = "$VDstatus"; + $VD_uniqueid[$z] = "$VDuniqueid"; + $VD_callerid[$z] = "$VDcallerid"; + $VD_random[$z] = "$VDrandom"; + + $z++; + } + if ($V) {print STDERR "$z remote agents on calls\n";} + } + $z=0; + foreach(@VD_user) + { + $dbhA->query("SELECT count(*) FROM vicidial_auto_calls where uniqueid='$VD_uniqueid[$z]' and server_ip='$server_ip'"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $autocallexists[$z] = "$record->[0]"; + } + } + if ($autocallexists[$z] < 1) + { + $stmtA = "UPDATE vicidial_live_agents set random_id='$VD_random[$z]',status='READY', last_call_finish='$SQLdate',lead_id='',uniqueid='',callerid='',channel='' where user='$VD_user[$z]' and server_ip='$server_ip'"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($V) {print STDERR "$VD_user[$z] CALL WIPE UPDATE: $affected_rows|$VD_uniqueid[$z]\n";} + } + + $z++; + } + + + + + + + ############################################################################### + ###### last, wait for a little bit and repeat the loop + ############################################################################### + + ### sleep for X seconds before beginning the loop again + usleep(1*$loop_delay*1000); + + $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 + if (-e '/home/cron/VDAD.kill') + { + unlink('/home/cron/VDAD.kill'); + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n" + } + + $bad_grabber_counter=0; + + + } + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} + + $event_string='HANGING UP|'; + &event_logger; + + $one_day_interval--; + +} + + $event_string='CLOSING DB CONNECTION|'; + &event_logger; + + + $dbhA->close; + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} + + +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)); + ($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $filedate = "$year-$mon-$mday"; + +$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";} + $PDtsSQLdate = "$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";} + $XDSQLdate = "$Xyear-$Xmon-$Xmday $Xhour:$Xmin:$Xsec"; + +$TDtarget = ($secX - 600); +($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";} + ### open the log file for writing ### + open(Lout, ">>/home/cron/remote.$filedate") + || die "Can't open /home/cron/remote.$filedate: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} diff --git a/agc_2-X/trunk/AST_agent_week.pl b/agc_2-X/trunk/AST_agent_week.pl new file mode 100644 index 00000000..e8eb993a --- /dev/null +++ b/agc_2-X/trunk/AST_agent_week.pl @@ -0,0 +1,336 @@ +#!/usr/bin/perl + +# AST_agent_week.pl +# +# This script is designed to gather stats for all agent activity over the course +# of a week(Sunday to Saturday) and print it in an ASCI text file to be placed +# on a web server for viewing. +# +# CHANGES +# 60517-1100 - First version +# + +$txt = '.txt'; +$US = '_'; +$MT[0] = ''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n\n"; + exit; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; + print "\n-----DEBUG MODE-----\n\n"; + } + if ($args =~ /-q/i) + { + $q=1; $Q=1; + } + if ($args =~ /-t/i) + { + $T=1; $TEST=1; + print "\n-----TESTING-----\n\n"; + } + } +} +else +{ +print "no command line options set\n"; +} +### end parsing run-time options ### + + +$secX = time(); + ($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";} + $filedate = "$year$mon$mday-$hour$min$sec"; + $ABIfiledate = "$mon-$mday-$year$us$hour$min$sec"; + $shipdate = "$year-$mon-$mday"; + $datestamp = "$year/$mon/$mday $hour:$min"; + + $STARTtarget = ($secX - (86400 * $wday)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($STARTtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $START_week = (($Syday/7)+1); $START_week = sprintf("%2d", $START_week); + $STARTtarget_date = "$Syear-$Smon-$Smday"; + + $ENDtarget = ($STARTtarget + (86400 * 6)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($ENDtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $ENDtarget_date = "$Syear-$Smon-$Smday"; + + $PAST_STARTtarget = ($STARTtarget - (86400 * 7)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_STARTtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_START_week = (($Syday/7)+1); $PAST_START_week = sprintf("%2d", $PAST_START_week); + $PAST_STARTtarget_date = "$Syear-$Smon-$Smday"; + + $PAST_ENDtarget = ($ENDtarget - (86400 * 7)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_ENDtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_ENDtarget_date = "$Syear-$Smon-$Smday"; + + $PAST_date[0] = $PAST_STARTtarget_date; + $PAST_day[0] = 'Sunday '; + $PAST_date[6] = $PAST_ENDtarget_date; + $PAST_day[6] = 'Saturday '; + + $PAST_Mondaytarget = ($STARTtarget - (86400 * 6)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Mondaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[1] = "$Syear-$Smon-$Smday"; + $PAST_day[1] = 'Monday '; + + $PAST_Tuesdaytarget = ($STARTtarget - (86400 * 5)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Tuesdaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[2] = "$Syear-$Smon-$Smday"; + $PAST_day[2] = 'Tuesday '; + + $PAST_Wednesdaytarget = ($STARTtarget - (86400 * 4)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Wednesdaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[3] = "$Syear-$Smon-$Smday"; + $PAST_day[3] = 'Wednesday'; + + $PAST_Thursdaytarget = ($STARTtarget - (86400 * 3)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Thursdaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[4] = "$Syear-$Smon-$Smday"; + $PAST_day[4] = 'Thursday '; + + $PAST_Fridaytarget = ($STARTtarget - (86400 * 2)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Fridaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[5] = "$Syear-$Smon-$Smday"; + $PAST_day[5] = 'Friday '; + +print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_agent_week.pl --\n\n"; +print "This program is designed to print stats to a file for agents' activity for the previous week. \n\n"; + +$TLoutfile = ''; +$TLoutfile .= "TODAY: $shipdate\n"; +$TLoutfile .= "THIS WEEK: week $START_week $STARTtarget_date - $ENDtarget_date\n"; +$TLoutfile .= "LAST WEEK: week $PAST_START_week $PAST_STARTtarget_date - $PAST_ENDtarget_date\n\n"; + +#$h=0; +#foreach(@PAST_date) +#{ +#$TLoutfile .= "$PAST_day[$h] $PAST_date[$h]\n"; +#$h++; +#} + +#print "$TLoutfile"; + + +$outfile = "AGENT_HOURS_$PAST_STARTtarget_date$US$PAST_ENDtarget_date$txt"; + +#$dir = '/usr/local/apache2/htdocs'; +$dir = '/home/www/htdocs'; + +### open the X out file for writing ### +open(out, ">$dir/vicidial/agent_reports/$outfile") + || die "Can't open $outfile: $!\n"; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +$dbhB = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +#$vicidial_agent_log = 'vicidial_agent_log_archive'; +$vicidial_agent_log = 'vicidial_agent_log'; + +########################################################################### +########### PAST WEEK STAT GATHERING LOOP ################################# +########################################################################### +$h=0; +foreach(@PAST_date) +{ + print out "\n$PAST_day[$h] $PAST_date[$h]\n\n"; + print out "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n"; + print "\n$PAST_day[$h] $PAST_date[$h]\n\n"; + print "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n"; + + $stmtA = "select count(*) as calls, full_name,vicidial_users.user,sum(talk_sec),sum(pause_sec),sum(wait_sec),sum(dispo_sec) from vicidial_users,$vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and vicidial_users.user=$vicidial_agent_log.user and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by vicidial_users.user order by full_name limit 10000;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + + $calls = sprintf("%7s", $aryA[0]); + $name = sprintf("%-20s", $aryA[1]); while(length($name)>20) {chop($name);} + $user = sprintf("%-8s", $aryA[2]); + + ### TOTAL ACTIVE TIME + $active = ($aryA[3] + $aryA[4] + $aryA[5] + $aryA[6]); + $TIME_S = $active; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $active = sprintf("%9s", $TIME_HMS); + + ### TOTAL TALK TIME + $TIME_S = $aryA[3]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $talk = sprintf("%9s", $TIME_HMS); + + ### TOTAL PAUSE TIME + $TIME_S = $aryA[4]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $pause = sprintf("%9s", $TIME_HMS); + + ### TOTAL WAIT TIME + $TIME_S = $aryA[5]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $wait = sprintf("%9s", $TIME_HMS); + + ### TOTAL DISPO TIME + $TIME_S = $aryA[6]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $dispo = sprintf("%9s", $TIME_HMS); + + $stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time limit 1;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtA ", $dbhB->errstr; + @aryB = $sthB->fetchrow_array; + $first_time = sprintf("%21s", $aryB[0]); + $first_log = $aryB[1]; + + $stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time desc limit 1;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtA ", $dbhB->errstr; + @aryB = $sthB->fetchrow_array; + $last_time = sprintf("%21s", $aryB[0]); + $last_log = $aryB[1]; + + $TIME_S = ($last_log - $first_log); + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $login_time = sprintf("%9s", $TIME_HMS); + + + + print out "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n"; + print "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n"; + + + $rec_count++; + } + $sthA->finish(); + + + + + + + + + + +#if ($h=='1') +# { +# exit; +# } + +$h++; +} + + + +close(out); + +### calculate time to run script ### +$secY = time(); +$secZ = ($secY - $secX); +$secZm = ($secZ /60); + +print "script execution time in seconds: $secZ minutes: $secZm\n"; + +exit; + + + + + diff --git a/agc_2-X/trunk/AST_cleanup_agent_log.pl b/agc_2-X/trunk/AST_cleanup_agent_log.pl new file mode 100644 index 00000000..7f405a09 --- /dev/null +++ b/agc_2-X/trunk/AST_cleanup_agent_log.pl @@ -0,0 +1,236 @@ +#!/usr/bin/perl +# +# AST_cleanup_agent_log.pl version 0.1 +# +# DESCRIPTION: +# to be run frequently to clean up the vicidial_agent_log to fix erroneous time +# calculations due to out-of-order vicidial_agent_log updates. This happens 0.5% +# of the time in our test setups, but that leads to inaccurate time logs so we +# wrote this script to fix the miscalculations +# +# This program only needs to be run by one server +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + + +# constants +$COUNTER_OUTPUT=1; # set to 1 to display the counter as the script runs +$US='__'; +$MT[0]=''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + print "\n----- DEBUGGING -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + print "\n----- TEST RUN, NO UPDATES -----\n\n"; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use Net::MySQL; + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + + if ($DB) {print " - cleaning up pause time\n";} + ### Grab any pause time record greater than 50000 + $stmtA = "SELECT agent_log_id,pause_epoch,wait_epoch from vicidial_agent_log where pause_sec>50000;"; + if ($DBX) {print "$stmtA\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $i=0; + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBout = ''; + $agent_log_id[$i] = "$record->[0]"; + $pause_epoch[$i] = "$record->[1]"; + $wait_epoch[$i] = "$record->[2]"; + $pause_sec[$i] = int($wait_epoch[$i] - $pause_epoch[$i]); + if ( ($pause_sec[$i] < 0) || ($pause_sec[$i] > 50000) ) + { + $DBout = "Override output: $pause_sec[$i]"; + $pause_sec[$i] = 0; + } + if ($DBX) {print "$i - $agent_log_id[$i] |$wait_epoch[$i]|$pause_epoch[$i]|$pause_sec[$i]|$DBout|\n";} + $i++; + } + } + $h=0; + while ($h < $i) + { + $stmtA = "UPDATE vicidial_agent_log set pause_sec='$pause_sec[$h]' where agent_log_id='$agent_log_id[$h]';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + if (!$TEST) {$dbhA->query($stmtA); }# or die "Couldn't execute query: |$stmtA|\n"; + $h++; + } + if ($DB) {print STDERR " Pause times fixed: $h\n";} + + + + + + @agent_log_id=@MT; + @wait_epoch=@MT; + + if ($DBX) {print "\n\n";} + if ($DB) {print " - cleaning up wait time\n";} + ### Grab any pause time record greater than 50000 + $stmtA = "SELECT agent_log_id,wait_epoch,talk_epoch from vicidial_agent_log where wait_sec>50000;"; + if ($DBX) {print "$stmtA\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $i=0; + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBout = ''; + $agent_log_id[$i] = "$record->[0]"; + $wait_epoch[$i] = "$record->[1]"; + $talk_epoch[$i] = "$record->[2]"; + $wait_sec[$i] = int($talk_epoch[$i] - $wait_epoch[$i]); + if ( ($wait_sec[$i] < 0) || ($wait_sec[$i] > 50000) ) + { + $DBout = "Override output: $wait_sec[$i]"; + $wait_sec[$i] = 0; + } + if ($DBX) {print "$i - $agent_log_id[$i] |$talk_epoch[$i]|$wait_epoch[$i]|$wait_sec[$i]|$DBout|\n";} + $i++; + } + } + $h=0; + while ($h < $i) + { + $stmtA = "UPDATE vicidial_agent_log set wait_sec='$wait_sec[$h]' where agent_log_id='$agent_log_id[$h]';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + if (!$TEST) {$dbhA->query($stmtA); }# or die "Couldn't execute query: |$stmtA|\n"; + $h++; + } + if ($DB) {print STDERR " Wait times fixed: $h\n";} + + + + + + @agent_log_id=@MT; + @talk_epoch=@MT; + + if ($DBX) {print "\n\n";} + if ($DB) {print " - cleaning up talk time\n";} + ### Grab any pause time record greater than 50000 + $stmtA = "SELECT agent_log_id,talk_epoch,dispo_epoch from vicidial_agent_log where talk_sec>50000;"; + if ($DBX) {print "$stmtA\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $i=0; + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBout = ''; + $agent_log_id[$i] = "$record->[0]"; + $talk_epoch[$i] = "$record->[1]"; + $dispo_epoch[$i] = "$record->[2]"; + $talk_sec[$i] = int($dispo_epoch[$i] - $talk_epoch[$i]); + if ( ($talk_sec[$i] < 0) || ($talk_sec[$i] > 50000) ) + { + $DBout = "Override output: $talk_sec[$i]"; + $talk_sec[$i] = 0; + } + if ($DBX) {print "$i - $agent_log_id[$i] |$dispo_epoch[$i]|$talk_epoch[$i]|$talk_sec[$i]|$DBout|\n";} + $i++; + } + } + $h=0; + while ($h < $i) + { + $stmtA = "UPDATE vicidial_agent_log set talk_sec='$talk_sec[$h]' where agent_log_id='$agent_log_id[$h]';"; + if($DBX){print STDERR "|$stmtA|\n";} + if (!$TEST) {$dbhA->query($stmtA); }# or die "Couldn't execute query: |$stmtA|\n"; + $h++; + } + if ($DB) {print STDERR " Talk times fixed: $h\n";} + + + + + + @agent_log_id=@MT; + @dispo_epoch=@MT; + + if ($DBX) {print "\n\n";} + if ($DB) {print " - cleaning up dispo time\n";} + $stmtA = "UPDATE vicidial_agent_log set dispo_sec='0' where dispo_sec>50000;"; + if($DBX){print STDERR "|$stmtA|\n";} + if (!$TEST) + { + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + $affected_rows = $dbhA->get_affected_rows_length; + } + if ($DB) {print STDERR " Bad Dispo times zeroed out: $affected_rows\n";} + + + + + + + + + + + + if ($DB) {print STDERR "\nDONE\n";} + + + + $dbhA->close; + + +exit; + + + + + + diff --git a/agc_2-X/trunk/AST_conf_update.pl b/agc_2-X/trunk/AST_conf_update.pl new file mode 100644 index 00000000..70d874a9 --- /dev/null +++ b/agc_2-X/trunk/AST_conf_update.pl @@ -0,0 +1,220 @@ +#!/usr/bin/perl +# +# AST_conf_update.pl version 0.3 +# +# DESCRIPTION: +# uses the Asterisk Manager interface and Net::MySQL to update whether a conference +# is still in use or not. If not in use 3 times in a row the extension in the +# conferences DB record is erased freeing that conference to be used again +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with conferences +# +# This program should be in the cron running every minute (like AST_vm_update.pl) +# +# For this program to work you need to have the "asterisk" MySQL database +# created with the conferences table in it, also make sure +# that the account running this program has read/write/update/delete access +# to that database +# +# It is recommended that you run this program on the local Asterisk machine +# +# If this script is run ever minute there is a theoretical limit of +# 600 conferences that it can check due to the wait interval. If you have +# more than this either change the cron when this script is run or change the +# wait interval below +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50810-1532 - Added database server variable definitions lookup +# 50823-1456 - Added commandline arguments for debug at runtime +# + +# constants +$DB=0; # Debug flag, set to 0 for no debug messages per minute +$US='__'; +$MT[0]=''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; +use Net::Telnet (); + + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### 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 FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEupdate = "$record->[4]"; + $DBASTmgrUSERNAMElisten = "$record->[5]"; + $DBASTmgrUSERNAMEsend = "$record->[6]"; + $DBmax_vicidial_trunks = "$record->[7]"; + $DBanswer_transfer_agent= "$record->[8]"; + $DBSERVER_GMT = "$record->[9]"; + $DBext_context = "$record->[10]"; + 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;} + if ($DBmax_vicidial_trunks) {$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;} + } + } + + + +@PTextensions=@MT; @PT_conf_extens=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT; +$dbhA->query("SELECT extension,conf_exten from conferences where server_ip='$server_ip' and extension is NOT NULL and extension != '';"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $PTextensions[$rec_count] = "$record->[0]"; + $PT_conf_extens[$rec_count] = "$record->[1]"; + $rec_count++; + } + } + +if (!$telnet_port) {$telnet_port = '5038';} + +### connect to asterisk manager through telnet +$t = new Net::Telnet (Port => $telnet_port, + Prompt => '/.*[\$%#>] $/', + Output_record_separator => '',); +#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log + if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;} + else {$telnet_login = $ASTmgrUSERNAME;} + +$t->open("$telnet_host"); +$t->waitfor('/0\n$/'); # print login +$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n"); +$t->waitfor('/Authentication accepted/'); # waitfor auth accepted + + +$i=0; +foreach(@PTextensions) + { + @list_channels=@MT; + $t->buffer_empty; + @list_channels = $t->cmd(String => "Action: Command\nCommand: Meetme list $PT_conf_extens[$i]\n\nAction: Ping\n\n", Prompt => '/Response: Pong.*/'); + + $j=0; + $conf_empty[$i]=0; + $conf_users[$i]=''; + foreach(@list_channels) + { + if($DB){print "|$list_channels[$j]|\n";} + if ($list_channels[$j] =~ /No active conferences|No such conference/i) + {$conf_empty[$i]++;} +# if ($list_channels[$j] =~ /^User /i) +# { +# $userx = ''; +# $userx = $list_channels[$j]; +# $userx =~ s/User \#: //gi; +# $conf_users[$i] .= "$userx|"; +# } + $j++; + } + + if($DB){print "Meetme list $PT_conf_extens[$i]- Exten:|$PTextensions[$i]| Empty:|$conf_empty[$i]| ";} + if (!$conf_empty[$i]) + { + if($DB){print "CONFERENCE STILL HAS PARTICIPANTS, DOING NOTHING FOR THIS CONFERENCE\n";} + if ($PTextensions[$i] =~ /Xtimeout\d$/i) + { + $PTextensions[$i] =~ s/Xtimeout\d$//gi; + $stmtA = "UPDATE conferences set extension='$PTextensions[$i]' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$i]';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:|$stmtA|\n"; + } + } + else + { + $NEWexten[$i] = $PTextensions[$i]; + if ($PTextensions[$i] =~ /Xtimeout3$/i) {$NEWexten[$i] =~ s/Xtimeout3$/Xtimeout2/gi;} + if ($PTextensions[$i] =~ /Xtimeout2$/i) {$NEWexten[$i] =~ s/Xtimeout2$/Xtimeout1/gi;} + if ($PTextensions[$i] =~ /Xtimeout1$/i) {$NEWexten[$i] = '';} + if ( ($PTextensions[$i] !~ /Xtimeout\d$/i) and (length($PTextensions[$i])> 0) ) {$NEWexten[$i] .= 'Xtimeout3';} + + + $stmtA = "UPDATE conferences set extension='$NEWexten[$i]' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$i]';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:|$stmtA|\n"; + } + + $i++; + ### sleep for 10 hundredths of a second + usleep(1*100*1000); + } + + +$t->buffer_empty; +@hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/"); +$t->buffer_empty; +$ok = $t->close; + +$dbhA->close; + +if($DB){print "DONE... Exiting... Goodbye... See you later... \n";} + +exit; + + + + diff --git a/agc_2-X/trunk/AST_flush_DBqueue.pl b/agc_2-X/trunk/AST_flush_DBqueue.pl new file mode 100644 index 00000000..cf76ffa7 --- /dev/null +++ b/agc_2-X/trunk/AST_flush_DBqueue.pl @@ -0,0 +1,189 @@ +#!/usr/bin/perl +# +# AST_flush_DBqueue.pl version 0.2 +# +# DESCRIPTION: +# - clears out mysql records for this server for the ACQS vicidial_manager table +# - optimizes tables used frequently by VICIDIAL +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$secX = time(); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year = ($year + 1900); + $yy = $year; $yy =~ s/^..//gi; + $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";} +$SQLdate_NOW="$year-$mon-$mday $hour:$min:$sec"; + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time()-3600); + $year = ($year + 1900); + $yy = $year; $yy =~ s/^..//gi; + $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";} +$SQLdate_NEG_1hour="$year-$mon-$mday $hour:$min:$sec"; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [--debug] = debugging messages\n\n"; + } + else + { + if ($args =~ /-q/i) + { + $q=1; $Q=1; + } + if ($args =~ /--debug/i) + { + $DB=1; + print "\n-----DEBUGGING -----\n\n"; + } + if ($args =~ /-t|--test/i) + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } + } +} +else +{ +print "no command line options set\n"; +} +### end parsing run-time options ### + + +if (!$Q) {print "TEST\n\n";} +if (!$Q) {print "NOW DATETIME: $SQLdate_NOW\n";} +if (!$Q) {print "1 HOUR AGO DATETIME: $SQLdate_NEG_1hour\n\n";} + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use Net::MySQL; + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + + $stmtA = "delete from vicidial_manager where server_ip='$server_ip' and entry_date < '$SQLdate_NEG_1hour';"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if (!$Q) {print " - vicidial_manager 2 hour flush\n";} + + + $stmtA = "update park_log set status='HUNGUP' where hangup_time is not null;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countY=0; + while ($recordA = $iterA->each) + { + if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + if (!$Q) {print " - park_log HUNGUP flush \n";} + + + $stmtA = "optimize table vicidial_manager;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countY=0; + while ($recordA = $iterA->each) + { + if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + if (!$Q) {print " - optimize vicidial_manager \n";} + + + $stmtA = "optimize table vicidial_live_agents;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countY=0; + while ($recordA = $iterA->each) + { + if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + if (!$Q) {print " - optimize vicidial_live_agents \n";} + + + $stmtA = "optimize table vicidial_auto_calls;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countY=0; + while ($recordA = $iterA->each) + { + if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + if (!$Q) {print " - optimize vicidial_auto_calls \n";} + + + $stmtA = "optimize table vicidial_hopper;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) {$dbhA->query($stmtA); } + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countY=0; + while ($recordA = $iterA->each) + { + if (!$Q) {print "|",$recordA->[0],"|",$recordA->[1],"|",$recordA->[2],"|",$recordA->[3],"|","\n";} + } + } + + if (!$Q) {print " - optimize vicidial_hopper \n";} + + + + + $dbhA->close; + + +exit; + + + + + + diff --git a/agc_2-X/trunk/AST_manager_kill_hung_congested.pl b/agc_2-X/trunk/AST_manager_kill_hung_congested.pl new file mode 100644 index 00000000..52636af4 --- /dev/null +++ b/agc_2-X/trunk/AST_manager_kill_hung_congested.pl @@ -0,0 +1,335 @@ +#!/usr/bin/perl +# +# AST_manager_kill_hung_congested.pl version 0.2 +# +# Part of the Asterisk Central Queue System (ACQS) +# +# DESCRIPTION: +# kills CONGEST local channels every 15 seconds +# +# For the client program to work in ACQS mode, this program must be running +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# In your Asterisk server setup you also need to have several things activated +# and defined. See the CONF_Asterisk.txt file for details +# +# put this in the cron to run every minute +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50823-1525 - Added commandline debug options with debug printouts +# + +# constants +$DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate thousands of lines of output per minute +$US='__'; +$MT[0]=''; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + + &get_time_now; + +# $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; +# &event_logger; + +#use lib './lib', '../lib'; +use Net::MySQL; +#use Net::Telnet (); + +my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass") +or die "Couldn't connect to database: \n"; + +#$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; +#&event_logger; + +$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99"; +# $event_string="SQL_QUERY|$stmtA|"; +# &event_logger; + +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"\n";} + $congest_kill[$rec_count] = "$record->[0]"; + $rec_count++; + } + + } + +$i=0; +foreach(@congest_kill) + { + $i_count = $i; + if ($i_count < 10) {$i_count = "0$i_count";} + + if (length($congest_kill[$i])>0) + { + ### use manager middleware-app to zapbarge call being placed from meetme + $KCqueryCID = "KC$i_count$CIDdate"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')"; + + $event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|"; + event_logger; + + if ($DB) {print "KILLING $congest_kill[$i]\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + } + $i++; + } + + +sleep(14); + +######## 22222 starting another loop + &get_time_now; +@congest_kill = @MT; + + + +$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99"; +# $event_string="SQL_QUERY|$stmtA|"; +# &event_logger; + +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"\n";} + $congest_kill[$rec_count] = "$record->[0]"; + $rec_count++; + } + + } + +$i=0; +foreach(@congest_kill) + { + $i_count = $i; + if ($i_count < 10) {$i_count = "0$i_count";} + + if (length($congest_kill[$i])>0) + { + ### use manager middleware-app to zapbarge call being placed from meetme + $KCqueryCID = "KC$i_count$CIDdate"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')"; + + $event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|"; + event_logger; + + if ($DB) {print "KILLING $congest_kill[$i]\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + } + $i++; + } + + +sleep(15); + +######## 33333 starting another loop + &get_time_now; +@congest_kill = @MT; + + + + +$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99"; +# $event_string="SQL_QUERY|$stmtA|"; +# &event_logger; + +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"\n";} + $congest_kill[$rec_count] = "$record->[0]"; + $rec_count++; + } + + } + +$i=0; +foreach(@congest_kill) + { + $i_count = $i; + if ($i_count < 10) {$i_count = "0$i_count";} + + if (length($congest_kill[$i])>0) + { + ### use manager middleware-app to zapbarge call being placed from meetme + $KCqueryCID = "KC$i_count$CIDdate"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')"; + + $event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|"; + event_logger; + + if ($DB) {print "KILLING $congest_kill[$i]\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + } + $i++; + } + + +sleep(15); + +######## 44444 starting another loop + &get_time_now; +@congest_kill = @MT; + + + + + +$stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99"; +# $event_string="SQL_QUERY|$stmtA|"; +# &event_logger; + +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"\n";} + $congest_kill[$rec_count] = "$record->[0]"; + $rec_count++; + } + + } + +$i=0; +foreach(@congest_kill) + { + $i_count = $i; + if ($i_count < 10) {$i_count = "0$i_count";} + + if (length($congest_kill[$i])>0) + { + ### use manager middleware-app to zapbarge call being placed from meetme + $KCqueryCID = "KC$i_count$CIDdate"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Hangup','$KCqueryCID','Channel: $congest_kill[$i]','','','','','','','','','')"; + + $event_string = "SUBRT|killing_congest|KC|$KCqueryCID|$congest_kill[$i]|$stmtA|"; + event_logger; + + if ($DB) {print "KILLING $congest_kill[$i]\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + } + $i++; + } + + + +# $event_string='CLOSING DB CONNECTION|'; +# &event_logger; + + $dbhA->close; + + + if($DB){print "DONE... Exiting... Goodbye... See you later... \n";} + + +exit; + + + + + + + +sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes +{ +($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) {$Fhour = "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"; +$action_log_date = "$year-$mon-$mday"; +$CIDdate = "$year$mon$mday$hour$min$sec"; +} + + + + + +sub event_logger { + ### open the log file for writing ### + open(Lout, ">>$KHLOGfile") + || die "Can't open $KHLOGfile: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} diff --git a/agc_2-X/trunk/AST_manager_listen.pl b/agc_2-X/trunk/AST_manager_listen.pl new file mode 100644 index 00000000..6d407cbd --- /dev/null +++ b/agc_2-X/trunk/AST_manager_listen.pl @@ -0,0 +1,594 @@ +#!/usr/bin/perl +# +# AST_manager_listen.pl version 1.1.11 build 60403-1230 +# +# Part of the Asterisk Central Queue System (ACQS) +# +# DESCRIPTION: +# connects to the Asterisk Manager interface and updates records in the +# vicidial_manager table of the asterisk database in MySQL based upon the +# events that it receives +# +# SUMMARY: +# This program was designed as the listen-only part of the ACQS. It's job is to +# look for certain events and based upon either the uniqueid or the callerid of +# the call update the status and information of an action record in the +# vicidial_manager table of the asterisk MySQL database. +# +# Win32 - ActiveState Perl 5.8.0 +# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded +# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded +# +# For the client program to work in ACQS mode, this program must be running +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# In your Asterisk server setup you also need to have several things activated +# and defined. See the CONF_Asterisk.txt file for details +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 50322-1300 changed callerid parsing to remove quotes and number +# 50616-1559 Added NewCallerID parsing and updating +# 50621-1406 Added Asterisk server shutdown and connection dead detection +# 50810-1534 Added database server variable definitions lookup +# 50824-1606 Altered CVS/1.2 support for different output +# 50901-2359 Another CVS/1.2 output parsing fix +# 51222-1553 fixed parentheses bug in manager output +# 60403-1230 Added SVN/1.2.6 support for different output +# + +# constants +$DB=1; # Debug flag, set to 0 for no debug messages, lots of output +$US='__'; +$MT[0]=''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + + &get_time_now; + + $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; + &event_logger; + +#use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; +use Net::Telnet (); + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + + +### 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 FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEupdate = "$record->[4]"; + $DBASTmgrUSERNAMElisten = "$record->[5]"; + $DBASTmgrUSERNAMEsend = "$record->[6]"; + $DBmax_vicidial_trunks = "$record->[7]"; + $DBanswer_transfer_agent= "$record->[8]"; + $DBSERVER_GMT = "$record->[9]"; + $DBext_context = "$record->[10]"; + 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;} + if ($DBmax_vicidial_trunks) {$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 (!$telnet_port) {$telnet_port = '5038';} + +$one_day_interval = 90; # 1 day loops for 3 months +while($one_day_interval > 0) +{ + + $event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; +# Errmode => Return, + + ### connect to asterisk manager through telnet + $tn = new Net::Telnet (Port => $telnet_port, + Prompt => '/.*[\$%#>] $/', + Output_record_separator => '',); + #$fh = $tn->dump_log("$LItelnetlog"); # uncomment for telnet log + if (length($ASTmgrUSERNAMElisten) > 3) {$telnet_login = $ASTmgrUSERNAMElisten;} + else {$telnet_login = $ASTmgrUSERNAME;} + $tn->open("$telnet_host"); + $tn->waitfor('/0\n$/'); # print login + $tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n"); + $tn->waitfor('/Authentication accepted/'); # waitfor auth accepted + + $tn->buffer_empty; + + $event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + + $endless_loop=864000; # 1 day at .10 seconds per loop + + while($endless_loop > 0) + { + ### sleep for 10 hundredths of a second + usleep(1*100*1000); + + $msg=''; + $read_input_buf = $tn->get(Errmode => Return, Timeout => 1,); + $input_buf_length = length($read_input_buf); + $msg = $tn->errmsg; + if ($msg =~ /filehandle isn\'t open/i) + { + $endless_loop=0; + $one_day_interval=0; + print "ERRMSG: |$msg|\n"; + print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n"; + $event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|$msg|"; + &event_logger; + } + + if ( ($read_input_buf !~ /\n\n/) or ($input_buf_length < 10) ) + { + # if ($read_input_buf =~ /\n/) {print "\n|||$input_buf_length|||$read_input_buf|||\n";} + $input_buf = "$input_buf$read_input_buf"; + } + else + { + $partial=0; + $partial_input_buf=''; + + if ($read_input_buf !~ /\n\n$/) + { + $read_input_buf =~ s/\(|\)/ /gi; # replace parens with space + $partial_input_buf = $read_input_buf; + $partial_input_buf =~ s/\n/-----/gi; + $partial_input_buf =~ s/\*/\\\*/gi; + $partial_input_buf =~ s/.*----------//gi; + $partial_input_buf =~ s/-----/\n/gi; + $read_input_buf =~ s/$partial_input_buf$//gi; + $partial++; + } + + +# |1 DIALINGs updated| +# Nested quantifiers in regex; marked by <-- HERE in m/Event: Newexten +# Channel: Zap/16-1 +# Context: demo +# Extension: 990009*CL_UMGCOF_L** <-- HERE 1479503*conf*** +# Priority: 2 +# Application: Dial +# AppData: Zap/g3/90009*CL_UMGCOF_L**1479503*conf***|20 +# Uniqueid: 1101224775.6783 +# $/ at /home/cron/AST_manager_listen.pl line 114. + + + $input_buf = "$input_buf$read_input_buf"; + @input_lines = split(/\n\n/, $input_buf); + + if($DB){print "input buffer: $input_buf_length lines: $#input_lines partial: $partial\n";} + if ( ($DB) && ($partial) ) {print "-----[$partial_input_buf]-----\n\n";} + if($DB){print "|$input_buf|\n";} + + $manager_string = "$input_buf"; + &manager_output_logger; + + $input_buf = "$partial_input_buf"; + + + @command_line=@MT; + $ILcount=0; + foreach(@input_lines) + { + if ( ($input_lines[$ILcount] =~ /State: Ringing|State: Up|State: Dialing|Event: Newstate|Event: Hangup|Event: Newcallerid|Event: Shutdown/) && ($input_lines[$ILcount] !~ /ZOMBIE/) ) + { + $input_lines[$ILcount] =~ s/^\n|^\n\n//gi; + @command_line=split(/\n/, $input_lines[$ILcount]); + if ($input_lines[$ILcount] =~ /Event: Shutdown/) + { + $endless_loop=0; + $one_day_interval=0; + print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n"; + $event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + } + + if ($input_lines[$ILcount] =~ /Event: Hangup/) + { + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) ) ### post 2005-08-07 CVS -- added Privilege line + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $uniqueid = $command_line[3]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='DEAD', channel='$channel' where server_ip = '$server_ip' and uniqueid = '$uniqueid'"; + + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows HANGUPS updated|\n";} + } + else + { + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[4] =~ /^Uniqueid: /i) ) ### post 2006-03-20 SVN -- Added Timestamp line + { + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $uniqueid = $command_line[4]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='DEAD', channel='$channel' where server_ip = '$server_ip' and uniqueid = '$uniqueid'"; + + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows HANGUPS updated|\n";} + } + else + { + $channel = $command_line[1]; + $channel =~ s/Channel: |\s*$//gi; + $uniqueid = $command_line[2]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='DEAD', channel='$channel' where server_ip = '$server_ip' and uniqueid = '$uniqueid'"; + + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows HANGUPS updated|\n";} + } + } + } + + if ($input_lines[$ILcount] =~ /State: Dialing/) + { + if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^Uniqueid: /i) ) ### pre 2004-10-07 CVS + { + $channel = $command_line[1]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[3]; + $callid =~ s/Callerid: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[4]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows DIALINGs updated|\n";} + } + if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^CalleridName: /i) ) ### post 2004-10-07 CVS + { + $channel = $command_line[1]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CalleridName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[5]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows DIALINGs updated|\n";} + } + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^CalleridName: /i) ) ### post 2005-08-07 CVS + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[5]; + $callid =~ s/CalleridName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[6]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows DIALINGs updated|\n";} + } + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[6] =~ /^CalleridName: /i) ) ### post 2006-03-20 -- Added Timestamp line + { + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[6]; + $callid =~ s/CalleridName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[7]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='SENT', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows DIALINGs updated|\n";} + } + } + if ($input_lines[$ILcount] =~ /State: Ringing|State: Up/) + { + if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^Uniqueid: /i) ) ### pre 2004-10-07 CVS + { + $channel = $command_line[1]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[3]; + $callid =~ s/Callerid: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[4]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + if ($channel !~ /local/i) + { + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[4] =~ /^CalleridName: /i) ) ### post 2004-10-07 CVS + { + $channel = $command_line[1]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[4]; + $callid =~ s/CalleridName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[5]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + if ($channel !~ /local/i) + { + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[5] =~ /^CalleridName: /i) ) ### post 2005-08-07 CVS + { + $channel = $command_line[2]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[5]; + $callid =~ s/CalleridName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[6]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + if ($channel !~ /local/i) + { + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[6] =~ /^CalleridName: /i) ) ### post 2006-03-20 SVN -- Added Timestamp line + { + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[6]; + $callid =~ s/CalleridName: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[7]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + if ($channel !~ /local/i) + { + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + } + + if ($input_lines[$ILcount] =~ /Event: Newcallerid/) + { + if ( ($command_line[1] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) ) + { + $channel = $command_line[1]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[2]; + $callid =~ s/Callerid: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[3]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + if ($channel =~ /local/i) + { + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + if ( ($command_line[3] =~ /^Channel: /i) && ($command_line[6] =~ /^Uniqueid: /i) ) ### post 2006-03-20 SVN -- Added Timestamp line + { + $channel = $command_line[3]; + $channel =~ s/Channel: |\s*$//gi; + $callid = $command_line[5]; + $callid =~ s/Callerid: |\s*$//gi; + $callid =~ s/^\"//gi; $callid =~ s/\".*$//gi; + $uniqueid = $command_line[6]; + $uniqueid =~ s/Uniqueid: |\s*$//gi; + $stmtA = "UPDATE vicidial_manager set status='UPDATED', channel='$channel', uniqueid = '$uniqueid' where server_ip = '$server_ip' and callerid = '$callid'"; + if ($channel =~ /local/i) + { + print STDERR "|$stmtA|\n"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if($DB){print "|$affected_rows RINGINGs updated|\n";} + } + } + } + + } + $ILcount++; + } + + } + + + $endless_loop--; + $keepalive_count_loop++; + if($DB){print STDERR "loop counter: |$endless_loop|$keepalive_count_loop|\r";} + + ### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program + if ( (-e '/home/cron/listenmgr.kill') or ($sendonlyone) ) + { + unlink('/home/cron/listenmgr.kill'); + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n"; + } + + ### run a keepalive command to flush whatever is in the buffer through and to keep the connection alive + if ($endless_loop =~ /00$|50$/) + { + &get_time_now; + + @list_lines = $tn->cmd(String => "Action: Command\nCommand: show uptime\n\n", Prompt => '/--END COMMAND--.*/', Errmode => Return, Timeout => 1); + if($DB){print "input lines: $#list_lines\n";} + + if($DB){print "+++++++++++++++++++++++++++++++sending keepalive transmit line $endless_loop|$now_date|\n";} + $keepalive_count_loop=0; + } + + + } + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";} + + $event_string='HANGING UP|'; + &event_logger; + + @hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/", Errmode => Return, Timeout => 1); + + $ok = $tn->close; + + $one_day_interval--; + +} + + $event_string='CLOSING DB CONNECTION|'; + &event_logger; + + + $dbhA->close; + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} + + +exit; + + + + + + + +sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes +{ +($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) {$Fhour = "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"; +$action_log_date = "$year-$mon-$mday"; +} + + + + + +sub event_logger { + ### open the log file for writing ### + open(Lout, ">>$LILOGfile") + || die "Can't open $LILOGfile: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} + + + + +sub manager_output_logger +{ +open(MOout, ">>/home/cron/listen.$action_log_date") + || die "Can't open /home/cron/listen.$action_log_date: $!\n"; + + print MOout "$now_date|$manager_string|\n"; + + close(MOout); +} diff --git a/agc_2-X/trunk/AST_manager_send.pl b/agc_2-X/trunk/AST_manager_send.pl new file mode 100644 index 00000000..222b6a9e --- /dev/null +++ b/agc_2-X/trunk/AST_manager_send.pl @@ -0,0 +1,384 @@ +#!/usr/bin/perl +# +# AST_manager_send.pl version 0.2 +# +# Part of the Asterisk Central Queue System (ACQS) +# +# DESCRIPTION: +# spawns child processes (AST_send_action_child.pl) to execute action commands +# on the Asterisk manager interface from records in the vicidial_manager table +# of the asterisk database in MySQL that are marked as a status of NEW +# +# SUMMARY: +# This program was designed as the send-only part of the ACQS. It's job is to +# pick NEW actions from the vicidial_manager table and send them to be executed +# by separate child process. This allows for a higher degree of flexibility and +# scalability over just using a single process. Also, this means that a single +# action execution lock cannot bring the entire system down. +# +# Win32 - ActiveState Perl 5.8.0 +# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded +# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded +# +# For the client program to work in ACQS mode, this program must be running +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# In your Asterisk server setup you also need to have several things activated +# and defined. See the CONF_Asterisk.txt file for details +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50823-1514 - Added commandline debug options with debug printouts +# 50902-1051 - Added extra debug output launch sub(commented out) +# + +# constants +$COUNTER_OUTPUT=1; # set to 1 to display the counter as the script runs +$US='__'; +$MT[0]=''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-sendonlyone/i) + { + $sendonlyone=1; + print "\n-----SEND ONLY ONE COMMAND -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + + &get_time_now; + + $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; + &event_logger; + +#use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; +#use Net::Telnet (); + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + +$one_day_interval = 90; # 1 day loops for 3 months +while($one_day_interval > 0) +{ + + + $endless_loop=864000; # 10 days at .20 seconds per loop + + while($endless_loop > 0) + { + + $affected_rows=0; + $NEW_actions=0; + + $stmtA = "SELECT count(*) from vicidial_manager where server_ip = '$server_ip' and status = 'NEW'"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0]," NEW Actions to send on server $server_ip $endless_loop\n";} + $NEW_actions = "$record->[0]"; + } + } + + if (!$NEW_actions) + { + $affected_rows=0; + } + else + { + $stmtA = "UPDATE vicidial_manager set status='QUEUE' where server_ip = '$server_ip' and status = 'NEW' order by entry_date limit 1"; + $dbhA->query("$stmtA"); + $affected_rows = $dbhA->get_affected_rows_length; + if ($DB) {print STDERR "rows updated to QUEUE: |$affected_rows|\n";} + } + + + if ($affected_rows) + { + $stmtA = "SELECT * FROM vicidial_manager where server_ip = '$server_ip' and status = 'QUEUE' order by entry_date desc limit 1"; + $event_string="SQL_QUERY|$stmtA|"; + &event_logger; + + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"|", $record->[1],"|", $record->[6],"|", $record->[7],"|", $record->[8],"\n";} + $man_id = "$record->[0]"; + $uniqueid = "$record->[1]"; + $channel = "$record->[6]"; + $action = "$record->[7]"; + $callid = "$record->[8]"; + $cmd_line_b = "$record->[9]"; + $cmd_line_c = "$record->[10]"; + $cmd_line_d = "$record->[11]"; + $cmd_line_e = "$record->[12]"; + $cmd_line_f = "$record->[13]"; + $cmd_line_g = "$record->[14]"; + $cmd_line_h = "$record->[15]"; + $cmd_line_i = "$record->[16]"; + $cmd_line_j = "$record->[17]"; + $cmd_line_k = "$record->[18]"; + + $originate_command = ''; + $originate_command .= "Action: $action\n"; + if (length($cmd_line_b)>3) {$originate_command .= "$cmd_line_b\n";} + if (length($cmd_line_c)>3) {$originate_command .= "$cmd_line_c\n";} + if (length($cmd_line_d)>3) {$originate_command .= "$cmd_line_d\n";} + if (length($cmd_line_e)>3) {$originate_command .= "$cmd_line_e\n";} + if (length($cmd_line_f)>3) {$originate_command .= "$cmd_line_f\n";} + if (length($cmd_line_g)>3) {$originate_command .= "$cmd_line_g\n";} + if (length($cmd_line_h)>3) {$originate_command .= "$cmd_line_h\n";} + if (length($cmd_line_i)>3) {$originate_command .= "$cmd_line_i\n";} + if (length($cmd_line_j)>3) {$originate_command .= "$cmd_line_j\n";} + if (length($cmd_line_k)>3) {$originate_command .= "$cmd_line_k\n";} + $originate_command .= "\n"; + + $SENDNOW=1; + if ($originate_command =~ /Action: Hangup|Action: Redirect/) + { + $SENDNOW=0; + if($DB){print STDERR "\n|checking for dead call before executing|$callid|$uniqueid|\n";} + $dbhA->query("SELECT count(*) FROM vicidial_manager where server_ip = '$server_ip' and callerid='$callid' and status = 'DEAD'"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countH=0; + while ( $record = $iter->each) + { + $rec_countH = "$record->[0]"; + } + if (!$rec_countH){$SENDNOW=1;} + else + { + $launch_string = "|not sending command line is dead|$callid|$uniqueid|"; + # &launch_logger; + if($DB){print STDERR "\n$launch_string\n";} + + } + } + + } + + $event_string="----BEGIN NEW COMMAND----\n$originate_command----END NEW COMMAND----\n"; + &event_logger; + + if ($SENDNOW) + { + # $tn->buffer_empty; + + $launch_string = "/home/cron/AST_send_action_child.pl --data1=$man_id $callid $uniqueid $channel"; + # &launch_logger; + + system("/home/cron/AST_send_action_child.pl --data1=$man_id >> /home/cron/action.$action_log_date \&"); + + $launch_string = "SENT $man_id $callid $uniqueid $channel"; + # &launch_logger; + + $stmtA = "UPDATE vicidial_manager set status='SENT' where man_id='$man_id'"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + $event_string="SQL_QUERY|$stmtA|"; + &event_logger; + } + else + { + $stmtA = "UPDATE vicidial_manager set status='DEAD' where man_id='$man_id'"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $event_string="COMMAND NOT SENT, SQL_QUERY|$stmtA|"; + &event_logger; + } + + } + } + + } + + if ($affected_rows) + { + ### sleep for 10 hundredths of a second + usleep(1*100*1000); + } + else + { + ### sleep for 20 hundredths of a second + usleep(1*200*1000); + } + + $endless_loop--; + if( ($COUNTER_OUTPUT) or ($DB) ){print STDERR "loop counter: |$endless_loop|\r";} + + ### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program + if ( (-e '/home/cron/sendmgr.kill') or ($sendonlyone) ) + { + unlink('/home/cron/sendmgr.kill'); + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n"; + } + + if ($endless_loop =~ /0$/) + { + &get_time_now; + + if( ($COUNTER_OUTPUT) or ($DB) ){print "checking to see if listener is dead |$sendonlyone|$running_listen|\n";} + #@psoutput = `/bin/ps -f --no-headers -A`; + @psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + + $running_listen = 0; + + $i=0; + foreach (@psoutput) + { + chomp($psoutput[$i]); + + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + + if ($psline[1] =~ /AST_manager_li/) + { + $running_listen++; + if ($DB) {print "SEND RUNNING: |$psline[1]|\n";} + } + + $i++; + } + + if (!$running_listen) + { + $sendonlyone++; + if( ($COUNTER_OUTPUT) or ($DB) ){print "LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT\n";} + $event_string='LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT|'; + &event_logger; + `/usr/bin/at now < /home/cron/ADMIN_keepalive_send_listen.at 2>/dev/null 1>&2`; + } + } + + + } + + + if( ($COUNTER_OUTPUT) or ($DB) ){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";} + + $one_day_interval--; + +} + + $event_string='CLOSING DB CONNECTION|'; + &event_logger; + + + $dbhA->close; + + + if( ($COUNTER_OUTPUT) or ($DB) ){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} + + +exit; + + + + + + + +sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes +{ +($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) {$Fhour = "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"; +$action_log_date = "$year-$mon-$mday"; +} + + + + + +sub event_logger { + ### open the log file for writing ### + open(Lout, ">>$MSLOGfile") + || die "Can't open $MSLOGfile: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} + +sub launch_logger { + ### open the log file for writing ### + open(LLout, ">>/home/cron/action_launch.$action_log_date") + || die "Can't open /home/cron/action_launch.$action_log_date: $!\n"; + + print LLout "$now_date|$launch_string|\n"; + + close(LLout); + +$event_string=''; +} diff --git a/agc_2-X/trunk/AST_reset_mysql_vars.pl b/agc_2-X/trunk/AST_reset_mysql_vars.pl new file mode 100644 index 00000000..0409266a --- /dev/null +++ b/agc_2-X/trunk/AST_reset_mysql_vars.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl +# +# AST_reset_mysql_vars.pl version 0.2 +# +# !!! DO NOT RUN THIS WHILE THERE ARE ACTIVE CALLS ON THE ASTERISK SERVER !!! +# +# DESCRIPTION: +# clears out mysql records for this server +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use Net::MySQL; + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + + $stmtA = "UPDATE conferences set extension='' where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - conferences reset\n"; + + $stmtA = "UPDATE vicidial_conferences set extension='' where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_conferences reset\n"; + +# $stmtA = "UPDATE vicidial_manager set status='DEAD' where server_ip='$server_ip' and status='NEW';"; +# if($DB){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; +# print " - vicidial_manager queue reset\n"; + + $stmtA = "DELETE from vicidial_manager where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_manager delete\n"; + + $stmtA = "DELETE from vicidial_auto_calls where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_manager delete\n"; + + $stmtA = "DELETE from vicidial_live_agents where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_manager delete\n"; + + $stmtA = "DELETE from vicidial_users where full_name='5555';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_manager delete\n"; + + $dbhA->close; + + +exit; + + + + + + diff --git a/agc_2-X/trunk/AST_send_action_child.pl b/agc_2-X/trunk/AST_send_action_child.pl new file mode 100644 index 00000000..b15eb8b8 --- /dev/null +++ b/agc_2-X/trunk/AST_send_action_child.pl @@ -0,0 +1,258 @@ +#!/usr/bin/perl +# +# AST_send_action_child.pl version 0.2 +# +# Part of the Asterisk Central Queue System (ACQS) +# +# DESCRIPTION: +# This script is spawned every time an action is to be executed by the main +# AST_manager_send.pl script and sends actions blindly to the Asterisk manager +# +# SUMMARY: +# This program was designed as the blind-send part of the ACQS. It's job is to +# be spawned by the AST_manager_send.pl script lookup the record in the MySQL DB +# to be executed. connect to the manager interface, send the action and logoff +# then exit. +# +# Win32 - ActiveState Perl 5.8.0 +# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded +# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded +# +# For the client program to work in ACQS mode, this program must be running +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# In your Asterisk server setup you also need to have several things activated +# and defined. See the CONF_Asterisk.txt file for details +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50810-1547 - Added database server variable definitions lookup +# 50823-1527 - Altered commandline debug options with debug printouts +# 50902-1032 - Changed default logging to fulllog +# + +$FULL_LOG = 1; # set to 1 for a full response log to be created in /home/cron/action_full.date + +$secX = time(); + +($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) {$Fhour = "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"; +$action_log_date = "$year-$mon-$mday"; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $ARGS = "$ARGS $ARGV[$i]\n"; + $i++; + } + +# print "DB0: |$ARGS|$#ARGV|$i|\n"; + + if ($ARGS =~ /--help/i) + { + print "allowed run time options:\n [-debug] = debug output\n [-debugX] = Extra-debug output\n [-fulllog] = full response logging\n [--data1=XXXXXXX] = vicidial_manager record\n\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-fulllog/i) + { + $FULL_LOG=1; # Full response logging enabled + } + if ($ARGS =~ /--data1=/i) + { + $data1 = $ARGS; +# print "DB1: |$ARGS|\n"; + $data1 =~ s/^.*--data1=//gi; +# print "DB2: |$data1|\n"; + $data1 =~ s/ .*$//gi; +# print "DB3: |$data1|\n"; + } + + } +} +else +{ +#print "no command line options set\n\n"; +} + +if (length($data1)>1) + { +# print "Data1 value = |$data1|\n"; + +use Net::MySQL; +use Net::Telnet (); + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + ### Grab Server values from the database + $stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEsend FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEsend = "$record->[4]"; + if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;} + if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;} + if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;} + if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;} + if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;} + } + } + + + $stmtA = "SELECT * FROM vicidial_manager where man_id = '$data1'"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $man_id = "$record->[0]"; + $uniqueid = "$record->[1]"; + $channel = "$record->[6]"; + $action = "$record->[7]"; + $callid = "$record->[8]"; + $cmd_line_b = "$record->[9]"; + $cmd_line_c = "$record->[10]"; + $cmd_line_d = "$record->[11]"; + $cmd_line_e = "$record->[12]"; + $cmd_line_f = "$record->[13]"; + $cmd_line_g = "$record->[14]"; + $cmd_line_h = "$record->[15]"; + $cmd_line_i = "$record->[16]"; + $cmd_line_j = "$record->[17]"; + $cmd_line_k = "$record->[18]"; + + $originate_command = ''; + $originate_command .= "Action: $action\n"; + if (length($cmd_line_b)>3) {$originate_command .= "$cmd_line_b\n";} + if (length($cmd_line_c)>3) {$originate_command .= "$cmd_line_c\n";} + if (length($cmd_line_d)>3) {$originate_command .= "$cmd_line_d\n";} + if (length($cmd_line_e)>3) {$originate_command .= "$cmd_line_e\n";} + if (length($cmd_line_f)>3) {$originate_command .= "$cmd_line_f\n";} + if (length($cmd_line_g)>3) {$originate_command .= "$cmd_line_g\n";} + if (length($cmd_line_h)>3) {$originate_command .= "$cmd_line_h\n";} + if (length($cmd_line_i)>3) {$originate_command .= "$cmd_line_i\n";} + if (length($cmd_line_j)>3) {$originate_command .= "$cmd_line_j\n";} + if (length($cmd_line_k)>3) {$originate_command .= "$cmd_line_k\n";} + $originate_command .= "\n"; + } + } + + $dbhA->close; + + + print "$now_date|$data1|\n$originate_command"; + $event_string = "0|$data1|"; + $event_string .= "\n$originate_command"; + if ($FULL_LOG) {&full_event_logger;} + +if (!$telnet_port) {$telnet_port = '5038';} + + ### connect to asterisk manager through telnet + $tn = new Net::Telnet (Port => $telnet_port, + Prompt => '/.*[\$%#>] $/', + Output_record_separator => '', + Errmode => Return,); + #$fh = $tn->dump_log("$MStelnetlog"); # uncomment for telnet log + if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;} + else {$telnet_login = $ASTmgrUSERNAME;} + $tn->open("$telnet_host"); + $tn->waitfor('/0\n$/'); # print login + $tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n"); + $tn->waitfor('/Authentication accepted/'); # waitfor auth accepted + + $tn->buffer_empty; + + @list_channels = $tn->cmd(String => "$originate_command", Prompt => '/.*/'); + +sleep(3); + + if ($FULL_LOG) + { + $event_string = "1|$data1|"; $k=0; + foreach(@list_channels) {$event_string .= "$list_channels[$k]"; $k++;} + $read_input_buf = $tn->get(Errmode => Return, Timeout => 1,); + $event_string .= "$read_input_buf"; + &full_event_logger; + } + + $tn->buffer_empty; + + @hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/"); + +sleep(2); + + if ($FULL_LOG) + { + $event_string = "2|$data1|"; $k=0; + foreach(@list_channels) {$event_string .= "$list_channels[$k]"; $k++;} + $read_input_buf = $tn->get(Errmode => Return, Timeout => 1,); + $event_string .= "$read_input_buf"; + &full_event_logger; + } + + $tn->buffer_empty; + + $ok = $tn->close; + + + + + } + +$secZ = time(); +$script_time = ($secZ - $secX); +print "DONE execute time: $script_time seconds\n"; + +exit; + +sub full_event_logger { + ### open the log file for writing ### + open(Lout, ">>/home/cron/action_full.$action_log_date") + || die "Can't open /home/cron/action_full.$action_log_date: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} diff --git a/agc_2-X/trunk/AST_update.pl b/agc_2-X/trunk/AST_update.pl new file mode 100644 index 00000000..12f0a053 --- /dev/null +++ b/agc_2-X/trunk/AST_update.pl @@ -0,0 +1,1110 @@ +#!/usr/bin/perl +# +# AST_update.pl version 1.1.11 (build 60411-1032) +# +# DESCRIPTION: +# uses the Asterisk Manager interface and Net::MySQL to update the live_channels +# tables and verify the parked_channels table in the asterisk MySQL database +# This "near-live-status of Zap/SIP/Local/IAX channels" list is used by clients +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with Digium +# Zaptel telco cards and SIP VOIP hardphones or softphones as extensions, it +# could be adapted to other functions, but I designed it specifically for +# Zap/IAX2/SIP users. The program will run on UNIX or Win32 command line +# providing the following criteria are met: +# +# Win32 - ActiveState Perl 5.8.0 +# UNIX - Gnome or KDE with Tk/Tcl and perl Tk/Tcl modules loaded +# Both - Net::MySQL, Net::Telnet and Time::HiRes perl modules loaded +# +# For the client program to work, this program must always be running +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the MySQL_AST_CREATE_tables.sql file, +# also make sure that the machine running this program has select/insert/update/delete +# access to that database +# +# In your Asterisk server setup you also need to have several things activated +# and defined. See the CONF_Asterisk.txt file for details +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# version changes: +# 41228-1659 - modified to compensate for manager output response hiccups +# 50107-1611 - modified to add Zap and IAX2 clients (differentiate from trunks) +# 50117-1537 - modified to add MySQL port ($DB_port) var from conf file +# 50303-0958 - modified to compensate for Zap manager output hiccups +# 50406-1320 - added channel_data to live_channels table for more flexibility +# also added Zap/IAX client check every 100 loop instead of only once +# 50509-1047 - added collection of server_performance data with SYSPERF flag +# 50621-1307 - modified to allow for SIP trunks +# 50810-1601 - Added database server variable definitions lookup +# 50823-1625 - Altered Debug vars and initial CVS/1.2 support for changed output +# 50824-1606 - Altered CVS/1.2 support for "show channels concise" output +# 50829-1134 - Added processor percentage usage to stat collection +# 51229-1355 - Added ability to take ! as delimited for 1.2 show channels concise +# 60117-1202 - Changed IAX2 client phone channel to reflect change to '-' iteration +# 60411-1032 - Fixed bug in test section that caused crash with ** in extension +# + +$build = '60411-1032'; + +# constants +$SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds +$SYSPERF_rec=0; # is dial-time recording turned on +$DB=0; # Debug flag, set to 1 for debug messages WARNING LOTS OF OUTPUT!!! +$DBX=0; # Debug flag, set to 1 for debug messages WARNING LOTS OF OUTPUT!!! +$US='__'; +$AMP='@'; +$MT[0]=''; +$cpuUSERprev=0; +$cpuSYSTprev=0; +$cpuIDLEprev=0; + +# DB table variables for testing + $parked_channels = 'parked_channels'; + $live_channels = 'live_channels'; + $live_sip_channels = 'live_sip_channels'; + $server_updater = 'server_updater'; +# $parked_channels = 'TEST_parked_channels'; +# $live_channels = 'TEST_live_channels'; +# $live_sip_channels = 'TEST_live_sip_channels'; +# $server_updater = 'TEST_server_updater'; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-sysperf] = system performance logging\n [-sysperfdebug] = system performance debug output\n [-debug] = verbose debug messages\n [-debugX] = Extra-verbose debug messages\n\n"; + exit; + } + else + { + if ($args =~ /-sysperf/i) + { + $SYSPERF=1; # System performance logging flag + } + if ($args =~ /-sysperfdebug/i) + { + $SYSPERFDB=1; # prints system performance data out to STDOUT + } + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\nBUILD: $build\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + + &get_time_now; + + $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; + &event_logger; + +use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; +use Net::Telnet (); + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + +### 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,asterisk_version FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEupdate = "$record->[4]"; + $DBASTmgrUSERNAMElisten = "$record->[5]"; + $DBASTmgrUSERNAMEsend = "$record->[6]"; + $DBmax_vicidial_trunks = "$record->[7]"; + $DBanswer_transfer_agent= "$record->[8]"; + $DBSERVER_GMT = "$record->[9]"; + $DBext_context = "$record->[10]"; + $DBasterisk_version = "$record->[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;} + if ($DBmax_vicidial_trunks) {$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 ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + } + } + + if ($AST_ver =~ /^1\.2|^CVS|^SVN/i) {$show_channels_12_format = 1;} + else {$show_channels_12_format = 0;} + +##### LOOK FOR ZAP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS + print STDERR "LOOKING FOR Zap clients assigned to this server:\n"; + $Zap_client_count=0; + $Zap_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'Zap' and server_ip='$server_ip'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + print STDERR $record->[0],"\n"; + $Zap_client_list .= "$record->[0]|"; + $Zap_client_count++; + } + } + +##### LOOK FOR IAX2 CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS + print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n"; + $IAX2_client_count=0; + $IAX2_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'IAX2' and server_ip='$server_ip'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + print STDERR $record->[0],"\n"; + $IAX2_client_list .= "$record->[0]|"; + if ($record->[0] !~ /\@/) + {$IAX2_client_list .= "$record->[0]$AMP$record->[0]|";} + else + { + $IAX_user = $record->[0]; + $IAX_user =~ s/\@.*$//gi; + $IAX2_client_list .= "$IAX_user|"; + } + $IAX2_client_count++; + } + } + +##### LOOK FOR SIP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS + print STDERR "LOOKING FOR SIP clients assigned to this server:\n"; + $SIP_client_count=0; + $SIP_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'SIP' and server_ip='$server_ip'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + print STDERR $record->[0],"\n"; + $SIP_client_list .= "$record->[0]|"; + if ($record->[0] !~ /\@/) + {$SIP_client_list .= "$record->[0]$AMP$record->[0]|";} + else + { + $SIP_user = $record->[0]; + $SIP_user =~ s/\@.*$//gi; + $SIP_client_list .= "$SIP_user|"; + } + $SIP_client_count++; + } + } + + print STDERR "Zap Clients: $Zap_client_list\n"; + print STDERR "IAX2 Clients: $IAX2_client_list\n"; + print STDERR "SIP Clients: $SIP_client_list\n"; + +$one_day_interval = 12; # 2 hour loops for one day +while($one_day_interval > 0) +{ + + $event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + +if (!$telnet_port) {$telnet_port = '5038';} + + ### connect to asterisk manager through telnet + $t = new Net::Telnet (Port => $telnet_port, + Prompt => '/.*[\$%#>] $/', + Output_record_separator => '',); + #$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log + if (length($ASTmgrUSERNAMEupdate) > 3) {$telnet_login = $ASTmgrUSERNAMEupdate;} + else {$telnet_login = $ASTmgrUSERNAME;} + $t->open("$telnet_host"); + $t->waitfor('/0\n$/'); # print login + $t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n"); + $t->waitfor('/Authentication accepted/'); # waitfor auth accepted + + $event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + + $endless_loop=5769999; # 30 days minutes at .45 seconds per loop + + while($endless_loop > 0) + { + + + @DBchannels=@MT; + @DBsips=@MT; + @list_channels=@MT; + @test_channels=@MT; + + &get_current_channels; + + &validate_parked_channels; + + + $t->buffer_empty; + if (!$show_channels_12_format) + { + @list_channels = $t->cmd(String => "Action: Command\nCommand: show channels\n\n", Prompt => '/--END COMMAND-.*/'); + } + else + { + @list_channels = $t->cmd(String => "Action: Command\nCommand: show channels concise\n\n", Prompt => '/--END COMMAND-.*/'); + } + + ##### TEST CHANNELS ZAP/IAX2/Local TO SEE IF THERE WAS A LARGE HICCUP IN OUTPUT FROM PREVIOUS OUTPUT + @test_channels=@list_channels; + $test_zap_count=0; + $test_iax_count=0; + $test_local_count=0; + $test_sip_count=0; + $s=0; + foreach(@test_channels) + { + chomp($test_channels[$s]); + if($DBX){print "$s|$test_channels[$s]\n";} + $test_channels[$s] =~ s/Congestion\s+\(Empty\)/ SIP\/CONGEST/gi; + $test_channels[$s] =~ s/\(Outgoing Line\)|\(None\)/SIP\/ring/gi; + $test_channels[$s] =~ s/\(Empty\)/SIP\/internal/gi; + if (!$show_channels_12_format) + { + $test_channels[$s] =~ s/^\s*|\s*$//gi; + $test_channels[$s] =~ s/\(.*\)//gi; + } + else + { + $EXcount = 0; + $EXcount = @{[$test_channels[$s] =~ /\!/g]}; + if ($EXcount > 10) + { + @test_chan_12 = split(/\!/, $test_channels[$s]); + } + else + { + @test_chan_12 = split(/:/, $test_channels[$s]); + } + # @test_chan_12 = split(/:/, $test_channels[$s]); + if (length($test_chan_12[6])<2) {$test_chan_12[6] = 'SIP/ring';} + $test_channels[$s] = "$test_chan_12[0] $test_chan_12[6]"; + } + if ($test_channels[$s] =~ /^Zap|^IAX2|^SIP|^Local/) + { + if ($test_channels[$s] =~ /^(\S+)\s+.+\s+(\S+)$/) + { + $channel = $1; + $extension = $2; + if ($show_channels_12_format) + {$extension =~ s/^.*\(|\).*$//gi;} + $extension =~ s/^SIP\/|-\S+$//gi; + $extension =~ s/\|.*//gi; + if ($channel =~ /^SIP/) {$test_sip_count++;} + if ($channel =~ /^Local/) {$test_local_count++;} + if ($IAX2_client_count) + { + $channel_match=$channel; + $channel_match =~ s/\/\d+$|-\d+$//gi; + $channel_match =~ s/^IAX2\///gi; + if ($IAX2_client_list =~ /\|$channel_match\|/i) {$test_iax_count++;} + } + if ($Zap_client_count) + { + $channel_match=$channel; + $channel_match =~ s/^Zap\///gi; + if ($Zap_client_list =~ /\|$channel_match\|/i) {$test_zap_count++;} + } + } + } + $s++; + } + + + + # $DB_live_lines = ($#DBchannels + $#DBsips); + $DB_live_lines = ($channel_counter + $sip_counter); + if ( (!$DB_live_lines) or ($#list_channels < 2) ) + {$PERCENT_static = 0;} + else + { + $PERCENT_static = ( ($#list_channels / $DB_live_lines) * 100); + $PERCENT_static = sprintf("%6.2f", $PERCENT_static); + } + + if ( (!$test_zap_count) or ($zap_client_counter < 2) ) + {$PERCENT_ZC_static = 0;} + else + { + $PERCENT_ZC_static = ( ($test_zap_count / $zap_client_counter) * 100); + $PERCENT_ZC_static = sprintf("%6.2f", $PERCENT_ZC_static); + } + + if ( (!$test_iax_count) or ($iax_client_counter < 2) ) + {$PERCENT_IC_static = 0;} + else + { + $PERCENT_IC_static = ( ($test_iax_count / $iax_client_counter) * 100); + $PERCENT_IC_static = sprintf("%6.2f", $PERCENT_IC_static); + } + + if ( (!$test_local_count) or ($local_client_counter < 2) ) + {$PERCENT_LC_static = 0;} + else + { + $PERCENT_LC_static = ( ($test_local_count / $local_client_counter) * 100); + $PERCENT_LC_static = sprintf("%6.2f", $PERCENT_LC_static); + } + + if ( (!$test_sip_count) or ($sip_client_counter < 2) ) + {$PERCENT_SC_static = 0;} + else + { + $PERCENT_SC_static = ( ($test_sip_count / $sip_client_counter) * 100); + $PERCENT_SC_static = sprintf("%6.2f", $PERCENT_SC_static); + } + + if ($endless_loop =~ /0$/) + {print "-$now_date $PERCENT_static $#list_channels $#DBchannels:$channel_counter $#DBsips:$sip_counter $PERCENT_ZC_static|$test_zap_count:$zap_client_counter $PERCENT_IC_static|$test_iax_count:$iax_client_counter $PERCENT_LC_static|$test_local_count:$local_client_counter $PERCENT_SC_static|$test_sip_count:$sip_client_counter\n";} + + if ( ( ($PERCENT_static < 10) && ( ($channel_counter > 3) or ($sip_counter > 4) ) ) or + ( ($PERCENT_static < 20) && ( ($channel_counter > 10) or ($sip_counter > 10) ) ) or + ( ($PERCENT_static < 30) && ( ($channel_counter > 20) or ($sip_counter > 20) ) ) or + ( ($PERCENT_static < 40) && ( ($channel_counter > 30) or ($sip_counter > 30) ) ) or + ( ($PERCENT_static < 50) && ( ($channel_counter > 40) or ($sip_counter > 40) ) ) or + ( ($PERCENT_ZC_static < 20) && ( $zap_client_counter > 3 ) ) or + ( ($PERCENT_ZC_static < 40) && ( $zap_client_counter > 9 ) ) or + ( ($PERCENT_IC_static < 20) && ( $iax_client_counter > 3 ) ) or + ( ($PERCENT_IC_static < 40) && ( $iax_client_counter > 9 ) ) or + ( ($PERCENT_SC_static < 20) && ( $sip_client_counter > 3 ) ) or + ( ($PERCENT_SC_static < 40) && ( $sip_client_counter > 9 ) ) ) + { + $UD_bad_grab++; + $event_string="------ UPDATER BAD GRAB!!! UBGcount: $UD_bad_grab\n $PERCENT_static $#list_channels $#DBchannels:$channel_counter $#DBsips:$sip_counter $PERCENT_ZC_static|$test_zap_count:$zap_client_counter $PERCENT_IC_static|$test_iax_count:$iax_client_counter $PERCENT_LC_static|$test_local_count:$local_client_counter $PERCENT_SC_static|$test_sip_count:$sip_client_counter\n"; + print "$event_string\n"; + &event_logger; + if ($UD_bad_grab > 20) {$UD_bad_grab=0;} + } + else + { + $UD_bad_grab=0; + if ( ($endless_loop =~ /0$/) && ($SYSPERF) ) + { + $cpuUSERcent=0; $cpuSYSTcent=0; $cpuIDLEcent=0; + ### get processor usage seconds ### + # cpu 924841 211725 270473 6961811 + @cpuUSE = `/usr/bin/cat /proc/stat`; + if ($cpuUSE[0] =~ /cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) + { + $cpuUSER = ($1 + $2); + $cpuSYST = $3; + $cpuIDLE = $4; + $cpuUSERdiff = ($cpuUSER - $cpuUSERprev); + $cpuSYSTdiff = ($cpuSYST - $cpuSYSTprev); + $cpuIDLEdiff = ($cpuIDLE - $cpuIDLEprev); + $cpuIDLEdiffTOTAL = (($cpuUSERdiff + $cpuSYSTdiff) + $cpuIDLEdiff); + if ($cpuIDLEdiffTOTAL > 0) + { + $cpuUSERcent = sprintf("%.0f", (($cpuUSERdiff / $cpuIDLEdiffTOTAL) * 100)); + $cpuSYSTcent = sprintf("%.0f", (($cpuSYSTdiff / $cpuIDLEdiffTOTAL) * 100)); + $cpuIDLEcent = sprintf("%.0f", (($cpuIDLEdiff / $cpuIDLEdiffTOTAL) * 100)); + } + $cpuUSERprev=$cpuUSER; + $cpuSYSTprev=$cpuSYST; + $cpuIDLEprev=$cpuIDLE; + } + + ### get system load ### + $serverLOAD = `/usr/bin/cat /proc/loadavg`; + $serverLOAD =~ s/ .*//gi; + $serverLOAD =~ s/\D//gi; + + ### get memory usage ### + @GRABserverMEMORY = `/usr/bin/free -m -t`; + if ($GRABserverMEMORY[1] =~ /Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+/) + { + $MEMused = $2; + $MEMfree = $3; + } + ### get number of system processes ### + @GRABserverPROCESSES = `/bin/ps -A --no-heading`; + $serverPROCESSES = $#GRABserverPROCESSES; + + if ($SYSPERF_rec) {$recording_count = ($test_local_count / 2)} + else {$recording_count=0;} + + if ($SYSPERFDB) + {print "$serverLOAD $MEMfree $MEMused $serverPROCESSES $#list_channels $cpuUSERcent $cpuSYSTcent $cpuIDLEcent\n";} + + $stmtA = "INSERT INTO server_performance (start_time,server_ip,sysload,freeram,usedram,processes,channels_total,trunks_total,clients_total,clients_zap,clients_iax,clients_local,clients_sip,live_recordings,cpu_user_percent,cpu_system_percent,cpu_idle_percent) values('$now_date','$server_ip','$serverLOAD','$MEMfree','$MEMused','$serverPROCESSES','$#list_channels','$channel_counter','$sip_counter','$test_zap_count','$test_iax_count','$test_local_count','$test_sip_count','$recording_count','$cpuUSERcent','$cpuSYSTcent','$cpuIDLEcent')"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } + } + + if ($endless_loop =~ /00$/) + { + ##### LOOK FOR ZAP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS + print STDERR "LOOKING FOR Zap clients assigned to this server:\n"; + $Zap_client_count=0; + $Zap_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'Zap' and server_ip='$server_ip'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + print STDERR $record->[0],"\n"; + $Zap_client_list .= "$record->[0]|"; + $Zap_client_count++; + } + } + + ##### LOOK FOR IAX2 CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS + print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n"; + $IAX2_client_count=0; + $IAX2_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'IAX2' and server_ip='$server_ip'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + print STDERR $record->[0],"\n"; + $IAX2_client_list .= "$record->[0]|"; + if ($record->[0] !~ /\@/) + {$IAX2_client_list .= "$record->[0]$AMP$record->[0]|";} + else + { + $IAX_user = $record->[0]; + $IAX_user =~ s/\@.*$//gi; + $IAX2_client_list .= "$IAX_user|"; + } + $IAX2_client_count++; + } + } + + ##### LOOK FOR SIP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS + print STDERR "LOOKING FOR SIP clients assigned to this server:\n"; + $SIP_client_count=0; + $SIP_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'SIP' and server_ip='$server_ip'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + print STDERR $record->[0],"\n"; + $SIP_client_list .= "$record->[0]|"; + if ($record->[0] !~ /\@/) + {$SIP_client_list .= "$record->[0]$AMP$record->[0]|";} + else + { + $SIP_user = $record->[0]; + $SIP_user =~ s/\@.*$//gi; + $SIP_client_list .= "$SIP_user|"; + } + $SIP_client_count++; + } + } + + + print STDERR "Zap Clients: $Zap_client_list\n"; + print STDERR "IAX2 Clients: $IAX2_client_list\n"; + print STDERR "SIP Clients: $SIP_client_list\n"; + } + + @list_chan_12=@MT; + $EXcount = 0; + $EXcount = @{[$list_channels[2] =~ /\!/g]}; + if ($EXcount > 10) + { + @list_chan_12 = split(/\!/, $list_channels[2]); + } + else + { + @list_chan_12 = split(/:/, $list_channels[2]); + } + if( ($DB) && ($show_channels_12_format) ) {print "concise: $#list_chan_12\n";} + if ( ( ( ($list_channels[1] =~ /State Appl\./) or ($list_channels[2] =~ /State Appl\.|Application\(Data\)/) or ($list_channels[3] =~ /State Appl\.|Application\(Data\)/) ) || ($#list_chan_12 > 8) ) && (!$UD_bad_grab) ) + { + + $c=0; + if($DB){print "lines: $#list_channels\n";} + if($DB){print "DBchn: $#DBchannels\n";} + if($DB){print "DBsip: $#DBsips\n";} + foreach(@list_channels) + { + # $DBchannels =~ s/^\|//g; + + chomp($list_channels[$c]); + if( ($DB) or ($UD_bad_grab) ){print "-|$c|$list_channels[$c]|\n";} + $list_channels[$c] =~ s/Congestion\s+\(Empty\)/ SIP\/CONGEST/gi; + $list_channels[$c] =~ s/\(Outgoing Line\)|\(None\)/SIP\/ring/gi; + $list_channels[$c] =~ s/\(Empty\)/SIP\/internal/gi; + if (!$show_channels_12_format) + { + $list_channels[$c] =~ s/^\s*|\s*$//gi; + $list_channels[$c] =~ s/\(.*\)//gi; + } + else + { + @list_chan_12=@MT; + if ($EXcount > 10) + { + @list_chan_12 = split(/\!/, $list_channels[$c]); + } + else + { + @list_chan_12 = split(/:/, $list_channels[$c]); + } + if ($DBX) {print "EXcount: $EXcount\n";} + if (length($list_chan_12[6])<2) {$list_chan_12[6] = 'SIP/ring';} + $list_channels[$c] = "$list_chan_12[0] $list_chan_12[6]"; + } + $list_SIP[$c] = $list_channels[$c]; + if( ($DB) or ($UD_bad_grab) ){print "+|$c|$list_channels[$c]|\n\n";} + + ########## PARSE EACH LINE TO DETERMINE WHETHER IT IS TRUNK OR CLIENT AND PUT IN APPROPRIATE TABLE + if ($list_channels[$c] =~ /^Zap|^IAX2|^SIP|^Local/) + { + if ($list_channels[$c] =~ /^(\S+)\s+.+\s+(\S+)$/) + { + $line_type = ''; + $channel = $1; + $extension = $2; + $channel_data = $extension; + if ($show_channels_12_format) + { + $extension =~ s/^.*\(|\).*$//gi; + #### new data in 1.2 for future use + # SIP/cc160-7b91:default:917274514920:3:Up:Dial:Zap/g2/17274514920|30|o:cc160::3:9:Zap/25-1 + # Zap/30-1:demo:010*010*010*012*8600091:1:Up:Dial:IAX2/TESTast2:test@10.10.10.12:4569/8600051|25|o:::3:123:IAX2/TESTast2-29 + # Zap/9-1:demo:990009*CL_UMGCOF_L**6317906**9545541833*13678*:2:Up:Dial:Zap/r3/90009*CL_UMGCOF_L**6317906**9545541833*13678*|120|o:::3:334:Zap/82-1 + # $channel = $list_chan_12[0]; + # $channel_data = $list_chan_12[0]; + # $context = $list_chan_12[1]; + # $dialed = $list_chan_12[2]; + # $priority = $list_chan_12[3]; + # $state = $list_chan_12[4]; + # $extension = $list_chan_12[6]; + # $callerid = $list_chan_12[7]; + # $duration = $list_chan_12[10]; + # $bridged = $list_chan_12[11]; + } + $extension =~ s/^SIP\/|-\S+$//gi; + $extension =~ s/\|.*//gi; + $QRYchannel = "$channel$US$extension"; + + if( ($DB) or ($UD_bad_grab) ){print "channel: |$channel|\n";} + if( ($DB) or ($UD_bad_grab) ){print "extension: |$extension|\n";} + if( ($DB) or ($UD_bad_grab) ){print "QRYchannel:|$QRYchannel|\n";} + + if ($channel =~ /^SIP|^Zap|^IAX2/) {$line_type = 'TRUNK';} + if ($channel =~ /^Local/) {$line_type = 'CLIENT';} + if ($IAX2_client_count) + { + $channel_match=$channel; + $channel_match =~ s/\/\d+$|-\d+$//gi; + $channel_match =~ s/^IAX2\///gi; + # print "checking for IAX2 client: |$channel_match|\n"; + if ($IAX2_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} + } + if ($Zap_client_count) + { + $channel_match=$channel; + $channel_match =~ s/^Zap\///gi; + # print "checking for Zap client: |$channel_match|\n"; + if ($Zap_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} + } + if ($SIP_client_count) + { + $channel_match=$channel; + $channel_match =~ s/-\S+$//gi; + $channel_match =~ s/^SIP\///gi; + # print "checking for SIP client: |$channel_match|\n"; + if ($SIP_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} + } + + if ($line_type eq 'TRUNK') + { + if( ($DB) or ($UD_bad_grab) ){print "current channels: $#DBchannels\n";} + + $k=0; + $channel_in_DB=0; + foreach(@DBchannels) + { + if ( ($DBchannels[$k] eq "$QRYchannel") && (!$channel_in_DB) ) + { + $DBchannels[$k] = ''; + $channel_in_DB++; + } + if( ($DB) or ($UD_bad_grab) ){print "DB $k|$DBchannels[$k]| |";} + $k++; + } + + if ( (!$channel_in_DB) && (length($QRYchannel)>3) ) + { + $stmtA = "INSERT INTO $live_channels (channel,server_ip,extension,channel_data) values('$channel','$server_ip','$extension','$channel_data')"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } + } + + if ($line_type eq 'CLIENT') + { + if( ($DB) or ($UD_bad_grab) ){print "current sips: $#DBsips\n";} + + $k=0; + $sipchan_in_DB=0; + foreach(@DBsips) + { + if ( ($DBsips[$k] eq "$QRYchannel") && (!$sipchan_in_DB) ) + { + $DBsips[$k] = ''; + $sipchan_in_DB++; + } + if( ($DB) or ($UD_bad_grab) ){print "DB $k|$DBsips[$k]| |";} + $k++; + } + + if ( (!$sipchan_in_DB) && (length($QRYchannel)>3) ) + { + $stmtA = "INSERT INTO $live_sip_channels (channel,server_ip,extension,channel_data) values('$channel','$server_ip','$extension','$channel_data')"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } + } + } + } + + $c++; + } + if($DB){print "COUNT: $c|$#list_channels|$endless_loop\n";} + + + if ($#DBchannels >= 0) + { + $d=0; + foreach(@DBchannels) + { + if (length($DBchannels[$d])>4) + { + ($DELchannel, $DELextension) = split(/\_\_/, $DBchannels[$d]); + $stmtB = "DELETE FROM $live_channels where server_ip='$server_ip' and channel='$DELchannel' and extension='$DELextension' limit 1"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $dbhA->query($stmtB); + # $dbhA->query($stmtB) or die "Couldn't execute query:\n"; + } + $d++; + } + } + + if ($#DBsips >= 0) + { + $d=0; + foreach(@DBsips) + { + if (length($DBsips[$d])>4) + { + ($DELchannel, $DELextension) = split(/\_\_/, $DBsips[$d]); + $stmtB = "DELETE FROM $live_sip_channels where server_ip='$server_ip' and channel='$DELchannel' and extension='$DELextension' limit 1"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $dbhA->query($stmtB); + # $dbhA->query($stmtB) or die "Couldn't execute query:\n"; + } + $d++; + } + } + + ### sleep for 45 hundredths of a second + usleep(1*450*1000); + + $endless_loop--; + if($DB){print STDERR "\nloop counter: |$endless_loop|\n";} + + ### putting a blank file called "update.kill" in a directory will automatically safely kill this program + if (-e '/home/cron/update.kill') + { + unlink('/home/cron/update.kill'); + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n" + } + + $bad_grabber_counter=0; + $no_channels_12_counter=0; + } + + else + { + if ( ($list_channels[1] !~ /Privilege: Command/) && ($show_channels_12_format) ) + { + $bad_grabber_counter++; + if($DB){print STDERR "\nbad grab, trying again\n";} + ### sleep for 20 hundredths of a second + usleep(1*200*1000); + + $event_string="BAD GRAB TRYING AGAIN|BAD_GRABS: $bad_grabber_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + + if ($bad_grabber_counter > 100) + { + $endless_loop=0; + $event_string="TOO MANY BAD GRABS, STARTING NEW CONNECTION|BAD_GRABS: $bad_grabber_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + $bad_grabber_counter=0; + } + } + else + { + $no_channels_12_counter++; + $event_string="NO CHANNELS HERE|COUNTER: $no_channels_12_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|$list_channels[1]"; + &event_logger; + + if($DBX) {print "*|EMPTY CHANNELS: $no_channels_12_counter|$#list_channels|$list_channels[1]";} + + ### sleep for 40 hundredths of a second + usleep(1*400*1000); + if ($no_channels_12_counter == 3) + { + ### there are no channels, delete all from live_channels, live_sip_channels + $event_string="NO CHANNELS HERE|COUNTER: $no_channels_12_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|$list_channels[1]"; + &event_logger; + $stmtB = "DELETE FROM $live_sip_channels where server_ip='$server_ip'"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $dbhA->query($stmtB); + $stmtB = "DELETE FROM $live_channels where server_ip='$server_ip'"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $dbhA->query($stmtB); + } + + } + } + + + } + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} + + $event_string='HANGING UP|'; + &event_logger; + + @hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/"); + + $ok = $t->close; + + $one_day_interval--; + +} + + $event_string='CLOSING DB CONNECTION|'; + &event_logger; + + + $dbhA->close; + + + if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} + + +exit; + + + + + + + +####################################################################### +# This subroutine simply grabs all active channel/extension combinations from +# the asterisk MySQL database to be compared to the Asterisk Manager results +####################################################################### +sub get_current_channels +{ +$channel_counter=0; +$sip_counter=0; +$zap_client_counter=0; +$iax_client_counter=0; +$local_client_counter=0; +$sip_client_counter=0; + + if($DB){print STDERR "\n|SELECT channel,extension FROM $live_channels where server_ip = '$server_ip'|\n";} + +$dbhA->query("SELECT channel,extension FROM $live_channels where server_ip = '$server_ip'"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"|", $record->[1],"\n";} + $DBchannels[$channel_counter] = "$record->[0]$US$record->[1]"; + + $channel_counter++; + $rec_count++; + } + } + +$dbhA->query("SELECT channel,extension FROM $live_sip_channels where server_ip = '$server_ip'"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count_sip=0; + while ( $record = $iter->each) + { + if($DB){print STDERR $record->[0],"|", $record->[1],"\n";} + $DBsips[$sip_counter] = "$record->[0]$US$record->[1]"; + + if ($record->[0] =~ /^Zap/) {$zap_client_counter++;} + if ($record->[0] =~ /^IAX/) {$iax_client_counter++;} + if ($record->[0] =~ /^Local/) {$local_client_counter++;} + if ($record->[0] =~ /^SIP/) {$sip_client_counter++;} + $sip_counter++; + $rec_count_sip++; + } + } + + &get_time_now; + +$stmtU = "UPDATE $server_updater set last_update='$now_date' where server_ip='$server_ip'"; + if($DB){print STDERR "\n|$stmtU|\n";} +$dbhA->query($stmtU); + +} + + + + + +####################################################################### +# The purpose of this subroutine is to make sure that the calls that are +# listed as parked in the parked_channels table are in fact live (to make +# sure the caller has not hung up) and if the channel is not live to delete +# the parked_channels entry for that specific parked channel entry +# +# Yes it does use two DB connections all by itself, I just did that for speed +# and ease of programming to be backward compatible with MySQL < 4.1 or else +# I would have used a delete with subselect and saved all of this bloated code +####################################################################### +sub validate_parked_channels +{ + +if (!$run_validate_parked_channels_now) + { + + $parked_counter=0; + @ARchannel=@MT; @ARextension=@MT; @ARparked_time=@MT; @ARparked_time_UNIX=@MT; + $dbhA->query("SELECT channel,extension,parked_time,UNIX_TIMESTAMP(parked_time) FROM $parked_channels where server_ip = '$server_ip' order by channel desc, parked_time desc"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $PQchannel = $record->[0]; + $PQextension = $record->[1]; + $PQparked_time = $record->[2]; + $PQparked_time_UNIX = $record->[3]; + if($DB){print STDERR "\n|$PQchannel|$PQextension|$PQparked_time|$PQparked_time_UNIX|\n";} + + my $dbhC = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + $AR=0; + $record_deleted=0; + foreach(@ARchannel) + { + if (@ARchannel[$AR] eq "$PQchannel") + { + if (@ARparked_time_UNIX[$AR] > $PQparked_time_UNIX) + { + if($DBX){print "Duplicate parked channel delete: |$PQchannel|$PQparked_time|\n";} + $stmtPQ = "DELETE FROM $parked_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension' and parked_time='$PQparked_time' limit 1"; + if($DB){print STDERR "\n|$stmtPQ|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n\n";} + $dbhC->query($stmtPQ); + + $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; + $$DEL_chan_park_counter=0; + $record_deleted++; + } + + } + + $AR++; + } + + + + if (!$record_deleted) + { + $ARchannel[$rec_count] = $record->[0]; + $ARextension[$rec_count] = $record->[1]; + $ARparked_time[$rec_count] = $record->[2]; + $ARparked_time_UNIX[$rec_count] = $record->[3]; + + + my $dbhB = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + $event_string='LOGGED INTO MYSQL SERVER ON 2 CONNECTIONS TO VALIDATE PARKED CALLS|'; + &event_logger; + + + $dbhB->query("SELECT count(*) FROM $live_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension'"); + if ($dbhB->has_selected_record) + { + $iterB=$dbhB->create_record_iterator; + $rec_countB=0; + while ( $recordB = $iterB->each) + { + $PQcount = $recordB->[0]; + if($DB){print STDERR "\n|$PQcount|\n";} + + if ($PQcount < 1) + { + $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; + $$DEL_chan_park_counter++; + if($DBX){print STDERR "Parked counter down|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n";} + + ### if the parked channel doesn't exist 6 times then delete it from table + if ($$DEL_chan_park_counter > 5) + { + if($DBX){print " parked channel delete: |$PQchannel|$PQparked_time|\n";} + $stmtPQ = "DELETE FROM $parked_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension' limit 1"; + if($DB){print STDERR "\n|$stmtPQ|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n\n";} + $dbhC->query($stmtPQ); + + $ARchannel[$rec_count] = ''; + $ARextension[$rec_count] = ''; + $ARparked_time[$rec_count] = ''; + $ARparked_time_UNIX[$rec_count] = ''; + $$DEL_chan_park_counter=0; + } + } + else + { + $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; + $$DEL_chan_park_counter=0; + } + } + } + + $event_string='CLOSING MYSQL CONNECTIONS OPENED TO VALIDATE PARKED CALLS|'; + &event_logger; + + + $dbhB->close; + + } + + $dbhC->close; + + } + $parked_counter++; + $rec_count++; + } + + $run_validate_parked_channels_now=5; # set to run every five times the subroutine runs + + } + + $run_validate_parked_channels_now--; + +} + + + + + +################################################################################ +##### get the current date and time and epoch for logging call lengths and datetimes +sub get_time_now +{ +($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) {$Fhour = "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"; +} + + + + + +################################################################################ +##### open the log file for writing ### +sub event_logger +{ +open(Lout, ">>$LOGfile") + || die "Can't open $LOGfile: $!\n"; +print Lout "$now_date|$event_string|\n"; +close(Lout); +$event_string=''; +} diff --git a/agc_2-X/trunk/AST_vm_update.pl b/agc_2-X/trunk/AST_vm_update.pl new file mode 100644 index 00000000..6125ad70 --- /dev/null +++ b/agc_2-X/trunk/AST_vm_update.pl @@ -0,0 +1,202 @@ +#!/usr/bin/perl +# +# AST_vm_update.pl version 0.3 +# +# DESCRIPTION: +# uses the Asterisk Manager interface and Net::MySQL to update the count of +# voicemail messages for each mailbox (in the phone table) in the voicemail +# table list is used by client apps for voicemail notification +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with voicemail +# +# For the client program to notify of new messaged, this program must be in the +# cron running every minute +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# It is recommended that you run this program on the local Asterisk machine +# +# If this script is run ever minute there is a theoretical limit of +# 600 mailboxes that it can check due to the wait interval. If you have +# more than this either change the cron when this script is run or change the +# wait interval below +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50823-1422 - Added database server variable definitions lookup +# 50823-1452 - Added commandline arguments for debug at runtime +# + +# constants +$DB=0; # Debug flag, set to 0 for no debug messages per minute +$US='__'; +$MT[0]=''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Net::MySQL; +use Net::Telnet (); + + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### 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 FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBtelnet_host = "$record->[0]"; + $DBtelnet_port = "$record->[1]"; + $DBASTmgrUSERNAME = "$record->[2]"; + $DBASTmgrSECRET = "$record->[3]"; + $DBASTmgrUSERNAMEupdate = "$record->[4]"; + $DBASTmgrUSERNAMElisten = "$record->[5]"; + $DBASTmgrUSERNAMEsend = "$record->[6]"; + $DBmax_vicidial_trunks = "$record->[7]"; + $DBanswer_transfer_agent= "$record->[8]"; + $DBSERVER_GMT = "$record->[9]"; + $DBext_context = "$record->[10]"; + 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;} + if ($DBmax_vicidial_trunks) {$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;} + } + } + +@PTextensions=@MT; @PTvoicemail_ids=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT; +$dbhA->query("SELECT extension,voicemail_id,messages,old_messages from phones where server_ip='$server_ip'"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) + { + $PTextensions[$rec_count] = "$record->[0]"; + $PTvoicemail_ids[$rec_count] = "$record->[1]"; + $PTmessages[$rec_count] = "$record->[2]"; + $PTold_messages[$rec_count] = "$record->[3]"; + $rec_count++; + } + } + + +### connect to asterisk manager through telnet +$t = new Net::Telnet (Port => 5038, + Prompt => '/.*[\$%#>] $/', + Output_record_separator => '',); +#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log + if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;} + else {$telnet_login = $ASTmgrUSERNAME;} + +$t->open("$telnet_host"); +$t->waitfor('/0\n$/'); # print login +$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n"); +$t->waitfor('/Authentication accepted/'); # waitfor auth accepted + + +$i=0; +foreach(@PTextensions) + { + @list_channels=@MT; + $t->buffer_empty; + @list_channels = $t->cmd(String => "Action: MailboxCount\nMailbox: $PTvoicemail_ids[$i]\n\nAction: Ping\n\n", Prompt => '/Response: Pong.*/'); + + $j=0; + foreach(@list_channels) + { + if ($list_channels[$j] =~ /Mailbox: $PTvoicemail_ids[$i]/) + { + $NEW_messages[$i] = "$list_channels[$j+1]"; + $NEW_messages[$i] =~ s/NewMessages: |\n//gi; + $OLD_messages[$i] = "$list_channels[$j+2]"; + $OLD_messages[$i] =~ s/OldMessages: |\n//gi; + } + + $j++; + } + + if($DB){print "MailboxCount- $PTvoicemail_ids[$i] NEW:|$NEW_messages[$i]| OLD:|$OLD_messages[$i]| ";} + if ( ($NEW_messages[$i] eq $PTmessages[$i]) && ($OLD_messages[$i] eq $PTold_messages[$i]) ) + { + if($DB){print "MESSAGE COUNT UNCHANGED, DOING NOTHING FOR THIS MAILBOX\n";} + } + else + { + $stmtA = "UPDATE phones set messages='$NEW_messages[$i]', old_messages='$OLD_messages[$i]' where server_ip='$server_ip' and extension='$PTextensions[$i]'"; + if($DB){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA) or die "Couldn't execute query:|$stmtA|\n"; + } + + $i++; + ### sleep for 10 hundredths of a second + usleep(1*100*1000); + } + + +$t->buffer_empty; +@hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/"); +$t->buffer_empty; +$ok = $t->close; + +$dbhA->close; + +if($DB){print "DONE... Exiting... Goodbye... See you later... \n";} + +exit; + + + + diff --git a/agc_2-X/trunk/DBI-scripts/AST_VDhopper.pl b/agc_2-X/trunk/DBI-scripts/AST_VDhopper.pl new file mode 100644 index 00000000..414bdded --- /dev/null +++ b/agc_2-X/trunk/DBI-scripts/AST_VDhopper.pl @@ -0,0 +1,1188 @@ +#!/usr/bin/perl +# +# AST_VDhopper.pl version 0.10 +# *** DBI version *** +# +# DESCRIPTION: +# uses DBD::MySQL to update the VICIDIAL leads hopper for the streamlined +# approach of allocating leads to client machines. +# +# SUMMARY: +# This program was designed for people using the Asterisk PBX with VICIDIAL +# +# For the client to use VICIDIAL, this program must be in the cron running +# every minute +# +# For this program to work you need to have the "asterisk" MySQL database +# created and create the tables listed in the CONF_MySQL.txt file, also make sure +# that the machine running this program has read/write/update/delete access +# to that database +# +# It is recommended that you run this program on the local Asterisk machine +# +# If this script is run ever minute and you are getting close to no leads after +# a minute, you may want to play with the variables below to streamline for +# your usage +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# 50810-1613 - Added database server variable definitions lookup +# 60215-1106 - Added Scheduled Callback release functionality +# 60228-1623 - Change Callback activation to set the called_since_last_reset=N +# 60228-1735 - Added hopper gmt validation to remove gmt outside of time range +# 60320-0932 - Added inactive lead list hopper deletion (Thanks Vic Jolin) +# 60322-1030 - Added super debug output +# 60418-0947 - Added lead filter per campaign +# 60509-1416 - Rewrite of local_call_time functions +# 60511-1150 - Added inserts into vicidial_campaign_stats table +# 60609-1451 - Added ability to filter by DNC list vicidial_dnc +# 60614-1159 - Added campaign lead recycling ability +# + +# constants +$DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute +$US='__'; +$MT[0]=''; +#$vicidial_hopper='TEST_vicidial_hopper'; # for testing +$vicidial_hopper='vicidial_hopper'; + +# options +$insert_auto_CB_to_hopper = 1; # set to 1 to automatically insert ANYONE callbacks into the hopper + + +($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) {$Fhour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$now_date = "$year-$mon-$mday $hour:$min:$sec"; +$VDL_date = "$year-$mon-$mday 00:00:01"; + +if (!$VDHLOGfile) {$VDHLOGfile = "/home/cron/hopper.$year-$mon-$mday";} + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [--dbgmt] = show GMT offset of records as they are inserted into hopper\n [-t] = test\n [--level=XXX] = force a hopper_level of XXX\n [--campaign=XXX] = run for campaign XXX only\n\n"; + } + else + { + if ($args =~ /--campaign=/i) + { + # print "\n|$ARGS|\n\n"; + @data_in = split(/--campaign=/,$args); + $CLIcampaign = $data_in[1]; + } + else + {$CLIcampaign = '';} + if ($args =~ /--level=/i) + { + @data_in = split(/--level=/,$args); + $CLIlevel = $data_in[1]; + $CLIlevel =~ s/ .*$//gi; + $CLIlevel =~ s/\D//gi; + print "\n-----HOPPER LEVEL OVERRIDE: $CLIlevel -----\n\n"; + } + else + {$CLIlevel = '';} + if ($args =~ /--debug/i) + { + $DB=1; + print "\n----- DEBUG -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER DEBUG -----\n\n"; + } + if ($args =~ /--dbgmt/i) + { + $DB_show_offset=1; + print "\n-----DEBUG GMT -----\n\n"; + } + if ($args =~ /-t/i) + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } + if ($args =~ /--wipe-hopper-clean/i) + { + $wipe_hopper_clean=1; + } + } +} +else +{ +print "no command line options set\n"; +} + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + +### Grab Server values from the database +$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +@aryA = $sthA->fetchrow_array; +$DBSERVER_GMT = $aryA[0]; +if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} +$sthA->finish(); + +$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)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($GMT_now); + $mon++; + $year = ($year + 1900); + 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";} + + if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} + +if ($wipe_hopper_clean) + { + $stmtA = "DELETE from $vicidial_hopper;"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "Hopper Wiped Clean: $affected_rows\n";} + $event_string = "|HOPPER WIPE CLEAN|"; + &event_logger; + + exit; + } +### Delete leads from inactive lists if there are any +$stmtA = "SELECT * FROM vicidial_lists where active='N';"; +if ($DB) {print $stmtA;} +$inactive_lists=''; +$inactive_lists_count=0; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +while ($sthArows > $inactive_lists_count) + { + @aryA = $sthA->fetchrow_array; + $inactive_list = $aryA[0]; + $inactive_lists .= "'$inactive_list',"; + $inactive_lists_count++; + } +$sthA->finish(); +if ($DB) {print "Inactive Lists: $inactive_lists_count\n";} + +if ($inactive_lists_count > 0) + { + chop($inactive_lists); + $stmtA = "DELETE from $vicidial_hopper where list_id IN($inactive_lists);"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "Inactive List Leads Deleted: $affected_rows |$stmtA|\n";} + $event_string = "|INACTIVE LIST DEL|$affected_rows|"; + &event_logger; + } + +### BEGIN Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed +$stmtA = "SELECT count(*) FROM vicidial_callbacks where callback_time <= '$now_date' and status='ACTIVE';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +@aryA = $sthA->fetchrow_array; +$CBHOLD_count = $aryA[0]; + if ($DB) {print "CALLBACK HOLD: $CBHOLD_count|$stmtA|\n";} +$sthA->finish(); + +if ($CBHOLD_count > 0) + { + $update_leads=''; + $cbc=0; + $cba=0; + $stmtA = "SELECT vicidial_callbacks.lead_id,recipient,campaign_id,vicidial_callbacks.list_id,gmt_offset_now FROM vicidial_callbacks,vicidial_list where callback_time <= '$now_date' and vicidial_callbacks.status='ACTIVE' and vicidial_callbacks.lead_id=vicidial_list.lead_id;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + while ($sthArows > $cbc) + { + @aryA = $sthA->fetchrow_array; + $lead_ids[$cbc] = $aryA[0]; + $recipient = $aryA[1]; + $update_leads .= "'$lead_ids[$cbc]',"; + if ($recipient == 'ANYONE') + { + $CA_lead_id[$cba] = $aryA[0]; + $CA_campaign_id[$cba] = $aryA[2]; + $CA_list_id[$cba] = $aryA[3]; + $CA_gmt_offset_now[$cba] = $aryA[4]; + $cba++; + } + $cbc++; + } + $sthA->finish(); + if ($cbc > 0) + { + chop($update_leads); + + $stmtA = "UPDATE vicidial_list set status='CALLBK', called_since_last_reset='N' where lead_id IN($update_leads);"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "Scheduled Callbacks Activated: $affected_rows\n";} + $event_string = "|CALLBACKS LISTACT|$affected_rows|"; + &event_logger; + + $stmtA = "UPDATE vicidial_callbacks set status='LIVE' where lead_id IN($update_leads);"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "Scheduled Callbacks Activated: $affected_rows\n";} + $event_string = "|CALLBACKS CB ACT |$affected_rows|"; + &event_logger; + + } + ### INSERT ANYONE CALLBACKS INTO HOPPER DIRECTLY ### + if ( ($cba > 0) && ($insert_auto_CB_to_hopper) ) + { + if ($DB) {print "ANYONE Scheduled Callbacks to Insert into hopper: $cba\n";} + $event_string = "|ANYONE CB HOPPER |$cba|"; + &event_logger; + $CAu=0; + foreach(@CA_lead_id) + { + $stmtA = "INSERT INTO $vicidial_hopper SET lead_id='$CA_lead_id[$CAu]',campaign_id='$CA_campaign_id[$CAu]',list_id='$CA_list_id[$CAu]',gmt_offset_now='$CA_gmt_offset_now[$CAu]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "ANYONE Scheduled Callback Inserted into hopper: $affected_rows|$CA_lead_id[$CAu]\n";} + $CAu++; + } + } + } +### END Change CBHOLD status leads to CALLBK if their vicidial_callbacks time has passed + + +@campaign_id=@MT; + +if ($CLIcampaign) + { + $stmtA = "SELECT * from vicidial_campaigns where campaign_id='$CLIcampaign'"; + } +else + { + $stmtA = "SELECT * from vicidial_campaigns where active='Y'"; + } +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; +while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $campaign_id[$rec_count] = "$aryA[0]"; + $dial_status_a[$rec_count] = "$aryA[3]"; + $dial_status_b[$rec_count] = "$aryA[4]"; + $dial_status_c[$rec_count] = "$aryA[5]"; + $dial_status_d[$rec_count] = "$aryA[6]"; + $dial_status_e[$rec_count] = "$aryA[7]"; + $lead_order[$rec_count] = "$aryA[8]"; + if (!$CLIlevel) + {$hopper_level[$rec_count] = "$aryA[13]";} + else + {$hopper_level[$rec_count] = "$CLIlevel";} + $local_call_time[$rec_count] = "$aryA[16]"; + $lead_filter_id[$rec_count] = "$aryA[35]"; + $use_internal_dnc[$rec_count] = "$aryA[43]"; + $rec_count++; + } +$sthA->finish(); +if ($DB) {print "CAMPAIGNS TO PROCESSES HOPPER FOR: $rec_count|$#campaign_id\n";} + + +##### LOOP THROUGH EACH CAMPAIGN AND PROCESS THE HOPPER ##### +$i=0; +foreach(@campaign_id) + { + $VCSdialable_leads=0; + $VCScalls_today=0; + $VCSdrops_today=0; + $VCSdrops_today_pct=0; + $vicidial_log = 'vicidial_log'; + + $stmtA = "SELECT dialable_leads from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $VCSdialable_leads = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $VCScalls_today = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($VCScalls_today > 0) + { + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $VCSdrops_today = "$aryA[0]"; + if ($VCSdrops_today > 0) + { + $VCSdrops_today_pct = ( ($VCSdrops_today / $VCScalls_today) * 100 ); + $VCSdrops_today_pct = sprintf("%.2f", $VCSdrops_today_pct); + } + $rec_count++; + } + $sthA->finish(); + } + + + + $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today',drops_today='$VCSdrops_today',drops_today_pct='$VCSdrops_today_pct' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "campaign stats updated: $affected_rows|$VCScalls_today|$VCSdrops_today|$VCSdrops_today_pct|$campaign_id[$i]|\n";} + + ##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + if ($DBX) {print "\n |GMT-DAY-HOUR| ";} + while ($p > -13) + { + $pzone = ($GMT_now + ($p * 3600)); + ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); + $phour=($phour * 100); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} + $g++; + } + if ($DBX) {print "\n";} + + $stmtA = "SELECT * FROM vicidial_call_times where call_time_id='$local_call_time[$i]';"; + if ($DBX) {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; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $Gct_default_start = "$aryA[3]"; + $Gct_default_stop = "$aryA[4]"; + $Gct_sunday_start = "$aryA[5]"; + $Gct_sunday_stop = "$aryA[6]"; + $Gct_monday_start = "$aryA[7]"; + $Gct_monday_stop = "$aryA[8]"; + $Gct_tuesday_start = "$aryA[9]"; + $Gct_tuesday_stop = "$aryA[10]"; + $Gct_wednesday_start = "$aryA[11]"; + $Gct_wednesday_stop = "$aryA[12]"; + $Gct_thursday_start = "$aryA[13]"; + $Gct_thursday_stop = "$aryA[14]"; + $Gct_friday_start = "$aryA[15]"; + $Gct_friday_stop = "$aryA[16]"; + $Gct_saturday_start = "$aryA[17]"; + $Gct_saturday_stop = "$aryA[18]"; + $Gct_state_call_times = "$aryA[19]"; + $rec_count++; + } + $sthA->finish(); + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $del_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (length($Gct_state_call_times)>2) + { + @state_rules = split(/\|/,$Gct_state_call_times); + $ct_srs = ($#state_rules - 2); + } + while($ct_srs >= $b) + { + if (length($state_rules[$b])>1) + { + $stmtA = "SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + if ($DBX) {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; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $Gstate_call_time_id = "$aryA[0]"; + $Gstate_call_time_state = "$aryA[1]"; + $Gsct_default_start = "$aryA[4]"; + $Gsct_default_stop = "$aryA[5]"; + $Gsct_sunday_start = "$aryA[6]"; + $Gsct_sunday_stop = "$aryA[7]"; + $Gsct_monday_start = "$aryA[8]"; + $Gsct_monday_stop = "$aryA[9]"; + $Gsct_tuesday_start = "$aryA[10]"; + $Gsct_tuesday_stop = "$aryA[11]"; + $Gsct_wednesday_start = "$aryA[12]"; + $Gsct_wednesday_stop = "$aryA[13]"; + $Gsct_thursday_start = "$aryA[14]"; + $Gsct_thursday_stop = "$aryA[15]"; + $Gsct_friday_start = "$aryA[16]"; + $Gsct_friday_stop = "$aryA[17]"; + $Gsct_saturday_start = "$aryA[18]"; + $Gsct_saturday_stop = "$aryA[19]"; + $ct_states .="'$Gstate_call_time_state',"; + $rec_count++; + } + $sthA->finish(); + + $r=0; + $state_gmt=''; + $del_state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + else + {$del_state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $del_state_gmt = "$del_state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + $del_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($del_state_gmt)) "; + } + + $b++; + } + if (length($ct_states)>2) + { + $ct_states =~ s/,$//gi; + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + $del_default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + else + {$del_default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $del_default_gmt = "$del_default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + $del_gmtSQL = "(gmt_offset_now IN($del_default_gmt) $ct_statesSQL) $del_state_gmt_SQL"; + + ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### + + ##### BEGIN lead recycling parsing and prep ### + + $stmtA = "SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id[$i]' and active='Y';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + @recycle_status=@MT; + @recycle_delay=@MT; + @recycle_maximum=@MT; + @RSQLdate=@MT; + $rec_ct=0; + while ($sthArows > $rec_ct) + { + @aryA = $sthA->fetchrow_array; + $recycle_status[$rec_ct] = "$aryA[2]"; + $recycle_delay[$rec_ct] = "$aryA[3]"; + $recycle_maximum[$rec_ct] = "$aryA[4]"; + $rec_ct++; + } + $sthA->finish(); + + if ($rec_ct > 0) + { + $rc=0; + $recycle_SQL = "( "; + while($rc < $rec_ct) + { + $secX = time(); + $Rtarget = ($secX - $recycle_delay[$rc]); + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate[$rc] = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + $Y=1; + $recycle_Y = "'Y'"; + while ($Y < $recycle_maximum[$rc]) + { + $recycle_Y .= ",'Y$Y'"; + $Y++; + } + + if ($rc > 0) {$recycle_SQL .= " or ";} + + $recycle_SQL .= "( (called_since_last_reset IN($recycle_Y)) and (status='$recycle_status[$rc]') and (modify_date < \"$RSQLdate[$rc]\") )"; + + if ($DBX) {print "RECYCLE: |$campaign_id[$i]|$recycle_status[$rc]|$recycle_delay[$rc]|$recycle_maximum[$rc]|$RSQLdate[$rc]|\n";} + $rc++; + } + + $recycle_SQL .= " )"; + + if ($DBX) {print "RECYCLE SQL: |$recycle_SQL|\n";} + } + ##### END lead recycling parsing and prep ### + + if ($DB) {print "Starting hopper run for $campaign_id[$i] campaign- GMT: $local_call_time[$i] HOPPER: $hopper_level[$i] \n";} + + ### Delete the DONE leads if there are any + $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status IN('DONE');"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print " hopper DONE cleared: $affected_rows\n";} + if ($DBX) {print " |$stmtA|\n";} + + ### Delete the leads that are out of GMT time range if there are any + $stmtA = "DELETE from $vicidial_hopper where campaign_id='$campaign_id[$i]' and ($del_gmtSQL);"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print " hopper GMT BAD cleared: $affected_rows\n";} + if ($DBX) {print " |$stmtA|\n";} + + ### Find out how many leads are in the hopper from a specific campaign + $hopper_ready_count=0; + $stmtA = "SELECT count(*) from $vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $hopper_ready_count = $aryA[0]; + if ($DB) {print " hopper READY count: $hopper_ready_count\n";} + if ($DBX) {print " |$stmtA|\n";} + $rec_count++; + } + $sthA->finish(); + $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]||"; + &event_logger; + + ##### IF hopper level is below set minimum, then try to add more leads ##### + if ($hopper_ready_count < $hopper_level[$i]) + { + if ($DB) {print " hopper too low ($hopper_ready_count|$hopper_level[$i]) starting hopper dump\n";} + + ### Get list of the lists in the campaign ### + $stmtA = "SELECT list_id FROM vicidial_lists where campaign_id='$campaign_id[$i]' and active='Y';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_countLISTS=0; + $camp_lists = ''; + while ($sthArows > $rec_countLISTS) + { + @aryA = $sthA->fetchrow_array; + $camp_lists .= "'$aryA[0]',"; + $rec_countLISTS++; + } + $sthA->finish(); + if (length($camp_lists)<3) {$camp_lists="''";} + else {chop($camp_lists);} + + if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";} + if ($DBX) {print " |$stmtA|\n";} + + if ( ($lead_filter_id[$i] !~ /NONE/) && (length($lead_filter_id[$i])>0) ) + { + ### Get SQL of lead filter for the campaign ### + $stmtA = "SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$lead_filter_id[$i]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $lead_filter_sql[$i] = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + $lead_filter_sql[$i] =~ s/^and|and$|^or|or$|^ and|and $|^ or|or $//gi; + $lead_filter_sql[$i] = "and $lead_filter_sql[$i]"; + if ($DB) {print " campaign lists count: $rec_countLISTS | $camp_lists\n";} + if ($DB) {print " lead filter $lead_filter_id[$i] defined for $campaign_id[$i]\n";} + if ($DBX) {print " |$lead_filter_sql[$i]|\n";} + } + else + { + $lead_filter_sql[$i] = ''; + if ($DB) {print " no lead filter defined for campaign: $campaign_id[$i]\n";} + if ($DBX) {print " |$lead_filter_id[$i]|\n";} + } + + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and ($all_gmtSQL) $lead_filter_sql[$i];"; + if ($DBX) {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; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $campaign_leads_to_call = "$aryA[0]"; + if ($DB) {print " leads to call count: $campaign_leads_to_call\n";} + if ($DBX) {print " |$stmtA|\n";} + $rec_count++; + } + $sthA->finish(); + + if ($lead_order[$i] =~ /DOWN COUNT 2nd NEW|DOWN COUNT 3rd NEW|DOWN COUNT 4th NEW/) + { + $stmtA = "SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and ($all_gmtSQL) $lead_filter_sql[$i];"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $NEW_campaign_leads_to_call = "$aryA[0]"; + if ($DB) {print " NEW leads to call count: $NEW_campaign_leads_to_call\n";} + if ($DBX) {print " |$stmtA|\n";} + $rec_count++; + } + $sthA->finish(); + } + + ##### IF no NEW leads to be called, error out of this campaign ##### + if ( ($lead_order[$i] =~ /DOWN COUNT 2nd NEW|DOWN COUNT 3rd NEW|DOWN COUNT 4th NEW/) && ($NEW_campaign_leads_to_call > 0) ) {$GOOD=1;} + else + { + if ($DB) {print " ERROR CANNOT ADD ANY NEW LEADS TO HOPPER\n";} + } + + ##### IF no leads to be called, error out of this campaign ##### + if ($campaign_leads_to_call < 1) + { + if ($DB) {print " ERROR CANNOT ADD ANY LEADS TO HOPPER\n";} + if ($VCSdialable_leads > 0) + { + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "CAMPAIGN STATS: $affected_rows|$stmtA|\n";} + } + } + else + { + if ($VCSdialable_leads != $campaign_leads_to_call) + { + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='$campaign_leads_to_call' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "CAMPAIGN STATS: $affected_rows|$stmtA|\n";} + } + if ($DB) {print " Getting Leads to add to hopper\n";} + ### grab leads already in hopper so we don't duplicate + $stmtA = "SELECT lead_id FROM $vicidial_hopper where campaign_id='$campaign_id[$i]';"; + if ($DBX) {print " |$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $lead_id_lists = ''; + $rec_countLISTS=0; + while ($sthArows > $rec_countLISTS) + { + @aryA = $sthA->fetchrow_array; + $lead_id_lists .= "'$aryA[0]',"; + $rec_countLISTS++; + } + $sthA->finish(); + $lead_id_lists .= "'0'"; + $order_stmt=''; + $NEW_count = 0; + $NEW_level = 0; + $OTHER_level = $hopper_level[$i]; + if ($lead_order[$i] eq "DOWN") {$order_stmt = 'order by lead_id asc';} + if ($lead_order[$i] eq "UP") {$order_stmt = 'order by lead_id desc';} + if ($lead_order[$i] eq "UP LAST NAME") {$order_stmt = 'order by last_name desc, lead_id asc';} + if ($lead_order[$i] eq "DOWN LAST NAME") {$order_stmt = 'order by last_name, lead_id asc';} + if ($lead_order[$i] eq "UP PHONE") {$order_stmt = 'order by phone_number desc, lead_id asc';} + if ($lead_order[$i] eq "DOWN PHONE") {$order_stmt = 'order by phone_number, lead_id asc';} + if ($lead_order[$i] eq "UP COUNT") {$order_stmt = 'order by called_count desc, lead_id asc';} + if ($lead_order[$i] eq "DOWN COUNT") {$order_stmt = 'order by called_count, lead_id asc';} + if ($lead_order[$i] eq "DOWN COUNT 2nd NEW") {$NEW_count = 2;} + if ($lead_order[$i] eq "DOWN COUNT 3rd NEW") {$NEW_count = 3;} + if ($lead_order[$i] eq "DOWN COUNT 4th NEW") {$NEW_count = 4;} + + ### BEGIN recycle grab leads ### + if ($rec_ct > 0) + { + if ($DB) {print " looking for RECYCLE leads, maximum of 100\n";} + + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where $recycle_SQL and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] limit 100;"; + if ($DBX) {print " |$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($DB) {print " RECYCLE leads to call count: $sthArows\n";} + if ($DBX) {print " |$stmtA|\n";} + $REC_rec_countLEADS=0; + @REC_leads_to_hopper=@MT; + @REC_lists_to_hopper=@MT; + @REC_phone_to_hopper=@MT; + while ($sthArows > $REC_rec_countLEADS) + { + @aryA = $sthA->fetchrow_array; + $REC_leads_to_hopper[$REC_rec_countLEADS] = "$aryA[0]"; + $REC_lists_to_hopper[$REC_rec_countLEADS] = "$aryA[1]"; + $REC_gmt_to_hopper[$REC_rec_countLEADS] = "$aryA[2]"; + $REC_phone_to_hopper[$REC_rec_countLEADS] = "$aryA[3]"; + $REC_state_to_hopper[$REC_rec_countLEADS] = "$aryA[4]"; + if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} + $REC_rec_countLEADS++; + } + $sthA->finish(); + } + ### END recycle grab leads ### + + + + + + + + + if ($NEW_count > 0) + { + $NEW_level = int($hopper_level[$i] / $NEW_count); + $OTHER_level = ($hopper_level[$i] - $NEW_level); + $order_stmt = 'order by called_count, lead_id asc'; + if ($DB) {print " looking for $NEW_level NEW leads mixed in with $OTHER_level other leads\n";} + + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] $order_stmt limit $NEW_level;"; + if ($DBX) {print " |$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $NEW_rec_countLEADS=0; + @NEW_leads_to_hopper=@MT; + @NEW_lists_to_hopper=@MT; + @NEW_phone_to_hopper=@MT; + while ($sthArows > $NEW_rec_countLEADS) + { + @aryA = $sthA->fetchrow_array; + $NEW_leads_to_hopper[$NEW_rec_countLEADS] = "$aryA[0]"; + $NEW_lists_to_hopper[$NEW_rec_countLEADS] = "$aryA[1]"; + $NEW_gmt_to_hopper[$NEW_rec_countLEADS] = "$aryA[2]"; + $NEW_phone_to_hopper[$NEW_rec_countLEADS] = "$aryA[3]"; + $NEW_state_to_hopper[$NEW_rec_countLEADS] = "$aryA[4]"; + if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} + $NEW_rec_countLEADS++; + } + $sthA->finish(); + } + + if ($DB) {print " lead call order: $order_stmt\n";} + $stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a[$i]','$dial_status_b[$i]','$dial_status_c[$i]','$dial_status_d[$i]','$dial_status_e[$i]') and list_id IN($camp_lists) and lead_id NOT IN($lead_id_lists) and ($all_gmtSQL) $lead_filter_sql[$i] $order_stmt limit $OTHER_level;"; + if ($DBX) {print " |$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_countLEADS=0; $NEW_dec=99; $NEW_in=0; + @leads_to_hopper=@MT; + @lists_to_hopper=@MT; + @gmt_to_hopper=@MT; + @state_to_hopper=@MT; + @phone_to_hopper=@MT; + $rec_count=0; + $REC_insert_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + if ( ($NEW_count > 0) && ($NEW_rec_countLEADS > $NEW_in) ) + { + if ($DB_show_offset) {print "NEW_COUNT: $NEW_count|$NEW_dec|$NEW_in|$NEW_rec_countLEADS\n";} + if ($NEW_count > $NEW_dec) + { + $NEW_dec++; + } + else + { + $leads_to_hopper[$rec_countLEADS] = "$NEW_leads_to_hopper[$NEW_in]"; + $lists_to_hopper[$rec_countLEADS] = "$NEW_lists_to_hopper[$NEW_in]"; + $gmt_to_hopper[$rec_countLEADS] = "$NEW_gmt_to_hopper[$NEW_in]"; + $state_to_hopper[$rec_countLEADS] = "$NEW_state_to_hopper[$NEW_in]"; + $phone_to_hopper[$rec_countLEADS] = "$NEW_phone_to_hopper[$NEW_in]"; + if ($DB_show_offset) {print "LEAD_ADD: $NEW_leads_to_hopper[$NEW_in] $NEW_phone_to_hopper[$NEW_in]\n";} + $rec_countLEADS++; + $NEW_in++; + $NEW_dec=2; + } + } + if ($REC_rec_countLEADS > $REC_insert_count) + { + $leads_to_hopper[$rec_countLEADS] = "$REC_leads_to_hopper[$REC_insert_count]"; + $lists_to_hopper[$rec_countLEADS] = "$REC_lists_to_hopper[$REC_insert_count]"; + $gmt_to_hopper[$rec_countLEADS] = "$REC_gmt_to_hopper[$REC_insert_count]"; + $state_to_hopper[$rec_countLEADS] = "$REC_state_to_hopper[$REC_insert_count]"; + $phone_to_hopper[$rec_countLEADS] = "$REC_phone_to_hopper[$REC_insert_count]"; + $rec_countLEADS++; + $REC_insert_count++; + } + $leads_to_hopper[$rec_countLEADS] = "$aryA[0]"; + $lists_to_hopper[$rec_countLEADS] = "$aryA[1]"; + $gmt_to_hopper[$rec_countLEADS] = "$aryA[2]"; + $state_to_hopper[$rec_countLEADS] = "$aryA[4]"; + $phone_to_hopper[$rec_countLEADS] = "$aryA[3]"; + if ($DB_show_offset) {print "LEAD_ADD: $aryA[2] $aryA[3] $aryA[4]\n";} + $rec_countLEADS++; + $rec_count++; + } + $sthA->finish(); + if ($DB) {print " Adding to hopper: $rec_countLEADS\n";} + $event_string = "|$campaign_id[$i]|Added to hopper $rec_countLEADS|"; + &event_logger; + + $h=0; + foreach(@leads_to_hopper) + { + if ($leads_to_hopper[$h] != '0') + { + $DNClead=0; + if ($use_internal_dnc[$i] =~ /Y/) + { + if ($DB) {print " Doinbg DNC Check: $phone_to_hopper[$h] - $use_internal_dnc[$i]\n";} + $stmtA = "SELECT count(*) from vicidial_dnc where phone_number='$phone_to_hopper[$h]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $DNClead = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($DNClead != '0') + { + $stmtA = "UPDATE vicidial_list SET status='DNCL' where lead_id='$leads_to_hopper[$h]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "Flagging DNC lead: $affected_rows $phone_to_hopper[$h]\n";} + } + } + if ($DNClead == '0') + { + $stmtA = "INSERT INTO $vicidial_hopper (lead_id,campaign_id,status,user,list_id,gmt_offset_now,state) values('$leads_to_hopper[$h]','$campaign_id[$i]','READY','','$lists_to_hopper[$h]','$gmt_to_hopper[$h]','$state_to_hopper[$h]');"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "LEAD INSERTED: $affected_rows|$leads_to_hopper[$h]|\n";} + } + } + $h++; + } + if ($DB) {print " DONE with this campaign\n";} + + } + } + + + $i++; + } + + +$dbhA->disconnect(); + +if($DB){print "DONE... Exiting... Goodbye... See you later... Really, I mean it :)\n";} + +exit; + + + +sub event_logger { + ### open the log file for writing ### + open(Lout, ">>$VDHLOGfile") + || die "Can't open $VDHLOGfile: $!\n"; + + print Lout "$now_date|$event_string|\n"; + + close(Lout); + +$event_string=''; +} + + diff --git a/agc_2-X/trunk/DBI-scripts/AST_agent_week.pl b/agc_2-X/trunk/DBI-scripts/AST_agent_week.pl new file mode 100644 index 00000000..e8eb993a --- /dev/null +++ b/agc_2-X/trunk/DBI-scripts/AST_agent_week.pl @@ -0,0 +1,336 @@ +#!/usr/bin/perl + +# AST_agent_week.pl +# +# This script is designed to gather stats for all agent activity over the course +# of a week(Sunday to Saturday) and print it in an ASCI text file to be placed +# on a web server for viewing. +# +# CHANGES +# 60517-1100 - First version +# + +$txt = '.txt'; +$US = '_'; +$MT[0] = ''; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n\n"; + exit; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; + print "\n-----DEBUG MODE-----\n\n"; + } + if ($args =~ /-q/i) + { + $q=1; $Q=1; + } + if ($args =~ /-t/i) + { + $T=1; $TEST=1; + print "\n-----TESTING-----\n\n"; + } + } +} +else +{ +print "no command line options set\n"; +} +### end parsing run-time options ### + + +$secX = time(); + ($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";} + $filedate = "$year$mon$mday-$hour$min$sec"; + $ABIfiledate = "$mon-$mday-$year$us$hour$min$sec"; + $shipdate = "$year-$mon-$mday"; + $datestamp = "$year/$mon/$mday $hour:$min"; + + $STARTtarget = ($secX - (86400 * $wday)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($STARTtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $START_week = (($Syday/7)+1); $START_week = sprintf("%2d", $START_week); + $STARTtarget_date = "$Syear-$Smon-$Smday"; + + $ENDtarget = ($STARTtarget + (86400 * 6)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($ENDtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $ENDtarget_date = "$Syear-$Smon-$Smday"; + + $PAST_STARTtarget = ($STARTtarget - (86400 * 7)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_STARTtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_START_week = (($Syday/7)+1); $PAST_START_week = sprintf("%2d", $PAST_START_week); + $PAST_STARTtarget_date = "$Syear-$Smon-$Smday"; + + $PAST_ENDtarget = ($ENDtarget - (86400 * 7)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_ENDtarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_ENDtarget_date = "$Syear-$Smon-$Smday"; + + $PAST_date[0] = $PAST_STARTtarget_date; + $PAST_day[0] = 'Sunday '; + $PAST_date[6] = $PAST_ENDtarget_date; + $PAST_day[6] = 'Saturday '; + + $PAST_Mondaytarget = ($STARTtarget - (86400 * 6)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Mondaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[1] = "$Syear-$Smon-$Smday"; + $PAST_day[1] = 'Monday '; + + $PAST_Tuesdaytarget = ($STARTtarget - (86400 * 5)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Tuesdaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[2] = "$Syear-$Smon-$Smday"; + $PAST_day[2] = 'Tuesday '; + + $PAST_Wednesdaytarget = ($STARTtarget - (86400 * 4)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Wednesdaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[3] = "$Syear-$Smon-$Smday"; + $PAST_day[3] = 'Wednesday'; + + $PAST_Thursdaytarget = ($STARTtarget - (86400 * 3)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Thursdaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[4] = "$Syear-$Smon-$Smday"; + $PAST_day[4] = 'Thursday '; + + $PAST_Fridaytarget = ($STARTtarget - (86400 * 2)); + ($Ssec,$Smin,$Shour,$Smday,$Smon,$Syear,$Swday,$Syday,$Sisdst) = localtime($PAST_Fridaytarget); + $Syear = ($Syear + 1900); $Smon++; + if ($Smon < 10) {$Smon = "0$Smon";} + if ($Smday < 10) {$Smday = "0$Smday";} + $PAST_date[5] = "$Syear-$Smon-$Smday"; + $PAST_day[5] = 'Friday '; + +print "\n\n\n\n\n\n\n\n\n\n\n\n-- AST_agent_week.pl --\n\n"; +print "This program is designed to print stats to a file for agents' activity for the previous week. \n\n"; + +$TLoutfile = ''; +$TLoutfile .= "TODAY: $shipdate\n"; +$TLoutfile .= "THIS WEEK: week $START_week $STARTtarget_date - $ENDtarget_date\n"; +$TLoutfile .= "LAST WEEK: week $PAST_START_week $PAST_STARTtarget_date - $PAST_ENDtarget_date\n\n"; + +#$h=0; +#foreach(@PAST_date) +#{ +#$TLoutfile .= "$PAST_day[$h] $PAST_date[$h]\n"; +#$h++; +#} + +#print "$TLoutfile"; + + +$outfile = "AGENT_HOURS_$PAST_STARTtarget_date$US$PAST_ENDtarget_date$txt"; + +#$dir = '/usr/local/apache2/htdocs'; +$dir = '/home/www/htdocs'; + +### open the X out file for writing ### +open(out, ">$dir/vicidial/agent_reports/$outfile") + || die "Can't open $outfile: $!\n"; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +$dbhB = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +#$vicidial_agent_log = 'vicidial_agent_log_archive'; +$vicidial_agent_log = 'vicidial_agent_log'; + +########################################################################### +########### PAST WEEK STAT GATHERING LOOP ################################# +########################################################################### +$h=0; +foreach(@PAST_date) +{ + print out "\n$PAST_day[$h] $PAST_date[$h]\n\n"; + print out "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n"; + print "\n$PAST_day[$h] $PAST_date[$h]\n\n"; + print "AGENT USER CALLS TALK PAUSE WAIT DISPO ACTIVE LOGTIME FIRST LAST \n"; + + $stmtA = "select count(*) as calls, full_name,vicidial_users.user,sum(talk_sec),sum(pause_sec),sum(wait_sec),sum(dispo_sec) from vicidial_users,$vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and vicidial_users.user=$vicidial_agent_log.user and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by vicidial_users.user order by full_name limit 10000;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + + $calls = sprintf("%7s", $aryA[0]); + $name = sprintf("%-20s", $aryA[1]); while(length($name)>20) {chop($name);} + $user = sprintf("%-8s", $aryA[2]); + + ### TOTAL ACTIVE TIME + $active = ($aryA[3] + $aryA[4] + $aryA[5] + $aryA[6]); + $TIME_S = $active; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $active = sprintf("%9s", $TIME_HMS); + + ### TOTAL TALK TIME + $TIME_S = $aryA[3]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $talk = sprintf("%9s", $TIME_HMS); + + ### TOTAL PAUSE TIME + $TIME_S = $aryA[4]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $pause = sprintf("%9s", $TIME_HMS); + + ### TOTAL WAIT TIME + $TIME_S = $aryA[5]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $wait = sprintf("%9s", $TIME_HMS); + + ### TOTAL DISPO TIME + $TIME_S = $aryA[6]; + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $dispo = sprintf("%9s", $TIME_HMS); + + $stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time limit 1;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtA ", $dbhB->errstr; + @aryB = $sthB->fetchrow_array; + $first_time = sprintf("%21s", $aryB[0]); + $first_log = $aryB[1]; + + $stmtB = "select event_time,UNIX_TIMESTAMP(event_time) from $vicidial_agent_log where event_time <= '$PAST_date[$h] 23:59:59' and event_time >= '$PAST_date[$h] 00:00:00' and user='$aryA[2]' order by event_time desc limit 1;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtA ", $dbhB->errstr; + @aryB = $sthB->fetchrow_array; + $last_time = sprintf("%21s", $aryB[0]); + $last_log = $aryB[1]; + + $TIME_S = ($last_log - $first_log); + $TIME_H = int($TIME_S / 3600); + $TIME_S = ($TIME_S - ($TIME_H * 3600)); + $TIME_M = int($TIME_S / 60); + $TIME_S = ($TIME_S - ($TIME_M * 60)); + if ($TIME_S < 10) {$TIME_S = "0$TIME_S";} + if ($TIME_M < 10) {$TIME_M = "0$TIME_M";} + $TIME_HMS = "$TIME_H:$TIME_M:$TIME_S"; + $login_time = sprintf("%9s", $TIME_HMS); + + + + print out "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n"; + print "$name$user$calls$talk$pause$wait$dispo$active$login_time$first_time$last_time\n"; + + + $rec_count++; + } + $sthA->finish(); + + + + + + + + + + +#if ($h=='1') +# { +# exit; +# } + +$h++; +} + + + +close(out); + +### calculate time to run script ### +$secY = time(); +$secZ = ($secY - $secX); +$secZm = ($secZ /60); + +print "script execution time in seconds: $secZ minutes: $secZm\n"; + +exit; + + + + + diff --git a/agc_2-X/trunk/DTMF_sounds/0.gsm b/agc_2-X/trunk/DTMF_sounds/0.gsm new file mode 100644 index 00000000..8c57c411 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/0.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/0.wav b/agc_2-X/trunk/DTMF_sounds/0.wav new file mode 100644 index 00000000..fe3fc124 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/0.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/1.gsm b/agc_2-X/trunk/DTMF_sounds/1.gsm new file mode 100644 index 00000000..7f6c842f --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/1.gsm @@ -0,0 +1 @@ +8z*PScOȪP,r)" +E<7j2h#8誙B,65Cb (Ra.4WFR2) 8z.hK]%Mq]ͷM] %ty\ ,Yc:Sd<,iUK:B.eZ%Vn*䡝QE!t+DC5сWETbok]bcCzՔ.46_M]]Dbv])`]kʜ_uY]UU2Fr.]MtZld]C]6]Y[.jR=_a 뭺_ܭ1Z]r2բ)6A]](,Q]\gS4a&Q2c>v\udI$P`u \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/1.wav b/agc_2-X/trunk/DTMF_sounds/1.wav new file mode 100644 index 00000000..e5f5359a Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/1.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/2.gsm b/agc_2-X/trunk/DTMF_sounds/2.gsm new file mode 100644 index 00000000..82d6e751 --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/2.gsm @@ -0,0 +1,3 @@ +xZP4e5cU\ #n7#HVc ͌xC=A`a肹 B+3+x;4QӇx7 T_ xJB<]%]и +]t1]"0s wb2"hϣ& 0_C%,#dAxZ=a#^TIXVաs6IsBtIrx%~—b!a8sa8cF )8xZvEX]#yM02":#8txZv"%|_,äϢ)YxJA}me+6j_-gF|xK>a- +wCY 藡J,FsͮZx<>_"q- ) *Ƭs Psv_cgβrG$R 埗Y \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/2.wav b/agc_2-X/trunk/DTMF_sounds/2.wav new file mode 100644 index 00000000..c3e9edd9 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/2.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/3.gsm b/agc_2-X/trunk/DTMF_sounds/3.gsm new file mode 100644 index 00000000..a41d6679 --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/3.gsm @@ -0,0 +1,2 @@ +;=PW1W#X [r)d[K%7 +$c#2+)UBV4F¬SC{4[Hnpޥꕷbªσ`gC?=W n(*En,{Q6qR=!Ʈ\b#V) h~R=ѓ \%.kn\R=pzr>ܙ=$u R=ρfGϠȵj&ayC<·+61㍂aϣpK;WClRLJ$=Rf%>##xwb LM}bj&V:3k+[? kS%vAbÝ97qݑ \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/3.wav b/agc_2-X/trunk/DTMF_sounds/3.wav new file mode 100644 index 00000000..bc37ff5d Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/3.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/4.gsm b/agc_2-X/trunk/DTMF_sounds/4.gsm new file mode 100644 index 00000000..d2bae3f8 --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/4.gsm @@ -0,0 +1,2 @@ +8PRW\-elG'XVb,b*V rK"bTJ5~aȋf9ZTȁ`IZ^8nYZ2!Qhzk*"xS8nƸ*"fsSzCdփHΡQTmqZsb=iB +Vbc #meTQJeS;4UQ\H'k JX+ 82U" #9k:'Q "I.Sc"7оRr%ڜD~V΢e Vqr!EKi}9EiUELyXz9#3ȭrQ Ysq[HܘaM2 \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/4.wav b/agc_2-X/trunk/DTMF_sounds/4.wav new file mode 100644 index 00000000..05f1adf8 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/4.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/5.gsm b/agc_2-X/trunk/DTMF_sounds/5.gsm new file mode 100644 index 00000000..239c7aca --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/5.gsm @@ -0,0 +1 @@ +xj=P3cWcT qFܚ$DVD%CHxS&TxD?4A9E'ڸU2r [SyqxbWXWlK%a.Ռ̩ح4+Mv_dȗ˱.#IZAY \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/6.wav b/agc_2-X/trunk/DTMF_sounds/6.wav new file mode 100644 index 00000000..7c32ca36 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/6.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/7.gsm b/agc_2-X/trunk/DTMF_sounds/7.gsm new file mode 100644 index 00000000..0260531d --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/7.gsm @@ -0,0 +1,2 @@ +8PR=:^ +r(۞fM[E88vG(QE!f݅ Q[O*֩r<HWSwt8Dx"IGDL4:RīUXj]H䋨L~rA fa֮2_(9FܗL]ëRQh_7#uGB.Vi]McjE2[vADyac]loHtRFz􇁗Hy!Aq8!QȤc=6 B)SdޭU9"<55c=ۉmbSc_ܩHUD{7=_!1֥!S왩n:5P!ku \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/7.wav b/agc_2-X/trunk/DTMF_sounds/7.wav new file mode 100644 index 00000000..6cdce5c1 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/7.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/8.gsm b/agc_2-X/trunk/DTMF_sounds/8.gsm new file mode 100644 index 00000000..e931896a Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/8.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/8.wav b/agc_2-X/trunk/DTMF_sounds/8.wav new file mode 100644 index 00000000..3ed04b3b Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/8.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/9.gsm b/agc_2-X/trunk/DTMF_sounds/9.gsm new file mode 100644 index 00000000..4a994705 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/9.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/9.wav b/agc_2-X/trunk/DTMF_sounds/9.wav new file mode 100644 index 00000000..1439a595 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/9.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_pol_survey_hello.gsm b/agc_2-X/trunk/DTMF_sounds/US_pol_survey_hello.gsm new file mode 100644 index 00000000..62e844ee Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_pol_survey_hello.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_pol_survey_transfer.gsm b/agc_2-X/trunk/DTMF_sounds/US_pol_survey_transfer.gsm new file mode 100644 index 00000000..897afabb Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_pol_survey_transfer.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_reminder_callback.gsm b/agc_2-X/trunk/DTMF_sounds/US_reminder_callback.gsm new file mode 100644 index 00000000..dfb73f5e Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_reminder_callback.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_reminder_goodbye.gsm b/agc_2-X/trunk/DTMF_sounds/US_reminder_goodbye.gsm new file mode 100644 index 00000000..4759fdf8 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_reminder_goodbye.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_reminder_message.gsm b/agc_2-X/trunk/DTMF_sounds/US_reminder_message.gsm new file mode 100644 index 00000000..863cbabf Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_reminder_message.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_reminder_options.gsm b/agc_2-X/trunk/DTMF_sounds/US_reminder_options.gsm new file mode 100644 index 00000000..774fe35c Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_reminder_options.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/US_thanks_no_contact.gsm b/agc_2-X/trunk/DTMF_sounds/US_thanks_no_contact.gsm new file mode 100644 index 00000000..c0e6a2b2 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/US_thanks_no_contact.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/auth-thankyou.gsm b/agc_2-X/trunk/DTMF_sounds/auth-thankyou.gsm new file mode 100644 index 00000000..45e7104e Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/auth-thankyou.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/buzz.gsm b/agc_2-X/trunk/DTMF_sounds/buzz.gsm new file mode 100644 index 00000000..9549d64c Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/buzz.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/ding.gsm b/agc_2-X/trunk/DTMF_sounds/ding.gsm new file mode 100644 index 00000000..2680c52e Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/ding.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/enter.gsm b/agc_2-X/trunk/DTMF_sounds/enter.gsm new file mode 100644 index 00000000..aa4dafb6 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/enter.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/four_digit_id.gsm b/agc_2-X/trunk/DTMF_sounds/four_digit_id.gsm new file mode 100644 index 00000000..5c60505d Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/four_digit_id.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/generic_hold.gsm b/agc_2-X/trunk/DTMF_sounds/generic_hold.gsm new file mode 100644 index 00000000..c76eccd8 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/generic_hold.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/hash.gsm b/agc_2-X/trunk/DTMF_sounds/hash.gsm new file mode 100644 index 00000000..0d0a8ecf --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/hash.gsm @@ -0,0 +1,2 @@ +\}PcȣP tۆD#E)#i(*E3yBF:W2wWԢ6TyuWI+sdWysuk2yct9,,Wk|UTWu#.1c}yQ( dº\2! Q\?;waWnfy.7FW){?YW!Q nSB*qUUy>XWQDm! \ No newline at end of file diff --git a/agc_2-X/trunk/DTMF_sounds/hash.wav b/agc_2-X/trunk/DTMF_sounds/hash.wav new file mode 100644 index 00000000..a079f449 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/hash.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/hold_tone.gsm b/agc_2-X/trunk/DTMF_sounds/hold_tone.gsm new file mode 100644 index 00000000..8f9686cd Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/hold_tone.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/ld_invalid_pin_number.gsm b/agc_2-X/trunk/DTMF_sounds/ld_invalid_pin_number.gsm new file mode 100644 index 00000000..a733207e Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/ld_invalid_pin_number.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/ld_welcome_pin_number.gsm b/agc_2-X/trunk/DTMF_sounds/ld_welcome_pin_number.gsm new file mode 100644 index 00000000..1e77f4b3 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/ld_welcome_pin_number.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/leave.gsm b/agc_2-X/trunk/DTMF_sounds/leave.gsm new file mode 100644 index 00000000..7b3bef01 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/leave.gsm differ diff --git a/agc_2-X/trunk/DTMF_sounds/silence.wav b/agc_2-X/trunk/DTMF_sounds/silence.wav new file mode 100644 index 00000000..62565704 Binary files /dev/null and b/agc_2-X/trunk/DTMF_sounds/silence.wav differ diff --git a/agc_2-X/trunk/DTMF_sounds/star.gsm b/agc_2-X/trunk/DTMF_sounds/star.gsm new file mode 100644 index 00000000..5ec8908e --- /dev/null +++ b/agc_2-X/trunk/DTMF_sounds/star.gsm @@ -0,0 +1,2 @@ +:nPSat֪j*PR6۞D IDCtb LICENSE: GPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Inbound Calls Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Inbound Calls Stats                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls That came into this number:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- TIME STATS\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/admin.php b/agc_2-X/trunk/LANG_admin/astguiclient/admin.php new file mode 100644 index 00000000..75f407c7 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient/admin.php @@ -0,0 +1,1824 @@ + LICENSE: GPLv2 +# +# AST GUI database administration +# +# CHANGES +# 50913-1118 - Added outbound_cid for web-client calls +# 50926-1356 - Modified to allow for language translation +# 50926-1613 - Added WeBRooTWritablE write controls +# 51128-1254 - Modified to allow PHP global vars off +# 51208-2120 - Added option to login with vicidial_user login if allowed +# 51213-1650 - Added option to delete phones if allowed by vicidial_users +# 60421-1430 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1137 - Fixed phone search bug +# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '1.1.12'; +$build = '60620-1243'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS and Dots +$phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); +$computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); + +### DIGITS ONLY ### +$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); +$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id); +$outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); +$VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); +$park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); +$conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); +$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); +$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); +$recording_exten = ereg_replace("[^0-9]","",$recording_exten); +$monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); +$answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); +$DBX_port = ereg_replace("[^0-9]","",$DBX_port); +$DBY_port = ereg_replace("[^0-9]","",$DBY_port); +$telnet_port = ereg_replace("[^0-9]","",$telnet_port); +$max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); +$auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); +$VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); +$enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); +$enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); +$user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); +$updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); +$QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); +$conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); +$voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); +$CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); +$call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); +$AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); +$AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); +$admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); +$admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); +$admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); +$fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); +$ADD = ereg_replace("[^0-9]","",$ADD); + +### ALPHA-NUMERIC and underscore and dash and slash and at and dot +$extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); +$old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); +$install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); +$client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); +$dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); +$call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); +$telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); +$DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); +$DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + +### ALPHA-NUMERIC (and underscore and dash) +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$login = ereg_replace("[^-\_0-9a-zA-Z]","",$login); +$user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); +$status = ereg_replace("[^-\_0-9a-zA-Z]","",$status); +$protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); +$ASTmgrUSERNAMEupdate = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); +$ASTmgrUSERNAMEsend = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); +$ASTmgrUSERNAMElisten = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); +$ASTmgrUSERNAME = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAME); +$ASTmgrSECRET = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrSECRET); +$login_user = ereg_replace("[^-\_0-9a-zA-Z]","",$login_user); +$login_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$login_pass); +$login_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$login_campaign); +$DBX_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_user); +$DBY_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_user); +$DBX_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_pass); +$DBY_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_pass); +$DBX_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_database); +$DBY_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_database); +$VICIDIAL_park_on_filename = ereg_replace("[^-\_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); +$server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); +$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id); +$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context); +$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); +$company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); +$picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); +$local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); +$server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); +$asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + +### VARIABLES TO BE mysql_real_escape_string ### +# $VICIDIAL_web_URL = +# $local_web_callerID_URL = + +##### END VARIABLE FILTERING FOR SECURITY ##### + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +if (!isset($ADD)) {$ADD=0;} + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + +if ($ADD==1) {$process = 'ADD NEW PHONE';} +if ($ADD==11) {$process = 'ADD NEW SERVER';} +if ($ADD==111) {$process = 'ADD NEW CONFERENCE';} +if ($ADD==2) {$process = 'ADDING NEW PHONE';} +if ($ADD==21) {$process = 'ADDING NEW SERVER';} +if ($ADD==211) {$process = 'ADDING NEW CONFERENCE';} +if ($ADD==3) {$process = 'MODIFY PHONE';} +if ($ADD==31) {$process = 'MODIFY SERVER';} +if ($ADD==311) {$process = 'MODIFY CONFERENCE';} +if ($ADD==4) {$process = 'MODIFYING PHONE';} +if ($ADD==41) {$process = 'MODIFYING SERVER';} +if ($ADD==411) {$process = 'MODIFYING CONFERENCE';} +if ($ADD==5) {$process = 'DELETE PHONE';} +if ($ADD==6) {$process = 'DELETE PHONE';} +if ($ADD==55) {$process = 'SEARCH PHONES';} +if ($ADD==66) {$process = 'SEARCH PHONES RESULTS';} +if ($ADD==0) {$process = 'PHONE LIST';} +if ($ADD==10) {$process = 'SERVER LIST';} +if ($ADD==100) {$process = 'CONFERENCE LIST';} +if ($ADD==99999) {$process = 'HELP';} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if ($auth<1) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > '6' and ast_admin_access='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGdelete_phones =$row[17]; + } + } + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + echo "|$stmt|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + if (strlen($LOGfullname) < 1) + { + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "\n"; + $o++; + } + + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); + +$NWB = "   \"HELP\""; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "ASTERISK ADMIN: Administration - $process \n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ASTERISK ADMIN: HELP


\n"; + +?> +PHONES TABLE

+ +
+Phone extension - This field is where you put the phones name as it appears to Asterisk not including the protocol or slash at the beginning. For Example: for the SIP phone SIP/test101 the Phone extension would be test101. Also, for IAX2 phones make sure you use the full phones name: IAX2/IAXphone1@IAXphone1 would be IAXphone1@IAXphone1. For Zap phones make sure you put the full channel: Zap/25-1 would be 25-1. Another note, make sure you set the Protocol below correctly for your type of phone. + +
+
+
+Dialplan number - This field is for the number you dial to have the phone ring. This number is defined in the extensions.conf file of your Asterisk server + +
+
+
+Voicemail Box - This field is for the voicemail box that the messages go to for the user of this phone. We use this to check for voicemail messages and for the user to be able to use the VOICEMAIL button on astGUIclient app. + +
+
+
+Outbound CallerID - This field is where you would enter the callerID number that you would like to appear on outbound calls placed form the astguiclient web-client. This does not work on RBS, non-PRI, T1/E1s. + +
+
+
+Phone IP address - This field is for the phone's IP address if it is a VOIP phone. This is an optional field + +
+
+
+Computer IP address - This field is for the user's computer IP address. This is an optional field + +
+
+
+Server IP - This menu is where you select which server the phone is active on. + +
+
+
+Login - The login used for the phone user to login to the client applications. + +
+
+
+Password - The password used for the phone user to login to the client applications. + +
+
+
+Status - The status of the phone in the system, ACTIVE and ADMIN allow for GUI clients to work. ADMIN allows access to this administrative web site. All other statuses do not allow GUI or Admin web access. + +
+
+
+Active Account - Whether the phone is active to put it in the list in the GUI client. + +
+
+
+Phone Type - Purely for administrative notes. + +
+
+
+Full Name - Used by the GUIclient in the list of active phones. + +
+
+
+Company - Purely for administrative notes. + +
+
+
+Picture - Not yet Implemented. + +
+
+
+New Messages - Number of new voicemail messages for this phone on the Asterisk server. + +
+
+
+Old Messages - Number of old voicemail messages for this phone on the Asterisk server. + +
+
+
+Client Protocol - The protocol that the phone uses to connect to the Asterisk server: SIP, IAX2, Zap . Also, there is EXTERNAL for remote dial numbers or speed dial numbers that you want to list as phones. + +
+
+
+Local GMT - The difference from Greenwich Mean time, or ZULU time where the phone is located. DO NOT ADJUST FOR DAYLIGHT SAVINGS TIME. This is used by the VICIDIAL campaign to accurately display the time and customer time. + +
+
+
+Manager Login - This is the login that the GUI clients for this phone will use to access the Database where the server data resides. + +
+
+
+Manager Secret - This is the password that the GUI clients for this phone will use to access the Database where the server data resides. + +
+
+
+VICIDIAL Default User - This is to place a default value in the VICIDIAL user field whenever this phone user opens the astVICIDIAL client app. Leave blank for no user. + +
+
+
+VICIDIAL Default Pass - This is to place a default value in the VICIDIAL password field whenever this phone user opens the astVICIDIAL client app. Leave blank for no pass. + +
+
+
+VICIDIAL Default Campaign - This is to place a default value in the VICIDIAL campaign field whenever this phone user opens the astVICIDIAL client app. Leave blank for no campaign. + +
+
+
+Park Exten - This is the default Parking extension for the client apps. Verify that a different one works before you change this. + +
+
+
+Conf Exten - This is the default Conference park extension for the client apps. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park Exten - This is the default Parking extension for VICIDIAL client app. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park File - This is the default VICIDIAL park extension file name for the client apps. Verify that a different one works before you change this. limited to 10 characters. + +
+
+
+Monitor Prefix - This is the dialplan prefix for monitoring of Zap channels automatically within the astGUIclient app. Only change according to the extensions.conf ZapBarge extensions records. + +
+
+
+Recording Exten - This is the dialplan extension for the recording extension that is used to drop into meetme conferences to record them. It usually lasts upto one hour if not stopped. verify with extensions.conf file before changing. + +
+
+
+VMAIL Main Exten - This is the dialplan extension going to check your voicemail. verify with extensions.conf file before changing. + +
+
+
+VMAIL Dump Exten - This is the dialplan prefix used to send calls directly to a user's voicemail from a live call in the astGUIclient app. verify with extensions.conf file before changing. + +
+
+
+Exten Context - This is the dialplan context that this phone primarily uses. It is assumed that all numbers dialed by the client apps are using this context so it is a good idea to make sure this is the most wide context possible. verify with extensions.conf file before changing. + +
+
+
+DTMF send Channel - This is the channel string used to send DTMF sounds into meetme conferences from the client apps. Verify the exten and context with the extensions.conf file. + +
+
+
+Outbound Call Group - This is the channel group that outbound calls from this phone are placed out of. There are a couple routines in the client apps that use this. For Zap channels you want to use something like Zap/g2 , for IAX2 trunks you would want to use the full IAX prefix like IAX2/VICItest1:secret@10.10.10.15:4569. Verify the trunks with the extensions.conf file, it is usually what you have defined as the TRUNK global variable at the top of the file. + +
+
+
+Browser Location - This is applicable to only UNIX/LINUX clients, the absolute path to Mozilla or Firefox browser on the machine. verify this by launching it manually. + +
+
+
+Install Directory - This is the place where the astGUIclient and astVICIDIAL scripts are located on your machine. For Win32 it should be something like C:\AST_VICI and for UNIX it should be something like /usr/local/perl_TK. verify this manually. + +
+
+
+CallerID URL - This is the web address of the page used to do custom callerID lookups. default testing address is: http://astguiclient.sf.net/test_callerid_output.php + +
+
+
+VICIDIAL Default URL - This is the web address of the page used to do custom VICIDIAL Web Form queries. default testing address is: http://astguiclient.sf.net/test_VICIDIAL_output.php + +
+
+
+Call Logging - This is set to true if the call_log.agi file is in place in the extensions.conf file for all outbound and hangup 'h' extensions to log all calls. This should always be 1 because it is manditory for many astGUIclient and VICIDIAL features to work properly. + +
+
+
+User Switching - Set to true to allow user to switch to another user account. NOTE: If user switches they can initiate recording on the new user's phone conversation + +
+
+
+Conferencing - Set to true to allow user to start conference calls with upto six external lines. + +
+
+
+Admin Hangup - Set to true to allow user to be able to hangup any line at will through astGUIclient. Good idea only to enable this for Admin users. + +
+
+
+Admin Hijack - Set to true to allow user to be able to grab and redirect to their extension any line at will through astGUIclient. Good idea only to enable this for Admin users. But is very useful for Managers. + +
+
+
+Admin Monitor - Set to true to allow user to be able to grab and redirect to their extension any line at will through astGUIclient. Good idea only to enable this for Admin users. But is very useful for Managers and as a training tool. + +
+
+
+Call Park - Set to true to allow user to be able to park calls on astGUIclient hold to be picked up by any other astGUIclient user on the system. Calls stay on hold for upto a half hour then hangup. Usually enabled for all. + +
+
+
+Updater Check - Set to true to display a popup warning that the updater time has not changed in 20 seconds. Useful for Admin users. + +
+
+
+AF Logging - Set to true to log many actions of astGUIclient usage to a text file on the user's computer. + +
+
+
+Queue Enabled - Set to true to have client apps use the Asterisk Central Queue system. Required for VICIDIAL and recommended for all users. + +
+
+
+CallerID Popup - Set to true to allow for numbers defined in the extensions.conf file to send CallerID popup screens to astGUIclient users. + +
+
+
+VMail Button - Set to true to display the VOICEMAIL button and the messages count display on astGUIclient. + +
+
+
+Fast Refresh - Set to true to enable a new rate of refresh of call information for the astGUIclient. Default disabled rate is 1000 ms ,1 second. Can increase system load if you lower this number. + +
+
+
+Fast Refresh Rate - in milliseconds. Only used if Fast Refresh is enabled. Default disabled rate is 1000 ms ,1 second. Can increase system load if you lower this number. + +
+
+
+Persistant MySQL - If enabled the astGUIclient connection will remain connected instead of connecting every second. Useful if you have a fast refresh rate set. It will increase the number of connections on your MySQL machine. + +
+
+
+Auto Dial Next Number - If enabled the VICIDIAL client will dial the next number on the list automatically upon disposition of a call unless they selected to "Stop Dialing" on the disposition screen. + +
+
+
+Stop Rec after each call - If enabled the VICIDIAL client will stop whatever recording is going on after each call has been dispositioned. Useful if you are doing a lot of recording or you are using a web form to trigger recording. + +
+
+
+DBX Server - The MySQL database server that this user should be connecting to. + +
+
+
+DBX Database - The MySQL database that this user should be connecting to. Default is asterisk. + +
+
+
+DBX User - The MySQL user login that this user should be using when connecting. Default is cron. + +
+
+
+DBX Pass - The MySQL user password that this user should be using when connecting. Default is 1234. + +
+
+
+DBX Port - The MySQL TCP port that this user should be using when connecting. Default is 3306. + +
+
+
+DBY Server - The MySQL database server that this user should be connecting to. Secondary server, not used currently. + +
+
+
+DBY Database - The MySQL database that this user should be connecting to. Default is asterisk. Secondary server, not used currently. + +
+
+
+DBY User - The MySQL user login that this user should be using when connecting. Default is cron. Secondary server, not used currently. + +
+
+
+DBY Pass - The MySQL user password that this user should be using when connecting. Default is 1234. Secondary server, not used currently. + +
+
+
+DBY Port - The MySQL TCP port that this user should be using when connecting. Default is 3306. Secondary server, not used currently. + + +



+ +SERVERS TABLE

+
+
+Server ID - This field is where you put the Asterisk servers name, doesnt have to be an official domain sub, just a nickname to identify the server to Admin users. + +
+
+
+Server Description - The field where you use a small phrase to describe the Asterisk server. + +
+
+
+Server IP Address - The field where you put the Network IP address of the Asterisk server. + +
+
+
+Active - Set whether the Asterisk server is active or inactive. + +
+
+
+Asterisk Version - Set the version of Asterisk that you have installed on this server. Examples: '1.2', '1.0.8', '1.0.7', 'CVS_HEAD', 'REALLY OLD', etc... This is used because versions 1.0.8 and 1.0.9 have a different method of dealing with Local/ channels, a bug that has been fixed in CVS v1.0, and need to be treated differently when handling their Local/ channels. Also, current CVS_HEAD and the 1.2 release tree uses different manager and command output so it must be treated differently as well. + +
+
+
+Max VICIDIAL Trunks - This field will determine the maximum number of lines that the VICIDIAL auto-dialer will attempt to call on this server. If you want to dedicate two full PRI T1s to VICIDIALing on a server then you would set this to 46. Default is 96. + +
+
+
+Telnet Host - This is the address or name of the Asterisk server and is how the manager applications connect to it from where they are running. If they are running on the Asterisk server, then the default of 'localhost' is fine. + +
+
+
+Telnet Port - This is the port of the Asterisk server Manager connection and is how the manager applications connect to it from where they are running. The default of '5038' is fine for a standard install. + +
+
+
+Manager User - The username or login used to connect genericly to the Asterisk server manager. Default is 'cron' + +
+
+
+Manager Secret - The secret or password used to connect genericly to the Asterisk server manager. Default is '1234' + +
+
+
+Manager Update User - The username or login used to connect to the Asterisk server manager optimized for the Update scripts. Default is 'updatecron' and assumes the same secret as the generic user. + +
+
+
+Manager Listen User - The username or login used to connect to the Asterisk server manager optimized for scripts that only listen for output. Default is 'listencron' and assumes the same secret as the generic user. + +
+
+
+Manager Send User - The username or login used to connect to the Asterisk server manager optimized for scripts that only send Actions to the manager. Default is 'sendcron' and assumes the same secret as the generic user. + +
+
+
+Server GMT offset - The difference in hours from GMT time not adjusted for Daylight-Savings-Time of the server. Default is '-5' + +
+
+
+VMail Dump Exten - The extension prefix used on this server to send calls directly through agc to a specific voicemail box. Default is '85026666666666' + +
+
+
+VICIDIAL AD extension - The default extension if none is present in the campaign to send calls to for VICIDIAL auto dialing. Default is '8365' + +
+
+
+Default Context - The default dialplan context used for scripts that operate for this server. Default is 'default' + + +



+ +CONFERENCES TABLE

+
+
+Conference Number - This field is where you put the meetme conference dialpna number. It is also recommended that the meetme number in meetme.conf matches this number for each entry. This is for the conferences in astGUIclient and is used for leave-3way-call functionality in VICIDIAL. + +
+
+
+Server IP - The menu where you select the Asterisk server that this conference will be on. + + + + + + +







+







+THE END +
+ + + +ASTERISK ADMIN: Administration - <? echo $process ?> + + + +
+ + + + + + +
  ASTERISK ADMIN - Logout  
  LIST ALL PHONES | ADD A NEW PHONE | SEARCH FOR A PHONE | ADD A SERVER | LIST ALL SERVERS
  SHOW ALL CONFERENCES | ADD A NEW CONFERENCE
+"; + +echo "
ADD A NEW PHONE
\n"; +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW SERVERS FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
ADD A NEW SERVER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW CONFERENCES FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
ADD A NEW CONFERENCE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference Number: (digits only)$NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new phone to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
PHONE NOT ADDED - there is already a Phone in the system with this extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
PHONE NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
PHONE ADDED\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new server to the system +###################### + +if ($ADD==21) +{ + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SERVER NOT ADDED - there is already a server in the system with this ID\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVER NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
SERVER ADDED\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new conference to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFERENCE NOT ADDED - there is already a conference in the system with this ID and server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCE NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
CONFERENCE ADDED\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=100; +} + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of phone +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGdelete_phones < 1) ) + { + echo "
PHONE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Server IP be at least 7 characters in length\n"; + } + else + { + echo "
PHONE DELETION CONFIRMATION: $extension - $server_ip\n"; + echo "

Click here to delete phone $extension - $server_ip


\n"; + } + +$ADD='3'; # go to phone modification below +} + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete phone record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGdelete_phones < 1) ) + { + echo "
PHONE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Server IP be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING PHONE!!!|$PHP_AUTH_USER|$ip|extension='$extension'|server_ip='$server_ip'|\n"); + fclose($fp); + } + echo "
PHONE DELETION COMPLETED: $extension - $server_ip\n"; + echo "

\n"; + } + +$ADD='0'; # go to phone list +} + + + + + + +###################### +# ADD=3 modify phone info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A PHONE RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
New Messages: $row[14]$NWB#phones-messages$NWE
Old Messages: $row[15]$NWB#phones-old_messages$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
VICIDIAL Default Pass: $NWB#phones-login_pass$NWE
VICIDIAL Default Campaign: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park File: $NWB#phones-VICIDIAL_park_on_filename$NWE
Monitor Prefix: $NWB#phones-monitor_prefix$NWE
Recording Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Context: $NWB#phones-ext_context$NWE
DTMFSend Channel: $NWB#phones-dtmf_send_extension$NWE
Outbound Call Group: $NWB#phones-call_out_number_group$NWE
Browser Location: $NWB#phones-client_browser$NWE
Install Directory: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Default URL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
User Switching: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hangup: $NWB#phones-admin_hangup_enabled$NWE
Admin Hijack: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Call Park: $NWB#phones-call_parking_enabled$NWE
Updater Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Queue Enabled: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Button: $NWB#phones-voicemail_button_enabled$NWE
Fast Refresh: $NWB#phones-enable_fast_refresh$NWE
Fast Refresh Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Dial Next Number: $NWB#phones-auto_dial_next_number$NWE
Stop Rec after each call: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Server: (Primary DB Server)$NWB#phones-DBX_server$NWE
DBX Database: (Primary Server Database)$NWB#phones-DBX_database$NWE
DBX User: (Primary DB Login)$NWB#phones-DBX_user$NWE
DBX Pass: (Primary DB Secret)$NWB#phones-DBX_pass$NWE
DBX Port: (Primary DB Port)$NWB#phones-DBX_port$NWE
DBY Server: (Secondary DB Server)$NWB#phones-DBY_server$NWE
DBY Database: (Secondary Server Database)$NWB#phones-DBY_database$NWE
DBY User: (Secondary DB Login)$NWB#phones-DBY_user$NWE
DBY Pass: (Secondary DB Secret)$NWB#phones-DBY_pass$NWE
DBY Port: (Secondary DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Click here for phone stats\n"; + +if ($LOGdelete_phones > 0) + { + echo "

DELETE THIS PHONE\n"; + } + +} + + +###################### +# ADD=31 modify server info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A SERVER RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
PHONES WITHIN THIS SERVER:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIONNAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This server has $active_lists active phones and $inactive_lists inactive phones

\n"; +echo "
\n"; +} + + +###################### +# ADD=311 modify conference info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A CONFERENCE RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference: $NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
Current Extension:
\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=4 submit phone modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
PHONE NOT MODIFIED - there is already a Phone in the system with this extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
PHONE NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
PHONE MODIFIED: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A PHONE RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
New Messages: $row[14]$NWB#phones-messages$NWE
Old Messages: $row[15]$NWB#phones-old_messages$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
VICIDIAL Default Pass: $NWB#phones-login_pass$NWE
VICIDIAL Default Campaign: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park File: $NWB#phones-VICIDIAL_park_on_filename$NWE
Monitor Prefix: $NWB#phones-monitor_prefix$NWE
Recording Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Context: $NWB#phones-ext_context$NWE
DTMFSend Channel: $NWB#phones-dtmf_send_extension$NWE
Outbound Call Group: $NWB#phones-call_out_number_group$NWE
Browser Location: $NWB#phones-client_browser$NWE
Install Directory: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Default URL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
User Switching: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hangup: $NWB#phones-admin_hangup_enabled$NWE
Admin Hijack: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Call Park: $NWB#phones-call_parking_enabled$NWE
Updater Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Queue Enabled: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Button: $NWB#phones-voicemail_button_enabled$NWE
Fast Refresh: $NWB#phones-enable_fast_refresh$NWE
Fast Refresh Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Dial Next Number: $NWB#phones-auto_dial_next_number$NWE
Stop Rec after each call: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Server: (Primary DB Server)$NWB#phones-DBX_server$NWE
DBX Database: (Primary Server Database)$NWB#phones-DBX_database$NWE
DBX User: (Primary DB Login)$NWB#phones-DBX_user$NWE
DBX Pass: (Primary DB Secret)$NWB#phones-DBX_pass$NWE
DBX Port: (Primary DB Port)$NWB#phones-DBX_port$NWE
DBY Server: (Secondary DB Server)$NWB#phones-DBY_server$NWE
DBY Database: (Secondary Server Database)$NWB#phones-DBY_database$NWE
DBY User: (Secondary DB Login)$NWB#phones-DBY_user$NWE
DBY Pass: (Secondary DB Secret)$NWB#phones-DBY_pass$NWE
DBY Port: (Secondary DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Click here for phone stats\n"; + +if ($LOGdelete_phones > 0) + { + echo "

DELETE THIS PHONE\n"; + } + +} + +###################### +# ADD=41 submit server modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
SERVER NOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
SERVER NOT MODIFIED - there is already a server in the system with this server_ip\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVER NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
SERVER MODIFIED: $server_ip\n"; + + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + } + } + } + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A SERVER RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
PHONES WITHIN THIS SERVER:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIONNAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This server has $active_lists active phones and $inactive_lists inactive phones

\n"; +echo "
\n"; + +} + +###################### +# ADD=411 submit conference modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
CONFERENCE NOT MODIFIED - there is already a Conference in the system with this extension-server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCE NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
CONFERENCE MODIFIED: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from conferences where conf_exten='$conf_exten';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A CONFERENCE RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference: $NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
Current Extension:
\n"; + +echo "
\n"; + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo ""; + +echo "
SEARCH FOR A PHONE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
extension:
Full Name:
Phone type:
\n"; + +} + +###################### +# ADD=66 phone search results +###################### + +if ($ADD==66) +{ + echo ""; + + $SQL = ''; + if ($extension) {$SQL .= "extension LIKE \"%$extension%\" and";} + if ($fullname) {$SQL .= "fullname LIKE \"%$fullname%\" and";} + if ($phone_type) {$SQL .= "phone_type LIKE \"%$phone_type%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from phones $SQL order by extension,server_ip;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFY | STATS
\n"; + +} + + + +###################### +# ADD=0 display all active phones +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from phones order by extension,server_ip"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
PHONE LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[16]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFY | STATS
\n"; +} + +###################### +# ADD=10 display all servers +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SERVER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[4] $row[3]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all conferences +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
CONFERENCE LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]  MODIFY
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BUILD: $build
\n"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/dbconnect.php b/agc_2-X/trunk/LANG_admin/astguiclient/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/help.gif b/agc_2-X/trunk/LANG_admin/astguiclient/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/astguiclient/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/inbound_popup.php b/agc_2-X/trunk/LANG_admin/astguiclient/inbound_popup.php new file mode 100644 index 00000000..6f451656 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient/inbound_popup.php @@ -0,0 +1,228 @@ + LICENSE: GPLv2 +### +# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# +# changes: +# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK REMOTE INBOUND: Popup + + +
+ + 0) +{ + + $stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for channel $channel       $NOW_TIME\n

\n"; + + + $url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&'; + $Suser = 'username='; + $Spass = '&passwd='; + $Sphone = '&phone='; + + $newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone"; + if ( ($phone == 'unknown') or (strlen($phone)<9) ) + {$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";} + + echo "Look up this customer in Customer Service System\n

\n"; + + echo "Close this window\n

\n"; +} +else +{ + echo "Redirect command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Close this window\n

\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/phone_stats.php b/agc_2-X/trunk/LANG_admin/astguiclient/phone_stats.php new file mode 100644 index 00000000..8498746a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient/phone_stats.php @@ -0,0 +1,244 @@ + LICENSE: GPLv2 +# +# +# changes: +# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$admin_page = './admin.php'; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $row[0]; + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ADMIN: Phone Stats + + +
+
+ + + + + + +\n"; +echo "
  ASTERISK ADMIN: Administration  
  LIST ALL PHONES | ADD A NEW PHONE | SEARCH FOR A PHONE | ADD A SERVER | LIST ALL SERVERS
  SHOW ALL CONFERENCES | ADD A NEW CONFERENCE
  \n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + +echo "
\n"; + +echo "CALL TIME AND CHANNELS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} +# echo "|$stmt|\n"; + +echo "\n"; +echo "
CHANNEL GROUP COUNT HOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
TOTAL CALLS $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LAST 1000 CALLS FOR DATE RANGE:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + + $call_seconds=0; + $o++; + } + + +echo "
NUMBER CHANNEL GROUP DATE LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/remote_inbound.php b/agc_2-X/trunk/LANG_admin/astguiclient/remote_inbound.php new file mode 100644 index 00000000..06642677 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient/remote_inbound.php @@ -0,0 +1,162 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + echo"\n"; + echo"ASTERISK REMOTE INBOUND: Main\n"; + echo"\n"; + echo"\n"; + echo"\n"; + +?> + + +
+ +
\n"; + +echo "Click on the channel below that you would like to have directed to your phone

\n"; + +echo "
\n";
+echo "CHANNEL    SERVER        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME        \n";
+echo "----------------------------------------------------------------------------------------------\n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$extension =		sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		echo "$channel$server$channel_group$extension$parked_by$parked_time\n";
+
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "*************************************** NO PARKED CALLS **************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient/test.php b/agc_2-X/trunk/LANG_admin/astguiclient/test.php new file mode 100644 index 00000000..62f8277b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient/test.php @@ -0,0 +1,30 @@ + LICENSE: GPLv2 +### + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + + +$link=mysql_connect("localhost", "cron", "1234"); +mysql_select_db("asterisk"); + + $stmt="SELECT * from phones;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + print "|$auth|\n"; + +exit; + + + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/AST_inboundEXTstats.php b/agc_2-X/trunk/LANG_admin/astguiclient_de/AST_inboundEXTstats.php new file mode 100644 index 00000000..3a70336a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_de/AST_inboundEXTstats.php @@ -0,0 +1,400 @@ + LICENSE: GPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Inbound Anruf-Notfall\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "WÄHLEN Sie BITTE Eine ZAHL Vor UND DATUM OBEN UND KLICKEN REICHT Ein\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Inbound Anruf-Notfall                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Gesamtanrufe, die in diese Zahl kamen:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- TIME STATS\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN VON GESAMTANRUFEN\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/admin.php b/agc_2-X/trunk/LANG_admin/astguiclient_de/admin.php new file mode 100644 index 00000000..1a98ea49 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_de/admin.php @@ -0,0 +1,1824 @@ + LICENSE: GPLv2 +# +# AST GUI database administration +# +# CHANGES +# 50913-1118 - Added outbound_cid for web-client calls +# 50926-1356 - Modified to allow for language translation +# 50926-1613 - Added WeBRooTWritablE write controls +# 51128-1254 - Modified to allow PHP global vars off +# 51208-2120 - Added option to login with vicidial_user login if allowed +# 51213-1650 - Added option to delete phones if allowed by vicidial_users +# 60421-1430 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1137 - Fixed phone search bug +# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '1.1.12'; +$build = '60620-1243'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS and Dots +$phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); +$computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); + +### DIGITS ONLY ### +$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); +$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id); +$outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); +$VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); +$park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); +$conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); +$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); +$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); +$recording_exten = ereg_replace("[^0-9]","",$recording_exten); +$monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); +$answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); +$DBX_port = ereg_replace("[^0-9]","",$DBX_port); +$DBY_port = ereg_replace("[^0-9]","",$DBY_port); +$telnet_port = ereg_replace("[^0-9]","",$telnet_port); +$max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); +$auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); +$VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); +$enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); +$enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); +$user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); +$updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); +$QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); +$conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); +$voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); +$CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); +$call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); +$AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); +$AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); +$admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); +$admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); +$admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); +$fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); +$ADD = ereg_replace("[^0-9]","",$ADD); + +### ALPHA-NUMERIC and underscore and dash and slash and at and dot +$extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); +$old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); +$install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); +$client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); +$dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); +$call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); +$telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); +$DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); +$DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + +### ALPHA-NUMERIC (and underscore and dash) +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$login = ereg_replace("[^-\_0-9a-zA-Z]","",$login); +$user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); +$status = ereg_replace("[^-\_0-9a-zA-Z]","",$status); +$protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); +$ASTmgrUSERNAMEupdate = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); +$ASTmgrUSERNAMEsend = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); +$ASTmgrUSERNAMElisten = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); +$ASTmgrUSERNAME = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAME); +$ASTmgrSECRET = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrSECRET); +$login_user = ereg_replace("[^-\_0-9a-zA-Z]","",$login_user); +$login_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$login_pass); +$login_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$login_campaign); +$DBX_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_user); +$DBY_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_user); +$DBX_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_pass); +$DBY_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_pass); +$DBX_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_database); +$DBY_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_database); +$VICIDIAL_park_on_filename = ereg_replace("[^-\_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); +$server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); +$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id); +$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context); +$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); +$company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); +$picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); +$local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); +$server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); +$asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + +### VARIABLES TO BE mysql_real_escape_string ### +# $VICIDIAL_web_URL = +# $local_web_callerID_URL = + +##### END VARIABLE FILTERING FOR SECURITY ##### + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Sie haben jetzt heraus geloggt. Danke\n"; + exit; +} + +if (!isset($ADD)) {$ADD=0;} + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + +if ($ADD==1) {$process = 'ADDIEREN SIE NEUES TELEFON';} +if ($ADD==11) {$process = 'ADDIEREN SIE NEUEN BEDIENER';} +if ($ADD==111) {$process = 'ADDIEREN SIE NEUE KONFERENZ';} +if ($ADD==2) {$process = 'ADDIEREN DES NEUEN TELEFONS';} +if ($ADD==21) {$process = 'ADDIEREN DES NEUEN BEDIENERS';} +if ($ADD==211) {$process = 'ADDIEREN DER NEUEN KONFERENZ';} +if ($ADD==3) {$process = 'ÄNDERN SIE TELEFON';} +if ($ADD==31) {$process = 'ÄNDERN SIE BEDIENER';} +if ($ADD==311) {$process = 'ÄNDERN SIE KONFERENZ';} +if ($ADD==4) {$process = 'ÄNDERNDES TELEFON';} +if ($ADD==41) {$process = 'ÄNDERNDER BEDIENER';} +if ($ADD==411) {$process = 'ÄNDERNDE KONFERENZ';} +if ($ADD==5) {$process = 'DELETE PHONE';} +if ($ADD==6) {$process = 'DELETE PHONE';} +if ($ADD==55) {$process = 'SUCHTELEFONE';} +if ($ADD==66) {$process = 'SUCHE RUFT RESULTATE AN';} +if ($ADD==0) {$process = 'TELEFON-LISTE';} +if ($ADD==10) {$process = 'BEDIENER-LISTE';} +if ($ADD==100) {$process = 'KONFERENZ-LISTE';} +if ($ADD==99999) {$process = 'HILFE';} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if ($auth<1) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > '6' and ast_admin_access='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGdelete_phones =$row[17]; + } + } + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + echo "|$stmt|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + if (strlen($LOGfullname) < 1) + { + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "\n"; + $o++; + } + + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); + +$NWB = "   \"HILFE\""; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "STERNCHEN ADMIN: Leitung - $process \n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ASTERISK ADMIN: HILFE


\n"; + +?> +TELEFON-TABELLE

+ +
+Telefonverlängerung - Dieses fangen ist auf, wohin Sieden Telefonnamen setzen, während er scheint, nicht einschließlichdas Protokoll oder den Schrägstrich am Anfang mit einem Sternchenzuversehen. Z.B.: für das SIP Telefon SIP\/test101 würde dieTelefonverlängerung test101 sein. Auch denn Telefone IAX2 stellen Siesicher, daß Sie den vollen Telefonnamen verwenden:IAX2\/IAXphone1@IAXphone1 würde IAXphone1@IAXphone1 sein. Für ZapTelefone sicherstellen, daß Sie die volle Führung setzen: Zap/25-1würde 25-1 sein. Eine andere Anmerkung, stellen sicher, daß Sie dasProtokoll unten richtig für Ihre Art des Telefons einstellen. + +
+
+
+Dialplan number - This field is for the number you dial to have the phone ring. This number is defined in the extensions.conf file of your Asterisk server + +
+
+
+Voicemail Kasten - Dieses fangen ist für den voicemailKasten auf, daß die Anzeigen für zum Benutzer dieses Telefons gehen.Wir verwenden dieses, um auf voicemail Anzeigen und auf den Benutzerzu überprüfen, zum in der Lage zuSEIN, die VOICEMAIL Taste aufastGUIclient APP zu benutzen. + +
+
+
+Outbound CallerID - Dieses fangen ist auf, wo Sie diecallerID Zahl eintragen würden, die Sie möchten, daß auf outboundAnrufe gesetzter Form der astguiclient Netz-Klient aussieht. Diesesarbeitet nicht auf RBS, non-PRI, T1/Eß. + +
+
+
+Telefon-IP address - Dieses fangen ist für IP addressdes Telefons auf, wenn es ein VOIP Telefon ist. Dieses istauffangen ein wahlweise freigestelltes + +
+
+
+Computer-IP address - Dieses fangen ist für IP addressComputer des Benutzers auf. Dieses ist auffangen einwahlweise freigestelltes + +
+
+
+Bediener IP - Dieses Menü ist, wo Sie vorwählen, dem Bedienerdas Telefon auf aktiv ist. + +
+
+
+LOGON - Der LOGON gewöhnt ge$$$WESEN für den Telefonbenutzer anLOGON zu den Klient Anwendungen. + +
+
+
+Kennwort - Das Kennwort gewöhnt ge$$$WESEN für denTelefonbenutzer an LOGON zu den Klient Anwendungen. + +
+
+
+Status - Der Status des Telefons im System, die AKTIVEN und ADMINdürfen, damit GUI Klienten arbeiten. Admin erlaubt Zugang zu dieseradministrativen Web site. Alle weiteren Status erlauben nicht GUI oderAdmin Netzzugang. + +
+
+
+Aktives Konto - Ob das Telefon aktiv ist, es in die Liste im GUIKlienten einzusetzen. + +
+
+
+Telefon-Art - Lediglich für administrative Anmerkungen. + +
+
+
+Voller Name - Verwendet durch das GUIclient in der Liste deraktiven Telefone. + +
+
+
+Firma - Lediglich für administrative Anmerkungen. + +
+
+
+Abbildung - Nicht schon eingeführt. + +
+
+
+Neue Anzeigen - Zahl der neuen voicemail Anzeigen für diesesTelefon auf dem Sternchenbediener. + +
+
+
+Alte Anzeigen - Zahl der alten voicemail Anzeigen für diesesTelefon auf dem Sternchenbediener. + +
+
+
+Klient Protokoll - Das Protokoll, das das Telefon verwendet, anden Sternchenbediener anzuschließen: Sip, IAX2, Zap. Auch, es gibtexternal für Remotevorwahlknopfzahlen oder GeschwindigkeitVorwahlknopfzahlen, die Sie als Telefone verzeichnen möchten. + +
+
+
+Lokales GMT - Der Unterschied Greenwich-Zeit von oder VON DERZULU-Zeit, in der das Telefon lokalisiert wird. STELLEN SIE NICHT AUFTAGESLICHT-SPARUNGEN ZEIT EIN. Dieses wird durch die VICIDIAL Kampagneverwendet, um die Zeit und Kunde Zeit genau anzuzeigen. + +
+
+
+Manager-LOGON - Dieses ist der LOGON, dem die GUI Klienten fürdieses Telefon pflegen, die Datenbank zugänglich zu machen, in derdie Bedienerdaten liegen. + +
+
+
+Manager-Geheimnis - Dieses ist das Kennwort, dem die GUI Klientenfür dieses Telefon pflegen, die Datenbank zugänglich zu machen, inder die Bedienerdaten liegen. + +
+
+
+VICIDIAL Rückstellung Benutzer - Dieses soll einen Default-Wertin den VICIDIAL Benutzer legen auffangen, wann immer dieserTelefonbenutzer die astVICIDIAL Klient APP öffnet. Lassen Sie freienRaum für keinen Benutzer. + +
+
+
+VICIDIAL Rückstellung Durchlauf - Dieses soll einen Default-Wertin das VICIDIAL Kennwort legen auffangen, wann immer dieserTelefonbenutzer die astVICIDIAL Klient APP öffnet. Lassen Sie freienRaum für keinen Durchlauf. + +
+
+
+VICIDIAL Rückstellung Kampagne - Dieses soll einen Default-Wertin die VICIDIAL Kampagne legen auffangen, wann immer dieserTelefonbenutzer die astVICIDIAL Klient APP öffnet. Lassen Sie freienRaum für keine Kampagne. + +
+
+
+Park Exten - Dieses ist die Rückstellung Parkenverlängerung fürdie Klient apps. Überprüfen Sie, daß ein unterschiedliches manarbeitet, bevor Sie dieses ändern. + +
+
+
+Conf Exten - This is the default Conference park extension for the client apps. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park Exten - Dieses ist die RückstellungParkenverlängerung für VICIDIAL Klient APP. Überprüfen Sie, daßein unterschiedliches man arbeitet, bevor Sie dieses ändern. + +
+
+
+VICIDIAL Park-Akte - Dieses ist der Rückstellung VICIDIALPark-Verlängerung Dateiname für die Klient apps. Überprüfen Sie,daß ein unterschiedliches man arbeitet, bevor Sie dieses ändern, daszu 10 Buchstaben begrenzt wird. + +
+
+
+Überwachen Sie Präfix - This is the dialplan prefix for monitoring of Zap channels automatically within the astGUIclient app. Only change according to the extensions.conf ZapBarge extensions records. + +
+
+
+Aufnahme Exten - Dieses ist die dialplan Verlängerung für dieAufnahmeverlängerung, die verwendet wird, um in meetme Konferenzen zufallen, um sie zu notieren. Es dauert normalerweise bis zu einerStunde, wenn es nicht gestoppt wird, überprüft mit extensions.confAkte, bevor es ändert. + +
+
+
+VMAIL Hauptexten - Dieses ist die dialplan Verlängerung, diegeht, Ihr voicemail. zu überprüfen, überprüfen mit extensions.confAkte, bevor es ändert. + +
+
+
+VMAIL Dump Exten - Dieses ist das dialplan Präfix, das verwendetwird, um Anrufe direkt zum voicemail eines Benutzers von einemPhasenanruf in der astGUIclient APP zu schicken, überprüfen mitextensions.conf Akte, bevor es ändert. + +
+
+
+Exten Kontext - Dieses ist der dialplan Kontext, den diesesTelefon hauptsächlich verwendet. Es wird angenommen, daß alleNummern, die durch die Klient apps gewählt werden, diesen Kontextverwenden, also es eine gute Idee ist sicherzustellen, daß dieses derbreiteste Kontext ist, der möglich ist, überprüfen mitextensions.conf Akte, bevor es ändert. + +
+
+
+DTMF senden Führung - Dieses ist die Führung Zeichenkette, diebenutzt wird, um DTMF Töne in meetme Konferenzen von den Klient appszu senden. Überprüfen Sie, daß und Kontext mit der extensions.confAkte exten. + +
+
+
+Outbound Anruf-Gruppe - Dieses ist die Kanalgruppe, daß outboundAnrufe von diesem Telefon aus gesetzt werden. Es gibt Programme einesPaares in den Klient apps, die dieses verwenden. Für Zap Führungen,die Sie etwas wie Zap/g2 verwenden möchten, denn Stämme IAX2 Siedas volle IAX Präfix wie IAX2/VICItest1:secret@10.10.10.15:4569würden verwenden wollen. Überprüfen Sie die Stämme mit derextensions.conf Akte, es ist normalerweise, was Sie als die globaleVariable des STAMMES an der Oberseite der Akte definiert haben. + +
+
+
+Datenbanksuchroutine-Position - Dieses ist auf nur UNIX/LINUXKlienten, der absolute Weg zu Mozilla anwendbar, oder FirefoxDatenbanksuchroutine auf der Maschine überprüfen dieses, indem siemanuell es ausstößt. + +
+
+
+Anbringen Sie Verzeichnis - Dieses ist der Platz, in dem dieastGUIclient und astVICIDIAL Indexe auf Ihrer Maschine sind. FürWin32 sollte es etwas wie C:\\AST_VICI sein und für UNIX sollte esetwas wie /usr/local/perl_TK. sein überprüft dieses manuell. + +
+
+
+CallerID URL - Dieses ist die Netzadresse der Seite, die benutztwird, um kundenspezifische callerID Nachschlagen zu tun, Rückstellungprüfen, dieadresse ist:http://astguiclient.sf.net/test_callerid_output.php + +
+
+
+VICIDIAL Rückstellung URL - Dieses ist die Netzadresse der Seite,die benutzt wird, um kundenspezifische VICIDIAL Netz-Formfragen zutun, Rückstellung prüfen, dieadresse ist:http://astguiclient.sf.net/test_VICIDIAL_output.php + +
+
+
+Anruf-Protokollierung - Dieses wird eingestellt, um auszurichten,wenn die call_log.agi Akte im Platz in der extensions.conf Akte füralles outbound ist und die Verlängerungen des Hängezustands ' h ',zum alle zu loggen benennt. Diese sollte 1, weil es für vieleastGUIclient und DIE VICIDIAL manditory ist Eigenschaften immer sein,zum richtig zu arbeiten. + +
+
+
+Benutzer-Schaltung - Set to true to allow user to switch to another user account. NOTE: If user switches they can initiate recording on the new user's phone conversation + +
+
+
+Conferencing - Stellen Sie ein, um auszurichten, um Benutzer zuerlauben, Konferenzanrufe mit bis zu sechs externen Linien zubeginnen. + +
+
+
+Admin Hängezustand - um Benutzer zu erlauben auszurichten Satz,zum Hängezustand irgendeine Linie am Willen durch astGUIclient in derLage zuSEIN. Gute Idee, diesem für Admin Benutzer nur zuermöglichen. + +
+
+
+Admin Straßenräuber - Stellen Sie ein, um auszurichten, umBenutzer zu erlauben, in der Lage zuSEIN, zu ihrer Verlängerung jedemögliche Linie zu ergreifen und umzuadressieren am Willen durchastGUIclient. Gute Idee, diesem für Admin Benutzer nur zuermöglichen. Aber ist für Manager sehr nützlich. + +
+
+
+Admin Monitor - Stellen Sie ein, um auszurichten, um Benutzer zuerlauben, in der Lage zuSEIN, zu ihrer Verlängerung jede möglicheLinie zu ergreifen und umzuadressieren am Willen durch astGUIclient.Gute Idee, diesem für Admin Benutzer nur zu ermöglichen. Aber istfür Manager und als Training Werkzeug sehr nützlich. + +
+
+
+Parkschaltung - um Benutzer zu erlauben auszurichten der Satz, inder Lage zuSEIN zu parken ersucht um astGUIclient Einfluß, von jedemanderen astGUIclient Benutzer auf dem System aufgehoben zu werden.Anrufe bleiben auf Einfluß für bis zu einen halbe Stunde dannHängezustand. Normalerweise ermöglicht für alle. + +
+
+
+Updater Überprüfung - Stellen Sie ein, um auszurichten, um einepopup Warnung anzuzeigen, die die updater Zeit nicht in 20 Sekundengeändert hat. Nützlich für Admin Benutzer. + +
+
+
+Af Protokollierung - Stellen Sie ein, um auszurichten, um vieleTätigkeiten des astGUIclient Verbrauches in einer Textakte auf demComputer des Benutzers zu protokollieren. + +
+
+
+Warteschlange ermöglichte - um Klient apps auszurichten Satz dasSternchen-zentrale Warteschlange System benutzen zu lassen. Erfordertfür VICIDIAL und für alle Benutzer empfohlen. + +
+
+
+CallerID Popup - Stellen Sie ein, um auszurichten, um die Zahlenzuzulassen, die in der extensions.conf Akte definiert werden, umCallerID popup Schirme zu schicken den astGUIclient Benutzern. + +
+
+
+VMail Taste - Stellen Sie ein, um auszurichten, um die VOICEMAILTaste anzuzeigen und die Anzeigen zählen Anzeige auf astGUIclient. + +
+
+
+Schnell erneuern Sie - Stellen Sie ein, um auszurichten, um einerneuen Rate von zu ermöglichen erneuern von den Anrufinformationenfür das astGUIclient. Rückstellung arbeitsunfähige Rate ist 1000zweite des Ms.1. Kann Anlagen-Belastung erhöhen, wenn Sie diese Zahlsenken. + +
+
+
+Schnell erneuern Sie Rate - in den Millisekunden. Nur verwendet,wenn schnell, erneuern Sie wird ermöglicht. Rückstellungarbeitsunfähige Rate ist 1000 zweite des Ms.1. Kann Anlagen-Belastungerhöhen, wenn Sie diese Zahl senken. + +
+
+
+Persistant MySQL - Wenn er ermöglicht wird, bleibt derastGUIclient Anschluß angeschlossen, anstatt, jede Sekundeanzuschließen. Nützlich, wenn Sie ein schnelles die eingestellteRate erneuern lassen. Sie erhöht die Zahl Anschlüssen auf IhrerMySQL Maschine. + +
+
+
+Selbstvorwahlknopf-folgende Zahl - wenn er ermöglicht wird,wählt der VICIDIAL Klient die folgende Nummer auf der Listeautomatisch nach Einteilung eines Anrufs, es sei denn sie vorwählten"auf, dem Einteilung Schirm zu wählen zu stoppen". + +
+
+
+Stoppen Sie Rec nach jedem Anruf - wenn er ermöglicht wird,stoppt der VICIDIAL Klient, was Aufnahme weitergeht, nachdem jederAnruf dispositioned gewesen ist. Nützlich, wenn Sie eine MengeAufnahme tun oder Sie benutzen eine Netzform, um Aufnahme auszulösen. + +
+
+
+DBX Bediener - Der MySQL Datenbankbediener, den dieser Benutzeranschließen sollte an. + +
+
+
+DBX Datenbank - Die MySQL Datenbank, die dieser Benutzeranschließen sollte an. Rückstellung ist Sternchen. + +
+
+
+DBX Benutzer - Der MySQL Benutzer-LOGON, den dieser Benutzer beimAnschließen verwenden sollte. Rückstellung ist cron. + +
+
+
+DBX Durchlauf - Das MySQL Benutzerkennwort, das dieser Benutzerbeim Anschließen verwenden sollte. Rückstellung ist 1234. + +
+
+
+DBX Tor - Das MySQL TCP Tor, das dieser Benutzer beim Anschließenbenutzen sollte. Rückstellung ist 3306. + +
+
+
+DBY Bediener - Der MySQL Datenbankbediener, den dieser Benutzeranschließen sollte an. Zweitensserver, nicht z.Z. verwendet. + +
+
+
+DBY Datenbank - Die MySQL Datenbank, die dieser Benutzeranschließen sollte an. Rückstellung ist Sternchen. Zweitensserver, nicht z.Z. verwendet. + +
+
+
+DBY Benutzer - Der MySQL Benutzer-LOGON, den dieser Benutzer beimAnschließen verwenden sollte. Rückstellung ist cron. Zweitensserver, nicht z.Z. verwendet. + +
+
+
+DBY Durchlauf - Das MySQL Benutzerkennwort, das dieser Benutzerbeim Anschließen verwenden sollte. Rückstellung ist 1234. Zweitensserver, nicht z.Z. verwendet. + +
+
+
+DBY Tor - Das MySQL TCP Tor, das dieser Benutzer beim Anschließenbenutzen sollte. Rückstellung ist 3306. Zweitensserver, nicht z.Z. verwendet. + + +



+ +BEDIENER-TABELLE

+
+
+Bediener Identifikation - Dieses fangen ist, wohin Sieden Sternchenbedienernamen setzen, doesnt müssen ein amtliches GebietUnterseeboot, gerade ein Spitzname sein auf, um den Bediener zu denAdmin Benutzern zu kennzeichnen. + +
+
+
+Bediener-Beschreibung - auffangen, wo Sie eine kleine Phraseverwenden, um den Sternchenbediener zu beschreiben. + +
+
+
+Bediener-IP address - auffangen, wo Sie das Netz-IP addressdes Sternchenbedieners setzten. + +
+
+
+Aktiv - Stellen Sie ein, ob der Sternchenbediener aktiv oderunaktiviert ist. + +
+
+
+Sternchen-Version - Stellen Sie die Version des Sternchens ein,die Sie auf diesen Bediener angebracht haben. Beispiele: ' 1.2 ', '1.0.8 ', ' 1.0.7 ', ' CVS_HEAD ', ' WIRKLICH ALTES ', usw.... Dieseswird verwendet, weil Versionen 1.0.8 und 1.0.9 eine andere Methode desBeschäftigens Local/ Führungen, eine Wanze, die in CVS v1.0geregelt worden ist, und Notwendigkeit, anders als behandelt zu werdenhaben, wenn die Behandlung ihres Local/ lenkt. Auch gegenwärtigesCVS_HEAD und der 1.2 Freigabebaumgebrauch unterschiedlicher Managerund Befehl gaben aus, also muß es anders als außerdem behandeltwerden. + +
+
+
+Maximale VICIDIAL Stämme - Dieses fangen feststellt diemaximale Zeilenzahl auf, um denen der VICIDIAL Auto-dialer versucht,diesen Bediener zu ersuchen. Wenn Sie zwei volle PRI Tß VICIDIALingauf einem Bediener einweihen möchten dann, würden Sie dieses bis 46einstellen. Rückstellung ist 96. + +
+
+
+Telnet Wirt - Dieses ist die Adresse oder der Name desSternchenbedieners und ist, wie die Manageranwendungen an ihnanschließen von, wo sie laufen. Wenn sie auf den Sternchenbedienerlaufen, dann ist die Rückstellung von ' localhost ' fein. + +
+
+
+Telnet Tor - Dieses ist das Tor des SternchenbedienerManageranschlußes und ist, wie die Manageranwendungen an ihnanschließen von, wo sie laufen. Die Rückstellung von ' 5038 ' istfein für einen Standard anbringen. + +
+
+
+Manager-Benutzer - Das username oder der LOGON verwendeten, an denSternchenbedienermanager genericly anzuschließen. Rückstellung ist 'cron ' + +
+
+
+Manager-Geheimnis - Das Geheimnis oder das Kennwort verwendeten,an den Sternchenbedienermanager genericly anzuschließen.Rückstellung ist ' 1234 ' + +
+
+
+Manager-Update-Benutzer - Das username oder der LOGON verwendeten,an den Sternchenbedienermanager anzuschließen, der für dieUpdateindexe optimiert wurde. Fallen Sie ist ' updatecron ' undannimmt das gleiche Geheimnis wie der generische Benutzer zurück. + +
+
+
+Manager hören Benutzer - Das username oder der LOGON verwendeten,an den Sternchenbedienermanager anzuschließen, der für Indexeoptimiert wurde, die nur auf Ausgang hören. Fallen Sie ist 'listencron ' und annimmt das gleiche Geheimnis wie der generischeBenutzer zurück. + +
+
+
+Manager senden Benutzer - Das username oder der LOGON verwendeten,an den Sternchenbedienermanager anzuschließen, der für Indexeoptimiert wurde, die dem Manager nur Tätigkeiten schicken. Fallen Sieist ' sendcron ' und annimmt das gleiche Geheimnis wie der generischeBenutzer zurück. + +
+
+
+Bediener GMT versetzt - Der Unterschied bezüglich der Stunden vonder GMT Zeit eingestellt nicht auf Tageslicht-Sparung-Zeit desBedieners. Rückstellung ist ' - 5 ' + +
+
+
+VMail Dump Exten - Das Verlängerung Präfix verwendet auf diesemBediener, um Anrufe direkt durch agc zu einem spezifischen voicemailKasten zu schicken. Rückstellung ist ' 85026666666666 ' + +
+
+
+VICIDIAL ANZEIGE Verlängerung - Die Rückstellung Verlängerung,wenn keines in der Kampagne anwesend ist, Anrufe für VICIDIAL zumSelbstwählen zu schicken. Rückstellung ist ' 8365 ' + +
+
+
+Rückstellung Kontext - Der Rückstellung dialplan Kontextverwendet für Indexe, die für diesen Bediener funktionieren.Rückstellung ist ' Rückstellung ' + + +



+ +KONFERENZTISCH

+
+
+Konferenz-Zahl - Dieses fangen ist auf, wohin Sie diemeetme Konferenz dialpna Zahl setzen. Es wird auch empfohlen, daß diemeetme Zahl in meetme.conf diese Zahl für jede Eintragungzusammenbringt. Dieses ist für die Konferenzen in astGUIclient undwird für leave-3way-call Funktionalität in VICIDIAL verwendet. + +
+
+
+Bediener IP - Das Menü, wo Sie den Sternchenbediener vorwählen,daß diese Konferenz eingeschaltet ist. + + + + + + +







+







+DAS ENDE +
+ + + +STERNCHEN ADMIN: Leitung - <? echo $process ?> + + + +
+ + + + + + +
  ASTERISK ADMIN - Logout  
  VERZEICHNEN SIE ALLE TELEFONE | ADDIEREN Sie Ein NEUES TELEFON | SUCHE NACH Einem TELEFON | ADDIEREN Sie Einen BEDIENER | VERZEICHNEN SIE ALLE BEDIENER
  ZEIGEN SIE ALLE KONFERENZEN | ADDIEREN Sie Eine NEUE KONFERENZ
+"; + +echo "
ADDIEREN Sie Ein NEUES TELEFON
\n"; +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefonverlängerung: $NWB#phones-extension$NWE
Dialplan Zahl: (nur Stellen)$NWB#phones-dialplan_number$NWE
Voicemail Kasten: (nur Stellen)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (nur Stellen)$NWB#phones-outbound_cid$NWE
Telefon-IP address: (optional)$NWB#phones-phone_ip$NWE
Computer-IP address: (optional)$NWB#phones-computer_ip$NWE
Bediener IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Kennwort:$NWB#phones-pass$NWE
Status:$NWB#phones-status$NWE
Aktives Konto: $NWB#phones-active$NWE
Telefon-Art: $NWB#phones-phone_type$NWE
Voller Name: $NWB#phones-fullname$NWE
Firma:$NWB#phones-company$NWE
Abbildung:$NWB#phones-picture$NWE
Klient Protokoll: $NWB#phones-protocol$NWE
Lokales GMT: (Stellen Sie NICHT auf DST ein)$NWB#phones-local_gmt$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW SERVERS FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
ADDIEREN Sie Einen NEUEN BEDIENER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Bediener Identifikation: $NWB#servers-server_id$NWE
Bediener-Beschreibung: $NWB#servers-server_description$NWE
Bediener-IP address: $NWB#servers-server_ip$NWE
Aktiv:$NWB#servers-active$NWE
Sternchen-Version: $NWB#servers-asterisk_version$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW CONFERENCES FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
ADDIEREN Sie Eine NEUE KONFERENZ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Konferenz-Zahl: (nur Stellen)$NWB#conferences-conf_exten$NWE
Bediener IP: $NWB#conferences-server_ip$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new phone to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
TELEFON NICHT ADDIERT - es gibt bereits ein Telefon im System mitdiesem extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
TELEFON NICHT ADDIERT - gehen Sie bitte zurück und betrachten Sie dieDaten, die Sie eingaben\n";} + else + { + echo "
TELEFON FÜGTE HINZU\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new server to the system +###################### + +if ($ADD==21) +{ + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
BEDIENERNOT ADDED - there is already a server in the system with this ID\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
BEDIENERNOT ADDED - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n";} + else + { + echo "
BEDIENERADDED\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new conference to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
KONFERENZ NICHT ADDIERT - es gibt bereits eine Konferenz im System mitdieser Identifikation und Bediener\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
KONFERENZ NICHT ADDIERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n";} + else + { + echo "
KONFERENZ FÜGTE HINZU\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=100; +} + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of phone +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGdelete_phones < 1) ) + { + echo "
TELEFON NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Bediener IP be at least 7 characters in length\n"; + } + else + { + echo "
TELEFON-AUSLASSUNG BESTÄTIGUNG: $extension - $server_ip\n"; + echo "

Klicken Sie hier, um Telefon zu löschen $extension - $server_ip


\n"; + } + +$ADD='3'; # go to phone modification below +} + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete phone record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGdelete_phones < 1) ) + { + echo "
TELEFON NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Bediener IP be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING PHONE!!!|$PHP_AUTH_USER|$ip|extension='$extension'|server_ip='$server_ip'|\n"); + fclose($fp); + } + echo "
TELEFON-AUSLASSUNG DURCHGEFÜHRT: $extension - $server_ip\n"; + echo "

\n"; + } + +$ADD='0'; # go to phone list +} + + + + + + +###################### +# ADD=3 modify phone info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ÄNDERN Sie Einen TELEFON-SATZ: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefonverlängerung: $NWB#phones-extension$NWE
Dialplan Zahl: (nur Stellen)$NWB#phones-dialplan_number$NWE
Voicemail Kasten: (nur Stellen)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (nur Stellen)$NWB#phones-outbound_cid$NWE
Telefon-IP address: (optional)$NWB#phones-phone_ip$NWE
Computer-IP address: (optional)$NWB#phones-computer_ip$NWE
Bediener IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Kennwort:$NWB#phones-pass$NWE
Status:$NWB#phones-status$NWE
Aktives Konto: $NWB#phones-active$NWE
Telefon-Art: $NWB#phones-phone_type$NWE
Voller Name: $NWB#phones-fullname$NWE
Firma:$NWB#phones-company$NWE
Abbildung:$NWB#phones-picture$NWE
Neue Anzeigen: $row[14]$NWB#phones-messages$NWE
Alte Anzeigen: $row[15]$NWB#phones-old_messages$NWE
Klient Protokoll: $NWB#phones-protocol$NWE
Lokales GMT: (Stellen Sie NICHT auf DST ein)$NWB#phones-local_gmt$NWE
Manager-LOGON: $NWB#phones-ASTmgrUSERNAME$NWE
Manager-Geheimnis: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Rückstellung Benutzer: $NWB#phones-login_user$NWE
VICIDIAL Rückstellung Durchlauf: $NWB#phones-login_pass$NWE
VICIDIAL Rückstellung Kampagne: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park-Akte: $NWB#phones-VICIDIAL_park_on_filename$NWE
Überwachen Sie Präfix: $NWB#phones-monitor_prefix$NWE
Aufnahme Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Kontext: $NWB#phones-ext_context$NWE
DTMFSend Führung: $NWB#phones-dtmf_send_extension$NWE
Outbound Anruf-Gruppe: $NWB#phones-call_out_number_group$NWE
Datenbanksuchroutine-Position: $NWB#phones-client_browser$NWE
Bringen Sie Verzeichnis An: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Rückstellung URL: $NWB#phones-VICIDIAL_web_URL$NWE
Anruf-Protokollierung: $NWB#phones-AGI_call_logging_enabled$NWE
Benutzer-Schaltung: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hängezustand: $NWB#phones-admin_hangup_enabled$NWE
Admin Straßenräuber: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Parkschaltung: $NWB#phones-call_parking_enabled$NWE
Updater Überprüfung: $NWB#phones-updater_check_enabled$NWE
Af Protokollierung: $NWB#phones-AFLogging_enabled$NWE
Warteschlange Ermöglicht: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Taste: $NWB#phones-voicemail_button_enabled$NWE
Schnell Erneuern Sie: $NWB#phones-enable_fast_refresh$NWE
Schnell Erneuern Sie Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Selbstvorwahlknopf-Folgende Zahl: $NWB#phones-auto_dial_next_number$NWE
Stoppen Sie Rec nach jedem Anruf: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Bediener: (HauptsächlichDB Server)$NWB#phones-DBX_server$NWE
DBX Datenbank: (HauptsächlichServer Database)$NWB#phones-DBX_database$NWE
DBX Benutzer: (HauptsächlichDB Login)$NWB#phones-DBX_user$NWE
DBX Durchlauf: (HauptsächlichDB Secret)$NWB#phones-DBX_pass$NWE
DBX Tor: (HauptsächlichDB Port)$NWB#phones-DBX_port$NWE
DBY Bediener: (ZweitensDB Server)$NWB#phones-DBY_server$NWE
DBY Datenbank: (ZweitensServer Database)$NWB#phones-DBY_database$NWE
DBY Benutzer: (ZweitensDB Login)$NWB#phones-DBY_user$NWE
DBY Durchlauf: (ZweitensDB Secret)$NWB#phones-DBY_pass$NWE
DBY Tor: (ZweitensDB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Klicken Sie hier für Telefonnotfall\n"; + +if ($LOGdelete_phones > 0) + { + echo "

LÖSCHEN SIE DIESES TELEFON\n"; + } + +} + + +###################### +# ADD=31 modify server info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ÄNDERN Sie Einen BEDIENER-SATZ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Bediener Identifikation: $NWB#servers-server_id$NWE
Bediener-Beschreibung: $NWB#servers-server_description$NWE
Bediener-IP address: $NWB#servers-server_ip$NWE
Aktiv:$NWB#servers-active$NWE
Sternchen-Version: $NWB#servers-asterisk_version$NWE
Maximale VICIDIAL Stämme: $NWB#servers-max_vicidial_trunks$NWE
Telnet Wirt: $NWB#servers-telnet_host$NWE
Telnet Tor: $NWB#servers-telnet_port$NWE
Manager-Benutzer: $NWB#servers-ASTmgrUSERNAME$NWE
Manager-Geheimnis: $NWB#servers-ASTmgrSECRET$NWE
Manager-Update-Benutzer: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Hören Benutzer: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Senden Benutzer: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Lokales GMT: (Stellen Sie NICHT auf DST ein)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL ANZEIGE Verlängerung: $NWB#servers-answer_transfer_agent$NWE
Rückstellung Kontext: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
TELEFONE INNERHALB DIESES BEDIENERS:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
VERLÄNGERUNGNAMEAKTIV
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Dieser Bediener hat $active_lists aktive Telefone und $inactive_lists unaktivierte Telefone

\n"; +echo "
\n"; +} + + +###################### +# ADD=311 modify conference info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ÄNDERN Sie Einen KONFERENZ-SATZ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Konferenz:$NWB#conferences-conf_exten$NWE
Bediener IP: $NWB#conferences-server_ip$NWE
Gegenwärtige Verlängerung:
\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=4 submit phone modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
TELEFON NICHT GEÄNDERT - es gibt bereits ein Telefon im System mitdiesem extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
TELEFON NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n";} + else + { + echo "
TELEFON GEÄNDERT: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ÄNDERN Sie Einen TELEFON-SATZ: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefonverlängerung: $NWB#phones-extension$NWE
Dialplan Zahl: (nur Stellen)$NWB#phones-dialplan_number$NWE
Voicemail Kasten: (nur Stellen)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (nur Stellen)$NWB#phones-outbound_cid$NWE
Telefon-IP address: (optional)$NWB#phones-phone_ip$NWE
Computer-IP address: (optional)$NWB#phones-computer_ip$NWE
Bediener IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Kennwort:$NWB#phones-pass$NWE
Status:$NWB#phones-status$NWE
Aktives Konto: $NWB#phones-active$NWE
Telefon-Art: $NWB#phones-phone_type$NWE
Voller Name: $NWB#phones-fullname$NWE
Firma:$NWB#phones-company$NWE
Abbildung:$NWB#phones-picture$NWE
Neue Anzeigen: $row[14]$NWB#phones-messages$NWE
Alte Anzeigen: $row[15]$NWB#phones-old_messages$NWE
Klient Protokoll: $NWB#phones-protocol$NWE
Lokales GMT: (Stellen Sie NICHT auf DST ein)$NWB#phones-local_gmt$NWE
Manager-LOGON: $NWB#phones-ASTmgrUSERNAME$NWE
Manager-Geheimnis: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Rückstellung Benutzer: $NWB#phones-login_user$NWE
VICIDIAL Rückstellung Durchlauf: $NWB#phones-login_pass$NWE
VICIDIAL Rückstellung Kampagne: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park-Akte: $NWB#phones-VICIDIAL_park_on_filename$NWE
Überwachen Sie Präfix: $NWB#phones-monitor_prefix$NWE
Aufnahme Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Kontext: $NWB#phones-ext_context$NWE
DTMFSend Führung: $NWB#phones-dtmf_send_extension$NWE
Outbound Anruf-Gruppe: $NWB#phones-call_out_number_group$NWE
Datenbanksuchroutine-Position: $NWB#phones-client_browser$NWE
Bringen Sie Verzeichnis An: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Rückstellung URL: $NWB#phones-VICIDIAL_web_URL$NWE
Anruf-Protokollierung: $NWB#phones-AGI_call_logging_enabled$NWE
Benutzer-Schaltung: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hängezustand: $NWB#phones-admin_hangup_enabled$NWE
Admin Straßenräuber: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Parkschaltung: $NWB#phones-call_parking_enabled$NWE
Updater Überprüfung: $NWB#phones-updater_check_enabled$NWE
Af Protokollierung: $NWB#phones-AFLogging_enabled$NWE
Warteschlange Ermöglicht: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Taste: $NWB#phones-voicemail_button_enabled$NWE
Schnell Erneuern Sie: $NWB#phones-enable_fast_refresh$NWE
Schnell Erneuern Sie Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Selbstvorwahlknopf-Folgende Zahl: $NWB#phones-auto_dial_next_number$NWE
Stoppen Sie Rec nach jedem Anruf: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Bediener: (HauptsächlichDB Server)$NWB#phones-DBX_server$NWE
DBX Datenbank: (HauptsächlichServer Database)$NWB#phones-DBX_database$NWE
DBX Benutzer: (HauptsächlichDB Login)$NWB#phones-DBX_user$NWE
DBX Durchlauf: (HauptsächlichDB Secret)$NWB#phones-DBX_pass$NWE
DBX Tor: (HauptsächlichDB Port)$NWB#phones-DBX_port$NWE
DBY Bediener: (ZweitensDB Server)$NWB#phones-DBY_server$NWE
DBY Datenbank: (ZweitensServer Database)$NWB#phones-DBY_database$NWE
DBY Benutzer: (ZweitensDB Login)$NWB#phones-DBY_user$NWE
DBY Durchlauf: (ZweitensDB Secret)$NWB#phones-DBY_pass$NWE
DBY Tor: (ZweitensDB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Klicken Sie hier für Telefonnotfall\n"; + +if ($LOGdelete_phones > 0) + { + echo "

LÖSCHEN SIE DIESES TELEFON\n"; + } + +} + +###################### +# ADD=41 submit server modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
BEDIENERNOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
BEDIENER NICHT GEÄNDERT - es gibt bereits einen Bediener im Systemmit diesem server_ip\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
BEDIENER NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n";} + else + { + echo "
BEDIENER GEÄNDERT: $server_ip\n"; + + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + } + } + } + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ÄNDERN Sie Einen BEDIENER-SATZ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Bediener Identifikation: $NWB#servers-server_id$NWE
Bediener-Beschreibung: $NWB#servers-server_description$NWE
Bediener-IP address: $NWB#servers-server_ip$NWE
Aktiv:$NWB#servers-active$NWE
Sternchen-Version: $NWB#servers-asterisk_version$NWE
Maximale VICIDIAL Stämme: $NWB#servers-max_vicidial_trunks$NWE
Telnet Wirt: $NWB#servers-telnet_host$NWE
Telnet Tor: $NWB#servers-telnet_port$NWE
Manager-Benutzer: $NWB#servers-ASTmgrUSERNAME$NWE
Manager-Geheimnis: $NWB#servers-ASTmgrSECRET$NWE
Manager-Update-Benutzer: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Hören Benutzer: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Senden Benutzer: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Lokales GMT: (Stellen Sie NICHT auf DST ein)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL ANZEIGE Verlängerung: $NWB#servers-answer_transfer_agent$NWE
Rückstellung Kontext: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
TELEFONE INNERHALB DIESES BEDIENERS:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
VERLÄNGERUNGNAMEAKTIV
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Dieser Bediener hat $active_lists aktive Telefone und $inactive_lists unaktivierte Telefone

\n"; +echo "
\n"; + +} + +###################### +# ADD=411 submit conference modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
KONFERENZ NICHT GEÄNDERT - es gibt bereits eine Konferenz im Systemmit diesem Verlängerung-Bediener\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
KONFERENZ NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n";} + else + { + echo "
KONFERENZ ÄNDERTE: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from conferences where conf_exten='$conf_exten';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ÄNDERN Sie Einen KONFERENZ-SATZ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Konferenz:$NWB#conferences-conf_exten$NWE
Bediener IP: $NWB#conferences-server_ip$NWE
Gegenwärtige Verlängerung:
\n"; + +echo "
\n"; + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo ""; + +echo "
SUCHE NACH Einem TELEFON\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Verlängerung:
Voller Name:
Phone type:
\n"; + +} + +###################### +# ADD=66 phone search results +###################### + +if ($ADD==66) +{ + echo ""; + + $SQL = ''; + if ($extension) {$SQL .= "extension LIKE \"%$extension%\" and";} + if ($fullname) {$SQL .= "fullname LIKE \"%$fullname%\" and";} + if ($phone_type) {$SQL .= "phone_type LIKE \"%$phone_type%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from phones $SQL order by extension,server_ip;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SUCHRESULTATE:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]ÄNDERN Sie | Notfall
\n"; + +} + + + +###################### +# ADD=0 display all active phones +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from phones order by extension,server_ip"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
TELEFON-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[16]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]ÄNDERN Sie | Notfall
\n"; +} + +###################### +# ADD=10 display all servers +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
BEDIENER-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[4] $row[3]  ÄNDERN Sie
\n"; +} + + +###################### +# ADD=100 display all conferences +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
KONFERENZ-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]  ÄNDERN Sie
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BAU: $build
\n"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/dbconnect.php b/agc_2-X/trunk/LANG_admin/astguiclient_de/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_de/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/help.gif b/agc_2-X/trunk/LANG_admin/astguiclient_de/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/astguiclient_de/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/inbound_popup.php b/agc_2-X/trunk/LANG_admin/astguiclient_de/inbound_popup.php new file mode 100644 index 00000000..e75f7a74 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_de/inbound_popup.php @@ -0,0 +1,228 @@ + LICENSE: GPLv2 +### +# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# +# changes: +# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ENTFERNTINBOUND: Popup + + +
+ + 0) +{ + + $stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Adressieren Sie den Befehl um, der für Führung gesendet wird $channel       $NOW_TIME\n

\n"; + + + $url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&'; + $Suser = 'username='; + $Spass = '&passwd='; + $Sphone = '&phone='; + + $newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone"; + if ( ($phone == 'unknown') or (strlen($phone)<9) ) + {$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";} + + echo "Schauen Sie oben diesen Kunden im Kundendienst-System\n

\n"; + + echo "Schließen Sie dieses Fenster\n

\n"; +} +else +{ + echo "Adressieren Sie den Befehl um, der für Führung VERLASSEN wird $channel       $NOW_TIME\n

\n"; + echo "Schließen Sie dieses Fenster\n

\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/phone_stats.php b/agc_2-X/trunk/LANG_admin/astguiclient_de/phone_stats.php new file mode 100644 index 00000000..59855fcb --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_de/phone_stats.php @@ -0,0 +1,244 @@ + LICENSE: GPLv2 +# +# +# changes: +# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$admin_page = './admin.php'; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $row[0]; + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ADMIN: Telefon-Notfall + + +
+
+ + + + + + +\n"; +echo "
  STERNCHEN ADMIN: Leitung  
  VERZEICHNEN SIE ALLE TELEFONE | ADDIEREN Sie Ein NEUES TELEFON | SUCHE NACH Einem TELEFON | ADDIEREN Sie Einen BEDIENER | VERZEICHNEN SIE ALLE BEDIENER
  ZEIGEN SIE ALLE KONFERENZEN | ADDIEREN Sie Eine NEUE KONFERENZ
  \n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + +echo "
\n"; + +echo "ANRUF-ZEIT UND FÜHRUNGEN:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} +# echo "|$stmt|\n"; + +echo "\n"; +echo "
KANALGRUPPE ZÄHLIMPULS HOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
GESAMTANRUFE $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "ANRUFE DES LETZT-1000 FÜR DATUM-STRECKE:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + + $call_seconds=0; + $o++; + } + + +echo "
ZAHL KANALGRUPPE DATUM LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_de/remote_inbound.php b/agc_2-X/trunk/LANG_admin/astguiclient_de/remote_inbound.php new file mode 100644 index 00000000..df7b50d4 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_de/remote_inbound.php @@ -0,0 +1,162 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + echo"\n"; + echo"ASTERISK ENTFERNTINBOUND: Hauptsächlich\n"; + echo"\n"; + echo"\n"; + echo"\n"; + +?> + + +
+ +
\n"; + +echo "Klicken Sie an die Führung unter der, die Sie auf Ihr Telefonverwiesen haben möchten

\n"; + +echo "
\n";
+echo "CHANNEL    BEDIENER       CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME        \n";
+echo "----------------------------------------------------------------------------------------------\n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$extension =		sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		echo "$channel$server$channel_group$extension$parked_by$parked_time\n";
+
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "*************************************** NO PARKED CALLS **************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/AST_inboundEXTstats.php b/agc_2-X/trunk/LANG_admin/astguiclient_el/AST_inboundEXTstats.php new file mode 100644 index 00000000..f8436560 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_el/AST_inboundEXTstats.php @@ -0,0 +1,400 @@ + LICENSE: GPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Στατιστικά Εισερχομένων Κλησεων\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΕΝΑΝ ΑΡΙΘΜΟ ΚΑΙ ΗΜΕΡΟΜΗΝΙΑ ΑΝΩΤΕΡΩ, ΚΑΙ ΠΑΤΗΣΤΕ ΕΠΙΒΕΒΑΙΩΣΗ\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Στατιστικά Εισερχομένων Κλησεων                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Συνολικές κλήσεις που ήρθαν σε αυτό τον αριθμό:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- ΕΓΚΑΤΑΛ\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΟΝΟΥ\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "ΓΡΑΦΙΚΗ ΠΑΡΑΣΤΑΣΗ ΜΕ 15ΛΕΠΤΕΣ ΑΥΞΗΣΕΙΣ ΤΩΝ ΣΥΝΟΛΙΚΩΝ ΚΛΗΣΕΩΝ\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/admin.php b/agc_2-X/trunk/LANG_admin/astguiclient_el/admin.php new file mode 100644 index 00000000..d332d0f6 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_el/admin.php @@ -0,0 +1,1824 @@ + LICENSE: GPLv2 +# +# AST GUI database administration +# +# CHANGES +# 50913-1118 - Added outbound_cid for web-client calls +# 50926-1356 - Modified to allow for language translation +# 50926-1613 - Added WeBRooTWritablE write controls +# 51128-1254 - Modified to allow PHP global vars off +# 51208-2120 - Added option to login with vicidial_user login if allowed +# 51213-1650 - Added option to delete phones if allowed by vicidial_users +# 60421-1430 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1137 - Fixed phone search bug +# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '1.1.12'; +$build = '60620-1243'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS and Dots +$phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); +$computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); + +### DIGITS ONLY ### +$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); +$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id); +$outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); +$VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); +$park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); +$conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); +$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); +$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); +$recording_exten = ereg_replace("[^0-9]","",$recording_exten); +$monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); +$answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); +$DBX_port = ereg_replace("[^0-9]","",$DBX_port); +$DBY_port = ereg_replace("[^0-9]","",$DBY_port); +$telnet_port = ereg_replace("[^0-9]","",$telnet_port); +$max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); +$auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); +$VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); +$enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); +$enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); +$user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); +$updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); +$QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); +$conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); +$voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); +$CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); +$call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); +$AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); +$AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); +$admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); +$admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); +$admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); +$fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); +$ADD = ereg_replace("[^0-9]","",$ADD); + +### ALPHA-NUMERIC and underscore and dash and slash and at and dot +$extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); +$old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); +$install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); +$client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); +$dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); +$call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); +$telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); +$DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); +$DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + +### ALPHA-NUMERIC (and underscore and dash) +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$login = ereg_replace("[^-\_0-9a-zA-Z]","",$login); +$user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); +$status = ereg_replace("[^-\_0-9a-zA-Z]","",$status); +$protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); +$ASTmgrUSERNAMEupdate = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); +$ASTmgrUSERNAMEsend = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); +$ASTmgrUSERNAMElisten = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); +$ASTmgrUSERNAME = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAME); +$ASTmgrSECRET = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrSECRET); +$login_user = ereg_replace("[^-\_0-9a-zA-Z]","",$login_user); +$login_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$login_pass); +$login_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$login_campaign); +$DBX_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_user); +$DBY_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_user); +$DBX_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_pass); +$DBY_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_pass); +$DBX_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_database); +$DBY_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_database); +$VICIDIAL_park_on_filename = ereg_replace("[^-\_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); +$server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); +$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id); +$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context); +$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); +$company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); +$picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); +$local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); +$server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); +$asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + +### VARIABLES TO BE mysql_real_escape_string ### +# $VICIDIAL_web_URL = +# $local_web_callerID_URL = + +##### END VARIABLE FILTERING FOR SECURITY ##### + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Έχετε αποσυνδεθεί. Σας ευχαριστούμε\n"; + exit; +} + +if (!isset($ADD)) {$ADD=0;} + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + +if ($ADD==1) {$process = 'ΠΡΟΣΘΕΣΕ ΝΕΟ ΤΗΛΕΦΩΝΟ';} +if ($ADD==11) {$process = 'ΠΡΟΣΘΕΣΕ ΝΕΟ ΔΙΑΚΟΜΙΣΤΗ';} +if ($ADD==111) {$process = 'ΠΡΟΣΘΕΣΕ ΝΕΑ ΣΥΝΔΙΑΛΕΞΗ';} +if ($ADD==2) {$process = 'ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΤΗΛΕΦΩΝΟΥ';} +if ($ADD==21) {$process = 'ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΔΙΑΚΟΜΙΣΤΗ';} +if ($ADD==211) {$process = 'ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΣΥΝΔΙΑΛΕΞΗΣ';} +if ($ADD==3) {$process = 'ΤΡΟΠΟΠΟΙΗΣΕ ΤΗΛΕΦΩΝΟ';} +if ($ADD==31) {$process = 'ΤΡΟΠΟΠΟΙΗΣΕ ΔΙΑΚΟΜΙΣΤΗ';} +if ($ADD==311) {$process = 'ΤΡΟΠΟΠΟΙΗΣΕ ΣΥΝΔΙΑΛΕΞΗ';} +if ($ADD==4) {$process = 'ΤΡΟΠΟΠΟΙΗΣΗ ΤΗΛΕΦΩΝΟΥ';} +if ($ADD==41) {$process = 'ΤΡΟΠΟΠΟΙΗΣΗ ΔΙΑΚΟΜΙΣΤΗ';} +if ($ADD==411) {$process = 'ΤΡΟΠΟΠΟΙΗΣΗ ΣΥΝΔΙΑΛΕΞΗΣ';} +if ($ADD==5) {$process = 'DELETE PHONE';} +if ($ADD==6) {$process = 'DELETE PHONE';} +if ($ADD==55) {$process = 'ΑΝΑΖΗΤΗΣΗ ΤΗΛΕΦΩΝΩΝ';} +if ($ADD==66) {$process = 'ΑΝΑΖΗΤΗΣΗ ΑΠΟΤΕΛΕΣΜΑΤΩΝ ΤΗΛΕΦΩΝΩΝ';} +if ($ADD==0) {$process = 'ΛΙΣΤΑ ΤΗΛΕΦΩΝΟΥ';} +if ($ADD==10) {$process = 'ΛΙΣΤΑ ΔΙΑΚΟΜΙΣΤΗ';} +if ($ADD==100) {$process = 'ΛΙΣΤΑ ΣΥΝΔΙΑΛΕΞΕΩΝ';} +if ($ADD==99999) {$process = 'ΒΟΗΘΕΙΑ';} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if ($auth<1) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > '6' and ast_admin_access='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGdelete_phones =$row[17]; + } + } + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + echo "|$stmt|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + if (strlen($LOGfullname) < 1) + { + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "\n"; + $o++; + } + + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); + +$NWB = "   \"ΒΟΗΘΕΙΑ\""; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "ΣΥΣΤΗΜΑ ΚΛΗΣΕΩΝ: Διαχείριση - $process \n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ASTERISK ADMIN: ΒΟΗΘΕΙΑ


\n"; + +?> +ΠΙΝΑΚΑΣ ΤΗΛΕΦΩΝΩΝ

+ +
+Εσωτ.Σύνδεση Τηλεφώνου - Αυτό το πεδίο είναι για την καταχώρηση του ονόματος του τηλεφώνου, όπως αυτό εμφανίζεται στο Asterisk, χωρίς να συμπεριλαμβάνει το πρωτόκολλο ή slash στην αρχή. Για παράδειγμα: για SIP τηλέφωνο SIPVtest101 η Εσω.Γραμμή Τηλεφώνου θα είναι test101. Επίσης, για IAX2 τηλέφωνα χρησιμοποιείστε τα πλήρης ονόματα: IAX2/IAXphone1@IAXphone1 θα είναι IAXphone1@IAXphone1. Για Zap τηλέφωνα καταχωρήστε το πλήρες κανάλι: Zap/25-1 θα είναι 25-1. Αλλη σημείωση, ορίστε το πρωτόκολλο παρακάτω σωστά για τον τύπο του τηλεφώνου. + +
+
+
+Αριθμός Σχεδίου Κλήσεων - Αυτό το πεδίο είναι για τον αριθμό που καλείται για να κουδουνίζει το τηλέφωνο. Αυτός ο αριθμός ορίζεται στο αρχείο extensions.conf του διακομιστή Asterisk + +
+
+
+Περιεχόμενο Φωνητικού Ταχυδρομείου - Αυτό το πεδίο είναι για το περιεχόμενο του φωνητικού ταχυδρομείου, όπου πηγαίνουν τα μηνύματα του τηλεφώνου του χρήστη. Το χρησιμοποιούμαι για να ελέγξουμε τα φωνητικά μηνύματα και για να μπορεί ο χρήστης να χρησιμοποιήσει το πλήκτρο VOICEMAIL. + +
+
+
+CallerID Εξερχομένων - Αυτό το πεδίο είναι για την καταχώριση του αριθμού callerID που θα θέλατε να εμφανίζεται στις εξερχόμενες κλήσεις. + +
+
+
+Δνση IP Τηλεφώνου - Αυτό το πεδίο είναι για την δνση IP του τηλέφωνου εάν είναι ένα VOIP τηλέφωνο. Αυτό είναι ένα προαιρετικό πεδίο + +
+
+
+Δνση IP Υπολογιστού - Αυτό το πεδίο είναι για την δνση IP του υπολογιστή του χρήστη. Αυτό είναι ένα προαιρετικό πεδίο + +
+
+
+IP Διακομιστή - Αυτός ο κατάλογος επιλογών είναι που επιλέγετε σε ποιον διακομιστή το τηλέφωνο είναι ενεργό. + +
+
+
+Σύνδεση - η σύνδεση που χρησιμοποιείται για τον τηλεφωνικό χρήστηστη σύνδεση στις εφαρμογές πελατών. + +
+
+
+Κωδικός πρόσβασης - ο κωδικός πρόσβασης που χρησιμοποιείται γιατον τηλεφωνικό χρήστη στη σύνδεση στις εφαρμογές πελατών. + +
+
+
+Κατάσταση - Η κατάσταση του τηλεφώνου στο σύστημα, ΕΝΕΡΓΗ και ΔΙΑΧ επιτρέπουν στους GUI πελάτες να δουλέψουν. Η ΔΙΑΧ επιτρέπει την πρόσβαση στην ιστοσελίδα διαχείρισης. + +
+
+
+Ενεργός Λογαριασμός - Κατά πόσο το τηλέφωνο είναι ενεργό για να τοποθετηθεί στην λίστα στο GUI. + +
+
+
+Τύπος Τηλεφώνου - Απλά για σημειώσεις διαχείρισης. + +
+
+
+Πλήρες Ονομα - Χρησιμοποιείται από τον χρήστη GUI στην λίστα ενεργών τηλεφώνων. + +
+
+
+Εταιρία - Απλά για σημειώσεις διαχείρισης. + +
+
+
+Εικόνα - Δεν έχει υλοποιηθεί ακόμα. + +
+
+
+Νέα Μηνύματα - Αριθμός νέων φωνητικών μηνυμάτων για αυτό το τηλέφωνο στον διακομιστή Asterisk. + +
+
+
+Παλαιά Μηνύματα - Αριθμός παλαιών φωνητικών μηνυμάτων για αυτό το τηλέφωνο στον διακομιστή Asterisk. + +
+
+
+Πρωτόκολλο Πελάτη - Το πρωτόκολλο που χρησιμοποιεί το τηλέφωνο για συνδεθεί στον διακομιστή Asterisk: SIP, IAX2, Zap. + +
+
+
+οπική GMT - Η διαφορά από την GMT όπου το τηλέφωνο βρίσκεται. Μην το ρυθμίσετε για DAYLIGHT SAVINGS ΩΡΑ. Αυτή χρησιμοποιείται από την VICIDIAL εκστρατεία για την επακριβή εμφάνιση της ώρας. + +
+
+
+Σύνδεση Διαχειριστή - Αυτή είναι η σύνδεση που χρησιμοποιούν οι GUI χρήστες του τηλεφώνου, για πρόσβαση στην Βάση Δεδομένων όπου ο διακομιστής δεδομένων βρίσκεται. + +
+
+
+Μυστικό Διαχειριστή - Αυτός είναι ο κωδικός που χρησιμοποιούν οι GUI χρήστες του τηλεφώνου, για πρόσβαση στην Βάση Δεδομένων όπου ο διακομιστής δεδομένων βρίσκεται. + +
+
+
+Προκαθορισμένος VICIDIAL Χρήστης - Εδώ ορίζεται μία προκαθορισμένη τιμή χρήστη, οπουδήποτε αυτός ο χρήστης τηλεφώνου ανοίξει την εφαρμογή VICIDIAL. Αφήστε κενό για κανένα χρήστη. + +
+
+
+Προκαθορισμένος VICIDIAL Κωδικός - Εδώ ορίζεται μία προκαθορισμένη τιμή κωδικού, οπουδήποτε αυτός ο χρήστης τηλεφώνου ανοίξει την εφαρμογή VICIDIAL. Αφήστε κενό για κανένα κωδικό. + +
+
+
+VICIDIAL Προκαθορισμένη Εκστρατεία - Εδώ ορίζεται μα προκαθορισμένη τιμή εκστρατείας, οπουδήποτε αυτός ο χρήστης τηλεφώνου ανοίξει την εφαρμογή VICIDIAL. Αφήστε κενό για καμία εκστρατεία. + +
+
+
+Εσ.Σύνδ. Στάθμευσης - Αυτή είναι η προκαθορισμένη εσωτ.σύνδεση Στάθμευσης για τις εφαρμογές του χρήστη. + +
+
+
+Εσ.Σύνδ. Συνδιάλεξης - Αυτή είναι η προκαθορισμένη εσωτ.σύνδεση Συνδιάλεξης για τις εφαρμογές του χρήστη. + +
+
+
+Εσωτ.Σύνδεση Στάθμευσης VICIDIAL - Η προκαθορισμένη εσωτ.σύνδεση στάθμευσης. Εξακριβώστε ότι κάποια διαφορετική δουλεύει πριν την αλλάξετε. + +
+
+
+ Αρχείο Στάθμευσης VICIDIAL - Το προκαθορισμένο αρχείο στάθμευσης. Μέχρι 10 χαρακτήρες. + +
+
+
+Πρόθεμα παρακολούθησης - Αυτό είναι το πρόθεμα παρακολούθησης των καναλιών ZAP. + +
+
+
+Εσωτ.Σύνδεση Ηχογράφησης - Αυτή είναι η εσωτ.σύνδεση του πλάνου κλήσεων για την εσωτ.σύνδεση ηχογράφησης που χρησιμοποιείται για μεταφορά στις συνδιαλέξεις, ώστε να ηχογραφηθούν.Extensions.conf . + +
+
+
+Βασική Εσωτ.Σύνδεση VMAIL - Αυτή είναι η εσωτ.σύνδεση του πλάνου κλήσεων που ελέγχει την θυρίδα ηχητικών μηνυμάτων. + +
+
+
+Εσωτ.Σύνδεση απόρριψης VMAIL - Αυτο είναι το πρόθεμα του πλάνου κλήσεων που χρησιμοποιείται στο να στέλνει κλήσεις κατευθείαν στη θυρίδα του χρήστη από μία κλήση. + +
+
+
+Περιεχόμενο Εσωτ.Σύνδεσης - Αυτό είναι το περιεχόμενο του πλάνου κλήσεων όπου το τηλέφωνο χρησιμοποιεί. + +
+
+
+Κανάλι αποστολής DTMF - Αυτό είναι το κανάλι του χρησιμοποιείται για την αποστολή DTMF ήχων στις συνδιαλέξεις. + +
+
+
+Εξερχόμεη ομάδα κλήσης - αυτή είναι η ομάδα καναλιού όπου οι εξερχόμενες κλήσεις από αυτό το τηλέφωνο τοποθετούνται. Υπάρχουν ρουτίνες που την χρησιμοποιούν. Για τα κανάλια Zap θέλετε να χρησιμοποιήσετε κάτι σαν Zap/g2, για IAX2 trunks θα θέλετε να χρησιμοποιήσετε το πλήρες πρόθεμα IAX όπως IAX2/VICItest1:secret@10.10.10.15:4569. Ελέγξτε τα trunks με το αρχείο extensions.conf. + +
+
+
+Περιοχή Ιστο-Πλοηγού - Αυτό χρειάζεται μόνο σε Linux συστήματα. + +
+
+
+Κατάλογος Εγκατάστασης - . + +
+
+
+CallerID URL - Αυτή είναι η Δνση της ιστοσελίδας που χρησιμοποιείται για αναζήτηση με callerID + +
+
+
+Προκαθορισμένο VICIDIAL URL - Αυτή είναι η δνση ιστοσελίδας που χρησιμοποιείται για προσαρμοσμένα VICIDIAL ερωτήματα ιστοσελίδας + +
+
+
+Καταγραφή Γεγονότων Κλήσης - Αυτό τοποθετείται σε αληθές εάν το αρχείο call_log.agi βρίσκεται στο αρχείο extensions.conf για τις εξερχόμενες κλήσεις και για τις εσωτ.συνδέσεις 'h' που κλείνουν. Αυτό πρέπει πάντα να είναι 1 για να δουλεύουν σωστά πολλά χαρακτηριστικά των εφαρμογών. + +
+
+
+Μεταγωγή Χρήστη - Εάν το θέσετε σε αληθές θα επιτρέπετε στους χρήστες να μεταβούν σε άλλον λογαριασμό χρήστη + +
+
+
+Σε συνδιάλεξη - Εάν το θέσετε σε αληθές θα επιτρέπετε στους χρήστες να ξεκινούν συνδιαλέξεις μέχρι 6 εξωτερικές γραμμές. + +
+
+
+Διαχειριστού Κλείσιμο- Εάν το θέσετε σε αληθές θα επιτρέπετε στους χρήστες να κλείνουν κάθε γραμμή. + +
+
+
+Διαχειριστού Κλέψιμο - Εάν το θέσετε σε αληθές θα επιτρέπετε στους χρήστες να λαμβάνουν και να ανακατευθύνουν στην εσωτ.σύνδεσή τους οποιαδήποτε γραμμή. + +
+
+
+Διαχειριστού Παρακολούθηση - Εάν το θέσετε σε αληθές θα επιτρέπετε στους χρήστες να λαμβάνουν και να ανακατευθύνουν στην εσωτ.σύνδεσή τους οποιαδήποτε γραμμή. + +
+
+
+Στάθμευση Κλήσης - Εάν το θέσετε σε αληθές θα επιτρέπετε σε χρήστες να σταθμεύουν κλήσεις και κλήσεις σε αναμονή να διαχειρίζονται από οποιοδήποτε άλλο χρήστη. Οι κλήσεις μένουν σε αναμονή για 30 δευτερόλεπτα και μετά κλείνουν. Συνήθως ενεργοποιημένη για όλους. + +
+
+
+Ενεργοποιημένη Ουρά - Εάν το θέσετε σε αληθές θα εμφανίζεται ένα παράθυρο ειδοποίησης, ότι η ώρα ενημέρωσης δεν έχει αλλάξει σε 20 δευτερόλεπτα. + +
+
+
+AF Καταγραφή Γεγονότος - Εάν το θέσετε σε αληθές θα καταγράφονται οι ενέργειες χρήσης του astGUIclient σε ένα αρχείο στον υπολογιστή του χρήστη. + +
+
+
+Ενεργοποιημένη Ουρά - Εάν το θέσετε σε αληθές οι εφαρμογές θα χρησιμοποιούν το ACQS. + +
+
+
+Υπερεμφανιζόμενο παραθύρο CallerID - Εάν το θέσετε σε αληθές θα επιτρέψετε σε αριθμούς ορισμένους στο αρχείο extensions.conf, να στέλνουν οθόνες με CallerID στους astGUIclient χρήστες. + +
+
+
+VMail Πλήκτρο - Εάν το θέσετε σε αληθές θα εμφανιστεί το πλήκτρο VOICEMAIL και τα μηνύματα μπορούν να εμφανίζονται στο astGUIclient. + +
+
+
+Ταχύτητα Ανανέωσης - Εάν το θέσετε σε αληθές ενεργοποιείται ένα νέο ρυθμό ανανέωσης πληροφοριών κλήσης για το astGUIclient. Προκαθορισμένος απενεργοποιημένος ρυθμός είναι 1000 ms (1 δευτερόλεπτο). + +
+
+
+Ρυθμός Ανανέωσης Ταχύτητας - σε χιλιοστά δευτερολέπτου. Χρημοποιείται μόνο εάν η Ταχύτητα Ανανέωσης είναι ενεργοποιημένη. Προκαθορισμένος απενεργοποιημένος ρυθμός είναι 1000 ms (1 δευτερόλεπτο). + +
+
+
+Συνεχής MySQL - Εάν είναι ενεργοποιημένο, το astGUIclient θα παραμένει συνδεμένο αντί να συνδέεται κάθε δευτερόλεπτο. + +
+
+
+Αυτόματη Κλήση Επόμενου Αριθμού - Εάν είναι ενεργοποιημένο, μετά από τον τερματισμό θα γίνει κλήση του επόμενου αριθμού, εκτός εάν επιλέξουμε "Μη κάνεις κλήσεις". + +
+
+
+Σταμάτα την ηχογράφηση μετά από κάθε κλήση - Εάν είναι ενεργοποιημένο η ηχογράφηση θα σταματήσει μετά τον τερματισμό. + +
+
+
+DBΧ Διακομιστής - Ο διακομιστής της Βάσης Δεδομένων MySQL που ο χρήστης θα συνδεθεί. + +
+
+
+DBΧ Βάση Δεδομένων - Η βάση δεδομένων MySQL στην οποία ο χρήστης θα συνδεθεί. Η προκαθορισμένη είναι asterisk. + +
+
+
+DBΧ Χρήστης - Ο χρήστης MySQL για την σύνδεση. Ο προκαθορισμένος είναι cron. + +
+
+
+DBΧ Κωδικός - Ο κωδικός χρήστη MySQL που ο χρήστης χρησιμοποιεί όταν συνδέεται. Ο προκαθορισμένος είναι 1234. + +
+
+
+DBΧ Πόρτα - Η MySQL TCP πόρτα που ο χρήστης χρησιμοποιεί όταν συνδέεται. Η προκαθορισμένη είναι 3306. + +
+
+
+DBY Διακομιστής - Ο διακομιστής της Βάσης Δεδομένων MySQL που ο χρήστης θα συνδεθεί. Δευτερεύονserver, μην χρησιμοποιημένος αυτήν την περίοδο. + +
+
+
+DBY Βάση Δεδομένων - Η βάση δεδομένων MySQL στην οποία ο χρήστης θα συνδεθεί. Η προκαθορισμένη είναι asterisk. Δευτερεύονserver, μην χρησιμοποιημένος αυτήν την περίοδο. + +
+
+
+DBY Χρήστης - Ο χρήστης MySQL για την σύνδεση. Ο προκαθορισμένος είναι cron. Δευτερεύονserver, μην χρησιμοποιημένος αυτήν την περίοδο. + +
+
+
+DBY Κωδικός - Ο κωδικός χρήστη MySQL που ο χρήστης χρησιμοποιεί όταν συνδέεται. Ο προκαθορισμένος είναι 1234. Δευτερεύονserver, μην χρησιμοποιημένος αυτήν την περίοδο. + +
+
+
+DBY Πόρτα - Η MySQL TCP πόρτα που ο χρήστης χρησιμοποιεί όταν συνδέεται. Η προκαθορισμένη είναι 3306. Δευτερεύονserver, μην χρησιμοποιημένος αυτήν την περίοδο. + + +



+ +ΠΙΝΑΚΑΣ ΔΙΑΚΟΜΙΣΤΩΝ

+
+
+ID Διακομιστή - Σε αυτό το πεδίο ορίζεται το όνομα του διακομιστή Asterisk, είναι μόνο μία επωνυμία ώστε να αναγνωρίζεται από τους διαχειριστές. + +
+
+
+Περιγραφή Διακομιστή - Το πεδίο στο οποίο περιγράφεται με μία φράση τον διακομιστή Asterisk. + +
+
+
+Δνση IP Διακομιστή - Το πεδίο που ορίζεται η δνση IP του δικτύου του διακομιστή Asterisk. + +
+
+
+Ενεργός - Ορίζει κατά πόσον ο διακομιστής Asterisk είναι ενεργός ή μη ενεργός. + +
+
+
+Εκδοση Asterisk. + +
+
+
+Μέγιστος Αριθμός Trunk του VICIDIAL - Αυτό το πεδίο θα προσδιορίσει τον μέγιστο αριθμό γραμμών, τις οποίες θα χρησιμοποιήσει η διεργασία αυτόματης κλήσης. Εάν θέλετε να αφιερώσετε δύο PRI σε ένα διακομιστή τότε θα πρέπει να το ορίσετε σε 46. Το προκαθορισμένο είναι 96. + +
+
+
+Telnet Πελάτης - Αυτή είναι η δνση ή το όνομα του διακομιστή Asterisk και το πώς οι εφαρμογές διαχείρισης συνδέονται σε αυτόν, όπου τρέχουν. Το προκαθορισμένο είναι 'localhost'. + +
+
+
+Πόρτα Telnet - Αυτή είναι η πόρτα της σύνδεσης με τον διαχειριστή του διακομιστή Asterisk και το πώς οι εφαρμογές διαχείρισης συνδέονται σε αυτόν, όπου τρέχουν. Το προκαθορισμένο είναι '5038'. + +
+
+
+ Διαχειριστής Χρήστης - Το όνομα χρήστη που χρησιμοποιείτε γενικά για τον διαχειριστή του διακομιστή Asterisk. Το προκαθορισμένο είναι 'cron' + +
+
+
+Μυστικό Διαχειριστή - Το μυστικό ή κωδικός που χρησιμοποιείτε γενικά για τον διαχειριστή του διακομιστή Asterisk. Το προκαθορισμένο είναι '1111' + +
+
+
+Ενημέρωση Χρήστη Διαχειριστή - Το όνομα χρήστη που χρησιμοποιείτε για σύνδεση στον διακομιστή Asterisk, βελτιστοποιημένο για διεργασίες ενημέρωσης. Το προκαθορισμένο είναι 'updatecron'. + +
+
+
+Ακουσμα Χρήστη Διαχειριστή- Το όνομα χρήστη που χρησιμοποιείτε για σύνδεση στον διακομιστή Asterisk, βελτιστοποιημένο για διεργασίες που μόνο ακούν για έξοδο. Το προκαθορισμένο είναι 'listencron'. + +
+
+
+Αποστολή Διακομιστή Διαχειριστή- Το όνομα χρήστη που χρησιμοποιείτε για σύνδεση στον διακομιστή Asterisk, βελτιστοποιημένο για διεργασίες που μόνο στέλνουν Ενέργειες στον διαχειριστή.Το προκαθορισμένο είναι 'sendcron'. + +
+
+
+GMT offset Διακομιστής - Η διαφορά σε ώρες από την GMT ώρα που δεν έχει ρυθμιστεί με Daylight-Savings-Time. Το προκαθορισμένο είναι '-5' + +
+
+
+Εσωτ.σύνδεση απόρριψης VMail - Το πρόθεμα εσωτ.σύνδεσης που χρησιμοποιείται στον διακομιστή για να στείλει τις κλήσεις κατευθείαν μέσω agc σε ένα συγκεκριμένο φωνητικό ταχυδρομείο. Το προκαθορισμένο είναι '85026666666666' + +
+
+
+VICIDIAL AD εσωτ.σύνδεση - Η προκαθορισμένη εσωτ.σύνδεση εάν δεν έχει οριστεί στην εκστρατεία για να στείλει τις κλήσεις στην διεργασία αυτόματης κλήσης. Η προκαθορισμένη είναι '8365' + +
+
+
+Προκαθορισμένο Περιεχόμενο - Το προκαθορισμένο περιεχόμενο του πλάνου κλήσεων για διεργασίες του διακομιστή. Το προκαθορισμένο είναι 'προκαθορισμένο' + + +



+ +ΠΙΝΑΚΑΣ ΣΥΝΔΙΑΛΕΞΕΩΝ

+
+
+Αριθμός Συνδιάλεξης - Αυτό το πεδίο είναι για τον αριθμό συνδιάλεξης meetme στο σχέδιο κλήσεων. Επίσης, συνιστούμε ο αριθμός meetme στο meetme.conf να ταιριάζει με αυτό τον αριθμό για κάθε καταχώρηση. Αυτό είναι για τις συνδιαλέξε στο astGUIclient και χρησιμοποιείται για την λειτουργία αποχώρησης από κλήση με 3 γραμμές στο VICIDIAL. + +
+
+
+IP Διακομιστή- Ο κατάλογος που επιλέξατε τον διακομιστή ASTERISK όπου η συνδιάλεξη θα είναι. + + + + + + +







+







+ΤΕΛΟΣ +
+ + + +ΣΥΣΤΗΜΑ ΚΛΗΣΕΩΝ: Διαχείριση - <? echo $process ?> + + + +
+ + + + + + +
  ASTERISK ADMIN - Αποσύνδεση  
  ΛΙΣΤΑ ΤΗΛΕΦΩΝΩΝ | ΠΡΟΣΘΗΚΗ ΤΗΛΕΦΩΝΟΥ | ΑΝΑΖΗΤΗΣΗ ΤΗΛΕΦΩΝΟΥ | ΠΡΟΣΘΗΚΗ ΔΙΑΚΟΜΙΣΤΗ | ΛΙΣΤΑ ΔΙΑΚΟΜΙΣΤΩΝ
  ΕΜΦΑΝΙΣΗ ΣΥΝΔΙΑΛΕΞΕΩΝ | ΠΡΟΣΘΗΚΗ ΣΥΝΔΙΑΛΕΞΗΣ
+"; + +echo "
ΠΡΟΣΘΗΚΗ ΤΗΛΕΦΩΝΟΥ
\n"; +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Τηλ.σύνδεσης τηλεφώνου: $NWB#phones-extension$NWE
Αριθμός Σχεδίου Κλήσεων: (μόνο αριθμοί)$NWB#phones-dialplan_number$NWE
Περιεχόμενο Φωνητικού Ταχυδρομείου: (μόνο αριθμοί)$NWB#phones-voicemail_id$NWE
Εξερχόμενο CallerID: (μόνο αριθμοί)$NWB#phones-outbound_cid$NWE
Δνση IP Τηλεφώνου: (optional)$NWB#phones-phone_ip$NWE
Δνση IP Υπολογιστή: (optional)$NWB#phones-computer_ip$NWE
IP Διακομιστή: $NWB#phones-server_ip$NWE
Σύνδεση:$NWB#phones-login$NWE
Κωδικός:$NWB#phones-pass$NWE
Κατάσταση:$NWB#phones-status$NWE
Ενεργός Λογαριασμός: $NWB#phones-active$NWE
Τύπος τηλεφώνου: $NWB#phones-phone_type$NWE
Πλήρες Ονομα: $NWB#phones-fullname$NWE
Εταιρία:$NWB#phones-company$NWE
Εικόνα:$NWB#phones-picture$NWE
Προτόκολο Πελάτη: $NWB#phones-protocol$NWE
Τοπικό GMT: (Μην ρυθμίσεις για DST)$NWB#phones-local_gmt$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW SERVERS FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΔΙΑΚΟΜΙΣΤΗ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Διακομιστή: $NWB#servers-server_id$NWE
Περιγραφή Διακομιστή: $NWB#servers-server_description$NWE
Δνση IP Διακομιστή: $NWB#servers-server_ip$NWE
Ενεργή:$NWB#servers-active$NWE
Εκδοση Asterisk: $NWB#servers-asterisk_version$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW CONFERENCES FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΣΥΝΔΙΑΛΕΞΗΣ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Αριθμός Συνδιάλεξης: (μόνο αριθμοί)$NWB#conferences-conf_exten$NWE
IP Διακομιστή: $NWB#conferences-server_ip$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new phone to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη ένα τηλέφωνο με αυτή την εσωτ.σύνδεση/διακομιστή\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΠΡΟΣΤΕΘΗΚΕ\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new server to the system +###################### + +if ($ADD==21) +{ + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Ο ΔΙΑΚΟΜΙΣΤΗΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη ένας διακομιστής με αυτό το ID\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
Ο ΔΙΑΚΟΜΙΣΤΗΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + echo "
Ο ΔΙΑΚΟΜΙΣΤΗΣ ΠΡΟΣΤΕΘΗΚΕ\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new conference to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Η ΣΥΝΔΙΑΛΕΞΗ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μία συνδιάλεξη με αυτό το ID και διακομιστή\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
Η ΣΥΝΔΙΑΛΕΞΗ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + echo "
Η ΣΥΝΔΙΑΛΕΞΗ ΠΡΟΣΤΕΘΗΚΕ\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=100; +} + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of phone +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGdelete_phones < 1) ) + { + echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
IP Διακομιστή be at least 7 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΤΗΛΕΦΩΝΟΥ: $extension - $server_ip\n"; + echo "

Χτυπήστε εδώ για να διαγράψετε το τηλέφωνο $extension - $server_ip


\n"; + } + +$ADD='3'; # go to phone modification below +} + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete phone record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGdelete_phones < 1) ) + { + echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
IP Διακομιστή be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING PHONE!!!|$PHP_AUTH_USER|$ip|extension='$extension'|server_ip='$server_ip'|\n"); + fclose($fp); + } + echo "
Η ΔΙΑΓΡΑΦΗ ΤΟΥ ΤΗΛΕΦΩΝΟΥ ΟΛΟΚΛΗΡΩΘΗΚΕ: $extension - $server_ip\n"; + echo "

\n"; + } + +$ADD='0'; # go to phone list +} + + + + + + +###################### +# ADD=3 modify phone info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΤΗΛΕΦΩΝΟΥ: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Τηλ.σύνδεσης τηλεφώνου: $NWB#phones-extension$NWE
Αριθμός Σχεδίου Κλήσεων: (μόνο αριθμοί)$NWB#phones-dialplan_number$NWE
Περιεχόμενο Φωνητικού Ταχυδρομείου: (μόνο αριθμοί)$NWB#phones-voicemail_id$NWE
Εξερχόμενο CallerID: (μόνο αριθμοί)$NWB#phones-outbound_cid$NWE
Δνση IP Τηλεφώνου: (optional)$NWB#phones-phone_ip$NWE
Δνση IP Υπολογιστή: (optional)$NWB#phones-computer_ip$NWE
IP Διακομιστή: $NWB#phones-server_ip$NWE
Σύνδεση:$NWB#phones-login$NWE
Κωδικός:$NWB#phones-pass$NWE
Κατάσταση:$NWB#phones-status$NWE
Ενεργός Λογαριασμός: $NWB#phones-active$NWE
Τύπος τηλεφώνου: $NWB#phones-phone_type$NWE
Πλήρες Ονομα: $NWB#phones-fullname$NWE
Εταιρία:$NWB#phones-company$NWE
Εικόνα:$NWB#phones-picture$NWE
Νέα Μηνύματα: $row[14]$NWB#phones-messages$NWE
Παλαιά Μηνύματα: $row[15]$NWB#phones-old_messages$NWE
Προτόκολο Πελάτη: $NWB#phones-protocol$NWE
Τοπικό GMT: (Μην ρυθμίσεις για DST)$NWB#phones-local_gmt$NWE
Διαχειριστή Σύνδεση: $NWB#phones-ASTmgrUSERNAME$NWE
Κωδικός Διαχειριστή: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Προκαθορισμένος Χρήστης: $NWB#phones-login_user$NWE
VICIDIAL Προκαθορισμένος Κωδικός: $NWB#phones-login_pass$NWE
VICIDIAL Προκαθορισμένη εκστρατεία: $NWB#phones-login_campaign$NWE
Τηλ.σύνδ. Στάθμευσης: $NWB#phones-park_on_extension$NWE
Τηλ.σύνδ. Συνδ.: $NWB#phones-conf_on_extension$NWE
VICIDIAL Τηλ.σύνδ. Στάθμευσης: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Αρχείο Στάθμευσης: $NWB#phones-VICIDIAL_park_on_filename$NWE
Πρόθεμα Παρακολούθησης: $NWB#phones-monitor_prefix$NWE
Ηχογράφηση εσωτ.σύνδ.: $NWB#phones-recording_exten$NWE
VMailMain Τηλ.σύνδ.: $NWB#phones-voicemail_exten$NWE
VMailDump Τηλ.σύνδ.: $NWB#phones-voicemail_dump_exten$NWE
Περιεχόμενο Τηλ.σύνδ: $NWB#phones-ext_context$NWE
DTMFSend Κανάλι: $NWB#phones-dtmf_send_extension$NWE
Ομάδα Εξερχομένων Κλήσεων: $NWB#phones-call_out_number_group$NWE
Θέση Φυλλομετρητή: $NWB#phones-client_browser$NWE
Κατάλογος εγκατάστασης: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Προκαθορισμένο URL: $NWB#phones-VICIDIAL_web_URL$NWE
Καταγραφή Γεγονότος Κλήσης: $NWB#phones-AGI_call_logging_enabled$NWE
Μεταγωγή Χρήστη: $NWB#phones-user_switching_enabled$NWE
Σε συνδιαλέξη: $NWB#phones-conferencing_enabled$NWE
Διαχειριστού Κλείσιμο: $NWB#phones-admin_hangup_enabled$NWE
Διαχειριστού Κλέψιμο: $NWB#phones-admin_hijack_enabled$NWE
Διαχειριστού Παρακολούθηση: $NWB#phones-admin_monitor_enabled$NWE
Στάθμευση Κλήσης: $NWB#phones-call_parking_enabled$NWE
Ελεγχος ενημερωτή: $NWB#phones-updater_check_enabled$NWE
AF Καταγραφή Γεγονότος: $NWB#phones-AFLogging_enabled$NWE
Ενεργή Ουρά: $NWB#phones-QUEUE_ACTION_enabled$NWE
Υπερεμφανιζόμενο παραθύρο CallerID: $NWB#phones-CallerID_popup_enabled$NWE
Πλήκτρο VMail: $NWB#phones-voicemail_button_enabled$NWE
Ταχύτητα Ανανέωσης: $NWB#phones-enable_fast_refresh$NWE
Ρυθμός Ανανέωσης Ταχύτητας: (in ms)$NWB#phones-fast_refresh_rate$NWE
Συνεχής MySQL: $NWB#phones-enable_persistant_mysql$NWE
Αυτόματη Κλήση Επόμενου Αριθμού: $NWB#phones-auto_dial_next_number$NWE
Σταμάτα την ηχογράφηση μετά από κάθε κλήση: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Διακομιστής: (Πρωταρχικό DB Server)$NWB#phones-DBX_server$NWE
DBX Βάση Δεδομένων: (Πρωταρχικό Server Database)$NWB#phones-DBX_database$NWE
DBX Χρήστης: (Πρωταρχικό DB Login)$NWB#phones-DBX_user$NWE
DBX Κωδικός: (Πρωταρχικό DB Secret)$NWB#phones-DBX_pass$NWE
DBX Πόρτα: (Πρωταρχικό DB Port)$NWB#phones-DBX_port$NWE
DBY Διακομιστής: (ΔευτερεύονDB Server)$NWB#phones-DBY_server$NWE
DBY Βάση Δεδομένων: (ΔευτερεύονServer Database)$NWB#phones-DBY_database$NWE
DBY Χρήστης: (ΔευτερεύονDB Login)$NWB#phones-DBY_user$NWE
DBY Κωδικός: (ΔευτερεύονDB Secret)$NWB#phones-DBY_pass$NWE
DBY Πόρτα: (ΔευτερεύονDB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Επιλέξτε εδώ για στατιστικά τηλεφώνου\n"; + +if ($LOGdelete_phones > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΟ ΤΟ ΤΗΛΕΦΩΝΟ\n"; + } + +} + + +###################### +# ADD=31 modify server info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΔΙΑΚΟΜΙΣΤΗ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Διακομιστή: $NWB#servers-server_id$NWE
Περιγραφή Διακομιστή: $NWB#servers-server_description$NWE
Δνση IP Διακομιστή: $NWB#servers-server_ip$NWE
Ενεργή:$NWB#servers-active$NWE
Εκδοση Asterisk: $NWB#servers-asterisk_version$NWE
Μέγιστος Αριθμός Trunk: $NWB#servers-max_vicidial_trunks$NWE
Λήπτης Telnet: $NWB#servers-telnet_host$NWE
Πόρτα Telnet: $NWB#servers-telnet_port$NWE
Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAME$NWE
Κωδικός Διαχειριστή: $NWB#servers-ASTmgrSECRET$NWE
Ενημέρωση Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Παρακολούθηση Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Αποστολή Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Τοπικό GMT: (Μην ρυθμίσεις για DST)$NWB#servers-local_gmt$NWE
VMail εσωτ.σύνδεση απόρριψης: $NWB#servers-voicemail_dump_exten$NWE
AD εσωτ.σύνδεση: $NWB#servers-answer_transfer_agent$NWE
Προκαθορισμένο Περιεχόμενο: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
ΤΗΛΕΦΩΝΑ ΣΤΟΝ ΔΙΑΚΟΜΙΣΤΗ:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ΤΗΛ.ΣΥΝΔΕΣΗΟΝΟΜΑΕΝΕΡΓΑ
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Αυτός ο διακομιστής έχει $active_lists ενεργά τηλέφωνα και $inactive_lists μη ενεργά τηλέφωνα

\n"; +echo "
\n"; +} + + +###################### +# ADD=311 modify conference info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΣΥΝΔΙΑΛΕΞΗΣ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Συνδιαλέξη:$NWB#conferences-conf_exten$NWE
IP Διακομιστή: $NWB#conferences-server_ip$NWE
Ισχύουσα εσωτ.σύνδεση:
\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=4 submit phone modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - υπάρχει ήδη ένα τηλέφωνο με αυτή την εσωτ.σύνδεση/διακομιστή\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + echo "
ΤΟ ΤΗΛΕΦΩΝΟ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΤΗΛΕΦΩΝΟΥ: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Τηλ.σύνδεσης τηλεφώνου: $NWB#phones-extension$NWE
Αριθμός Σχεδίου Κλήσεων: (μόνο αριθμοί)$NWB#phones-dialplan_number$NWE
Περιεχόμενο Φωνητικού Ταχυδρομείου: (μόνο αριθμοί)$NWB#phones-voicemail_id$NWE
Εξερχόμενο CallerID: (μόνο αριθμοί)$NWB#phones-outbound_cid$NWE
Δνση IP Τηλεφώνου: (optional)$NWB#phones-phone_ip$NWE
Δνση IP Υπολογιστή: (optional)$NWB#phones-computer_ip$NWE
IP Διακομιστή: $NWB#phones-server_ip$NWE
Σύνδεση:$NWB#phones-login$NWE
Κωδικός:$NWB#phones-pass$NWE
Κατάσταση:$NWB#phones-status$NWE
Ενεργός Λογαριασμός: $NWB#phones-active$NWE
Τύπος τηλεφώνου: $NWB#phones-phone_type$NWE
Πλήρες Ονομα: $NWB#phones-fullname$NWE
Εταιρία:$NWB#phones-company$NWE
Εικόνα:$NWB#phones-picture$NWE
Νέα Μηνύματα: $row[14]$NWB#phones-messages$NWE
Παλαιά Μηνύματα: $row[15]$NWB#phones-old_messages$NWE
Προτόκολο Πελάτη: $NWB#phones-protocol$NWE
Τοπικό GMT: (Μην ρυθμίσεις για DST)$NWB#phones-local_gmt$NWE
Διαχειριστή Σύνδεση: $NWB#phones-ASTmgrUSERNAME$NWE
Κωδικός Διαχειριστή: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Προκαθορισμένος Χρήστης: $NWB#phones-login_user$NWE
VICIDIAL Προκαθορισμένος Κωδικός: $NWB#phones-login_pass$NWE
VICIDIAL Προκαθορισμένη εκστρατεία: $NWB#phones-login_campaign$NWE
Τηλ.σύνδ. Στάθμευσης: $NWB#phones-park_on_extension$NWE
Τηλ.σύνδ. Συνδ.: $NWB#phones-conf_on_extension$NWE
VICIDIAL Τηλ.σύνδ. Στάθμευσης: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Αρχείο Στάθμευσης: $NWB#phones-VICIDIAL_park_on_filename$NWE
Πρόθεμα Παρακολούθησης: $NWB#phones-monitor_prefix$NWE
Ηχογράφηση εσωτ.σύνδ.: $NWB#phones-recording_exten$NWE
VMailMain Τηλ.σύνδ.: $NWB#phones-voicemail_exten$NWE
VMailDump Τηλ.σύνδ.: $NWB#phones-voicemail_dump_exten$NWE
Περιεχόμενο Τηλ.σύνδ: $NWB#phones-ext_context$NWE
DTMFSend Κανάλι: $NWB#phones-dtmf_send_extension$NWE
Ομάδα Εξερχομένων Κλήσεων: $NWB#phones-call_out_number_group$NWE
Θέση Φυλλομετρητή: $NWB#phones-client_browser$NWE
Κατάλογος εγκατάστασης: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Προκαθορισμένο URL: $NWB#phones-VICIDIAL_web_URL$NWE
Καταγραφή Γεγονότος Κλήσης: $NWB#phones-AGI_call_logging_enabled$NWE
Μεταγωγή Χρήστη: $NWB#phones-user_switching_enabled$NWE
Σε συνδιαλέξη: $NWB#phones-conferencing_enabled$NWE
Διαχειριστού Κλείσιμο: $NWB#phones-admin_hangup_enabled$NWE
Διαχειριστού Κλέψιμο: $NWB#phones-admin_hijack_enabled$NWE
Διαχειριστού Παρακολούθηση: $NWB#phones-admin_monitor_enabled$NWE
Στάθμευση Κλήσης: $NWB#phones-call_parking_enabled$NWE
Ελεγχος ενημερωτή: $NWB#phones-updater_check_enabled$NWE
AF Καταγραφή Γεγονότος: $NWB#phones-AFLogging_enabled$NWE
Ενεργή Ουρά: $NWB#phones-QUEUE_ACTION_enabled$NWE
Υπερεμφανιζόμενο παραθύρο CallerID: $NWB#phones-CallerID_popup_enabled$NWE
Πλήκτρο VMail: $NWB#phones-voicemail_button_enabled$NWE
Ταχύτητα Ανανέωσης: $NWB#phones-enable_fast_refresh$NWE
Ρυθμός Ανανέωσης Ταχύτητας: (in ms)$NWB#phones-fast_refresh_rate$NWE
Συνεχής MySQL: $NWB#phones-enable_persistant_mysql$NWE
Αυτόματη Κλήση Επόμενου Αριθμού: $NWB#phones-auto_dial_next_number$NWE
Σταμάτα την ηχογράφηση μετά από κάθε κλήση: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Διακομιστής: (Πρωταρχικό DB Server)$NWB#phones-DBX_server$NWE
DBX Βάση Δεδομένων: (Πρωταρχικό Server Database)$NWB#phones-DBX_database$NWE
DBX Χρήστης: (Πρωταρχικό DB Login)$NWB#phones-DBX_user$NWE
DBX Κωδικός: (Πρωταρχικό DB Secret)$NWB#phones-DBX_pass$NWE
DBX Πόρτα: (Πρωταρχικό DB Port)$NWB#phones-DBX_port$NWE
DBY Διακομιστής: (ΔευτερεύονDB Server)$NWB#phones-DBY_server$NWE
DBY Βάση Δεδομένων: (ΔευτερεύονServer Database)$NWB#phones-DBY_database$NWE
DBY Χρήστης: (ΔευτερεύονDB Login)$NWB#phones-DBY_user$NWE
DBY Κωδικός: (ΔευτερεύονDB Secret)$NWB#phones-DBY_pass$NWE
DBY Πόρτα: (ΔευτερεύονDB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Επιλέξτε εδώ για στατιστικά τηλεφώνου\n"; + +if ($LOGdelete_phones > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΟ ΤΟ ΤΗΛΕΦΩΝΟ\n"; + } + +} + +###################### +# ADD=41 submit server modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
ΔΙΑΚΟΜΙΣΤΗΣ NOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
Ο ΔΙΑΚΟΜΙΣΤΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - υπάρχει ήδη ένας διακομιστής με αυτό το IP\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
Ο ΔΙΑΚΟΜΙΣΤΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + echo "
Ο ΔΙΑΚΟΜΙΣΤΗΣ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $server_ip\n"; + + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + } + } + } + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΔΙΑΚΟΜΙΣΤΗ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Διακομιστή: $NWB#servers-server_id$NWE
Περιγραφή Διακομιστή: $NWB#servers-server_description$NWE
Δνση IP Διακομιστή: $NWB#servers-server_ip$NWE
Ενεργή:$NWB#servers-active$NWE
Εκδοση Asterisk: $NWB#servers-asterisk_version$NWE
Μέγιστος Αριθμός Trunk: $NWB#servers-max_vicidial_trunks$NWE
Λήπτης Telnet: $NWB#servers-telnet_host$NWE
Πόρτα Telnet: $NWB#servers-telnet_port$NWE
Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAME$NWE
Κωδικός Διαχειριστή: $NWB#servers-ASTmgrSECRET$NWE
Ενημέρωση Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Παρακολούθηση Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Αποστολή Χρήστη Διαχειριστή: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Τοπικό GMT: (Μην ρυθμίσεις για DST)$NWB#servers-local_gmt$NWE
VMail εσωτ.σύνδεση απόρριψης: $NWB#servers-voicemail_dump_exten$NWE
AD εσωτ.σύνδεση: $NWB#servers-answer_transfer_agent$NWE
Προκαθορισμένο Περιεχόμενο: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
ΤΗΛΕΦΩΝΑ ΣΤΟΝ ΔΙΑΚΟΜΙΣΤΗ:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ΤΗΛ.ΣΥΝΔΕΣΗΟΝΟΜΑΕΝΕΡΓΑ
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Αυτός ο διακομιστής έχει $active_lists ενεργά τηλέφωνα και $inactive_lists μη ενεργά τηλέφωνα

\n"; +echo "
\n"; + +} + +###################### +# ADD=411 submit conference modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
Η ΣΥΝΔΙΑΛΕΞΗ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - υπάρχει ήδη μία συνδιάλεξη με αυτή την εσωτ.σύνδεση-διακομιστή\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
Η ΣΥΝΔΙΑΛΕΞΗ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + echo "
Η ΣΥΝΔΙΑΛΕΞΗ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from conferences where conf_exten='$conf_exten';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΣΥΝΔΙΑΛΕΞΗΣ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Συνδιαλέξη:$NWB#conferences-conf_exten$NWE
IP Διακομιστή: $NWB#conferences-server_ip$NWE
Ισχύουσα εσωτ.σύνδεση:
\n"; + +echo "
\n"; + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo ""; + +echo "
ΑΝΑΖΗΤΗΣΗ ΤΗΛΕΦΩΝΟΥ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Εσωτ.σύνδεση:
Πλήρες Ονομα:
Phone type:
\n"; + +} + +###################### +# ADD=66 phone search results +###################### + +if ($ADD==66) +{ + echo ""; + + $SQL = ''; + if ($extension) {$SQL .= "extension LIKE \"%$extension%\" and";} + if ($fullname) {$SQL .= "fullname LIKE \"%$fullname%\" and";} + if ($phone_type) {$SQL .= "phone_type LIKE \"%$phone_type%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from phones $SQL order by extension,server_ip;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
ΑΝΑΖΗΤΗΣΗ ΑΠΟΤΕΛΕΣΜΑΤΩΝ:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]ΤΡΟΠΟΠΟΙΗΣΗ | ΣΤΑΤΙΣΤΙΚΑ
\n"; + +} + + + +###################### +# ADD=0 display all active phones +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from phones order by extension,server_ip"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΑ ΤΗΛΕΦΩΝΑ:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[16]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]ΤΡΟΠΟΠΟΙΗΣΗ | ΣΤΑΤΙΣΤΙΚΑ
\n"; +} + +###################### +# ADD=10 display all servers +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΟΙ ΔΙΑΚΟΜΙΣΤΕΣ:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[4] $row[3]  ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=100 display all conferences +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΕΣ ΣΥΝΔΙΑΛΕΞΕΙΣ:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]  ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds"; +echo "             ΕΚΔΟΣΗ: $version"; +echo "             ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/dbconnect.php b/agc_2-X/trunk/LANG_admin/astguiclient_el/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_el/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/help.gif b/agc_2-X/trunk/LANG_admin/astguiclient_el/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/astguiclient_el/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/inbound_popup.php b/agc_2-X/trunk/LANG_admin/astguiclient_el/inbound_popup.php new file mode 100644 index 00000000..5c34ba2c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_el/inbound_popup.php @@ -0,0 +1,228 @@ + LICENSE: GPLv2 +### +# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# +# changes: +# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΕΙΣΕΡΧΟΜΕΝΟ: Υπερεμφανιζόμενο Παραθύρο + + +
+ + 0) +{ + + $stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Η εντολή ανακατεύθυνσης στάλθηκε για το κανάλι $channel       $NOW_TIME\n

\n"; + + + $url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&'; + $Suser = 'username='; + $Spass = '&passwd='; + $Sphone = '&phone='; + + $newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone"; + if ( ($phone == 'unknown') or (strlen($phone)<9) ) + {$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";} + + echo "Αναζήτηση του Πελάτη στο Σύστημα Εξυπηρέτησης Πελατών\n

\n"; + + echo "Κλείσε αυτό το παράθυρο\n

\n"; +} +else +{ + echo "Η εντολή ανακατεύθυνσης ΑΠΕΤΥΧΕ για το κανάλι $channel       $NOW_TIME\n

\n"; + echo "Κλείσε αυτό το παράθυρο\n

\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/phone_stats.php b/agc_2-X/trunk/LANG_admin/astguiclient_el/phone_stats.php new file mode 100644 index 00000000..133ce3cd --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_el/phone_stats.php @@ -0,0 +1,244 @@ + LICENSE: GPLv2 +# +# +# changes: +# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$admin_page = './admin.php'; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $row[0]; + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ADMIN: Στατιστικά Τηλεφώνου + + +
+
+ + + + + + +\n"; +echo "
  ΣΥΣΤΗΜΑ ΚΛΗΣΕΩΝ: Διαχείριση  
  ΛΙΣΤΑ ΤΗΛΕΦΩΝΩΝ | ΠΡΟΣΘΗΚΗ ΤΗΛΕΦΩΝΟΥ | ΑΝΑΖΗΤΗΣΗ ΤΗΛΕΦΩΝΟΥ | ΠΡΟΣΘΗΚΗ ΔΙΑΚΟΜΙΣΤΗ | ΛΙΣΤΑ ΔΙΑΚΟΜΙΣΤΩΝ
  ΕΜΦΑΝΙΣΗ ΣΥΝΔΙΑΛΕΞΕΩΝ | ΠΡΟΣΘΗΚΗ ΣΥΝΔΙΑΛΕΞΗΣ
  \n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + +echo "
\n"; + +echo "ΧΡΟΝΟΣ ΟΜΙΛΙΑΣ ΚΑΙ ΚΑΝΑΛΙΑ:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} +# echo "|$stmt|\n"; + +echo "\n"; +echo "
ΚΑΝΑΛΙ ΟΜΑΔΑΣ ΚΑΤΑΜΕΤΡΗΣΗ ΩΡΕΣ:ΛΕΠΤΑ
$row[1] $row[0] $call_hours_int:$call_minutes_int
ΣΥΝΟΛΙΚΕΣ ΚΛΗΣΕΙΣ $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "ΤΕΛΕΥΤΑΙΕΣ 1000 ΚΛΗΣΕΙΣ ΓΙΑ ΤΟ ΔΙΑΣΤΗΜΑ ΗΜΕΡΟΜΗΝΙΑΣ:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + + $call_seconds=0; + $o++; + } + + +echo "
ΑΡΙΘΜΟΣ ΚΑΝΑΛΙ ΟΜΑΔΑΣ ΗΜΕΡΑ LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_el/remote_inbound.php b/agc_2-X/trunk/LANG_admin/astguiclient_el/remote_inbound.php new file mode 100644 index 00000000..4c44b1ad --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_el/remote_inbound.php @@ -0,0 +1,162 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]; if (!$ΕΠΙΒΕΒΑΙΩΣΗ) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + echo"\n"; + echo"ASTERISK ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΕΙΣΕΡΧΟΜΕΝΟ: Κύριο\n"; + echo"\n"; + echo"\n"; + echo"\n"; + +?> + + +
+ +
\n"; + +echo "Πατήστε στο κανάλι παρακάτω, που θα επιθυμούσατε να έχετε κατευθύνει στο τηλέφωνό σας

\n"; + +echo "
\n";
+echo "CHANNEL    ΔΙΑΚΟΜΙΣΤΗΣ        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME        \n";
+echo "----------------------------------------------------------------------------------------------\n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$extension =		sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		echo "$channel$server$channel_group$extension$parked_by$parked_time\n";
+
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "*************************************** NO PARKED CALLS **************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/AST_inboundEXTstats.php b/agc_2-X/trunk/LANG_admin/astguiclient_en/AST_inboundEXTstats.php new file mode 100644 index 00000000..28c5b20d --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_en/AST_inboundEXTstats.php @@ -0,0 +1,400 @@ + LICENSE: GPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Inbound Calls Stats\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Inbound Calls Stats                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls That came into this number:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- TIME STATS\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/admin.php b/agc_2-X/trunk/LANG_admin/astguiclient_en/admin.php new file mode 100644 index 00000000..654e9f12 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_en/admin.php @@ -0,0 +1,1824 @@ + LICENSE: GPLv2 +# +# AST GUI database administration +# +# CHANGES +# 50913-1118 - Added outbound_cid for web-client calls +# 50926-1356 - Modified to allow for language translation +# 50926-1613 - Added WeBRooTWritablE write controls +# 51128-1254 - Modified to allow PHP global vars off +# 51208-2120 - Added option to login with vicidial_user login if allowed +# 51213-1650 - Added option to delete phones if allowed by vicidial_users +# 60421-1430 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1137 - Fixed phone search bug +# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '1.1.12'; +$build = '60620-1243'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS and Dots +$phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); +$computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); + +### DIGITS ONLY ### +$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); +$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id); +$outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); +$VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); +$park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); +$conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); +$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); +$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); +$recording_exten = ereg_replace("[^0-9]","",$recording_exten); +$monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); +$answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); +$DBX_port = ereg_replace("[^0-9]","",$DBX_port); +$DBY_port = ereg_replace("[^0-9]","",$DBY_port); +$telnet_port = ereg_replace("[^0-9]","",$telnet_port); +$max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); +$auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); +$VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); +$enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); +$enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); +$user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); +$updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); +$QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); +$conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); +$voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); +$CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); +$call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); +$AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); +$AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); +$admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); +$admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); +$admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); +$fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); +$ADD = ereg_replace("[^0-9]","",$ADD); + +### ALPHA-NUMERIC and underscore and dash and slash and at and dot +$extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); +$old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); +$install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); +$client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); +$dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); +$call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); +$telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); +$DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); +$DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + +### ALPHA-NUMERIC (and underscore and dash) +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$login = ereg_replace("[^-\_0-9a-zA-Z]","",$login); +$user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); +$status = ereg_replace("[^-\_0-9a-zA-Z]","",$status); +$protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); +$ASTmgrUSERNAMEupdate = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); +$ASTmgrUSERNAMEsend = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); +$ASTmgrUSERNAMElisten = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); +$ASTmgrUSERNAME = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAME); +$ASTmgrSECRET = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrSECRET); +$login_user = ereg_replace("[^-\_0-9a-zA-Z]","",$login_user); +$login_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$login_pass); +$login_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$login_campaign); +$DBX_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_user); +$DBY_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_user); +$DBX_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_pass); +$DBY_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_pass); +$DBX_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_database); +$DBY_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_database); +$VICIDIAL_park_on_filename = ereg_replace("[^-\_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); +$server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); +$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id); +$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context); +$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); +$company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); +$picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); +$local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); +$server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); +$asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + +### VARIABLES TO BE mysql_real_escape_string ### +# $VICIDIAL_web_URL = +# $local_web_callerID_URL = + +##### END VARIABLE FILTERING FOR SECURITY ##### + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +if (!isset($ADD)) {$ADD=0;} + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + +if ($ADD==1) {$process = 'ADD NEW PHONE';} +if ($ADD==11) {$process = 'ADD NEW SERVER';} +if ($ADD==111) {$process = 'ADD NEW CONFERENCE';} +if ($ADD==2) {$process = 'ADDING NEW PHONE';} +if ($ADD==21) {$process = 'ADDING NEW SERVER';} +if ($ADD==211) {$process = 'ADDING NEW CONFERENCE';} +if ($ADD==3) {$process = 'MODIFY PHONE';} +if ($ADD==31) {$process = 'MODIFY SERVER';} +if ($ADD==311) {$process = 'MODIFY CONFERENCE';} +if ($ADD==4) {$process = 'MODIFYING PHONE';} +if ($ADD==41) {$process = 'MODIFYING SERVER';} +if ($ADD==411) {$process = 'MODIFYING CONFERENCE';} +if ($ADD==5) {$process = 'DELETE PHONE';} +if ($ADD==6) {$process = 'DELETE PHONE';} +if ($ADD==55) {$process = 'SEARCH PHONES';} +if ($ADD==66) {$process = 'SEARCH PHONES RESULTS';} +if ($ADD==0) {$process = 'PHONE LIST';} +if ($ADD==10) {$process = 'SERVER LIST';} +if ($ADD==100) {$process = 'CONFERENCE LIST';} +if ($ADD==99999) {$process = 'HELP';} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if ($auth<1) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > '6' and ast_admin_access='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGdelete_phones =$row[17]; + } + } + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + echo "|$stmt|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + if (strlen($LOGfullname) < 1) + { + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "\n"; + $o++; + } + + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); + +$NWB = "   \"HELP\""; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "ASTERISK ADMIN: Administration - $process \n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ASTERISK ADMIN: HELP


\n"; + +?> +PHONES TABLE

+ +
+Phone extension - This field is where you put the phones name as it appears to Asterisk not including the protocol or slash at the beginning. For Example: for the SIP phone SIP/test101 the Phone extension would be test101. Also, for IAX2 phones make sure you use the full phones name: IAX2/IAXphone1@IAXphone1 would be IAXphone1@IAXphone1. For Zap phones make sure you put the full channel: Zap/25-1 would be 25-1. Another note, make sure you set the Protocol below correctly for your type of phone. + +
+
+
+Dialplan number - This field is for the number you dial to have the phone ring. This number is defined in the extensions.conf file of your Asterisk server + +
+
+
+Voicemail Box - This field is for the voicemail box that the messages go to for the user of this phone. We use this to check for voicemail messages and for the user to be able to use the VOICEMAIL button on astGUIclient app. + +
+
+
+Outbound CallerID - This field is where you would enter the callerID number that you would like to appear on outbound calls placed form the astguiclient web-client. This does not work on RBS, non-PRI, T1/E1s. + +
+
+
+Phone IP address - This field is for the phone's IP address if it is a VOIP phone. This is an optional field + +
+
+
+Computer IP address - This field is for the user's computer IP address. This is an optional field + +
+
+
+Server IP - This menu is where you select which server the phone is active on. + +
+
+
+Login - The login used for the phone user to login to the client applications. + +
+
+
+Password - The password used for the phone user to login to the client applications. + +
+
+
+Status - The status of the phone in the system, ACTIVE and ADMIN allow for GUI clients to work. ADMIN allows access to this administrative web site. All other statuses do not allow GUI or Admin web access. + +
+
+
+Active Account - Whether the phone is active to put it in the list in the GUI client. + +
+
+
+Phone Type - Purely for administrative notes. + +
+
+
+Full Name - Used by the GUIclient in the list of active phones. + +
+
+
+Company - Purely for administrative notes. + +
+
+
+Picture - Not yet Implemented. + +
+
+
+New Messages - Number of new voicemail messages for this phone on the Asterisk server. + +
+
+
+Old Messages - Number of old voicemail messages for this phone on the Asterisk server. + +
+
+
+Client Protocol - The protocol that the phone uses to connect to the Asterisk server: SIP, IAX2, Zap . Also, there is EXTERNAL for remote dial numbers or speed dial numbers that you want to list as phones. + +
+
+
+Local GMT - The difference from Greenwich Mean time, or ZULU time where the phone is located. DO NOT ADJUST FOR DAYLIGHT SAVINGS TIME. This is used by the VICIDIAL campaign to accurately display the time and customer time. + +
+
+
+Manager Login - This is the login that the GUI clients for this phone will use to access the Database where the server data resides. + +
+
+
+Manager Secret - This is the password that the GUI clients for this phone will use to access the Database where the server data resides. + +
+
+
+VICIDIAL Default User - This is to place a default value in the VICIDIAL user field whenever this phone user opens the astVICIDIAL client app. Leave blank for no user. + +
+
+
+VICIDIAL Default Pass - This is to place a default value in the VICIDIAL password field whenever this phone user opens the astVICIDIAL client app. Leave blank for no pass. + +
+
+
+VICIDIAL Default Campaign - This is to place a default value in the VICIDIAL campaign field whenever this phone user opens the astVICIDIAL client app. Leave blank for no campaign. + +
+
+
+Park Exten - This is the default Parking extension for the client apps. Verify that a different one works before you change this. + +
+
+
+Conf Exten - This is the default Conference park extension for the client apps. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park Exten - This is the default Parking extension for VICIDIAL client app. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park File - This is the default VICIDIAL park extension file name for the client apps. Verify that a different one works before you change this. limited to 10 characters. + +
+
+
+Monitor Prefix - This is the dialplan prefix for monitoring of Zap channels automatically within the astGUIclient app. Only change according to the extensions.conf ZapBarge extensions records. + +
+
+
+Recording Exten - This is the dialplan extension for the recording extension that is used to drop into meetme conferences to record them. It usually lasts upto one hour if not stopped. verify with extensions.conf file before changing. + +
+
+
+VMAIL Main Exten - This is the dialplan extension going to check your voicemail. verify with extensions.conf file before changing. + +
+
+
+VMAIL Dump Exten - This is the dialplan prefix used to send calls directly to a user's voicemail from a live call in the astGUIclient app. verify with extensions.conf file before changing. + +
+
+
+Exten Context - This is the dialplan context that this phone primarily uses. It is assumed that all numbers dialed by the client apps are using this context so it is a good idea to make sure this is the most wide context possible. verify with extensions.conf file before changing. + +
+
+
+DTMF send Channel - This is the channel string used to send DTMF sounds into meetme conferences from the client apps. Verify the exten and context with the extensions.conf file. + +
+
+
+Outbound Call Group - This is the channel group that outbound calls from this phone are placed out of. There are a couple routines in the client apps that use this. For Zap channels you want to use something like Zap/g2 , for IAX2 trunks you would want to use the full IAX prefix like IAX2/VICItest1:secret@10.10.10.15:4569. Verify the trunks with the extensions.conf file, it is usually what you have defined as the TRUNK global variable at the top of the file. + +
+
+
+Browser Location - This is applicable to only UNIX/LINUX clients, the absolute path to Mozilla or Firefox browser on the machine. verify this by launching it manually. + +
+
+
+Install Directory - This is the place where the astGUIclient and astVICIDIAL scripts are located on your machine. For Win32 it should be something like C:\AST_VICI and for UNIX it should be something like /usr/local/perl_TK. verify this manually. + +
+
+
+CallerID URL - This is the web address of the page used to do custom callerID lookups. default testing address is: http://astguiclient.sf.net/test_callerid_output.php + +
+
+
+VICIDIAL Default URL - This is the web address of the page used to do custom VICIDIAL Web Form queries. default testing address is: http://astguiclient.sf.net/test_VICIDIAL_output.php + +
+
+
+Call Logging - This is set to true if the call_log.agi file is in place in the extensions.conf file for all outbound and hangup 'h' extensions to log all calls. This should always be 1 because it is manditory for many astGUIclient and VICIDIAL features to work properly. + +
+
+
+User Switching - Set to true to allow user to switch to another user account. NOTE: If user switches they can initiate recording on the new user's phone conversation + +
+
+
+Conferencing - Set to true to allow user to start conference calls with upto six external lines. + +
+
+
+Admin Hangup - Set to true to allow user to be able to hangup any line at will through astGUIclient. Good idea only to enable this for Admin users. + +
+
+
+Admin Hijack - Set to true to allow user to be able to grab and redirect to their extension any line at will through astGUIclient. Good idea only to enable this for Admin users. But is very useful for Managers. + +
+
+
+Admin Monitor - Set to true to allow user to be able to grab and redirect to their extension any line at will through astGUIclient. Good idea only to enable this for Admin users. But is very useful for Managers and as a training tool. + +
+
+
+Call Park - Set to true to allow user to be able to park calls on astGUIclient hold to be picked up by any other astGUIclient user on the system. Calls stay on hold for upto a half hour then hangup. Usually enabled for all. + +
+
+
+Updater Check - Set to true to display a popup warning that the updater time has not changed in 20 seconds. Useful for Admin users. + +
+
+
+AF Logging - Set to true to log many actions of astGUIclient usage to a text file on the user's computer. + +
+
+
+Queue Enabled - Set to true to have client apps use the Asterisk Central Queue system. Required for VICIDIAL and recommended for all users. + +
+
+
+CallerID Popup - Set to true to allow for numbers defined in the extensions.conf file to send CallerID popup screens to astGUIclient users. + +
+
+
+VMail Button - Set to true to display the VOICEMAIL button and the messages count display on astGUIclient. + +
+
+
+Fast Refresh - Set to true to enable a new rate of refresh of call information for the astGUIclient. Default disabled rate is 1000 ms ,1 second. Can increase system load if you lower this number. + +
+
+
+Fast Refresh Rate - in milliseconds. Only used if Fast Refresh is enabled. Default disabled rate is 1000 ms ,1 second. Can increase system load if you lower this number. + +
+
+
+Persistant MySQL - If enabled the astGUIclient connection will remain connected instead of connecting every second. Useful if you have a fast refresh rate set. It will increase the number of connections on your MySQL machine. + +
+
+
+Auto Dial Next Number - If enabled the VICIDIAL client will dial the next number on the list automatically upon disposition of a call unless they selected to "Stop Dialing" on the disposition screen. + +
+
+
+Stop Rec after each call - If enabled the VICIDIAL client will stop whatever recording is going on after each call has been dispositioned. Useful if you are doing a lot of recording or you are using a web form to trigger recording. + +
+
+
+DBX Server - The MySQL database server that this user should be connecting to. + +
+
+
+DBX Database - The MySQL database that this user should be connecting to. Default is asterisk. + +
+
+
+DBX User - The MySQL user login that this user should be using when connecting. Default is cron. + +
+
+
+DBX Pass - The MySQL user password that this user should be using when connecting. Default is 1234. + +
+
+
+DBX Port - The MySQL TCP port that this user should be using when connecting. Default is 3306. + +
+
+
+DBY Server - The MySQL database server that this user should be connecting to. Secondary server, not used currently. + +
+
+
+DBY Database - The MySQL database that this user should be connecting to. Default is asterisk. Secondary server, not used currently. + +
+
+
+DBY User - The MySQL user login that this user should be using when connecting. Default is cron. Secondary server, not used currently. + +
+
+
+DBY Pass - The MySQL user password that this user should be using when connecting. Default is 1234. Secondary server, not used currently. + +
+
+
+DBY Port - The MySQL TCP port that this user should be using when connecting. Default is 3306. Secondary server, not used currently. + + +



+ +SERVERS TABLE

+
+
+Server ID - This field is where you put the Asterisk servers name, doesnt have to be an official domain sub, just a nickname to identify the server to Admin users. + +
+
+
+Server Description - The field where you use a small phrase to describe the Asterisk server. + +
+
+
+Server IP Address - The field where you put the Network IP address of the Asterisk server. + +
+
+
+Active - Set whether the Asterisk server is active or inactive. + +
+
+
+Asterisk Version - Set the version of Asterisk that you have installed on this server. Examples: '1.2', '1.0.8', '1.0.7', 'CVS_HEAD', 'REALLY OLD', etc... This is used because versions 1.0.8 and 1.0.9 have a different method of dealing with Local/ channels, a bug that has been fixed in CVS v1.0, and need to be treated differently when handling their Local/ channels. Also, current CVS_HEAD and the 1.2 release tree uses different manager and command output so it must be treated differently as well. + +
+
+
+Max VICIDIAL Trunks - This field will determine the maximum number of lines that the VICIDIAL auto-dialer will attempt to call on this server. If you want to dedicate two full PRI T1s to VICIDIALing on a server then you would set this to 46. Default is 96. + +
+
+
+Telnet Host - This is the address or name of the Asterisk server and is how the manager applications connect to it from where they are running. If they are running on the Asterisk server, then the default of 'localhost' is fine. + +
+
+
+Telnet Port - This is the port of the Asterisk server Manager connection and is how the manager applications connect to it from where they are running. The default of '5038' is fine for a standard install. + +
+
+
+Manager User - The username or login used to connect genericly to the Asterisk server manager. Default is 'cron' + +
+
+
+Manager Secret - The secret or password used to connect genericly to the Asterisk server manager. Default is '1234' + +
+
+
+Manager Update User - The username or login used to connect to the Asterisk server manager optimized for the Update scripts. Default is 'updatecron' and assumes the same secret as the generic user. + +
+
+
+Manager Listen User - The username or login used to connect to the Asterisk server manager optimized for scripts that only listen for output. Default is 'listencron' and assumes the same secret as the generic user. + +
+
+
+Manager Send User - The username or login used to connect to the Asterisk server manager optimized for scripts that only send Actions to the manager. Default is 'sendcron' and assumes the same secret as the generic user. + +
+
+
+Server GMT offset - The difference in hours from GMT time not adjusted for Daylight-Savings-Time of the server. Default is '-5' + +
+
+
+VMail Dump Exten - The extension prefix used on this server to send calls directly through agc to a specific voicemail box. Default is '85026666666666' + +
+
+
+VICIDIAL AD extension - The default extension if none is present in the campaign to send calls to for VICIDIAL auto dialing. Default is '8365' + +
+
+
+Default Context - The default dialplan context used for scripts that operate for this server. Default is 'default' + + +



+ +CONFERENCES TABLE

+
+
+Conference Number - This field is where you put the meetme conference dialpna number. It is also recommended that the meetme number in meetme.conf matches this number for each entry. This is for the conferences in astGUIclient and is used for leave-3way-call functionality in VICIDIAL. + +
+
+
+Server IP - The menu where you select the Asterisk server that this conference will be on. + + + + + + +







+







+THE END +
+ + + +ASTERISK ADMIN: Administration - <? echo $process ?> + + + +
+ + + + + + +
  ASTERISK ADMIN - Logout  
  LIST ALL PHONES | ADD A NEW PHONE | SEARCH FOR A PHONE | ADD A SERVER | LIST ALL SERVERS
  SHOW ALL CONFERENCES | ADD A NEW CONFERENCE
+"; + +echo "
ADD A NEW PHONE
\n"; +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW SERVERS FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
ADD A NEW SERVER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW CONFERENCES FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
ADD A NEW CONFERENCE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference Number: (digits only)$NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new phone to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
PHONE NOT ADDED - there is already a Phone in the system with this extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
PHONE NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
PHONE ADDED\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new server to the system +###################### + +if ($ADD==21) +{ + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SERVER NOT ADDED - there is already a server in the system with this ID\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVER NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
SERVER ADDED\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new conference to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFERENCE NOT ADDED - there is already a conference in the system with this ID and server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCE NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
CONFERENCE ADDED\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=100; +} + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of phone +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGdelete_phones < 1) ) + { + echo "
PHONE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Server IP be at least 7 characters in length\n"; + } + else + { + echo "
PHONE DELETION CONFIRMATION: $extension - $server_ip\n"; + echo "

Click here to delete phone $extension - $server_ip


\n"; + } + +$ADD='3'; # go to phone modification below +} + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete phone record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGdelete_phones < 1) ) + { + echo "
PHONE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Server IP be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING PHONE!!!|$PHP_AUTH_USER|$ip|extension='$extension'|server_ip='$server_ip'|\n"); + fclose($fp); + } + echo "
PHONE DELETION COMPLETED: $extension - $server_ip\n"; + echo "

\n"; + } + +$ADD='0'; # go to phone list +} + + + + + + +###################### +# ADD=3 modify phone info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A PHONE RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
New Messages: $row[14]$NWB#phones-messages$NWE
Old Messages: $row[15]$NWB#phones-old_messages$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
VICIDIAL Default Pass: $NWB#phones-login_pass$NWE
VICIDIAL Default Campaign: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park File: $NWB#phones-VICIDIAL_park_on_filename$NWE
Monitor Prefix: $NWB#phones-monitor_prefix$NWE
Recording Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Context: $NWB#phones-ext_context$NWE
DTMFSend Channel: $NWB#phones-dtmf_send_extension$NWE
Outbound Call Group: $NWB#phones-call_out_number_group$NWE
Browser Location: $NWB#phones-client_browser$NWE
Install Directory: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Default URL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
User Switching: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hangup: $NWB#phones-admin_hangup_enabled$NWE
Admin Hijack: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Call Park: $NWB#phones-call_parking_enabled$NWE
Updater Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Queue Enabled: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Button: $NWB#phones-voicemail_button_enabled$NWE
Fast Refresh: $NWB#phones-enable_fast_refresh$NWE
Fast Refresh Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Dial Next Number: $NWB#phones-auto_dial_next_number$NWE
Stop Rec after each call: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Server: (Primary DB Server)$NWB#phones-DBX_server$NWE
DBX Database: (Primary Server Database)$NWB#phones-DBX_database$NWE
DBX User: (Primary DB Login)$NWB#phones-DBX_user$NWE
DBX Pass: (Primary DB Secret)$NWB#phones-DBX_pass$NWE
DBX Port: (Primary DB Port)$NWB#phones-DBX_port$NWE
DBY Server: (Secondary DB Server)$NWB#phones-DBY_server$NWE
DBY Database: (Secondary Server Database)$NWB#phones-DBY_database$NWE
DBY User: (Secondary DB Login)$NWB#phones-DBY_user$NWE
DBY Pass: (Secondary DB Secret)$NWB#phones-DBY_pass$NWE
DBY Port: (Secondary DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Click here for phone stats\n"; + +if ($LOGdelete_phones > 0) + { + echo "

DELETE THIS PHONE\n"; + } + +} + + +###################### +# ADD=31 modify server info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A SERVER RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
PHONES WITHIN THIS SERVER:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIONNAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This server has $active_lists active phones and $inactive_lists inactive phones

\n"; +echo "
\n"; +} + + +###################### +# ADD=311 modify conference info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A CONFERENCE RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference: $NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
Current Extension:
\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=4 submit phone modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
PHONE NOT MODIFIED - there is already a Phone in the system with this extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
PHONE NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
PHONE MODIFIED: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A PHONE RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
New Messages: $row[14]$NWB#phones-messages$NWE
Old Messages: $row[15]$NWB#phones-old_messages$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
VICIDIAL Default Pass: $NWB#phones-login_pass$NWE
VICIDIAL Default Campaign: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park File: $NWB#phones-VICIDIAL_park_on_filename$NWE
Monitor Prefix: $NWB#phones-monitor_prefix$NWE
Recording Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Context: $NWB#phones-ext_context$NWE
DTMFSend Channel: $NWB#phones-dtmf_send_extension$NWE
Outbound Call Group: $NWB#phones-call_out_number_group$NWE
Browser Location: $NWB#phones-client_browser$NWE
Install Directory: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Default URL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
User Switching: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hangup: $NWB#phones-admin_hangup_enabled$NWE
Admin Hijack: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Call Park: $NWB#phones-call_parking_enabled$NWE
Updater Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Queue Enabled: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Button: $NWB#phones-voicemail_button_enabled$NWE
Fast Refresh: $NWB#phones-enable_fast_refresh$NWE
Fast Refresh Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Dial Next Number: $NWB#phones-auto_dial_next_number$NWE
Stop Rec after each call: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Server: (Primary DB Server)$NWB#phones-DBX_server$NWE
DBX Database: (Primary Server Database)$NWB#phones-DBX_database$NWE
DBX User: (Primary DB Login)$NWB#phones-DBX_user$NWE
DBX Pass: (Primary DB Secret)$NWB#phones-DBX_pass$NWE
DBX Port: (Primary DB Port)$NWB#phones-DBX_port$NWE
DBY Server: (Secondary DB Server)$NWB#phones-DBY_server$NWE
DBY Database: (Secondary Server Database)$NWB#phones-DBY_database$NWE
DBY User: (Secondary DB Login)$NWB#phones-DBY_user$NWE
DBY Pass: (Secondary DB Secret)$NWB#phones-DBY_pass$NWE
DBY Port: (Secondary DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Click here for phone stats\n"; + +if ($LOGdelete_phones > 0) + { + echo "

DELETE THIS PHONE\n"; + } + +} + +###################### +# ADD=41 submit server modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
SERVER NOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
SERVER NOT MODIFIED - there is already a server in the system with this server_ip\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVER NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
SERVER MODIFIED: $server_ip\n"; + + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + } + } + } + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A SERVER RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
PHONES WITHIN THIS SERVER:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIONNAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This server has $active_lists active phones and $inactive_lists inactive phones

\n"; +echo "
\n"; + +} + +###################### +# ADD=411 submit conference modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
CONFERENCE NOT MODIFIED - there is already a Conference in the system with this extension-server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCE NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
CONFERENCE MODIFIED: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from conferences where conf_exten='$conf_exten';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A CONFERENCE RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference: $NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
Current Extension:
\n"; + +echo "
\n"; + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo ""; + +echo "
SEARCH FOR A PHONE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
extension:
Full Name:
Phone type:
\n"; + +} + +###################### +# ADD=66 phone search results +###################### + +if ($ADD==66) +{ + echo ""; + + $SQL = ''; + if ($extension) {$SQL .= "extension LIKE \"%$extension%\" and";} + if ($fullname) {$SQL .= "fullname LIKE \"%$fullname%\" and";} + if ($phone_type) {$SQL .= "phone_type LIKE \"%$phone_type%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from phones $SQL order by extension,server_ip;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFY | STATS
\n"; + +} + + + +###################### +# ADD=0 display all active phones +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from phones order by extension,server_ip"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
PHONE LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[16]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFY | STATS
\n"; +} + +###################### +# ADD=10 display all servers +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SERVER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[4] $row[3]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all conferences +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
CONFERENCE LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]  MODIFY
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BUILD: $build
\n"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/dbconnect.php b/agc_2-X/trunk/LANG_admin/astguiclient_en/dbconnect.php new file mode 100644 index 00000000..fb6d5917 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_en/dbconnect.php @@ -0,0 +1,16 @@ + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/help.gif b/agc_2-X/trunk/LANG_admin/astguiclient_en/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/astguiclient_en/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/inbound_popup.php b/agc_2-X/trunk/LANG_admin/astguiclient_en/inbound_popup.php new file mode 100644 index 00000000..6f451656 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_en/inbound_popup.php @@ -0,0 +1,228 @@ + LICENSE: GPLv2 +### +# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# +# changes: +# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK REMOTE INBOUND: Popup + + +
+ + 0) +{ + + $stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for channel $channel       $NOW_TIME\n

\n"; + + + $url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&'; + $Suser = 'username='; + $Spass = '&passwd='; + $Sphone = '&phone='; + + $newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone"; + if ( ($phone == 'unknown') or (strlen($phone)<9) ) + {$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";} + + echo "Look up this customer in Customer Service System\n

\n"; + + echo "Close this window\n

\n"; +} +else +{ + echo "Redirect command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Close this window\n

\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/phone_stats.php b/agc_2-X/trunk/LANG_admin/astguiclient_en/phone_stats.php new file mode 100644 index 00000000..8498746a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_en/phone_stats.php @@ -0,0 +1,244 @@ + LICENSE: GPLv2 +# +# +# changes: +# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$admin_page = './admin.php'; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $row[0]; + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ADMIN: Phone Stats + + +
+
+ + + + + + +\n"; +echo "
  ASTERISK ADMIN: Administration  
  LIST ALL PHONES | ADD A NEW PHONE | SEARCH FOR A PHONE | ADD A SERVER | LIST ALL SERVERS
  SHOW ALL CONFERENCES | ADD A NEW CONFERENCE
  \n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + +echo "
\n"; + +echo "CALL TIME AND CHANNELS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} +# echo "|$stmt|\n"; + +echo "\n"; +echo "
CHANNEL GROUP COUNT HOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
TOTAL CALLS $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LAST 1000 CALLS FOR DATE RANGE:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + + $call_seconds=0; + $o++; + } + + +echo "
NUMBER CHANNEL GROUP DATE LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_en/remote_inbound.php b/agc_2-X/trunk/LANG_admin/astguiclient_en/remote_inbound.php new file mode 100644 index 00000000..06642677 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_en/remote_inbound.php @@ -0,0 +1,162 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + echo"\n"; + echo"ASTERISK REMOTE INBOUND: Main\n"; + echo"\n"; + echo"\n"; + echo"\n"; + +?> + + +
+ +
\n"; + +echo "Click on the channel below that you would like to have directed to your phone

\n"; + +echo "
\n";
+echo "CHANNEL    SERVER        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME        \n";
+echo "----------------------------------------------------------------------------------------------\n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$extension =		sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		echo "$channel$server$channel_group$extension$parked_by$parked_time\n";
+
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "*************************************** NO PARKED CALLS **************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/AST_inboundEXTstats.php b/agc_2-X/trunk/LANG_admin/astguiclient_es/AST_inboundEXTstats.php new file mode 100644 index 00000000..0e39d450 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_es/AST_inboundEXTstats.php @@ -0,0 +1,400 @@ + LICENSE: GPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Estadística de Llamadas Entrantes\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "SELECCIONE POR FAVOR Un NÚMERO Y La FECHA ARRIBA Y El TECLEO SOMETEN\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Estadística de Llamadas Entrantes                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Llamadas totales que vinieron en este número:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- ESTADÍSTICAS DEL TIEMPO\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "GRÁFICO EN 15 INCREMENTOS MINUCIOSOS DE LLAMADAS TOTALES\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/admin.php b/agc_2-X/trunk/LANG_admin/astguiclient_es/admin.php new file mode 100644 index 00000000..fcea423a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_es/admin.php @@ -0,0 +1,1824 @@ + LICENSE: GPLv2 +# +# AST GUI database administration +# +# CHANGES +# 50913-1118 - Added outbound_cid for web-client calls +# 50926-1356 - Modified to allow for language translation +# 50926-1613 - Added WeBRooTWritablE write controls +# 51128-1254 - Modified to allow PHP global vars off +# 51208-2120 - Added option to login with vicidial_user login if allowed +# 51213-1650 - Added option to delete phones if allowed by vicidial_users +# 60421-1430 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1137 - Fixed phone search bug +# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '1.1.12'; +$build = '60620-1243'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS and Dots +$phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); +$computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); + +### DIGITS ONLY ### +$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); +$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id); +$outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); +$VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); +$park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); +$conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); +$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); +$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); +$recording_exten = ereg_replace("[^0-9]","",$recording_exten); +$monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); +$answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); +$DBX_port = ereg_replace("[^0-9]","",$DBX_port); +$DBY_port = ereg_replace("[^0-9]","",$DBY_port); +$telnet_port = ereg_replace("[^0-9]","",$telnet_port); +$max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); +$auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); +$VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); +$enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); +$enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); +$user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); +$updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); +$QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); +$conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); +$voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); +$CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); +$call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); +$AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); +$AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); +$admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); +$admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); +$admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); +$fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); +$ADD = ereg_replace("[^0-9]","",$ADD); + +### ALPHA-NUMERIC and underscore and dash and slash and at and dot +$extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); +$old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); +$install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); +$client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); +$dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); +$call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); +$telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); +$DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); +$DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + +### ALPHA-NUMERIC (and underscore and dash) +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$login = ereg_replace("[^-\_0-9a-zA-Z]","",$login); +$user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); +$status = ereg_replace("[^-\_0-9a-zA-Z]","",$status); +$protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); +$ASTmgrUSERNAMEupdate = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); +$ASTmgrUSERNAMEsend = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); +$ASTmgrUSERNAMElisten = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); +$ASTmgrUSERNAME = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAME); +$ASTmgrSECRET = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrSECRET); +$login_user = ereg_replace("[^-\_0-9a-zA-Z]","",$login_user); +$login_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$login_pass); +$login_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$login_campaign); +$DBX_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_user); +$DBY_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_user); +$DBX_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_pass); +$DBY_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_pass); +$DBX_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_database); +$DBY_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_database); +$VICIDIAL_park_on_filename = ereg_replace("[^-\_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); +$server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); +$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id); +$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context); +$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); +$company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); +$picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); +$local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); +$server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); +$asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + +### VARIABLES TO BE mysql_real_escape_string ### +# $VICIDIAL_web_URL = +# $local_web_callerID_URL = + +##### END VARIABLE FILTERING FOR SECURITY ##### + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Usted ahora ha salido. Gracias\n"; + exit; +} + +if (!isset($ADD)) {$ADD=0;} + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + +if ($ADD==1) {$process = 'NUEVO TELÉFONO';} +if ($ADD==11) {$process = 'NUEVO SERVIDOR';} +if ($ADD==111) {$process = 'NUEVA CONFERENCIA';} +if ($ADD==2) {$process = 'CREANDO TELÉFONO';} +if ($ADD==21) {$process = 'CREANDO SERVIDOR';} +if ($ADD==211) {$process = 'CREANDO CONFERENCIA';} +if ($ADD==3) {$process = 'MODIFICAR EL TELÉFONO';} +if ($ADD==31) {$process = 'MODIFICAR EL SERVIDOR';} +if ($ADD==311) {$process = 'MODIFICAR LA CONFERENCIA';} +if ($ADD==4) {$process = 'MODIFICANDO EL TELÉFONO';} +if ($ADD==41) {$process = 'MODIFICANDO EL SERVIDOR';} +if ($ADD==411) {$process = 'MODIFICANDO LA CONFERENCIA';} +if ($ADD==5) {$process = 'DELETE PHONE';} +if ($ADD==6) {$process = 'DELETE PHONE';} +if ($ADD==55) {$process = 'BUSCAR TELÉFONOS';} +if ($ADD==66) {$process = 'RESULTADO DE LA BÚSQUEDA DE TELÉFONOS';} +if ($ADD==0) {$process = 'LISTA DE TELÉFONOS';} +if ($ADD==10) {$process = 'LISTA DE SERVIDORES';} +if ($ADD==100) {$process = 'LISTA DE CONFERENCIAS';} +if ($ADD==99999) {$process = 'AYUDA';} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if ($auth<1) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > '6' and ast_admin_access='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGdelete_phones =$row[17]; + } + } + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + echo "|$stmt|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + if (strlen($LOGfullname) < 1) + { + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "\n"; + $o++; + } + + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); + +$NWB = "   \"AYUDA\""; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "ASTERISK ADMIN: Administración - $process \n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ASTERISK ADMIN: AYUDA


\n"; + +?> +TABLA DE LOS TELÉFONOS

+ +
+Extensión del teléfono - este campo es donde usted pone los nombres del teléfono que aparecen al marcar con asterisco no incluyendo el protocolo o la barra vertical del principio. Por ejemplo: para el teléfono SIP/test101 del SIP la extensión del teléfono sería test101. También, para los teléfonos IAX2 compruebe que usted utiliza el nombre del teléfono completo: IAX2/IAXphone1@IAXphone1 sería IAXphone1@IAXphone1. Para zap los teléfonos compruebe que usted pone el canal completo: Zap/25-1 sería 25-1. Otra nota, compruebe que usted fija el protocolo abajo correctamente para su tipo de teléfono. + +
+
+
+Número del Dialplan - este campo está para el número que usted marca para tener el anillo del teléfono. Este número se define en el archivo de extensions.conf de su servidor asterisco + +
+
+
+Caja de Buzón de Voz - este campo es para la caja del buzón de voz donde van los mensajes para al usuario de este teléfono. Utilizamos esto para comprobar los mensajes del buzón de voz y para que el usuario pueda acceder al Buzón de Voz desde astGUIclient. + +
+
+
+CallerID de salida - este campo es donde usted incorporara el número del callerID que usted quiera que aparezca en las llamadas de salida. Esto no funciona en las líneas RTB(non-PRI) T1/E1. + +
+
+
+Dirección IP del teléfono - este campo es para la dirección IP del teléfono si es un teléfono de VOZIP. Este es un campo opcional + +
+
+
+Dirección IP del ordenador - este campo es para la dirección IP del ordenador del usuario. Es un campo opcional + +
+
+
+IP del servidor - Este menú es donde usted selecciona en que servidor está el teléfono activo. + +
+
+
+Conexión - la conexión usada para el usuario del teléfono a laconexión a los usos del cliente. + +
+
+
+Contraseña - la contraseña usada para el usuario del teléfono a laconexión a los usos del cliente. + +
+
+
+Estado - el estado del teléfono en el sistema, puede ser ACTIVO y ADMIN permiten que los clientes del GUI trabajen. ADMIN permite el acceso a este Web site de administración. El resto de los estados no permiten el acceso al GUI o al Web de Admin. + +
+
+
+Cuenta activa - si el teléfono está activado ponerla en la lista del cliente del GUI. + +
+
+
+Tipo de teléfono - solamente para información administrativas. + +
+
+
+Nombre completo - usado por el GUIclient en la lista de teléfonos activos. + +
+
+
+Compañía - solamente para las notas administrativas. + +
+
+
+Cuadro - todavía no puesto en ejecución. + +
+
+
+Nuevos mensajes - número de los nuevos mensajes del Buzón de Voz para este teléfono en el servidor del asterisco. + +
+
+
+Viejos mensajes - número de los viejos mensajes del Buzón de Voz para este teléfono en el servidor del asterisco. + +
+
+
+Protocolo del cliente - el protocolo que el teléfono utiliza para conectar con el servidor del asterisco: El Sip, IAX2, Zap. También, para los números External remotos o los números SpeedDial que usted desea enumerar como teléfonos. + +
+
+
+GMT local - La diferencia a partir del tiempo malo del ZULÚ del time(or de Greenwich) donde se localiza el teléfono. NO AJUSTE POR TIEMPO DE LOS AHORROS DE LA LUZ DEL DÍA. Esto es utilizada por la campaña de VICIDIAL para exhibir exactamente el tiempo y el tiempo del cliente. + +
+
+
+Conexión del encargado - Ésta es la conexión que los clientes del GUI para este teléfono utilizarán tener acceso a la base de datos donde residen los datos del servidor. + +
+
+
+Secreto del encargado - Ésta es la contraseña que los clientes del GUI para este teléfono utilizarán tener acceso a la base de datos donde residen los datos del servidor. + +
+
+
+Usuario del defecto de VICIDIAL - éste debe poner un valor prefijado en el campo del usuario de VICIDIAL siempre que este usuario del teléfono abra a cliente app de astVICIDIAL. Deje el espacio en blanco para ningún usuario. + +
+
+
+Paso del defecto de VICIDIAL - éste debe poner un valor prefijado en el campo de la contraseña de VICIDIAL siempre que este usuario del teléfono abra a cliente app de astVICIDIAL. Deje el espacio en blanco para ningún paso. + +
+
+
+Campaña del defecto de VICIDIAL - éste debe poner un valor prefijado en el campo de la campaña de VICIDIAL siempre que este usuario del teléfono abra a cliente app de astVICIDIAL. Deje el espacio en blanco para ninguna campaña. + +
+
+
+Parque Exten - Ésta es la extensión del estacionamiento del defecto para los apps del cliente. Verifique que diverso trabaje antes de que usted cambie esto. + +
+
+
+Extensión de la conferencia - Ésta es la extensión del parque de la conferencia del defecto para los apps del cliente. Verifique que diverso trabaje antes de que usted cambie esto. + +
+
+
+Parque Exten de VICIDIAL - Ésta es la extensión del estacionamiento del defecto para el cliente app de VICIDIAL. Verifique que diverso trabaje antes de que usted cambie esto. + +
+
+
+Archivo del parque de VICIDIAL - éste es el nombre del archivo de la extensión del parque del defecto VICIDIAL para los apps del cliente. Verifique que diverso trabaje antes de que usted cambie éste limitado a 10 caracteres. + +
+
+
+Prefijo del monitor - éste es el prefijo dialplan para supervisar de zap los canales automáticamente dentro del app astGUIclient. Cambie solamente según los expedientes de extensiones de extensions.conf ZapBarge. + +
+
+
+Grabación Exten - Ésta es la extensión dialplan para la extensión de la grabación que se utiliza para caer en conferencias del meetme para registrarlas. Dura generalmente hasta que una hora si no parada verifica con el archivo de extensions.conf antes de cambiar. + +
+
+
+VMAIL Exten principal - Ésta es la extensión dialplan que va a comprobar su voicemail. verifica con el archivo de extensions.conf antes de cambiar. + +
+
+
+Descarga Exten de VMAIL - éste es el prefijo dialplan usado para enviar llamadas directamente al voicemail de un usuario de una llamada viva en el app. astGUIclient verifica con el archivo de extensions.conf antes de cambiar. + +
+
+
+Contexto de Exten - éste es el contexto dialplan que este teléfono utiliza sobre todo. Se asume que todos los números marcados por los apps del cliente están utilizando este contexto así que es una buena idea cerciorarse de que éste es el contexto más amplio posible verifica con el archivo de extensions.conf antes de cambiar. + +
+
+
+DTMF envían el canal - Ésta es la secuencia del canal usada para enviar sonidos de DTMF en conferencias del meetme de los apps del cliente. Verifique que exten y contexto con el archivo de extensions.conf. + +
+
+
+Grupo de salida de la llamada - éste es el grupo de canal que las llamadas de salida de este teléfono están puestas de. Hay rutinas de un par en los apps del cliente que utilizan esto. Para zap los canales que usted desea utilizar algo como Zap/g2, porque los troncos IAX2 usted desearía utilizar el prefijo completo de IAX como IAX2/VICItest1:secret@10.10.10.15:4569. Verifique que los troncos con el file(it de extensions.conf sean generalmente lo que usted ha definido como la variable global del TRUNK en la tapa del archivo). + +
+
+
+Localización del browser - esto es aplicable solamente a los clientes de UNIX/LINUX, el camino absoluto a Mozilla o el browser de Firefox en la máquina verifica esto lanzándolo manualmente. + +
+
+
+Instale el directorio - éste es el lugar en donde las escrituras astGUIclient y de astVICIDIAL están situadas en su máquina. Para Win32 debe ser algo como C:\AST_VICI y para UNIX debe ser algo como /usr/local/perl_TK. verifica esto manualmente. + +
+
+
+URL de CallerID - Ústa es la dirección de la tela de la página usada para hacer operaciones de búsqueda de encargo del callerID que es la dirección de prueba del defecto: http://astguiclient.sf.net/test_callerid_output.php + +
+
+
+URL del defecto de VICIDIAL - Ésta es la dirección de la tela de la página usada para hacer preguntas de encargo de la forma del Web de VICIDIAL que es la dirección de prueba del defecto: http://astguiclient.sf.net/test_VICIDIAL_output.php + +
+
+
+Registración de la llamada - esto se fija para verdad si el archivo de call_log.agi está en lugar en el archivo de extensions.conf para todo el de salida y las extensiones del retraso ' h ' para registrar todo llama. Ústa debe siempre ser 1 porque es manditory para muchos astGUIclient y características de VICIDIAL a trabajar correctamente. + +
+
+
+Conmutación del usuario - fije para verdad para permitir que el usuario cambie a otra cuenta del usuario. NOTA: Si los interruptores del usuario ellos pueden iniciar la grabación en la conversación de teléfono del nuevo usuario + +
+
+
+Comunicación - fije para verdad para permitir que el usuario comience llamadas de conferencia con hasta que seis líneas externas. + +
+
+
+Retraso del Admin - sistema a verdad para permitir que el usuario pueda al retraso cualquier línea en la voluntad con astGUIclient. Buena idea de permitir solamente esto para los usuarios del Admin. + +
+
+
+Secuestro del Admin - fije para verdad para permitir que el usuario pueda asir y volver a dirigir a su extensión cualquier línea en la voluntad con astGUIclient. Buena idea de permitir solamente esto para los usuarios del Admin. Pero es muy útil para los encargados. + +
+
+
+Monitor del Admin - fije para verdad para permitir que el usuario pueda asir y volver a dirigir a su extensión cualquier línea en la voluntad con astGUIclient. Buena idea de permitir solamente esto para los usuarios del Admin. Pero es muy útil para los encargados y como herramienta del entrenamiento. + +
+
+
+Parque de llamada - el sistema a verdad para permitir que el usuario pueda parquear invita el asimiento astGUIclient para ser tomado por cualquier otro usuario astGUIclient en el sistema. Las llamadas permanecen en el asimiento para hasta que un retraso de la media-hora entonces. Permitido generalmente para todos. + +
+
+
+Cheque de Updater - fije para verdad para exhibir una advertencia del popup que el tiempo del updater no ha cambiado en 20 segundos. Útil para los usuarios del Admin. + +
+
+
+Af que registra - fije para verdad para registrar muchas acciones del uso astGUIclient a un archivo de texto en la computadora del usuario. + +
+
+
+La coleta permitió - al sistema verdad para hacer que los apps del cliente utilicen el sistema central de la coleta del asterisco. Requerido para VICIDIAL y recomendado para todos los usuarios. + +
+
+
+Ventana emergente del CallerID - sistema a verdad para tener en cuenta los números definidos en el archivo de extensions.conf para enviar las pantallas del popup de CallerID a los usuarios astGUIclient. + +
+
+
+Botón de VMail - fije para verdad para exhibir el botón de VOICEMAIL y los mensajes cuentan la exhibición en astGUIclient. + +
+
+
+Rápido restaure - fije para verdad para permitir un nuevo índice de restauran de la información de la llamada para el astGUIclient. La tarifa inhabilitada defecto es el ms 1000 (1 segundo). Puede aumentar la carga de sistema si usted baja este número. + +
+
+
+Rápido restaure la tarifa - en milisegundos. Utilizado solamente si es rápido restaure se permite. La tarifa inhabilitada defecto es el ms 1000 (1 segundo). Puede aumentar la carga de sistema si usted baja este número. + +
+
+
+Persistant MySQL - si está permitida la conexión astGUIclient seguirá conectada en vez de conectar cada segundo. Útil si usted hace que un rápido restaure la tarifa fijada. Aumentará el número de conexiones en su máquina de MySQL. + +
+
+
+Número siguiente del dial auto - si está permitido el cliente de VICIDIAL marcará el número siguiente en la lista automáticamente sobre la disposición de una llamada a menos que seleccionaran "para parar el marcar" en la pantalla de la disposición. + +
+
+
+Pare Rec después de cada llamada - si está permitido el cliente de VICIDIAL parará se está encendiendo cualquier grabación después de que haya sido cada llamada dispositioned. Útil si usted está haciendo muchos de la grabación o usted están utilizando una forma de la tela para accionar la grabación. + +
+
+
+Servidor de DBX - el servidor de la base de datos de MySQL con el cual este usuario debe conectar. + +
+
+
+Base de datos de DBX - la base de datos de MySQL con la cual este usuario debe conectar. El defecto es asterisco. + +
+
+
+Usuario de DBX - la conexión del usuario de MySQL que este usuario debe utilizar al conectar. El defecto es cron. + +
+
+
+Paso de DBX - la contraseña del usuario de MySQL que este usuario debe utilizar al conectar. El defecto es 1234. + +
+
+
+DBX viran - el puerto de MySQL hacia el lado de babor TCP que este usuario debe utilizar al conectar. El defecto es 3306. + +
+
+
+Servidor de DBY - el servidor de la base de datos de MySQL con el cual este usuario debe conectar. Secundario server, no utilizado actualmente. + +
+
+
+Base de datos de DBY - la base de datos de MySQL con la cual este usuario debe conectar. El defecto es asterisco. Secundario server, no utilizado actualmente. + +
+
+
+Usuario de DBY - la conexión del usuario de MySQL que este usuario debe utilizar al conectar. El defecto es cron. Secundario server, no utilizado actualmente. + +
+
+
+Paso de DBY - la contraseña del usuario de MySQL que este usuario debe utilizar al conectar. El defecto es 1234. Secundario server, no utilizado actualmente. + +
+
+
+DBY viran - el puerto de MySQL hacia el lado de babor TCP que este usuario debe utilizar al conectar. El defecto es 3306. Secundario server, no utilizado actualmente. + + +



+ +TABLA DE LOS SERVIDORES

+
+
+ID Del Servidor - Este campo es donde usted pone el nombre del servidor del asterisco, no tiene que ser un submarino oficial del dominio, apenas un apodo para identificar el servidor a los usuarios del Admin. + +
+
+
+Descripción del servidor - el campo donde usted utiliza una frase pequeña para describir el servidor del asterisco. + +
+
+
+IP address del servidor - el campo donde usted puso el IP address de la red del servidor del asterisco. + +
+
+
+Activo - fije si el servidor del asterisco es activo o inactivo. + +
+
+
+Versión del asterisco - fije la versión del asterisco que usted ha instalado en este servidor. Ejemplos: ' 1.2 ', ' 1.0.8 ', ' 1.0.7 ', ' CVS_HEAD ', ' REALMENTE VIEJO ', etc... Se utiliza esto porque las versiones 1.0.8 y 1.0.9 tienen un diverso método de ocuparse del insecto local del channels(a que ha estado fijado en CVS v1.0) y necesidad de ser tratado diferentemente cuando la manipulación de su Local/ acanala. También, CVS_HEAD actual y las 1.2 aplicaciones diverso encargado y comando del árbol del lanzamiento hicieron salir así que debe ser tratado diverso también. + +
+
+
+Troncos máximos de VICIDIAL - este campo determinará el número de las líneas máximo que el auto-dialer de VICIDIAL procurará invitar este servidor. Si usted desea dedicar dos PRI llenos T1 a VICIDIALing en un servidor entonces usted fijaría esto a 46. E1 defecto es 96. + +
+
+
+Anfitrión del telnet - éste es la dirección o el nombre del servidor del asterisco y es cómo los usos del encargado conectan con él de donde están funcionando. Si están funcionando en el servidor del asterisco, después el defecto del ' localhost ' está muy bien. + +
+
+
+El telnet vira hacia el lado de babor - éste es el puerto de la conexión del encargado del servidor del asterisco y es cómo los usos del encargado conectan con ella de donde están funcionando. El defecto de ' 5038 ' está para un estándar instala muy bien. + +
+
+
+Usuario del encargado - el username o la conexión conectaba genericly con el encargado del servidor del asterisco. El defecto es 'cron' + +
+
+
+Secreto del encargado - el secreto o la contraseña conectaba genericly con el encargado del servidor del asterisco. El defecto es '1234' + +
+
+
+Usuario en modo actualización del encargado - el username o la conexión conectaba con el encargado del servidor del asterisco optimizado para las escrituras de la actualización. Omita es 'updatecron' y asume el mismo secreto que el usuario genérico. + +
+
+
+El encargado escucha usuario - el username o la conexión usada para conectar con el encargado del servidor del asterisco optimizado para las escrituras que esperan a escuchar solamente salida. Omita es 'listencron' y asume el mismo secreto que el usuario genérico. + +
+
+
+El encargado envía a usuario - el username o la conexión usada para conectar con el encargado del servidor del asterisco optimizado para las escrituras que envían solamente acciones al encargado. Omita es 'sendcron' y asume el mismo secreto que el usuario genérico. + +
+
+
+El GMT del servidor compensó - la diferencia sobre horas a partir del tiempo del GMT no ajustado según el Luz del di'a-Ahorro-Tiempo del servidor. El defecto es '-5' + +
+
+
+Descarga Exten - el prefijo de VMail de la extensión usado en este servidor para enviar llamadas directamente a través de agc a una caja específica del voicemail. El defecto es '85026666666666' + +
+
+
+Extensión del ANUNCIO de VICIDIAL - la extensión del defecto si ninguno está presente en la campaña enviar llamadas para a marcar auto de VICIDIAL. El defecto es '8365' + +
+
+
+Contexto del defecto - el contexto dialplan del defecto usado para las escrituras que funcionan para este servidor. El defecto es 'defecto' + + +



+ +TABLA DE CONFERENCIAS

+
+
+Número de la conferencia - este campo es donde usted pone el número del dialpna de la conferencia del meetme. También se recomienda que el número del meetme en meetme.conf empareja este número para cada entrada. Esto está para las conferencias en astGUIclient y se utiliza para la funcionalidad de leave-3way-call en VICIDIAL. + +
+
+
+IP del servidor - El menú donde usted selecciona el servidor del asterisco que esta conferencia estará encendido. + + + + + + +







+







+EL EXTREMO +
+ + + +ASTERISK ADMIN: Administración - <? echo $process ?> + + + +
+ + + + + + +
  ASTERISK ADMIN - Salir  
  ENUMERE TODOS LOS TELÉFONOS | AGREGUE Un TELÉFONO NUEVO | BÚSQUEDA PARA Un TELÉFONO | AGREGUE Un SERVIDOR | ENUMERE TODOS LOS SERVIDORES
  DEMUESTRE TODAS LAS CONFERENCIAS | AGREGUE Una NUEVA CONFERENCIA
+"; + +echo "
AGREGUE Un TELÉFONO NUEVO
\n"; +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Extensión del teléfono: $NWB#phones-extension$NWE
Número De Dialplan: (Solamente dígitos)$NWB#phones-dialplan_number$NWE
Buzón de voz: (Solamente dígitos)$NWB#phones-voicemail_id$NWE
CallerID De salida: (Solamente dígitos)$NWB#phones-outbound_cid$NWE
Dirección IP del teléfono: (optional)$NWB#phones-phone_ip$NWE
Dirección IP del ordenador: (optional)$NWB#phones-computer_ip$NWE
IP Del Servidor: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Contraseña: $NWB#phones-pass$NWE
Estado: $NWB#phones-status$NWE
Cuenta Activa: $NWB#phones-active$NWE
Tipo Del Teléfono: $NWB#phones-phone_type$NWE
Nombre Completo: $NWB#phones-fullname$NWE
Compañía: $NWB#phones-company$NWE
Foto: $NWB#phones-picture$NWE
Protocolo Del Cliente: $NWB#phones-protocol$NWE
GMT Local: (No ajustar para el DST)$NWB#phones-local_gmt$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW SERVERS FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
AGREGAR Un SERVIDOR NUEVO\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Del Servidor: $NWB#servers-server_id$NWE
Descripción Del Servidor: $NWB#servers-server_description$NWE
Dirección IP del Servidor: $NWB#servers-server_ip$NWE
Activo: $NWB#servers-active$NWE
Versión De Asterisk: $NWB#servers-asterisk_version$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW CONFERENCES FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
AGREGUE Una NUEVA CONFERENCIA\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Número de la Conferencia: (Solamente dígitos)$NWB#conferences-conf_exten$NWE
IP Del Servidor: $NWB#conferences-server_ip$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new phone to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
TELÉFONO NO AGREGADO - hay ya un teléfono en el sistema con esta extensión/servidor\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
TELÉFONO NO AGREGADO - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + echo "
EL TELÉFONO AGREGÚ\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new server to the system +###################### + +if ($ADD==21) +{ + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SERVIDOR NO AGREGADO - hay ya un servidor en el sistema con esta identificación\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVIDOR NO AGREGADO - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + echo "
SERVIDOR AGREGADO\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new conference to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFERENCIA NO AGREGADA - hay ya una conferencia en el sistema con esta identificación y servidor\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCIA NO AGREGADA - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + echo "
LA CONFERENCIA AGREGÚ\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=100; +} + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of phone +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGdelete_phones < 1) ) + { + echo "
TELÉFONO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
IP Del Servidor be at least 7 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DEL TELÉFONO: $extension - $server_ip\n"; + echo "

Chasque aquí para suprimir el teléfono $extension - $server_ip


\n"; + } + +$ADD='3'; # go to phone modification below +} + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete phone record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGdelete_phones < 1) ) + { + echo "
TELÉFONO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
IP Del Servidor be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING PHONE!!!|$PHP_AUTH_USER|$ip|extension='$extension'|server_ip='$server_ip'|\n"); + fclose($fp); + } + echo "
LA CANCELADURA DEL TELÉFONO TERMINÓ: $extension - $server_ip\n"; + echo "

\n"; + } + +$ADD='0'; # go to phone list +} + + + + + + +###################### +# ADD=3 modify phone info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFICANDO EL TELÉFONO: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Extensión del teléfono: $NWB#phones-extension$NWE
Número De Dialplan: (Solamente dígitos)$NWB#phones-dialplan_number$NWE
Buzón de voz: (Solamente dígitos)$NWB#phones-voicemail_id$NWE
CallerID De salida: (Solamente dígitos)$NWB#phones-outbound_cid$NWE
Dirección IP del teléfono: (optional)$NWB#phones-phone_ip$NWE
Dirección IP del ordenador: (optional)$NWB#phones-computer_ip$NWE
IP Del Servidor: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Contraseña: $NWB#phones-pass$NWE
Estado: $NWB#phones-status$NWE
Cuenta Activa: $NWB#phones-active$NWE
Tipo Del Teléfono: $NWB#phones-phone_type$NWE
Nombre Completo: $NWB#phones-fullname$NWE
Compañía: $NWB#phones-company$NWE
Foto: $NWB#phones-picture$NWE
Mensajes Nuevos: $row[14]$NWB#phones-messages$NWE
Mensajes Viejos: $row[15]$NWB#phones-old_messages$NWE
Protocolo Del Cliente: $NWB#phones-protocol$NWE
GMT Local: (No ajustar para el DST)$NWB#phones-local_gmt$NWE
Login del Manager: $NWB#phones-ASTmgrUSERNAME$NWE
Contraseña del Manager: $NWB#phones-ASTmgrSECRET$NWE
Usuario por defecto de VICIDIAL: $NWB#phones-login_user$NWE
Contraseña por defecto de VICIDIAL: $NWB#phones-login_pass$NWE
Campaña por defecto de VICIDIAL: $NWB#phones-login_campaign$NWE
Extensión del parking: $NWB#phones-park_on_extension$NWE
Extensión de la conferencia: $NWB#phones-conf_on_extension$NWE
Exten. Del parking de VICIDIAL: $NWB#phones-VICIDIAL_park_on_extension$NWE
Archivo para música del parking de VICIDIAL: $NWB#phones-VICIDIAL_park_on_filename$NWE
Prefijo al monitorizar: $NWB#phones-monitor_prefix$NWE
Exten de Grabación: $NWB#phones-recording_exten$NWE
Exten de VmailMain: $NWB#phones-voicemail_exten$NWE
Exten de VmaiDumpl: $NWB#phones-voicemail_dump_exten$NWE
Contexto De Exten: $NWB#phones-ext_context$NWE
Canal de envío del DTMF: $NWB#phones-dtmf_send_extension$NWE
Grupo de las llamadas de salida: $NWB#phones-call_out_number_group$NWE
Localización del Navegador: $NWB#phones-client_browser$NWE
Directorio de instalación: $NWB#phones-install_directory$NWE
URL del CallerID: $NWB#phones-local_web_callerID_URL$NWE
URL por defecto de VICIDIAL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
Cambio de Usuario: $NWB#phones-user_switching_enabled$NWE
Conferencias: $NWB#phones-conferencing_enabled$NWE
Colgar del Admin: $NWB#phones-admin_hangup_enabled$NWE
Captura del Admin: $NWB#phones-admin_hijack_enabled$NWE
Monitorización del Admin: $NWB#phones-admin_monitor_enabled$NWE
Parking de Llamada: $NWB#phones-call_parking_enabled$NWE
Uptader Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Colas permitidas: $NWB#phones-QUEUE_ACTION_enabled$NWE
Ventana emergente del CallerID: $NWB#phones-CallerID_popup_enabled$NWE
Botón Vmail: $NWB#phones-voicemail_button_enabled$NWE
Refresco rápido: $NWB#phones-enable_fast_refresh$NWE
Refresco rápido de la tarifa: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Marcar el Siguiente Número: $NWB#phones-auto_dial_next_number$NWE
Parar de Grabar después de cada llamada: $NWB#phones-VDstop_rec_after_each_call$NWE
Servidor de DBX: (Primario DB Server)$NWB#phones-DBX_server$NWE
Base de datos de DBX: (Primario Server Database)$NWB#phones-DBX_database$NWE
Usuario de DBX: (Primario DB Login)$NWB#phones-DBX_user$NWE
Contraseña de DBX: (Primario DB Secret)$NWB#phones-DBX_pass$NWE
Puerto de DBX: (Primario DB Port)$NWB#phones-DBX_port$NWE
Servidor de DBY: (Secundario DB Server)$NWB#phones-DBY_server$NWE
Base de datos de DBY: (Secundario Server Database)$NWB#phones-DBY_database$NWE
Usuario de DBY: (Secundario DB Login)$NWB#phones-DBY_user$NWE
Contraseña de DBY: (Secundario DB Secret)$NWB#phones-DBY_pass$NWE
Puerto de DBY: (Secundario DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Pinchar aquí­ para ver las estadísticas del teléfono\n"; + +if ($LOGdelete_phones > 0) + { + echo "

SUPRIMA ESTE TELÉFONO\n"; + } + +} + + +###################### +# ADD=31 modify server info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFICAR UN REGISTRO DEL SERVIDOR: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Del Servidor: $NWB#servers-server_id$NWE
Descripción Del Servidor: $NWB#servers-server_description$NWE
Dirección IP del Servidor: $NWB#servers-server_ip$NWE
Activo: $NWB#servers-active$NWE
Versión De Asterisk: $NWB#servers-asterisk_version$NWE
Máx. Trunks en VICIDIAL: $NWB#servers-max_vicidial_trunks$NWE
Host Del Telnet: $NWB#servers-telnet_host$NWE
Puerto Del Telnet: $NWB#servers-telnet_port$NWE
Usuario Del Manager: $NWB#servers-ASTmgrUSERNAME$NWE
Contraseña del Manager: $NWB#servers-ASTmgrSECRET$NWE
Usuario del Updater del Manager: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Usuario Listen del Manager: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Usuario Send del Manager: $NWB#servers-ASTmgrUSERNAMEsend$NWE
GMT Local: (No ajustar para el DST)$NWB#servers-local_gmt$NWE
Extensión de Vmail Dump : $NWB#servers-voicemail_dump_exten$NWE
Extensión del AD de VICIDIAL: $NWB#servers-answer_transfer_agent$NWE
Contexto por Defecto: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
TELÉFONOS DENTRO DE ESTE SERVIDOR:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIÓNNOMBREACTIVO
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Este servidor tiene $active_lists Teléfonos activos y $inactive_lists Teléfonos inactivos

\n"; +echo "
\n"; +} + + +###################### +# ADD=311 modify conference info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFICAR UN REGISTRO DE LA CONFERENCIA: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conferencia: $NWB#conferences-conf_exten$NWE
IP Del Servidor: $NWB#conferences-server_ip$NWE
Extensión Actual:
\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=4 submit phone modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
TELÉFONO NO MODIFICADO - hay ya un teléfono en el sistema con esta extensión/servidor\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
TELÉFONO NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + echo "
TELÉFONO MODIFICADO: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFICANDO EL TELÉFONO: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Extensión del teléfono: $NWB#phones-extension$NWE
Número De Dialplan: (Solamente dígitos)$NWB#phones-dialplan_number$NWE
Buzón de voz: (Solamente dígitos)$NWB#phones-voicemail_id$NWE
CallerID De salida: (Solamente dígitos)$NWB#phones-outbound_cid$NWE
Dirección IP del teléfono: (optional)$NWB#phones-phone_ip$NWE
Dirección IP del ordenador: (optional)$NWB#phones-computer_ip$NWE
IP Del Servidor: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Contraseña: $NWB#phones-pass$NWE
Estado: $NWB#phones-status$NWE
Cuenta Activa: $NWB#phones-active$NWE
Tipo Del Teléfono: $NWB#phones-phone_type$NWE
Nombre Completo: $NWB#phones-fullname$NWE
Compañía: $NWB#phones-company$NWE
Foto: $NWB#phones-picture$NWE
Mensajes Nuevos: $row[14]$NWB#phones-messages$NWE
Mensajes Viejos: $row[15]$NWB#phones-old_messages$NWE
Protocolo Del Cliente: $NWB#phones-protocol$NWE
GMT Local: (No ajustar para el DST)$NWB#phones-local_gmt$NWE
Login del Manager: $NWB#phones-ASTmgrUSERNAME$NWE
Contraseña del Manager: $NWB#phones-ASTmgrSECRET$NWE
Usuario por defecto de VICIDIAL: $NWB#phones-login_user$NWE
Contraseña por defecto de VICIDIAL: $NWB#phones-login_pass$NWE
Campaña por defecto de VICIDIAL: $NWB#phones-login_campaign$NWE
Extensión del parking: $NWB#phones-park_on_extension$NWE
Extensión de la conferencia: $NWB#phones-conf_on_extension$NWE
Exten. Del parking de VICIDIAL: $NWB#phones-VICIDIAL_park_on_extension$NWE
Archivo para música del parking de VICIDIAL: $NWB#phones-VICIDIAL_park_on_filename$NWE
Prefijo al monitorizar: $NWB#phones-monitor_prefix$NWE
Exten de Grabación: $NWB#phones-recording_exten$NWE
Exten de VmailMain: $NWB#phones-voicemail_exten$NWE
Exten de VmaiDumpl: $NWB#phones-voicemail_dump_exten$NWE
Contexto De Exten: $NWB#phones-ext_context$NWE
Canal de envío del DTMF: $NWB#phones-dtmf_send_extension$NWE
Grupo de las llamadas de salida: $NWB#phones-call_out_number_group$NWE
Localización del Navegador: $NWB#phones-client_browser$NWE
Directorio de instalación: $NWB#phones-install_directory$NWE
URL del CallerID: $NWB#phones-local_web_callerID_URL$NWE
URL por defecto de VICIDIAL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
Cambio de Usuario: $NWB#phones-user_switching_enabled$NWE
Conferencias: $NWB#phones-conferencing_enabled$NWE
Colgar del Admin: $NWB#phones-admin_hangup_enabled$NWE
Captura del Admin: $NWB#phones-admin_hijack_enabled$NWE
Monitorización del Admin: $NWB#phones-admin_monitor_enabled$NWE
Parking de Llamada: $NWB#phones-call_parking_enabled$NWE
Uptader Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Colas permitidas: $NWB#phones-QUEUE_ACTION_enabled$NWE
Ventana emergente del CallerID: $NWB#phones-CallerID_popup_enabled$NWE
Botón Vmail: $NWB#phones-voicemail_button_enabled$NWE
Refresco rápido: $NWB#phones-enable_fast_refresh$NWE
Refresco rápido de la tarifa: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Marcar el Siguiente Número: $NWB#phones-auto_dial_next_number$NWE
Parar de Grabar después de cada llamada: $NWB#phones-VDstop_rec_after_each_call$NWE
Servidor de DBX: (Primario DB Server)$NWB#phones-DBX_server$NWE
Base de datos de DBX: (Primario Server Database)$NWB#phones-DBX_database$NWE
Usuario de DBX: (Primario DB Login)$NWB#phones-DBX_user$NWE
Contraseña de DBX: (Primario DB Secret)$NWB#phones-DBX_pass$NWE
Puerto de DBX: (Primario DB Port)$NWB#phones-DBX_port$NWE
Servidor de DBY: (Secundario DB Server)$NWB#phones-DBY_server$NWE
Base de datos de DBY: (Secundario Server Database)$NWB#phones-DBY_database$NWE
Usuario de DBY: (Secundario DB Login)$NWB#phones-DBY_user$NWE
Contraseña de DBY: (Secundario DB Secret)$NWB#phones-DBY_pass$NWE
Puerto de DBY: (Secundario DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Pinchar aquí­ para ver las estadísticas del teléfono\n"; + +if ($LOGdelete_phones > 0) + { + echo "

SUPRIMA ESTE TELÉFONO\n"; + } + +} + +###################### +# ADD=41 submit server modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
SERVIDOR NOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
SERVIDOR NO MODIFICADO - hay ya un servidor en el sistema con este server_ip\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVIDOR NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + echo "
SERVIDOR MODIFICADO: $server_ip\n"; + + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + } + } + } + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFICAR UN REGISTRO DEL SERVIDOR: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Del Servidor: $NWB#servers-server_id$NWE
Descripción Del Servidor: $NWB#servers-server_description$NWE
Dirección IP del Servidor: $NWB#servers-server_ip$NWE
Activo: $NWB#servers-active$NWE
Versión De Asterisk: $NWB#servers-asterisk_version$NWE
Máx. Trunks en VICIDIAL: $NWB#servers-max_vicidial_trunks$NWE
Host Del Telnet: $NWB#servers-telnet_host$NWE
Puerto Del Telnet: $NWB#servers-telnet_port$NWE
Usuario Del Manager: $NWB#servers-ASTmgrUSERNAME$NWE
Contraseña del Manager: $NWB#servers-ASTmgrSECRET$NWE
Usuario del Updater del Manager: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Usuario Listen del Manager: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Usuario Send del Manager: $NWB#servers-ASTmgrUSERNAMEsend$NWE
GMT Local: (No ajustar para el DST)$NWB#servers-local_gmt$NWE
Extensión de Vmail Dump : $NWB#servers-voicemail_dump_exten$NWE
Extensión del AD de VICIDIAL: $NWB#servers-answer_transfer_agent$NWE
Contexto por Defecto: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
TELÉFONOS DENTRO DE ESTE SERVIDOR:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIÓNNOMBREACTIVO
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Este servidor tiene $active_lists Teléfonos activos y $inactive_lists Teléfonos inactivos

\n"; +echo "
\n"; + +} + +###################### +# ADD=411 submit conference modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
CONFERENCIA - hay ya una conferencia en el sistema con esta extensión - servidor NO MODIFICADO\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCIA NO MODIFICADA - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + echo "
CONFERENCIA MODIFICADA: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from conferences where conf_exten='$conf_exten';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFICAR UN REGISTRO DE LA CONFERENCIA: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conferencia: $NWB#conferences-conf_exten$NWE
IP Del Servidor: $NWB#conferences-server_ip$NWE
Extensión Actual:
\n"; + +echo "
\n"; + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo ""; + +echo "
BÚSQUEDA PARA Un TELÉFONO\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Extensión:
Nombre Completo:
Phone type:
\n"; + +} + +###################### +# ADD=66 phone search results +###################### + +if ($ADD==66) +{ + echo ""; + + $SQL = ''; + if ($extension) {$SQL .= "extension LIKE \"%$extension%\" and";} + if ($fullname) {$SQL .= "fullname LIKE \"%$fullname%\" and";} + if ($phone_type) {$SQL .= "phone_type LIKE \"%$phone_type%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from phones $SQL order by extension,server_ip;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
RESULTADOS DE LA BÚSQUEDA:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFICAR | ESTADÍSTICAS
\n"; + +} + + + +###################### +# ADD=0 display all active phones +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from phones order by extension,server_ip"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
LISTADOS DE TELÉFONOS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[16]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFICAR | ESTADÍSTICAS
\n"; +} + +###################### +# ADD=10 display all servers +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
LISTADOS DEL SERVIDOR:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[4] $row[3]  MODIFICAR
\n"; +} + + +###################### +# ADD=100 display all conferences +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
LISTADOS DE CONFERENCIAS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]  MODIFICAR
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds"; +echo "             VERSIÓN: $version"; +echo "             CONSTRUCCION: $build
\n"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/dbconnect.php b/agc_2-X/trunk/LANG_admin/astguiclient_es/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_es/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/help.gif b/agc_2-X/trunk/LANG_admin/astguiclient_es/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/astguiclient_es/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/inbound_popup.php b/agc_2-X/trunk/LANG_admin/astguiclient_es/inbound_popup.php new file mode 100644 index 00000000..3f158865 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_es/inbound_popup.php @@ -0,0 +1,228 @@ + LICENSE: GPLv2 +### +# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# +# changes: +# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK SALIENTES REMOTOS: Popup + + +
+ + 0) +{ + + $stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Vuelva a dirigir el comando enviado para el canal $channel       $NOW_TIME\n

\n"; + + + $url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&'; + $Suser = 'username='; + $Spass = '&passwd='; + $Sphone = '&phone='; + + $newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone"; + if ( ($phone == 'unknown') or (strlen($phone)<9) ) + {$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";} + + echo "Mire para arriba a este cliente en sistema del servicio de cliente\n

\n"; + + echo "Cierre esta ventana\n

\n"; +} +else +{ + echo "Vuelva a dirigir el comando FALLADO para el canal $channel       $NOW_TIME\n

\n"; + echo "Cierre esta ventana\n

\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/phone_stats.php b/agc_2-X/trunk/LANG_admin/astguiclient_es/phone_stats.php new file mode 100644 index 00000000..c5286b55 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_es/phone_stats.php @@ -0,0 +1,244 @@ + LICENSE: GPLv2 +# +# +# changes: +# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$admin_page = './admin.php'; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $row[0]; + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ADMIN: Estadísticas Del Teléfono + + +
+
+ + + + + + +\n"; +echo "
  ASTERISK ADMIN: Administración  
  ENUMERE TODOS LOS TELÉFONOS | AGREGUE Un TELÉFONO NUEVO | BÚSQUEDA PARA Un TELÉFONO | AGREGUE Un SERVIDOR | ENUMERE TODOS LOS SERVIDORES
  DEMUESTRE TODAS LAS CONFERENCIAS | AGREGUE Una NUEVA CONFERENCIA
  \n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' group by channel_group order by channel_group"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + +echo "
\n"; + +echo "TIEMPO DE LLAMADA Y CANALES:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} +# echo "|$stmt|\n"; + +echo "\n"; +echo "
GRUPO DE CANALES CUENTA HORAS:MINUTOS
$row[1] $row[0] $call_hours_int:$call_minutes_int
LLAMADAS TOTALES $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LLAMADAS DEL ÚLTIMO 1000 PARA LA GAMA DE LA FECHA:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='$extension' and server_ip='$server_ip' and start_time >= '$begin_date 0:00:01' and start_time <= '$end_date 23:59:59' LIMIT 1000"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + + $call_seconds=0; + $o++; + } + + +echo "
NÚMERO GRUPO DE CANALES FECHA LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/astguiclient_es/remote_inbound.php b/agc_2-X/trunk/LANG_admin/astguiclient_es/remote_inbound.php new file mode 100644 index 00000000..c49b8e59 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/astguiclient_es/remote_inbound.php @@ -0,0 +1,162 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$ENVIAR=$_GET["ENVIAR"]; if (!$ENVIAR) {$ENVIAR=$_POST["ENVIAR"];} + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + echo"\n"; + echo"ASTERISK ENTRANTES REMOTOS: Principal\n"; + echo"\n"; + echo"\n"; + echo"\n"; + +?> + + +
+ +
\n"; + +echo "Chasque encendido el canal debajo de ése que usted quisiera haber dirigido a su teléfono

\n"; + +echo "
\n";
+echo "CHANNEL    SERVIDOR        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME        \n";
+echo "----------------------------------------------------------------------------------------------\n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$extension =		sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		echo "$channel$server$channel_group$extension$parked_by$parked_time\n";
+
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "*************************************** NO PARKED CALLS **************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_CLOSERstats.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_CLOSERstats.php new file mode 100644 index 00000000..b7a7bb8c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_CLOSERstats.php @@ -0,0 +1,396 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Closer Stats\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Closer Stats                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls placed from this Campaign:        $TOTALcalls\n";
+echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls:                             $DROPcalls  $DROPpercent%\n";
+echo "Average Length for DROP Calls in seconds:     $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_VDADstats.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_VDADstats.php new file mode 100644 index 00000000..9ac17006 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_VDADstats.php @@ -0,0 +1,417 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls placed from this Campaign:        $TOTALcalls\n";
+echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls:                             $DROPcalls  $DROPpercent%\n";
+echo "Average Length for DROP Calls in seconds:     $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- AUTO-DIAL NO ANSWERS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$NAcalls =	sprintf("%10s", $row[0]);
+$NApercent = (($NAcalls / $TOTALcalls) * 100);
+$NApercent = round($NApercent, 0);
+
+$average_na_seconds = ($row[1] / $row[0]);
+$average_na_seconds = round($average_na_seconds, 0);
+$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+
+echo "Total NA calls -Busy,Disconnect,BTvoicemail:  $NAcalls  $NApercent%\n";
+echo "Average Call Length for NA Calls in seconds:  $average_na_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..1824a939 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,161 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Hopper List\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Live Current Hopper List                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+
+echo "Total leads in hopper right now:       $TOTALcalls\n";
+
+
+##############################
+#########  LEAD STATS
+
+echo "\n";
+echo "---------- LEADS IN HOPPER\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+echo "|      | LEAD_ID   | PHONE NUM  | STATE | STATUS | COUNT | GMT    |\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$FMT_i =		sprintf("%-4s", $i);
+	$lead_id =		sprintf("%-9s", $row[0]);
+	$phone_number =	sprintf("%-10s", $row[1]);
+	$state =		sprintf("%-5s", $row[2]);
+	$status =		sprintf("%-6s", $row[3]);
+	$count =		sprintf("%-5s", $row[4]);
+	$gmt =			sprintf("%-6s", $row[5]);
+
+	echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
+
+	$i++;
+	}
+
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_admin_log_display.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_admin_log_display.php new file mode 100644 index 00000000..b5286873 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_admin_log_display.php @@ -0,0 +1,118 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date); + +# AST GUI database administration +# AST_admin_log_display.php +# +# CHANGES +# 50325-0932 - First build +# 51123-1443 - removed globals=on requirement +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '0.0.4'; +$build = '60620-1044'; + +$STARTtime = date("U"); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN LOG DISPLAY"; +echo "\n"; + +# Fri, 25 Mar 2005 + +$DAY_DATE = date("j"); +if ($DAY_DATE < 10) +# {$GREP_DATE = date("D, j M Y");} + {$GREP_DATE = date("D, 0j M Y");} +else + {$GREP_DATE = date("D, j M Y");} + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!$query_date) {$query_date = $GREP_DATE;} + +$Gquery_date = eregi_replace(" ",'\ ',$query_date); +echo "\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+echo "VICIDIAL ADMIN CHANGE LOG                             $NOW_TIME\n";
+
+#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
+passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_performance.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_performance.php new file mode 100644 index 00000000..a489bc7d --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_performance.php @@ -0,0 +1,232 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Agent Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_performance_detail.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_performance_detail.php
new file mode 100644
index 00000000..2dd3dc5e
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_performance_detail.php
@@ -0,0 +1,406 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 03:45:00";   
+	$query_date_END = "$query_date 15:15:00";
+	$time_BEGIN = "03:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:15:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance Detail                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TIME   | PAUSE  | PAUSAVG| WAIT   | WAITAVG| TALK   | TALKAVG| DISPO  | DISPAVG| A    | B    | DC   | DNC  | N    | NI   | CB   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$TOTtotWAIT=($TOTtotWAIT + $row[7]);
+	$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
+	$TOTtotDISPO=($TOTtotDISPO + $row[9]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtime =	($row[1] + $row[5] + $row[7] + $row[9]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+	$USERtotPAUSE =	$row[5];
+	$USERavgPAUSE =	$row[6];
+	$USERtotWAIT =	$row[7];
+	$USERavgWAIT =	$row[8];
+	$USERtotDISPO =	$row[9];
+	$USERavgDISPO =	$row[10];
+
+	$USERtime_M = ($USERtime / 60);
+	$USERtime_M = round($USERtime_M, 2);
+	$USERtime_M_int = intval("$USERtime_M");
+	$USERtime_S = ($USERtime_M - $USERtime_M_int);
+	$USERtime_S = ($USERtime_S * 60);
+	$USERtime_S = round($USERtime_S, 0);
+	if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
+	$USERtime_MS = "$USERtime_M_int:$USERtime_S";
+	$pfUSERtime_MS[$i] =		sprintf("%7s", $USERtime_MS);
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+
+	$USERtotPAUSE_M = ($USERtotPAUSE / 60);
+	$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
+	$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
+	$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
+	$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
+	$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
+	if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
+	$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
+	$pfUSERtotPAUSE_MS[$i] =		sprintf("%6s", $USERtotPAUSE_MS);
+
+	$USERavgPAUSE_M = ($USERavgPAUSE / 60);
+	$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
+	$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
+	$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
+	$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
+	$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
+	if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
+	$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
+	$pfUSERavgPAUSE_MS[$i] =		sprintf("%6s", $USERavgPAUSE_MS);
+
+	$USERtotWAIT_M = ($USERtotWAIT / 60);
+	$USERtotWAIT_M = round($USERtotWAIT_M, 2);
+	$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
+	$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
+	$USERtotWAIT_S = ($USERtotWAIT_S * 60);
+	$USERtotWAIT_S = round($USERtotWAIT_S, 0);
+	if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
+	$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
+	$pfUSERtotWAIT_MS[$i] =		sprintf("%6s", $USERtotWAIT_MS);
+
+	$USERavgWAIT_M = ($USERavgWAIT / 60);
+	$USERavgWAIT_M = round($USERavgWAIT_M, 2);
+	$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
+	$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
+	$USERavgWAIT_S = ($USERavgWAIT_S * 60);
+	$USERavgWAIT_S = round($USERavgWAIT_S, 0);
+	if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
+	$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
+	$pfUSERavgWAIT_MS[$i] =		sprintf("%6s", $USERavgWAIT_MS);
+	
+	$USERtotDISPO_M = ($USERtotDISPO / 60);
+	$USERtotDISPO_M = round($USERtotDISPO_M, 2);
+	$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
+	$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
+	$USERtotDISPO_S = ($USERtotDISPO_S * 60);
+	$USERtotDISPO_S = round($USERtotDISPO_S, 0);
+	if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
+	$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
+	$pfUSERtotDISPO_MS[$i] =		sprintf("%6s", $USERtotDISPO_MS);
+
+	$USERavgDISPO_M = ($USERavgDISPO / 60);
+	$USERavgDISPO_M = round($USERavgDISPO_M, 2);
+	$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
+	$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
+	$USERavgDISPO_S = ($USERavgDISPO_S * 60);
+	$USERavgDISPO_S = round($USERavgDISPO_S, 0);
+	if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
+	$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
+	$pfUSERavgDISPO_MS[$i] =		sprintf("%6s", $USERavgDISPO_MS);
+
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; $ctCB[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]);	$TOT_CB = ($TOT_CB + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtime_M = ($TOTtime / 60);
+	$TOTtime_M = round($TOTtime_M, 2);
+	$TOTtime_M_int = intval("$TOTtime_M");
+	$TOTtime_S = ($TOTtime_M - $TOTtime_M_int);
+	$TOTtime_S = ($TOTtime_S * 60);
+	$TOTtime_S = round($TOTtime_S, 0);
+	if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
+	$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
+	$TOTtime_MS =		sprintf("%7s", $TOTtime_MS);
+		while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOTtotDISPO_M = ($TOTtotDISPO / 60);
+	$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
+	$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
+	$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
+	$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
+	$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
+	if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
+	$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
+	$TOTtotDISPO_MS =		sprintf("%7s", $TOTtotDISPO_MS);
+		while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+
+	$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
+	$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
+	$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
+	$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
+	if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
+	$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
+	$TOTtotPAUSE_MS =		sprintf("%7s", $TOTtotPAUSE_MS);
+		while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+
+	$TOTtotWAIT_M = ($TOTtotWAIT / 60);
+	$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
+	$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
+	$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
+	$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
+	$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
+	if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
+	$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
+	$TOTtotWAIT_MS =		sprintf("%7s", $TOTtotWAIT_MS);
+		while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+
+
+	$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
+	$TOTavgTALK_M = round($TOTavgTALK_M, 2);
+	$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
+	$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
+	$TOTavgTALK_S = ($TOTavgTALK_S * 60);
+	$TOTavgTALK_S = round($TOTavgTALK_S, 0);
+	if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
+	$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
+	$TOTavgTALK_MS =		sprintf("%6s", $TOTavgTALK_MS);
+		while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+
+	$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
+	$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
+	$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
+	$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
+	$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
+	$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
+	if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
+	$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
+	$TOTavgDISPO_MS =		sprintf("%6s", $TOTavgDISPO_MS);
+		while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+
+	$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
+	$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
+	$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
+	$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
+	if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
+	$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
+	$TOTavgPAUSE_MS =		sprintf("%6s", $TOTavgPAUSE_MS);
+		while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+
+	$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
+	$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
+	$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
+	$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
+	$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
+	$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
+	if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
+	$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
+	$TOTavgWAIT_MS =		sprintf("%6s", $TOTavgWAIT_MS);
+		while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+
+	
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_CB = sprintf("%-5s", $TOT_CB);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
+echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_time_sheet.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_time_sheet.php
new file mode 100644
index 00000000..46659eb6
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_time_sheet.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "TOTAL CALLS TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_time_sheet_archive.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_time_sheet_archive.php
new file mode 100644
index 00000000..f14eca16
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_agent_time_sheet_archive.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1721 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "TOTAL CALLS TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_parkstats.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_parkstats.php
new file mode 100644
index 00000000..eef768ca
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_parkstats.php
@@ -0,0 +1,396 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1717 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select distinct channel_group from park_log;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$groups_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $groups_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Park Stats\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A GROUP AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Park Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(parked_sec) from park_log where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls taken in this Group:              $TOTALcalls\n";
+echo "Average Hold Time(seconds) for all Calls:     $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(parked_sec) from park_log where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Dropped Calls:                          $DROPcalls  $DROPpercent%\n";
+echo "Average Hold Time(seconds) for Dropped Calls: $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select park_log.user,full_name,count(*),sum(talked_sec),avg(talked_sec) from park_log,vicidial_users where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and park_log.user is not null and talked_sec is not null and talked_sec > 4 and park_log.user=vicidial_users.user group by park_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:00:00' and parked_time <= '$query_date $h:14:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:00:00' and parked_time <= '$query_date $h:14:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:15:00' and parked_time <= '$query_date $h:29:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:15:00' and parked_time <= '$query_date $h:29:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:30:00' and parked_time <= '$query_date $h:44:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:30:00' and parked_time <= '$query_date $h:44:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:45:00' and parked_time <= '$query_date $h:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:45:00' and parked_time <= '$query_date $h:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_server_performance.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_server_performance.php new file mode 100644 index 00000000..fdedb9d9 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_server_performance.php @@ -0,0 +1,310 @@ + LICENSE: GPLv2 +# +# CHANGES +# +# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +# path from root to where ploticus files will be stored +$DOCroot = "$WeBServeRRooT/vicidial/ploticus/"; + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($group)) {$group = '';} + +$stmt="select server_ip from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Server Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "             REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:32:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:32:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Server Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$HIGHload =	sprintf("%10s", $row[0]);
+$HIGHmulti = intval($HIGHload / 100);
+#$HIGHmulti = ($HIGHload / 100);
+
+$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$USEDram =	sprintf("%10s", $row[0]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average channels in use for server:       $AVGchannels\n";
+echo "Average load for server:                  $AVGload\n";
+echo "Peak load for server:                     $HIGHload\n";
+#echo "Peak used memory for server (in MB):      $USEDram\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 14 7\n";
+$HTMcontent .= "xscaletype: time hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHload\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc 30 minutes\n";
+$HTMcontent .= "minorticinc: 5 minutes\n";
+$HTMcontent .= "stubformat: hh:mm:ssa\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-2 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDAD.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDAD.php new file mode 100644 index 00000000..52efd9cc --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDAD.php @@ -0,0 +1,255 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Agents Time On Calls                         $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL    | STATUS | START TIME          | MINUTES |\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	$agentcount=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED",$row[4]))
+			{
+			$row[3]='';
+			$row[5]=' - WAITING - ';
+			$row[6]=$row[7];
+			}
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$sessionid =		sprintf("%-9s", $row[2]);
+		$channel =			sprintf("%-10s", $row[3]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[4]);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 5) {$G=''; $EG='';}
+		if ($call_time_M_int >= 10) {$G=''; $EG='';}
+		if (eregi("PAUSED",$row[4])) 
+			{
+			if ($call_time_M_int >= 1) 
+				{$i++; continue;} 
+			else
+				{$G=''; $EG='';}
+			}
+
+		$agentcount++;
+		echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+		echo "  $agentcount agents logged in on server $server_ip\n\n";
+
+		echo "             - Paused agents\n";
+		echo "             - 5 minutes or more on call\n";
+		echo "             - Over 10 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+echo "| CHANNEL    | STATUS | CAMPAIGN | PHONE NUMBER       | START TIME          | MINUTES |\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-8s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+		echo "  $i calls being placed on server $server_ip\n\n";
+
+		echo "             - LIVE CALL WAITING\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "******************************* NO LIVE CALLS WAITING *********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDAD_closer.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDAD_closer.php new file mode 100644 index 00000000..eb7d3c39 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDAD_closer.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Agents Time On Calls                         $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPAIGN     | FRONT  |\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED|CLOSER",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WAIT -';
+			$row[6]=$row[7];
+			}
+		$extension[$i] =		sprintf("%-10s", $row[0]);
+		$user[$i] =				sprintf("%-6s", $row[1]);
+		$sessionid[$i] =		sprintf("%-9s", $row[2]);
+		$channel[$i] =			sprintf("%-19s", $row[3]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $row[4]);
+		$start_time[$i] =		sprintf("%-8s", $row[5]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$row[8];
+		$lead_id[$i] =			$row[9];
+		$closer[$i] =			$row[1];
+		$call_time_S[$i] = ($STARTtime - $row[6]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+		$i++;
+		}
+		$ext_count = $i;
+		$i=0;
+	while ($i < $ext_count)
+		{
+
+		$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$camp_to_print = mysql_num_rows($rslt);
+		if ($camp_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$campaign = sprintf("%-12s", $row[0]);
+			$camp_color = $row[0];
+			}
+		else
+			{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+		if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+			{$campaign = '            ';   	$camp_color = '';}
+
+		$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$xfer_to_print = mysql_num_rows($rslt);
+		if ($xfer_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$fronter = sprintf("%-6s", $row[0]);
+			}
+		else
+			{$fronter = '      ';}
+
+		$G = '';		$EG = '';
+		$G=""; $EG='';
+	#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+	#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+		echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i agents logged in on server $server_ip\n\n";
+
+	#	echo "             - 5 minutes or more on call\n";
+	#	echo "             - Over 10 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPAIGN     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i calls being placed on server $server_ip\n\n";
+
+		echo "             - LIVE CALL WAITING\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "******************************* NO LIVE CALLS WAITING *********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDADall.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDADall.php new file mode 100644 index 00000000..540a5eb6 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDADall.php @@ -0,0 +1,349 @@ + LICENSE: GPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($group)) {$group='';} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Campaign: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Campaign: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFY | REPORTS \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo " NO LIVE CALLS WAITING \n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n\n"; + + $Aecho .= " - Paused agents\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS \n";
+	}
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDADall_SIPmonitor.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDADall_SIPmonitor.php new file mode 100644 index 00000000..0b24f82e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonVDADall_SIPmonitor.php @@ -0,0 +1,301 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala +# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];} +$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];} +$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];} +$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];} +$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];} +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!$RR) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VF DIALER: Time On VDAD Campaign: $group\n"; +echo "
\n"; +echo "VF DIALER: Realtime Campaign: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFY | REPORTS \n"; +echo "\n\n"; + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); + +echo "
"; +echo "DIAL LEVEL: $row[0]         "; +echo "STATUSES: $row[1], $row[2], $row[3], $row[4], $row[5]         "; +echo "ORDER: $row[6]"; +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";} +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo " NO LIVE CALLS WAITING \n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VF DIALER: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + $sessionid = trim($sessionid); + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n"; + + + $Aecho .= " - Paused agents\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS \n";
+	}
+
+?>
+
+ + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_timeoncall.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeoncall.php new file mode 100644 index 00000000..fc8eeced --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeoncall.php @@ -0,0 +1,180 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Call\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Call                                          $NOW_TIME\n\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+echo "| STATION    | SESSIONID | CHANNEL   | NUMBER DIALED    | START TIME          | MINUTES |\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+
+$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="select extension from live_channels where server_ip='$server_ip';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$ext_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_zap_counter=0;
+	$sessions = '';
+	while ($i < $ext_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if (preg_match("/^8600/i",$row[0]))
+			{
+			$sessions .= "$row[0]|";
+			}
+		$i++;
+		}
+	$sessions = preg_replace("/\|$/",'',$sessions);
+
+	if ($DB) {echo "SESSIONS: -$sessions-\n";}
+
+	$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_calls_counter=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
+			{
+			if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
+			$session_id = '';
+			}
+		else 
+			{
+			if (preg_match("/$row[3]/i",$sessions))
+				{
+				if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
+				$session_id = $row[3];
+				$station = preg_replace("/SIP\//",'',$row[0]);
+				$station = preg_replace("/-.*/",'',$station);
+			
+				$LIVE_sessions[$live_calls_counter] =			"$session_id";
+				$LIVE_sessions_FORMAT[$live_calls_counter] =	sprintf("%-9s", $session_id);
+				$LIVE_stations[$live_calls_counter] =			"$station";
+				$LIVE_stations_FORMAT[$live_calls_counter] =	sprintf("%-10s", $station);
+
+		#		echo "| $station | $session_id | \n";
+
+				$live_calls_counter++;
+				}
+			else
+				{
+				if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
+				$session_id = '';
+				}
+			}
+
+		$i++;
+		}
+
+		if ($live_calls_counter > 0)
+		{
+		$i=0;
+		$LC_counter = $live_calls_counter;
+
+		while ($i < $live_calls_counter)
+			{
+			$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$parked_to_print = mysql_num_rows($rslt);
+			$row=mysql_fetch_row($rslt);
+
+			$channel =			sprintf("%-9s", $row[0]);
+			$number_dialed =	sprintf("%-16s", $row[2]);
+			$start_time =		sprintf("%-19s", $row[3]);
+			$call_time_S = ($STARTtime - $row[4]);
+
+			$call_time_M = ($call_time_S / 60);
+			$call_time_M = round($call_time_M, 2);
+			$call_time_M_int = intval("$call_time_M");
+			$call_time_SEC = ($call_time_M - $call_time_M_int);
+			$call_time_SEC = ($call_time_SEC * 60);
+			$call_time_SEC = round($call_time_SEC, 0);
+			if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+			$call_time_MS = "$call_time_M_int:$call_time_SEC";
+			$call_time_MS =		sprintf("%7s", $call_time_MS);
+			$G = '';		$EG = '';
+			if ($call_time_M_int >= 12) {$G=''; $EG='';}
+			if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+			echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+			$i++;
+			}
+
+		echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+		echo "  $i stations on live calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on live call\n";
+		echo "             - Over 30 minutes on live call\n";
+
+		}
+		else
+		{
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*************************************** NO LIVE STATIONS ********************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		}
+
+	}
+	else
+	{
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*************************************** NO LIVE STATIONS ********************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	}
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonpark.php b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonpark.php new file mode 100644 index 00000000..2bc03bb1 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/AST_timeonpark.php @@ -0,0 +1,197 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park                       $NOW_TIME\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "******************** NO LIVE CALLS WAITING *********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/admin-old.php b/agc_2-X/trunk/LANG_admin/vicidial/admin-old.php new file mode 100644 index 00000000..2adf48f2 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/admin-old.php @@ -0,0 +1,2289 @@ +0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN: "; + +if ($ADD==1) {echo "Add New User";} +if ($ADD==11) {echo "Add New Campaign";} +if ($ADD==111) {echo "Add New List";} +if ($ADD==1111) {echo "Add New In-Group";} +if ($ADD==11111) {echo "Add New Remote Agents";} +if ($ADD==111111) {echo "Add New Users Group";} +if ($ADD==2) {echo "New User Addition";} +if ($ADD==21) {echo "New Campaign Addition";} +if ($ADD==22) {echo "New Campaign Status Addition";} +if ($ADD==211) {echo "New List Addition";} +if ($ADD==2111) {echo "New In-Group Addition";} +if ($ADD==21111) {echo "New Remote Agents Addition";} +if ($ADD==211111) {echo "New Users Group Addition";} +if ($ADD==3) {echo "Modify User";} +if ($ADD==31) {echo "Modify Campaign";} +if ($ADD==311) {echo "Modify List";} +if ($ADD==3111) {echo "Modify In-Group";} +if ($ADD==31111) {echo "Modify Remote Agents";} +if ($ADD==311111) {echo "Modify Users Groups";} +if ($ADD==4) {echo "Modify User";} +if ($ADD==41) {echo "Modify Campaign";} +if ($ADD==42) {echo "Modify Campaign Status";} +if ($ADD==411) {echo "Modify List";} +if ($ADD==4111) {echo "Modify In-Group";} +if ($ADD==41111) {echo "Modify Remote Agents";} +if ($ADD==411111) {echo "Modify Users Group";} +if ($ADD==0) {echo "Welcome";} +if ($ADD==10) {echo "Campaigns";} +if ($ADD==100) {echo "Lists";} +if ($ADD==1000) {echo "In-Groups";} +if ($ADD==10000) {echo "Remote Agents";} +if ($ADD==100000) {echo "User Groups";} +if ($ADD==5) {echo "Search Form";} +if ($ADD==6) {echo "Search Results";} +if ($ADD==99999) {echo "HELP";} + +if ( (strlen($ADD)>4) && ($ADD < 99998) ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rsltx=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rsltx); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rsltx=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rsltx); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<50) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
VICIDIAL ADMIN: HELP


\n"; + +?> +VICIDIAL_USERS TABLE

+ +
+User ID - This field is where you put the VICIDIAL user's ID number, can be up to 8 digits in length, Must be at least 2 characters in length. + +
+
+
+Password - This field is where you put the VICIDIAL user's password. Must be at least 2 characters in length. + +
+
+
+Full Name - This field is where you put the VICIDIAL user's full name. Must be at least 2 characters in length. + +
+
+
+User Level - This menu is where you select the VICIDIAL user's user level. Must be a level of 1 to log into VICIDIAL, Must be level greater than 2 to log in as a closer, Must be user level 8 or greater to get into admin web section. + +
+
+
+User Group - This menu is where you select the VICIDIAL user's group that this user will belong to. This does not have any restrictions at this time, this is just to subdivide users and allow for future features based upon it. + + +



+ +VICIDIAL_CAMPAIGNS TABLE

+
+
+Campaign ID - This is the short name of the campaign, it is not editable after initial submission, cannot contain spaces and must be between 2 and 8 characters in length. + +
+
+
+Campaign Name - This is the description of the campaign, it must be between 6 and 40 characters in length. + +
+
+
+Active - This is where you set the campaign to Active or Inactive. If Inactive, noone can log into it. + +
+
+
+Park Extension - This is where you can customize the on-hold music for VICIDIAL. Make sure the extension is in place in the extensions.conf and that it points to the filename below. + +
+
+
+Park File Name - This is where you can customize the on-hold music for VICIDIAL. Make sure the filename is 10 characters in length or less and that the file is in place in the /var/lib/asterisk/sounds directory. + +
+
+
+Web Form - This is where you can set the custom web page that will be opened when the user clicks on the WEB FORM button. + +
+
+
+Allow Closers - This is where you can set whether the users of this campaign will have the option to send the call to a closer. + +
+
+
+Dial Status - This is where you set the statuses that you are wanting to dial on within the lists that are active for the campaign below + +
+
+
+List Order - This menu is where you select how the leads(that match the statuses selected above) will be put in the lead hopper: +
  - DOWN: select the first leads loaded into the vicidial_list table +
  - UP: select the last leads loaded into the vicidial_list table +
  - UP PHONE: select the highest phone number and works it's way down +
  - DOWN PHONE: select the lowest phone number and works it's way up +
  - UP LAST NAME: starts with last names starting with Z and works it's way down +
  - DOWN LAST NAME: starts with last names starting with A and works it's way up +
  - UP COUNT: starts with most called leads and works its way down +
  - DOWN COUNT: starts with least called leads and works it's way up +
  - DOWN COUNT 2nd NEW: starts with least called leads and works it's way up inserting a NEW lead in every other lead(Must NOT have NEW selected in the dial statuses) +
  - DOWN COUNT 3nd NEW: starts with least called leads and works it's way up inserting a NEW lead in every third lead(Must NOT have NEW selected in the dial statuses) +
  - DOWN COUNT 4th NEW: starts with least called leads and works it's way up inserting a NEW lead in every forth lead(Must NOT have NEW selected in the dial statuses) + +
+
+
+Hopper Level - This is how many leads the VDhopper script tries to keep in the vicidial_hopper table for this campaign. If running VDhopper script every minute, make this slightly greater than the number of leads you go through in a minute. + +
+
+
+Force Reset of Hopper - This allows you to wipe out the hopper contents upon form submission. It should be filled again when the VDhopper script runs. + +
+
+
+Auto Dial Level - This is where you set how many lines VICIDIAL should use per active agent. zero (0) means auto dialing is off and the agents will click to dial each number. Otherwise VICIDIAL will keep dialing lines equal to active agents multiplied by the dial level to arrive at how many lines this campaign on each server should allow. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. + +
+
+
+Local Call Time - This is where you set during which hours you would like to dial, as determined by the local time in the are in which you are calling. This is controlled by area code and is adjusted for Daylight Savings time if applicable. General Guidelines in the USA for Business to Business is 9am to 5pm and Business to Consumer calls is 9am to 9pm. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Dial Timeout - If defined, calls that would normally hangup after the timeout defined in extensions.conf would instead timeout at this amount of seconds if it is less than the extensions.conf timeout. This allows for quickly changing dial timeouts from server to server and limiting the effects to a single campaign. If you are having a lot of Answering Machine or Voicemail calls you may want to try changing this value to between 21-26 and see if results improve. + +
+
+
+Dial Prefix - This field allows for more easily changing a path of dialing to go out through a different method without doing a reload in Asterisk. Default is 9 based upon a 91NXXNXXXXXX in the dialplan(extensions.conf). + +
+
+
+Campaign CallerID - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. This option is only available if you are using PRIs(ISDN T1s or E1s) that have the custom callerid feature turned on. This feature may also work with IAX2 trunks depending on what your provider allows. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Campaign VDAD extension - This field allows for a custom VDAD transfer extension. This allows you to use different VDADtransfer...agi scripts depending upon your campaign. The default transfer AGI(exten 8365 [agi-VDADtransfer.agi]) just immediately sends the calls on to agents as soon as they are picked up. An additional sample political survey AGI is also now included (8366 [agi-VDADtransferSURVEY.agi]) that plays a message to the called person and allows them to make a choice by pressing buttons(effectively pre-screening the lead). Please note that except for surveys, political calls and charities this form of calling is illegal in the United States. + + +



+ +VICIDIAL_LISTS TABLE

+
+
+List ID - This is the numerical name of the list, it is not editable after initial submission, must contain only numbers and must be between 2 and 8 characters in length. + +
+
+
+List Name - This is the description of the list, it must be between 2 and 20 characters in length. + +
+
+
+Campaign - This is the campaign that this list belongs to. A list can only be dialed on a single campaign at one time. + +
+
+
+Active - This defines whether the list is to be dialed on or not. + +
+
+
+Reset Lead-Called-Status for this list - This resets all leads in this list to N for "not called since last reset" and means that any lead can now be called if it is the right status as defined in the campaign screen. + + +



+ +VICIDIAL_INBOUND_GROUPS TABLE

+
+
+Group ID - This is the short name of the inbound group, it is not editable after initial submission, must not contain any spaces and must be between 2 and 20 characters in length. + +
+
+
+Group Name - This is the description of the group, it must be between 2 and 30 characters in length. Cannot include dashes '-', plusses '+' or spaces ' '. + +
+
+
+Group Color - This is the color that displays in the VICIDIAL client app when a call comes in on this group. It must be between 2 and 7 characters long. If this is a hex color definition you must remember to put a # at the beginning of the string or VICIDIAL will not work properly. + +
+
+
+Active - This determines whether this group show up in the selection box when a VICIDIAL agent logs in. + +
+
+
+Web Form - This is the custom address that clicking on the WEB FORM button in VICIDIAL will take you to for calls that come in on this group. + +
+
+
+Voicemail - If defined, this is the Voicemail box that calls will go to instead of being dropped if no agents are available after the hold time is up. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. + +
+
+
+Fronter Display - This field determines whether the inbound VICIDIAL agent would have the fronter name(if there is one) displayed in the Status field when the call comes to the agent. + + + +



+ +VICIDIAL_REMOTE_AGENTS TABLE

+
+
+User ID Start - This is the starting User ID that is used when the remote agent entries are inserted into the system. If the Number of Lines is set higher than 1, this number is incremented by one until each line has an entry. Make sure you create a new VICIDIAL user account with a user level of 4 or great if you want them to be able to use the vdremote.php page for remote web access of this account. + +
+
+
+Number of Lines - This defines how many remote agent entries the system creates, and determines how many lines it thinks it can safely send to the number below. + +
+
+
+Server IP - A remote agent entry is only good for one specific server, here is where you select which server you want. + +
+
+
+External Extension - This is the number that you want the calls forwarded to. Make sure that it is a full dialplan number and that if you need a 9 at the beginning you put it in here. Test by dialing this number from a phone on the system. + +
+
+
+Status - Here is where you turn the remote agent on and off. As soon as the agent is Active the system assumes that it can send calls to it. It may take up to 30 seconds once you change the status to Inactive to stop receiving calls. + +
+
+
+Campaign - Here is where you select the campaign that these remote agents will be logged into. Inbound needs to use the CLOSER campaign and select the inbound campaigns below that you want to receive calls from. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + + +



+ +VICIDIAL_CAMPAIGN_LISTS

+
+
+The lists within this campaign are listed here, whether they are active is denoted by the Y or N and you can go to the list screen by clicking on the list ID in the first column. + + +



+ +VICIDIAL_CAMPAIGN_STATUSES TABLE

+
+
+Through the use of Custom campaign statuses, you can have statuses that only exist for a specific campaign. The Status must be 1-8 characters in length, the description must be 2-30 characters in length and Selectable defines whether it shows up in VICIDIAL as a disposition. + + + + + +



+ +VICIDIAL_USER_GROUPS TABLE

+
+
+User Group - This is the short name of a Vicidial User group, try not to use any spaces or punctuation for this field. max 20 characters, minimum of 2 characters. + +
+
+
+Group Name - This is the description of the vicidial user group max of 40 characters. + + + + + +



+ +VICIDIAL LIST LOADER FUNCTIONALITY

+
+
+The VICIDIAL web-based lead loader is designed simply to take a lead file(up to 8MB in size) that is either tab or pipe delimited and load it into the vicidial_list table. The lead loader does not do data validation or check for duplicates in itself or other lists, so that is something you need to do before you load the leads. Also, make sure that you have created the list that these leads are to be under so that you can use them. There is also the matter of time-zone-coding these leads. You may want to increase the frequency that the ADMIN_adjust_GMTnow_on_leads.pl is being run in the cron on your Asterisk server so that any loaded leads can be coded faster. Here is a list of the fields in their proper order for the lead files: +
    +
  1. Vendor Lead Code - shows up in the Vendor ID field of the GUI +
  2. Source Code - internal use only for admins and DBAs +
  3. List ID - the list number that these leads will show up under +
  4. Phone Code - the prefix for the phone number(1 for US, 01144 for UK, 01161 for AUS, etc) +
  5. Phone Number - must be at least 8 digits long +
  6. Title - title of the customer(Mr. Ms. Mrs, etc...) +
  7. First Name +
  8. Middle Initial +
  9. Last Name +
  10. Address Line 1 +
  11. Address Line 2 +
  12. Address Line 3 +
  13. City +
  14. State - limited to 2 characters +
  15. Province +
  16. Postal Code +
  17. Country +
  18. Gender +
  19. Date of Birth +
  20. Alternate Phone Number +
  21. Email Address +
  22. Security Phrase +
  23. Comments +
+ + + +







+







+THE END +
+ + + + + +
+ + + + + + + +
  VICIDIAL ADMIN - Logout  
  LIST USERS | ADD NEW USER | SEARCH FOR A USER | ADD USER GROUP | LIST USER GROUPS
  ADD CAMPAIGN | LIST CAMPAIGNS | SHOW LISTS | ADD NEW LIST |               | LOAD NEW LEADS
  SHOW IN-GROUPS | ADD NEW IN-GROUP | SHOW REMOTE AGENTS | ADD NEW REMOTE AGENTS
  SERVER STATS | PARK REPORT | VDAD REPORT | CLOSER REPORT |               | SEARCH FOR A LEAD | GROUP HOURLY
+"; + +echo "
ADD A NEW USER
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User Number: $NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group: $NWB#vicidial_users-user_group$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
ADD A NEW CAMPAIGN\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
Campaign ID: $NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $NWB#vicidial_campaigns-park_ext$NWE
Park Filename: $NWB#vicidial_campaigns-park_file_name$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: (digits only)$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo ""; + +echo "
ADD A NEW INBOUND GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group ID: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo ""; + +echo "
ADD NEW REMOTE AGENTS\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo ""; + +echo "
ADD NEW USERS GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new person to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER NOT ADDED - there is already a user in the system with this user number\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
USER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
user id must be between 2 and 8 characters long\n"; + echo "
full name and password must be at least 2 characters long\n"; + } + else + { + echo "
USER ADDED: $user\n"; + + $stmt="INSERT INTO vicidial_users values('','$user','$pass','$full_name','$user_level','$user_group');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level'|\n"); + fclose($fp); + } + } +$ADD=0; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
CAMPAIGN NOT ADDED - Please go back and look at the data you entered\n"; + echo "
campaign ID must be between 2 and 8 characters in length\n"; + echo "
campaign name must be between 6 and 40 characters in length\n"; + } + else + { + echo "
CAMPAIGN ADDED: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns values('$campaign_id','$campaign_name','$active','','','','','','DOWN','$park_ext','$park_file_name','$web_form_address','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','','','','');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN |$PHP_AUTH_USER|$ip|'$campaign_id','$campaign_name','$active','','','','','','DOWN','$park_ext','$park_file_name','$web_form_address','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','','','',''|\n"); + fclose($fp); + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 8 characters in length\n"; + echo "
status name must be between 2 and 30 characters in length\n"; + } + else + { + echo "
CAMPAIGN STATUS ADDED: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LIST NOT ADDED - there is already a list in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
LIST NOT ADDED - Please go back and look at the data you entered\n"; + echo "
List ID must be between 2 and 8 characters in length\n"; + echo "
List name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST ADDED: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GROUP NOT ADDED - there is already a group in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi('-',$group_id)) or (eregi('+',$group_id)) ) + { + echo "
GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group ID must be between 2 and 20 characters in length and contain no ' -+'.\n"; + echo "
Group name and group color must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups values('$group_id','$group_name','$group_color','$active','$web_form_address','$voicemail_ext','$next_agent_call','$fronter_display');"; + $rslt=mysql_query($stmt, $link); + + echo "
GROUP ADDED: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|'$group_id','$group_name','$group_color','$active','$web_form_address','$voicemail_ext','$next_agent_call','$fronter_display'|\n"); + fclose($fp); + + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
REMOTE AGENTS NOT ADDED - there is already a remote agents entry starting with this userID\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
User ID start and external extension must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER GROUP NOT ADDED - there is already a user group entry with this name\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW USER GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + + } + } +$ADD=100000; +} + + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group' where user='$user'|\n"); + fclose($fp); + + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmt="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten' where campaign_id='$campaign_id'|$reset_hopper|\n"); + fclose($fp); + + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN STATUS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN STATUS DELETED: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LIST NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
list name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST MODIFIED: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
RESETTING LIST-CALLED-STATUS\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + if ($campaign_id != "$old_campaign_id") + { + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
group name and group color must be at least 2 characters in length\n"; + } + else + { + echo "
GROUP MODIFIED: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='$web_form_address', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|group_name='$group_name',group_color='$group_color',active='$active', web_form_address='$web_form_address', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display' where group_id='$group_id'|\n"); + fclose($fp); + + } + +$ADD=3111; # go to group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
User ID Start and External Extension must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + + } + +$ADD=311111; # go to user group modification form below +} + + + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[5]; + +echo "
MODIFY A USER'S RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User Number: $row[1]$NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group: $NWB#vicidial_users-user_group$NWE
\n"; + +echo "

Click here for user stats\n"; + +} + + +###################### +# ADD=31 modify campaign info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Web Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Dial Timeout: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Dial Prefix: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
Campaign CallerID: $NWB#vicidial_campaigns-campaign_cid$NWE
Campaign VDAD exten: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
\n"; + + ##### calculate what gmt_offset_now values are within the allowed local_call_time setting + if ($local_call_time == '24hours') + { + $p='13'; + $GMT_allowed = ''; + while ($p > -13) + { + $tz = sprintf("%.2f", $p); $GMT_allowed = "$GMT_allowed'$tz',"; + $p = ($p - 0.25); + } + } + if ($local_call_time == '9am-9pm') + { + $p='13'; + $GMT_allowed = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $phour=gmdate("G", time() + $pzone); + if ( ($phour >= 9) && ($phour <= 20) ){$tz = sprintf("%.2f", $p); $GMT_allowed = "$GMT_allowed'$tz',";} + $p = ($p - 0.25); + } + } + if ($local_call_time == '9am-5pm') + { + $p='13'; + $GMT_allowed = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $phour=gmdate("G", time() + $pzone); + if ( ($phour >= 9) && ($phour <= 16) ){$tz = sprintf("%.2f", $p); $GMT_allowed = "$GMT_allowed'$tz',";} + $p = ($p - 0.25); + } + } + if ($local_call_time == '12pm-5pm') + { + $p='13'; + $GMT_allowed = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $phour=gmdate("G", time() + $pzone); + if ( ($phour >= 12) && ($phour <= 16) ){$tz = sprintf("%.2f", $p); $GMT_allowed = "$GMT_allowed'$tz',";} + $p = ($p - 0.25); + } + } + if ($local_call_time == '12pm-9pm') + { + $p='13'; + $GMT_allowed = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $phour=gmdate("G", time() + $pzone); + if ( ($phour >= 12) && ($phour <= 20) ){$tz = sprintf("%.2f", $p); $GMT_allowed = "$GMT_allowed'$tz',";} + $p = ($p - 0.25); + } + } + if ($local_call_time == '5pm-9pm') + { + $p='13'; + $GMT_allowed = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $phour=gmdate("G", time() + $pzone); + if ( ($phour >= 17) && ($phour <= 20) ){$tz = sprintf("%.2f", $p); $GMT_allowed = "$GMT_allowed'$tz',";} + $p = ($p - 0.25); + } + } + + $GMT_allowed = "$GMT_allowed'99'"; + + + + + + + + + + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and gmt_offset_now IN($GMT_allowed)"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rsltx_rows = mysql_num_rows($rsltx); + if ($rsltx_rows) + { + $rowx=mysql_fetch_row($rsltx); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + +echo "This campaign has $active_leads leads to be dialed in those lists

\n"; + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
CUSTOM STATUSES WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rsltx=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rsltx); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
STATUSDESCRIPTIONSELECTABLEDELETE
$rowx[0]$rowx[1]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN STATUS
\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Description:   \n"; +echo "Selectable:   \n"; +echo "
\n"; + +echo "

\n"; + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + +echo "
MODIFY A LIST'S RECORD: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: $row[0]$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
Reset Lead-Called-Status for this list: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
STATUSES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + $rsltx=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rsltx); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $leads_in_list = ($leads_in_list + $rowx[2]); + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($rowx[1] == 'N') + { + $leads_in_list_N = ($leads_in_list_N + $rowx[2]); + echo "\n"; + } + else + { + $leads_in_list_Y = ($leads_in_list_Y + $rowx[2]); + echo "\n"; + + } + + $o++; + } + +echo "\n"; +echo "\n"; + +echo "
STATUSCALLEDNOT CALLED
$rowx[0] $rowx[2]
$rowx[0]$rowx[2]
SUBTOTALS$leads_in_list_Y$leads_in_list_N
TOTAL$leads_in_list

\n"; + + + + + +echo "
\n"; +echo "
TIME ZONES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rsltx=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rsltx); + + $o=0; + $plus='+'; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $leads_in_list = ($leads_in_list + $rowx[2]); + + $LOCALzone=3600 * $rowx[0]; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($rowx[0] >= 0) {$rowx[0] = "$plus$rowx[0]";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($rowx[1] == 'N') + { + $leads_in_list_N = ($leads_in_list_N + $rowx[2]); + echo "\n"; + } + else + { + $leads_in_list_Y = ($leads_in_list_Y + $rowx[2]); + echo "\n"; + + } + + $o++; + } + +echo "\n"; +echo "\n"; + +echo "
GMT OFFSET NOW (local time)CALLEDNOT CALLED
$rowx[0]     ($LOCALdate) $rowx[2]
$rowx[0]     ($LOCALdate)$rowx[2]
SUBTOTALS$leads_in_list_Y$leads_in_list_N
TOTAL$leads_in_list

\n"; + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rsltx=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rsltx); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
CALLED COUNTS WITHIN THIS LIST:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$status[$sts]") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + echo ""; + $first++; + } +echo "\n"; + +echo "
STATUS$firstSUBTOTAL
$status[$sts] $count_count[$o]  $leads_in_sts[$sts]
TOTAL$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + +echo "
MODIFY A GROUP'S RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
Group ID: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
MODIFY A USERS GROUP ENTRY\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + + + + + + + +###################### +# ADD=5 search form +###################### + +if ($ADD==5) +{ +echo ""; + +echo "
SEARCH FOR A USER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User Number:
Full Name:
User Level:
User Group:
\n"; + +} + +###################### +# ADD=6 user search results +###################### + +if ($ADD==6) +{ + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group LIKE \"%$user_group%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS
\n"; + +} + + + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
LIST LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  MODIFY
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
INBOUND GROUP LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  MODIFY
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
REMOTE AGENTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]MODIFY
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER GROUPS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/admin.php b/agc_2-X/trunk/LANG_admin/vicidial/admin.php new file mode 100644 index 00000000..e296c40c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/admin.php @@ -0,0 +1,6514 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["safe_harbor_message"])) {$safe_harbor_message=$_GET["safe_harbor_message"];} + elseif (isset($_POST["safe_harbor_message"])) {$safe_harbor_message=$_POST["safe_harbor_message"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_message"])) {$drop_message=$_GET["drop_message"];} + elseif (isset($_POST["drop_message"])) {$drop_message=$_POST["drop_message"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS ONLY ### +$user_level = ereg_replace("[^0-9]","",$user_level); +$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); +$xferconf_a_number = ereg_replace("[^0-9]","",$xferconf_a_number); +$xferconf_b_number = ereg_replace("[^0-9]","",$xferconf_b_number); +$drop_call_seconds = ereg_replace("[^0-9]","",$drop_call_seconds); +$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); +$safe_harbor_exten = ereg_replace("[^0-9]","",$safe_harbor_exten); +$am_message_exten = ereg_replace("[^0-9]","",$am_message_exten); +$campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); +$campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); +$drop_exten = ereg_replace("[^0-9]","",$drop_exten); +$dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); +$park_ext = ereg_replace("[^0-9]","",$park_ext); +$hopper_level = ereg_replace("[^0-9]","",$hopper_level); +$agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); +$hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); +$agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); +$agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); +$vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); +$vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); +$closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); +$alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); +$delete_users = ereg_replace("[^0-9]","",$delete_users); +$delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); +$delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); +$delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); +$delete_lists = ereg_replace("[^0-9]","",$delete_lists); +$delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); +$delete_filters = ereg_replace("[^0-9]","",$delete_filters); +$delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); +$delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); +$load_leads = ereg_replace("[^0-9]","",$delete_call_times); +$campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); +$ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); +$ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); +$modify_leads = ereg_replace("[^0-9]","",$modify_leads); +$change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); +$modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); +$ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); +$ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); +$ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); +$ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); +$ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); +$ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); +$ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); +$ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); +$ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); +$ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); +$ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); +$ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); +$ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); +$ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); +$ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); +$ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); +$number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); +$user_start = ereg_replace("[^0-9]","",$user_start); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +$remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); +$attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); +$hotkey = ereg_replace("[^0-9]","",$hotkey); +$list_id = ereg_replace("[^0-9]","",$list_id); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); +$allow_closers = ereg_replace("[^NY]","",$allow_closers); +$reset_hopper = ereg_replace("[^NY]","",$reset_hopper); +$amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); +$alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); +$safe_harbor_message = ereg_replace("[^NY]","",$safe_harbor_message); +$selectable = ereg_replace("[^NY]","",$selectable); +$reset_list = ereg_replace("[^NY]","",$reset_list); +$fronter_display = ereg_replace("[^NY]","",$fronter_display); +$drop_message = ereg_replace("[^NY]","",$drop_message); +$use_internal_dnc = ereg_replace("[^NY]","",$use_internal_dnc); + +### ALPHA-NUMERIC ONLY ### +$user = ereg_replace("[^0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^0-9a-zA-Z]","",$pass); +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); +$submit = ereg_replace("[^0-9a-zA-Z]","",$submit); +$CoNfIrM = ereg_replace("[^0-9a-zA-Z]","",$CoNfIrM); +$campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); +$get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); +$campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); +$ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); +$dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); +$state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); +$scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + +### DIGITS and Dots +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + +### DIGITS and spaces and hash and star and comma +$xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_a_dtmf); +$xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_b_dtmf); + +### ALPHA-NUMERIC and underscore and dash +$dial_status_e = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_e); +$dial_status_d = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_d); +$dial_status_c = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_c); +$dial_status_b = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_b); +$dial_status_a = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_a); +$stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); +$lead_filter_id = ereg_replace("[^-\_0-9a-zA-Z]","",$lead_filter_id); +$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); +$old_campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_campaign_id); +$park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); +$next_agent_call = ereg_replace("[^-\_0-9a-zA-Z]","",$next_agent_call); +$local_call_time = ereg_replace("[^-\_0-9a-zA-Z]","",$local_call_time); +$call_time_id = ereg_replace("[^-\_0-9a-zA-Z]","",$call_time_id); +$phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); +$phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); +$group_id = ereg_replace("[^-\_0-9a-zA-Z]","",$group_id); +$user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$user_group); +$OLDuser_group = ereg_replace("[^-\_0-9a-zA-Z]","",$OLDuser_group); +$state_rule = ereg_replace("[^-\_0-9a-zA-Z]","",$state_rule); + +### ALPHA-NUMERIC and spaces +$lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); +### ALPHA-NUMERIC and hash +$group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); +$campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); +$HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); +$status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); +$script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); +$script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); +$list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); +$lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); +$lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); +$campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); +$call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); +$call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + +### remove semi-colons ### +$lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + +### VARIABLES TO BE mysql_real_escape_string ### +# $web_form_address +# $script_text + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# AST GUI database administration +# admin.php +# +# CHANGES +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug +# + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$version = '1.1.12-3'; +$build = '60623-1159'; + +$STARTtime = date("U"); + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGuser_level =$row[4]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD==1) {$hh='users'; echo "Add New User";} +if ($ADD==11) {$hh='campaigns'; echo "Add New Campaign";} +if ($ADD==111) {$hh='lists'; echo "Add New List";} +if ($ADD==121) {$hh='lists'; echo "Add New DNC";} +if ($ADD==1111) {$hh='ingroups'; echo "Add New In-Group";} +if ($ADD==11111) {$hh='remoteagent'; echo "Add New Remote Agents";} +if ($ADD==111111) {$hh='usergroups'; echo "Add New Users Group";} +if ($ADD==1111111) {$hh='scripts'; echo "Add New Script";} +if ($ADD==11111111) {$hh='filters'; echo "Add New Filter";} +if ($ADD==111111111) {$hh='times'; echo "Add New Call Time";} +if ($ADD==1111111111) {$hh='times'; echo "Add New State Call Time";} +if ($ADD==2) {$hh='users'; echo "New User Addition";} +if ($ADD==21) {$hh='campaigns'; echo "New Campaign Addition";} +if ($ADD==22) {$hh='campaigns'; echo "New Campaign Status Addition";} +if ($ADD==23) {$hh='campaigns'; echo "New Campaign HotKey Addition";} +if ($ADD==25) {$hh='campaigns'; echo "New Campaign Lead Recycle Addition";} +if ($ADD==211) {$hh='lists'; echo "New List Addition";} +if ($ADD==2111) {$hh='ingroups'; echo "New In-Group Addition";} +if ($ADD==21111) {$hh='remoteagent'; echo "New Remote Agents Addition";} +if ($ADD==211111) {$hh='usergroups'; echo "New Users Group Addition";} +if ($ADD==2111111) {$hh='scripts'; echo "New Script Addition";} +if ($ADD==21111111) {$hh='filters'; echo "New Filter Addition";} +if ($ADD==211111111) {$hh='times'; echo "New Call Time Addition";} +if ($ADD==2111111111) {$hh='times'; echo "New State Call Time Addition";} +if ($ADD==3) {$hh='users'; echo "Modify User";} +if ($ADD==31) {$hh='campaigns'; echo "Modify Campaign";} +if ($ADD==34) {$hh='campaigns'; echo "Modify Campaign - Basic View";} +if ($ADD==311) {$hh='lists'; echo "Modify List";} +if ($ADD==3111) {$hh='ingroups'; echo "Modify In-Group";} +if ($ADD==31111) {$hh='remoteagent'; echo "Modify Remote Agents";} +if ($ADD==311111) {$hh='usergroups'; echo "Modify Users Groups";} +if ($ADD==3111111) {$hh='scripts'; echo "Modify Script";} +if ($ADD==31111111) {$hh='filters'; echo "Modify Filter";} +if ($ADD==311111111) {$hh='times'; echo "Modify Call Time";} +if ($ADD==321111111) {$hh='times'; echo "Modify Call Time State Definitions List";} +if ($ADD==3111111111) {$hh='times'; echo "Modify State Call Time";} +if ($ADD=="4A") {$hh='users'; echo "Modify User - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Modify User - Admin";} +if ($ADD==4) {$hh='users'; echo "Modify User";} +if ($ADD==41) {$hh='campaigns'; echo "Modify Campaign";} +if ($ADD==42) {$hh='campaigns'; echo "Modify Campaign Status";} +if ($ADD==43) {$hh='campaigns'; echo "Modify Campaign HotKey";} +if ($ADD==44) {$hh='campaigns'; echo "Modify Campaign - Basic View";} +if ($ADD==45) {$hh='campaigns'; echo "Modify Campaign Lead Recycle";} +if ($ADD==411) {$hh='lists'; echo "Modify List";} +if ($ADD==4111) {$hh='ingroups'; echo "Modify In-Group";} +if ($ADD==41111) {$hh='remoteagent'; echo "Modify Remote Agents";} +if ($ADD==411111) {$hh='usergroups'; echo "Modify Users Groups";} +if ($ADD==4111111) {$hh='scripts'; echo "Modify Script";} +if ($ADD==41111111) {$hh='filters'; echo "Modify Filter";} +if ($ADD==411111111) {$hh='times'; echo "Modify Call Time";} +if ($ADD==4111111111) {$hh='times'; echo "Modify State Call Time";} +if ($ADD==5) {$hh='users'; echo "Delete User";} +if ($ADD==51) {$hh='campaigns'; echo "Delete Campaign";} +if ($ADD==52) {$hh='campaigns'; echo "Logout Agents";} +if ($ADD==511) {$hh='lists'; echo "Delete List";} +if ($ADD==5111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==51111) {$hh='remoteagent'; echo "Delete Remote Agents";} +if ($ADD==511111) {$hh='usergroups'; echo "Delete Users Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Delete Script";} +if ($ADD==51111111) {$hh='filters'; echo "Delete Filter";} +if ($ADD==511111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==5111111111) {$hh='times'; echo "Delete State Call Time";} +if ($ADD==6) {$hh='users'; echo "Delete User";} +if ($ADD==61) {$hh='campaigns'; echo "Delete Campaign";} +if ($ADD==62) {$hh='campaigns'; echo "Logout Agents";} +if ($ADD==65) {$hh='campaigns'; echo "Delete Lead Recycle";} +if ($ADD==611) {$hh='lists'; echo "Delete List";} +if ($ADD==6111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==61111) {$hh='remoteagent'; echo "Delete Remote Agents";} +if ($ADD==611111) {$hh='usergroups'; echo "Delete Users Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Delete Script";} +if ($ADD==61111111) {$hh='filters'; echo "Delete Filter";} +if ($ADD==611111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==6111111111) {$hh='times'; echo "Delete State Call Time";} +if ($ADD==73) {$hh='campaigns'; echo "Dialable Lead Count";} +if ($ADD==7111111) {$hh='scripts'; echo "Preview Script";} +if ($ADD==0) {$hh='users'; echo "Users List";} +if ($ADD==8) {$hh='users'; echo "CallBacks Within Agent";} +if ($ADD==81) {$hh='campaigns'; echo "CallBacks Within Campaign";} +if ($ADD==811) {$hh='campaigns'; echo "CallBacks Within List";} +if ($ADD==10) {$hh='campaigns'; echo "Campaigns";} +if ($ADD==100) {$hh='lists'; echo "Lists";} +if ($ADD==1000) {$hh='ingroups'; echo "In-Groups";} +if ($ADD==10000) {$hh='remoteagent'; echo "Remote Agents";} +if ($ADD==100000) {$hh='usergroups'; echo "User Groups";} +if ($ADD==1000000) {$hh='scripts'; echo "Scripts";} +if ($ADD==10000000) {$hh='filters'; echo "Filters";} +if ($ADD==100000000) {$hh='times'; echo "Call Times";} +if ($ADD==1000000000) {$hh='times'; echo "State Call Times";} +if ($ADD==55) {$hh='users'; echo "Search Form";} +if ($ADD==66) {$hh='users'; echo "Search Results";} +if ($ADD==99999) {$hh='users'; echo "HELP";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or ($ADD==21) or ($ADD==31) or ($ADD==41) or ($ADD=="4A") or ($ADD=="4B") ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ($ADD==31) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<100) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
VICIDIAL ADMIN: HELP


\n"; + +?> +VICIDIAL_USERS TABLE

+ +
+User ID - This field is where you put the VICIDIAL users ID number, can be up to 8 digits in length, Must be at least 2 characters in length. + +
+
+
+Password - This field is where you put the VICIDIAL users password. Must be at least 2 characters in length. + +
+
+
+Full Name - This field is where you put the VICIDIAL users full name. Must be at least 2 characters in length. + +
+
+
+User Level - This menu is where you select the VICIDIAL users user level. Must be a level of 1 to log into VICIDIAL, Must be level greater than 2 to log in as a closer, Must be user level 8 or greater to get into admin web section. + +
+
+
+User Group - This menu is where you select the VICIDIAL users group that this user will belong to. This does not have any restrictions at this time, this is just to subdivide users and allow for future features based upon it. + +
+
+
+Phone Login - Here is where you can set a default phone login value for when the user logs into vicidial.php. This value will populate the phone_login automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. + +
+
+
+Phone Pass - Here is where you can set a default phone pass value for when the user logs into vicidial.php. This value will populate the phone_pass automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. + +
+
+
+HotKeys Active - This option if set to 1 allows the user to use the HotKeys quick-dispositioning function in vicidial.php. + +
+
+
+Agent Choose Ingroups - This option if set to 1 allows the user to choose the ingroups that they will receive calls from when they login to a CLOSER or INBOUND campaign. Otherwise the Manager will need to set this in their user detail screen of the admin page. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + +
+
+
+Scheduled Callbacks - This option allows an agent to disposition a call as CALLBK and choose the data and time at which the lead will be re-activated. + +
+
+
+Agent-Only Callbacks - This option allows an agent to set a callback so that they are the only Agent that can call the customer back. This also allows the agent to see their callback listings and call them back any time they want to. + +
+
+
+Agent Call Manual - This option allows an agent to manually enter a new lead into the system and call them. This also allows the calling of any phone number from their vicidial screen and puts that call into their session. Use this option with caution. + +
+
+
+Vicidial Recording - This option can prevent an agent from doing any recordings after they log in to vicidial. This option must be on for vicidial to follow the campaign recording session. + +
+
+
+Vicidial Transfers - This option can prevent an agent from opening the transfer - conference session of vicidial. If this is disabled, the agent cannot third party call or blind transfer any calls. + +
+
+
+Closer Default Blended - This option simply defaults the Blended checkbox on a CLOSER login screen. + +
+
+
+Alter Agent Interface Options - This option if set to 1 allows the administrative user to modify the Agents interface options in admin.php. + +
+
+
+Delete Users - This option if set to 1 allows the user to delete other users of equal or lesser user level from the system. + +
+
+
+Delete User Groups - This option if set to 1 allows the user to delete user groups from the system. + +
+
+
+Delete Lists - This option if set to 1 allows the user to delete vicidial lists from the system. + +
+
+
+Delete Campaigns - This option if set to 1 allows the user to delete vicidial campaigns from the system. + +
+
+
+Delete In-Groups - This option if set to 1 allows the user to delete vicidial In-Groups from the system. + +
+
+
+Delete Remote Agents - This option if set to 1 allows the user to delete vicidial remote agents from the system. + +
+
+
+Load Leads - This option if set to 1 allows the user to load vicidial leads into the vicidial_list table by way of the web based lead loader. + +
+
+
+Campaign Detail - This option if set to 1 allows the user to view and modify the campaign detail screen elements. + +
+
+
+AGC Admin Access - This option if set to 1 allows the user to login to the astGUIclient admin pages. + +
+
+
+AGC Delete Phones - This option if set to 1 allows the user to delete phone entries in the astGUIclient admin pages. + +
+
+
+Delete Scripts - This option if set to 1 allows the user to delete Campaign scripts in the script modification screen. + +
+
+
+Modify Leads - This option if set to 1 allows the user to modify leads in the admin section lead search results page. + +
+
+
+Change Agent Campaign - This option if set to 1 allows the user to alter the campaign that an agent is logged into while they are logged into it. + +
+
+
+Delete Filters - This option allows the user to be able to delete vicidial lead filters from the system. + +
+
+
+Delete Call Times - This option allows the user to be able to delete vicidial call times records and vicidial state call times records from the system. + +
+
+
+Modify Call Times - This option allows the user to view and modify the call times and state call times records. A user doesn't need this option enabled if they only need to change the call times option on the campaigns screen. + + + + +



+ +VICIDIAL_CAMPAIGNS TABLE

+
+
+Campaign ID - This is the short name of the campaign, it is not editable after initial submission, cannot contain spaces and must be between 2 and 8 characters in length. + +
+
+
+Campaign Name - This is the description of the campaign, it must be between 6 and 40 characters in length. + +
+
+
+Active - This is where you set the campaign to Active or Inactive. If Inactive, noone can log into it. + +
+
+
+Park Extension - This is where you can customize the on-hold music for VICIDIAL. Make sure the extension is in place in the extensions.conf and that it points to the filename below. + +
+
+
+Park File Name - This is where you can customize the on-hold music for VICIDIAL. Make sure the filename is 10 characters in length or less and that the file is in place in the /var/lib/asterisk/sounds directory. + +
+
+
+Web Form - This is where you can set the custom web page that will be opened when the user clicks on the WEB FORM button. + +
+
+
+Allow Closers - This is where you can set whether the users of this campaign will have the option to send the call to a closer. + +
+
+
+Dial Status - This is where you set the statuses that you are wanting to dial on within the lists that are active for the campaign below + +
+
+
+List Order - This menu is where you select how the leads that match the statuses selected above will be put in the lead hopper: +
  - DOWN: select the first leads loaded into the vicidial_list table +
  - UP: select the last leads loaded into the vicidial_list table +
  - UP PHONE: select the highest phone number and works its way down +
  - DOWN PHONE: select the lowest phone number and works its way up +
  - UP LAST NAME: starts with last names starting with Z and works its way down +
  - DOWN LAST NAME: starts with last names starting with A and works its way up +
  - UP COUNT: starts with most called leads and works its way down +
  - DOWN COUNT: starts with least called leads and works its way up +
  - DOWN COUNT 2nd NEW: starts with least called leads and works its way up inserting a NEW lead in every other lead - Must NOT have NEW selected in the dial statuses +
  - DOWN COUNT 3nd NEW: starts with least called leads and works its way up inserting a NEW lead in every third lead - Must NOT have NEW selected in the dial statuses +
  - DOWN COUNT 4th NEW: starts with least called leads and works its way up inserting a NEW lead in every forth lead - Must NOT have NEW selected in the dial statuses + +
+
+
+Hopper Level - This is how many leads the VDhopper script tries to keep in the vicidial_hopper table for this campaign. If running VDhopper script every minute, make this slightly greater than the number of leads you go through in a minute. + +
+
+
+Lead Filter - This is a method of filtering your leads using a fragment of a SQL query. Use this feature with caution, it is easy to stop dialing accidentally with the slightest alteration to the SQL statement. Default is NONE. + +
+
+
+Force Reset of Hopper - This allows you to wipe out the hopper contents upon form submission. It should be filled again when the VDhopper script runs. + +
+
+
+Auto Dial Level - This is where you set how many lines VICIDIAL should use per active agent. zero 0 means auto dialing is off and the agents will click to dial each number. Otherwise VICIDIAL will keep dialing lines equal to active agents multiplied by the dial level to arrive at how many lines this campaign on each server should allow. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. +
  - overall_user_level: orders by the user_level of the agent as defined in the vicidial_users table a higher user_level will receive more calls. + +
+
+
+Local Call Time - This is where you set during which hours you would like to dial, as determined by the local time in the are in which you are calling. This is controlled by area code and is adjusted for Daylight Savings time if applicable. General Guidelines in the USA for Business to Business is 9am to 5pm and Business to Consumer calls is 9am to 9pm. + +
+
+
+Dial Timeout - If defined, calls that would normally hangup after the timeout defined in extensions.conf would instead timeout at this amount of seconds if it is less than the extensions.conf timeout. This allows for quickly changing dial timeouts from server to server and limiting the effects to a single campaign. If you are having a lot of Answering Machine or Voicemail calls you may want to try changing this value to between 21-26 and see if results improve. + +
+
+
+Dial Prefix - This field allows for more easily changing a path of dialing to go out through a different method without doing a reload in Asterisk. Default is 9 based upon a 91NXXNXXXXXX in the dialplan - extensions.conf. + +
+
+
+Campaign CallerID - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. If you are using T1 or E1s to dial out this option is only available if you are using PRIs - ISDN T1s or E1s - that have the custom callerid feature turned on, this will not work with Robbed-bit service(RBS) circuits. This will also work through most VOIP(SIP or IAX trunks) providers that allow dynamic outbound callerID. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Campaign VDAD extension - This field allows for a custom VDAD transfer extension. This allows you to use different VDADtransfer...agi scripts depending upon your campaign. The default transfer AGI - exten 8365 agi-VDADtransfer.agi - just immediately sends the calls on to agents as soon as they are picked up. An additional sample political survey AGI is also now included - 8366 agi-VDADtransferSURVEY.agi - that plays a message to the called person and allows them to make a choice by pressing buttons - effectively pre-screening the lead - . Please note that except for surveys, political calls and charities this form of calling is illegal in the United States. + +
+
+
+Campaign Rec extension - This field allows for a custom recording extension to be used with VICIDIAL. This allows you to use different extensions depending upon how long you want to allow a maximum recording and what type of codec you want to record in. The default exten is 8309 which if you follow the SCRATCH_INSTALL examples will record in the WAV format for upto one hour. Another option included in the examples is 8310 which will record in GSM format for upto one hour. + +
+
+
+Campaign Recording - This menu allows you to choose what level of recording is allowed on this campaign. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. + +
+
+
+Campaign Rec Filename - This field allows you to customize the name of the recording when Campaign recording is ONDEMAND or ALLCALLS. The allowed variables are CAMPAIGN CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. The default is FULLDATE_AGENT and would look like this 20051020-103108_6666. Another example is CAMPAIGN_TINYDATE_CUSTPHONE which would look like this TESTCAMP_51020103108_3125551212. 50 char max. + +
+
+
+Campaign Script - This menu allows you to choose the script that will appear on the agents screen for this campaign. Select NONE to show no script for this campaign. + +
+
+
+Get Call Launch - This menu allows you to choose whether you want to auto-launch the web-form page in a separate window, auto-switch to the SCRIPT tab or do nothing when a call is sent to the agent for this campaign. + +
+
+
+Answering Machine Message - This field is for entering in an extension to blind transfer calls to when the agent gets an answering machine and clicks on the Answering Machine Message button in the transfer conference frame. You must set this exten up in the dialplan - extensions.conf - and make sure it plays an audio file then hangs up. + +
+
+
+AMD send to vm exten - This menu allows you to define whether a message is left on an answering machine when it is detected. the call will be immediately forwarded to the Answering-Machine-Message extension if AMD is active and it is determined that the call is an answering machine. + +
+
+
+Xfer-Conf DTMF - These four fields allow for you to have two sets of Transfer Conference and DTMF presets. When the call or campaign is loaded, the vicidial.php script will show two buttons on the transfer-conference frame and auto-populate the number-to-dial and the send-dtmf fields when pressed. + +
+
+
+Agent Alt Num Dialing - This option allows an agent to manually dial the alternate phone number or address3 field after the main number has been called. + +
+
+
+Scheduled Callbacks - This option allows an agent to disposition a call as CALLBK and choose the data and time at which the lead will be re-activated. + +
+
+
+Drop Call Seconds - The number of seconds from the time the customer line is picked up until the call is considered a DROP, only applies to outbound calls. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Safe Harbor Message - If set to Y will play a message to customer after the Drop Call Seconds timeout is reached without being transferred to an agent. This setting will override sending to a voicemail box if this is set to Y. + +
+
+
+Safe Harbor Exten - This is the dialplan extension that the desired Safe Harbor audio file is located at on your server. + +
+
+
+Wrapup Seconds - The number of seconds to force an agent to wait before allowing them to receive or dial another call. The timer begins as soon as an agent hangs up on their customer - or in the case of alternate number dialing when the agent finishes the lead - Default is 0 seconds. If the timer runs out before the agent has dispositioned the call, the agent still will NOT move on to the next call until they select a disposition. + +
+
+
+Wrapup Message - This is a campaign-specific message to be displayed on the wrapup screen if wrapup seconds is set. + +
+
+
+Wrapup Message - This is a campaign-specific message to be displayed on the wrapup screen if wrapup seconds is set. + +
+
+
+Use Internal DNC List - This defines whether this campaign is to filter leads against the Internal DNC list. If it is set to Y, the hopper will look for each phone number in the DNC list before placing it in the hopper. If it is in the DNC list then it will change that lead status to DNCL so it cannot be dialed. Default is N. + +
+
+
+Allowed Inbound Groups - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound/outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + + + +



+ +VICIDIAL_LISTS TABLE

+
+
+List ID - This is the numerical name of the list, it is not editable after initial submission, must contain only numbers and must be between 2 and 8 characters in length. + +
+
+
+List Name - This is the description of the list, it must be between 2 and 20 characters in length. + +
+
+
+Campaign - This is the campaign that this list belongs to. A list can only be dialed on a single campaign at one time. + +
+
+
+Active - This defines whether the list is to be dialed on or not. + +
+
+
+Reset Lead-Called-Status for this list - This resets all leads in this list to N for "not called since last reset" and means that any lead can now be called if it is the right status as defined in the campaign screen. + +
+
+
+VICIDIAL DNC List - This Do Not Call list contains every lead that has been set to a status of DNC in the system. Through the LISTS - ADD NUMBER TO DNC page you are able to manually add a number to this list so that it will not be called by campaigns that use the internal DNC list. + + + +



+ +VICIDIAL_INBOUND_GROUPS TABLE

+
+
+Group ID - This is the short name of the inbound group, it is not editable after initial submission, must not contain any spaces and must be between 2 and 20 characters in length. + +
+
+
+Group Name - This is the description of the group, it must be between 2 and 30 characters in length. Cannot include dashes, plusses or spaces . + +
+
+
+Group Color - This is the color that displays in the VICIDIAL client app when a call comes in on this group. It must be between 2 and 7 characters long. If this is a hex color definition you must remember to put a # at the beginning of the string or VICIDIAL will not work properly. + +
+
+
+Active - This determines whether this group show up in the selection box when a VICIDIAL agent logs in. + +
+
+
+Web Form - This is the custom address that clicking on the WEB FORM button in VICIDIAL will take you to for calls that come in on this group. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. +
  - overall_user_level: orders by the user_level of the agent as defined in the vicidial_users table a higher user_level will receive more calls. + +
+
+
+Fronter Display - This field determines whether the inbound VICIDIAL agent would have the fronter name - if there is one - displayed in the Status field when the call comes to the agent. + +
+
+
+Campaign Script - This menu allows you to choose the script that will appear on the agents screen for this campaign. Select NONE to show no script for this campaign. + +
+
+
+Get Call Launch - This menu allows you to choose whether you want to auto-launch the web-form page in a separate window, auto-switch to the SCRIPT tab or do nothing when a call is sent to the agent for this campaign. + +
+
+
+Xfer-Conf DTMF - These four fields allow for you to have two sets of Transfer Conference and DTMF presets. When the call or campaign is loaded, the vicidial.php script will show two buttons on the transfer-conference frame and auto-populate the number-to-dial and the send-dtmf fields when pressed. + +
+
+
+Drop Call Seconds - The number of seconds from the time the customer line is picked up until the call is considered a DROP, only applies to outbound calls. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Drop Message - If set to Y will play a message to customer after the Drop Call Seconds timeout is reached without being transferred to an agent. This setting will override sending to a voicemail box if this is set to Y. + +
+
+
+Drop Exten - This is the dialplan extension that the desired Dropped call audio file is located at on your server. + + + +



+ +VICIDIAL_REMOTE_AGENTS TABLE

+
+
+User ID Start - This is the starting User ID that is used when the remote agent entries are inserted into the system. If the Number of Lines is set higher than 1, this number is incremented by one until each line has an entry. Make sure you create a new VICIDIAL user account with a user level of 4 or great if you want them to be able to use the vdremote.php page for remote web access of this account. + +
+
+
+Number of Lines - This defines how many remote agent entries the system creates, and determines how many lines it thinks it can safely send to the number below. + +
+
+
+Server IP - A remote agent entry is only good for one specific server, here is where you select which server you want. + +
+
+
+External Extension - This is the number that you want the calls forwarded to. Make sure that it is a full dialplan number and that if you need a 9 at the beginning you put it in here. Test by dialing this number from a phone on the system. + +
+
+
+Status - Here is where you turn the remote agent on and off. As soon as the agent is Active the system assumes that it can send calls to it. It may take up to 30 seconds once you change the status to Inactive to stop receiving calls. + +
+
+
+Campaign - Here is where you select the campaign that these remote agents will be logged into. Inbound needs to use the CLOSER campaign and select the inbound campaigns below that you want to receive calls from. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + + +



+ +VICIDIAL_CAMPAIGN_LISTS

+
+
+The lists within this campaign are listed here, whether they are active is denoted by the Y or N and you can go to the list screen by clicking on the list ID in the first column. + + +



+ +VICIDIAL_CAMPAIGN_STATUSES TABLE

+
+
+Through the use of custom campaign statuses, you can have statuses that only exist for a specific campaign. The Status must be 1-8 characters in length, the description must be 2-30 characters in length and Selectable defines whether it shows up in VICIDIAL as a disposition. + + + +



+ +VICIDIAL_CAMPAIGN_HOTKEYS TABLE

+
+
+Through the use of custom campaign hotkeys, agents that use the vicidial web-client can hangup and disposition calls just by pressing a single key on their keyboard. + + + + +



+ +VICIDIAL_LEAD_RECYCLE TABLE

+
+
+Through the use of lead recycling, you can call specific statuses of leads again at a specified interval without resetting the entire list. Lead recycling is campaign-specific and does not have to be a selected dialable status in your campaign. The attempt delay field is the number of seconds until the lead can be placed back in the hopper, this number must be at least 120 seconds. The attempt maximum field is the maximum number of times that a lead of this status can be attempted before the list needs to be reset, this number can be from 1 to 10. You can activate and deactivate a lead recycle entry with the provided links. This feature only works in auto-dial mode, where dial level is greater than 0. + + + + + +



+ +VICIDIAL_USER_GROUPS TABLE

+
+
+User Group - This is the short name of a Vicidial User group, try not to use any spaces or punctuation for this field. max 20 characters, minimum of 2 characters. + +
+
+
+Group Name - This is the description of the vicidial user group max of 40 characters. + + + + + +



+ +VICIDIAL_SCRIPTS TABLE

+
+
+Script ID - This is the short name of a Vicidial Script. This needs to be a unique identifier. Try not to use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Script Name - This is the title of a Vicidial Script. This is a short summary of the script. max 50 characters, minimum of 2 characters. There should be no spaces or punctuation of any kind in theis field. + +
+
+Script Comments - This is where you can place comments for a Vicidial Script such as -changed to free upgrade on Sept 23-. max 255 characters, minimum of 2 characters. + +
+
+Script Text - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today? + +
+
+
+Active - This determines whether this script can be selected to be used by a campaign. + + + + + +



+ +VICIDIAL_LEAD_FILTERS TABLE

+
+
+Filter ID - This is the short name of a Vicidial Lead Filter. This needs to be a unique identifier. Do not use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Filter Name - This is a more descriptive name of the Filter. This is a short summary of the filter. max 30 characters, minimum of 2 characters. + +
+
+Filter Comments - This is where you can place comments for a Vicidial Filter such as -calls all California leads-. max 255 characters, minimum of 2 characters. + +
+
+Filter SQL - This is where you place the SQL query fragment that you want to filter by. do not begin or end with an AND, that will be added by the hopper cron script automatically. an example SQL query that would work here is- called_count > 4 and called_count < 8 -. + + + + + +



+ +VICIDIAL_CALL TIMES TABLE

+
+
+Call Time ID - This is the short name of a Vicidial Call Time Definition. This needs to be a unique identifier. Do not use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Call Time Name - This is a more descriptive name of the Call Time Definition. This is a short summary of the Call Time definition. max 30 characters, minimum of 2 characters. + +
+
+Call Time Comments - This is where you can place comments for a Vicidial Call Time Definition such as -10am to 4pm with extra call state restrictions-. max 255 characters. + +
+
+Default Start and Stop Times - This is the default time that calling will be allowed to be started or stopped within this call time definition if the day-of-the-week start time is not defined. 0 is midnight. To prevent calling completely set this field to 2400 and set the Default Stop time to 2400. To allow calling 24 hours a day set the start time to 0 and the stop time to 2400. + +
+
+Weekday Start and Stop Times - These are the custom times per day that can be set for the call time definition. same rules apply as with the Default start and stop times. + +
+
+State Call Time Definitions - This is the list of State specific call time definitions that are followed in this Call Time Definition. + +
+
+State Call Time State - This is the two letter code for the state that this calling time definition is for. For this to be in effect the local call time that is set in the campaign must have this state call time record in it as well as all of the leads having two letter state codes in them. + + + + +



+ +VICIDIAL LIST LOADER FUNCTIONALITY

+
+
+The VICIDIAL basic web-based lead loader is designed simply to take a lead file - up to 8MB in size - that is either tab or pipe delimited and load it into the vicidial_list table. There is also a new beta version super lead loader that allows for field choosing and TXT- Plain Text, CSV- Comma Separated Values and XLS- Excel file formats. The lead loader does not do data validation or check for duplicates in itself or other lists, so that is something you need to do before you load the leads. Also, make sure that you have created the list that these leads are to be under so that you can use them. There is also the matter of time-zone-coding these leads. You may want to increase the frequency that the ADMIN_adjust_GMTnow_on_leads.pl is being run in the cron on your Asterisk server so that any loaded leads can be coded faster. Here is a list of the fields in their proper order for the lead files: +
    +
  1. Vendor Lead Code - shows up in the Vendor ID field of the GUI +
  2. Source Code - internal use only for admins and DBAs +
  3. List ID - the list number that these leads will show up under +
  4. Phone Code - the prefix for the phone number - 1 for US, 01144 for UK, 01161 for AUS, etc +
  5. Phone Number - must be at least 8 digits long +
  6. Title - title of the customer - Mr. Ms. Mrs, etc... +
  7. First Name +
  8. Middle Initial +
  9. Last Name +
  10. Address Line 1 +
  11. Address Line 2 +
  12. Address Line 3 +
  13. City +
  14. State - limited to 2 characters +
  15. Province +
  16. Postal Code +
  17. Country +
  18. Gender +
  19. Date of Birth +
  20. Alternate Phone Number +
  21. Email Address +
  22. Security Phrase +
  23. Comments +
+ +
NOTES: The Excel Lead loader functionality is enabled by a series of perl scripts and needs to have a properly configured /home/cron/AST_SERVER_conf.pl file in place on the web server. Also, a couple perl modules must be loaded for it to work as well - OLE-Storage_Lite and Spreadsheet-ParseExcel. You can check for runtime errors in these by looking at your apache error_log file. + +







+







+THE END +
+\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$dial_status_a = $row[3]; +$dial_status_b = $row[4]; +$dial_status_c = $row[5]; +$dial_status_d = $row[6]; +$dial_status_e = $row[7]; +$local_call_time = $row[16]; +if ($lead_filter_id=='') + { + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + +$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$camp_lists=''; +$o=0; +while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; +if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} +} +$camp_lists = eregi_replace(".$","",$camp_lists); + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + +echo "

\n"; +echo "Show Dialable Leads Count -

\n"; +echo "CAMPAIGN: $campaign_id
\n"; +echo "LISTS: $camp_lists
\n"; +echo "STATUSES: $dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e
\n"; +echo "FILTER: $lead_filter_id
\n"; +echo "CALL TIME: $local_call_time

\n"; + +### call function to calculate and print dialable leads +dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + +echo "

\n"; +echo "\n"; + +exit; +} + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) +{ + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDORLEADCODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551212'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[1]; +$script_text = $row[3]; + +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); +$script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); +$script_text = eregi_replace("\n","
",$script_text); + + +echo ""; + +echo "Preview Script: $script_id
\n"; +echo "
\n"; +echo "
$script_name
\n"; +echo "$script_text\n"; +echo "
\n"; + +echo "\n"; + +exit; +} + + + + +######################### HTML HEADER BEGIN ####################################### +if ($hh=='users') {$users_hh='bgcolor ="#FFFF99"'; $users_fc='BLACK';} # yellow + else {$users_hh=''; $users_fc='WHITE';} +if ($hh=='campaigns') {$campaigns_hh='bgcolor ="#FFCC99"'; $campaigns_fc='BLACK';} # orange + else {$campaigns_hh=''; $campaigns_fc='WHITE';} +if ($hh=='lists') {$lists_hh='bgcolor ="#FFCCCC"'; $lists_fc='BLACK';} # red + else {$lists_hh=''; $lists_fc='WHITE';} +if ($hh=='ingroups') {$ingroups_hh='bgcolor ="#CC99FF"'; $ingroups_fc='BLACK';} # purple + else {$ingroups_hh=''; $ingroups_fc='WHITE';} +if ($hh=='remoteagent') {$remoteagent_hh='bgcolor ="#CCFFCC"'; $remoteagent_fc='BLACK';} # green + else {$remoteagent_hh=''; $remoteagent_fc='WHITE';} +if ($hh=='usergroups') {$usergroups_hh='bgcolor ="#CCFFFF"'; $usergroups_fc='BLACK';} # cyan + else {$usergroups_hh=''; $usergroups_fc='WHITE';} +if ($hh=='scripts') {$scripts_hh='bgcolor ="#99FFCC"'; $scripts_fc='BLACK';} # light teal + else {$scripts_hh=''; $scripts_fc='WHITE';} +if ($hh=='filters') {$filters_hh='bgcolor ="#CCCCCC"'; $filters_fc='BLACK';} # grey + else {$filters_hh=''; $filters_fc='WHITE';} +if ($hh=='times') {$times_hh='bgcolor ="#99FF33"'; $times_fc='BLACK';} # hard teal + else {$times_hh=''; $times_fc='WHITE';} + +?> + + + + +\n"; +?> +
+ + + + + + + + + + + + + + + + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + + + + +
  VICIDIAL ADMIN - Logout  
> SIZE=1> USERS > SIZE=1> CAMPAIGNS > SIZE=1> LISTS > SIZE=1> SCRIPTS > SIZE=1> FILTERS > SIZE=1> IN-GROUPS > SIZE=1> CALL TIMES > SIZE=1> USER GROUPS > SIZE=1> REMOTE AGENTS > REPORTS
  LIST USERS     |     ADD A NEW USER     |     SEARCH FOR A USER
  ADD CAMPAIGN     |     LIST CAMPAIGNS
  SHOW LISTS     |     ADD NEW LIST     |     SEARCH FOR A LEAD |     ADD NUMBER TO DNC           |     LOAD NEW LEADS
  ADD SCRIPT     |     VIEW SCRIPTS
  ADD FILTER     |     VIEW FILTERS
  SHOW IN-GROUPS     |     ADD NEW IN-GROUP
  SHOW CALL TIMES     |     ADD NEW CALL TIME     |     SHOW STATE CALL TIMES     |     ADD NEW STATE CALL TIME  
  ADD USER GROUP     |     LIST USER GROUPS     |     GROUP HOURLY
  SHOW REMOTE AGENTS     |     ADD NEW REMOTE AGENTS
 
+
\n"; +echo ""; + +echo "
ADD A NEW USER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "$NWB#vicidial_users-user_group$NWE\n"; +echo "\n"; +echo "
User Number: $NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group:
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW CAMPAIGN\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Campaign ID: $NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $NWB#vicidial_campaigns-park_ext$NWE
Park Filename: $NWB#vicidial_campaigns-park_file_name$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: (digits only)$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) +{ +echo "
\n"; +echo ""; + +if (strlen($phone_number) > 2) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DNC NOT ADDED - This phone number is already in the Do Not Call List: $phone_number

\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');"; + $rslt=mysql_query($stmt, $link); + + echo "
DNC ADDED: $phone_number

\n"; + + ### LOG INSERTION TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW DNC NUMBER|$PHP_AUTH_USER|$ip|'$phone_number'|\n"); + fclose($fp); + } + } + } + +echo "
ADD A NUMBER TO THE DNC LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
Phone Number: (digits only)$NWB#vicidial_list-dnc$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW INBOUND GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group ID: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW REMOTE AGENTS\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW USERS GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW SCRIPT\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Script ID: (no spaces or punctuation)$NWB#vicidial_scripts-script_id$NWE
Script Name: (title of the script)$NWB#vicidial_scripts-script_name$NWE
Script Comments: $NWB#vicidial_scripts-script_comments$NWE
Active: $NWB#vicidial_scripts-active$NWE
Script Text: $NWB#vicidial_scripts-script_text$NWE
\n"; + +} + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW FILTER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Filter ID: (no spaces or punctuation)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter Name: (short description of the filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter Comments: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; +} + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW CALL TIME\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Call Time ID: (no spaces or punctuation)$NWB#vicidial_call_times-call_time_id$NWE
Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Day and time options will appear once you have created the Call Time Definition
\n"; +} + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW STATE CALL TIME\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
State Call Time ID: (no spaces or punctuation)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (no spaces or punctuation)$NWB#vicidial_call_times-state_call_time_state$NWE
State Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
State Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Day and time options will appear once you have created the Call Time Definition
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER NOT ADDED - there is already a user in the system with this user number\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
USER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
user id must be between 2 and 8 characters long\n"; + echo "
full name and password must be at least 2 characters long\n"; + } + else + { + echo "
USER ADDED: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass'|\n"); + fclose($fp); + } + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
CAMPAIGN NOT ADDED - Please go back and look at the data you entered\n"; + echo "
campaign ID must be between 2 and 8 characters in length\n"; + echo "
campaign name must be between 6 and 40 characters in length\n"; + } + else + { + echo "
CAMPAIGN ADDED: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('$campaign_id','$campaign_name','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo ""; + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 8 characters in length\n"; + echo "
status name must be between 2 and 30 characters in length\n"; + } + else + { + echo "
CAMPAIGN STATUS ADDED: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } + } +$ADD=31; +} + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) +{ + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN HOTKEY NOT ADDED - there is already a campaign-hotkey in the system with this hotkey\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAIGN HOTKEY NOT ADDED - Please go back and look at the data you entered\n"; + echo "
hotkey must be a single character between 1 and 9 \n"; + echo "
status must be between 1 and 8 characters in length\n"; + } + else + { + echo "
CAMPAIGN HOTKEY ADDED: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN HOTKEY |$PHP_AUTH_USER|$ip|'$status','$hotkey','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) +{ + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - there is already a lead-recycle for this campaign with this status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD RECYCLE ADDED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LIST NOT ADDED - there is already a list in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
LIST NOT ADDED - Please go back and look at the data you entered\n"; + echo "
List ID must be between 2 and 8 characters in length\n"; + echo "
List name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST ADDED: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + } + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GROUP NOT ADDED - there is already a group in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group ID must be between 2 and 20 characters in length and contain no ' -+'.\n"; + echo "
Group name and group color must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + echo "
GROUP ADDED: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
REMOTE AGENTS NOT ADDED - there is already a remote agents entry starting with this userID\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
User ID start and external extension must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + } + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER GROUP NOT ADDED - there is already a user group entry with this name\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW USER GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + } + } + } +$ADD=100000; +} + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SCRIPT NOT ADDED - there is already a script entry with this name\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Script name, description and text must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT ADDED: $script_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000000; +} + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
FILTER NOT ADDED - there is already a filter entry with this ID\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Filter ID, name and SQL must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='$lead_filter_sql';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER ADDED: $lead_filter_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=10000000; +} + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Call Time ID and name must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + + echo "
CALL TIME ADDED: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + } +$ADD=311111111; +} + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATE CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
STATE CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered\n"; + echo "
State Call Time ID, name and state must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + + echo "
STATE CALL TIME ADDED: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=3111111111; +} + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN STATUS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN STATUS DELETED: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAIGN HOTKEY NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + echo "
the campaign hotkey needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN HOTKEY DELETED: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level',lead_filter_id='$lead_filter_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG HOPPER RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=34; # go to campaign modification form below +} + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LIST NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
list name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST MODIFIED: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
RESETTING LIST-CALLED-STATUS\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + } + if ($campaign_id != "$old_campaign_id") + { + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + } + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
group name and group color must be at least 2 characters in length\n"; + } + else + { + echo "
GROUP MODIFIED: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_message='$drop_message',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111; # go to in-group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
User ID Start and External Extension must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + } + } + +$ADD=311111; # go to user group modification form below +} + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Script name, description and text must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111; # go to script modification form below +} + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Filter ID, name and SQL must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='$lead_filter_sql' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31111111; # go to filter modification form below +} + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CALL TIME NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Call Time ID and name must be at least 2 characters in length\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
CALL TIME MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + +$ADD=311111111; # go to call time modification form below +} + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
STATE CALL TIME NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
State Call Time ID, name and state must be at least 2 characters in length\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
STATE CALL TIME MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111111; # go to state call time modification form below +} + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
USER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + echo "
USER DELETION CONFIRMATION: $user\n"; + echo "

Click here to delete user $user


\n"; + } + +$ADD='3'; # go to user modification below +} + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAIGN NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + echo "
CAMPAIGN DELETION CONFIRMATION: $campaign_id\n"; + echo "

Click here to delete campaign $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + echo "
AGENT LOGOUT CONFIRMATION: $campaign_id\n"; + echo "

Click here to log all agents out of $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) +{ + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
LIST NOT DELETED - Please go back and look at the data you entered\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
LIST DELETION CONFIRMATION: $list_id\n"; + echo "

Click here to delete list and all of its leads $list_id


\n"; + } + +$ADD='311'; # go to campaign modification below +} + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
IN-GROUP DELETION CONFIRMATION: $group_id\n"; + echo "

Click here to delete in-group $group_id


\n"; + } + +$ADD='3111'; # go to in-group modification below +} + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTE AGENT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
REMOTE AGENT DELETION CONFIRMATION: $remote_agent_id\n"; + echo "

Click here to delete remote agent $remote_agent_id


\n"; + } + +$ADD='31111'; # go to remote agent modification below +} + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
USER GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + echo "
USER GROUP DELETION CONFIRMATION: $user_group\n"; + echo "

Click here to delete user group $user_group


\n"; + } + +$ADD='311111'; # go to user group modification below +} + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
SCRIPT DELETION CONFIRMATION: $script_id\n"; + echo "

Click here to delete script $script_id


\n"; + } + +$ADD='3111111'; # go to script modification below +} + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Filter ID must be at least 2 characters in length\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Click here to delete filter $lead_filter_id


\n"; + } + +$ADD='31111111'; # go to filter modification below +} + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + echo "
CALL TIME DELETION CONFIRMATION: $call_time_id\n"; + echo "

Click here to delete call time $call_time_id


\n"; + } + +$ADD='311111111'; # go to call time modification below +} + +###################### +# ADD=5111111111 confirmation before deletion of call time record +###################### + +if ($ADD==5111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
STATE CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + echo "
STATE CALL TIME DELETION CONFIRMATION: $call_time_id\n"; + echo "

Click here to delete state call time $call_time_id


\n"; + } + +$ADD='3111111111'; # go to state call time modification below +} + + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
USER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING USER!!!!|$PHP_AUTH_USER|$ip|user='$user'|\n"); + fclose($fp); + } + echo "
USER DELETION COMPLETED: $user\n"; + echo "

\n"; + } + +$ADD='0'; # go to user list +} + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) +{ + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAIGN NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!DELETING CAMPAIGN!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
CAMPAIGN DELETION COMPLETED: $campaign_id\n"; + echo "

\n"; + } + +$ADD='10'; # go to campaigns list +} + +###################### +# ADD=62 Logout all agents fro a campaign +###################### + +if ($ADD==62) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!AGENT LOGOUT!!!!!!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
AGENT LOGOUT COMPLETED: $campaign_id\n"; + echo "

\n"; + } + +$ADD='31'; # go to campaign modification below +} + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD RECYCLE DELETED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) +{ + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
LIST NOT DELETED - Please go back and look at the data you entered\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST LEADS FROM VICIDIAL_LIST TABLE\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING LIST!!!!|$PHP_AUTH_USER|$ip|list_id='$list_id'|\n"); + fclose($fp); + } + echo "
LIST DELETION COMPLETED: $list_id\n"; + echo "

\n"; + } + +$ADD='100'; # go to lists list +} + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_groups where group_id='$group_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING IN-GROUP!!|$PHP_AUTH_USER|$ip|group_id='$group_id'|\n"); + fclose($fp); + } + echo "
IN-GROUP DELETION COMPLETED: $group_id\n"; + echo "

\n"; + } + +$ADD='1000'; # go to in-group list +} + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTE AGENT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING RMTAGENT!!|$PHP_AUTH_USER|$ip|remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + echo "
REMOTE AGENT DELETION COMPLETED: $remote_agent_id\n"; + echo "

\n"; + } + +$ADD='10000'; # go to remote agents list +} + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
USER GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING USRGROUP!!|$PHP_AUTH_USER|$ip|user_group='$user_group'|\n"); + fclose($fp); + } + echo "
USER GROUP DELETION COMPLETED: $user_group\n"; + echo "

\n"; + } + +$ADD='100000'; # go to user group list +} + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING SCRIPT!!!!|$PHP_AUTH_USER|$ip|script_id='$script_id'|\n"); + fclose($fp); + } + echo "
SCRIPT DELETION COMPLETED: $script_id\n"; + echo "

\n"; + } + +$ADD='1000000'; # go to script list +} + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Filter ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING FILTER!!!!|$PHP_AUTH_USER|$ip|lead_filter_id='$lead_filter_id'|\n"); + fclose($fp); + } + echo "
FILTER DELETION COMPLETED: $lead_filter_id\n"; + echo "

\n"; + } + +$ADD='10000000'; # go to filter list +} + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
CALL TIME DELETION COMPLETED: $call_time_id\n"; + echo "

\n"; + } + +$ADD='100000000'; # go to call times list +} + + +###################### +# ADD=6111111111 delete call times record +###################### + +if ($ADD==6111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
STATE CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + + while ($sct_to_print > $o) { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "State Rule Removed: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|state_call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
STATE CALL TIME DELETION COMPLETED: $call_time_id\n"; + echo "

\n"; + } + +$ADD='1000000000'; # go to call times list +} + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + +if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
You do not have permissions to modify this user: $row[1]\n"; + } +else + { + echo "
MODIFY A USERS RECORD: $row[1]\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($LOGuser_level > 8) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "
User Number: $row[1]$NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group: $NWB#vicidial_users-user_group$NWE
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
AGENT INTERFACE OPTIONS:
Agent Choose Ingroups: $NWB#vicidial_users-agent_choose_ingroups$NWE
HotKeys Active: $NWB#vicidial_users-hotkeys_active$NWE
Scheduled Callbacks: $NWB#vicidial_users-scheduled_callbacks$NWE
Agent-Only Callbacks: $NWB#vicidial_users-agentonly_callbacks$NWE
Agent Call Manual: $NWB#vicidial_users-agentcall_manual$NWE
Vicidial Recording: $NWB#vicidial_users-vicidial_recording$NWE
Vicidial Transfers: $NWB#vicidial_users-vicidial_transfers$NWE
Closer Default Blended: $NWB#vicidial_users-closer_default_blended$NWE
Inbound Groups: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_users-closer_campaigns$NWE
ADMIN INTERFACE OPTIONS:
Alter Agent Interface Options: $NWB#vicidial_users-alter_agent_interface_options$NWE
Delete Users: $NWB#vicidial_users-delete_users$NWE
Delete User Groups: $NWB#vicidial_users-delete_user_groups$NWE
Delete Lists: $NWB#vicidial_users-delete_lists$NWE
Delete Campaigns: $NWB#vicidial_users-delete_campaigns$NWE
Delete In-Groups: $NWB#vicidial_users-delete_ingroups$NWE
Delete Remote Agents: $NWB#vicidial_users-delete_remote_agents$NWE
Delete Scripts: $NWB#vicidial_users-delete_scripts$NWE
Load Leads: $NWB#vicidial_users-load_leads$NWE
Campaign Detail: $NWB#vicidial_users-campaign_detail$NWE
AGC Admin Access: $NWB#vicidial_users-ast_admin_access$NWE
AGC Delete Phones: $NWB#vicidial_users-ast_delete_phones$NWE
Modify Leads: $NWB#vicidial_users-modify_leads$NWE
Change Agent Campaign: $NWB#vicidial_users-change_agent_campaign$NWE
Delete Filters: $NWB#vicidial_users-delete_filters$NWE
Delete Call Times: $NWB#vicidial_users-delete_call_times$NWE
Modify Call Times: $NWB#vicidial_users-modify_call_times$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

DELETE THIS USER\n"; + } + echo "

Click here for user time sheet\n"; + echo "

Click here for user status\n"; + echo "

Click here for user stats\n"; + echo "

Click here for user CallBack Holds\n"; + } + +} + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed + +if ($ADD==31) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $safe_harbor_message = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; +# $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + +echo "
MODIFY A CAMPAIGNS RECORD: $row[0] - Basic View"; +echo " | Detail View | "; +echo "Realtime Screen\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +if (eregi("CLOSER", $campaign_id)) + { + echo "\n"; + } + + + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Dial Timeout: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Dial Prefix: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
Campaign CallerID: $NWB#vicidial_campaigns-campaign_cid$NWE
Campaign VDAD exten: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Campaign Rec exten: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Campaign Recording: $NWB#vicidial_campaigns-campaign_recording$NWE
Campaign Rec Filename: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
Answering Machine Message: $NWB#vicidial_campaigns-am_message_exten$NWE
AMD Send to VM exten: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf Number 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf Number 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Alt Number Dialing: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Scheduled Callbacks: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Drop Call Seconds: $NWB#vicidial_campaigns-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Use Safe Harbor Message: $NWB#vicidial_campaigns-safe_harbor_message$NWE
Safe Harbor Exten: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Wrapup Seconds: $NWB#vicidial_campaigns-wrapup_seconds$NWE
Wrapup Message: $NWB#vicidial_campaigns-wrapup_message$NWE
Use Internal DNC List: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Allowed Inbound Groups:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
\n"; + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - HIDE

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - SHOW

"; + } + + + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "Click here to see all CallBack Holds in this campaign

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
CUSTOM STATUSES WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
STATUSDESCRIPTIONSELECTABLEDELETE
$rowx[0]$rowx[1]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN STATUS
\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Description:   \n"; +echo "Selectable:   \n"; +echo "
\n"; + +echo "

\n"; + + + +echo "
CUSTOM HOTKEYS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
HOTKEYSTATUSDESCRIPTIONDELETE
$rowx[1]$rowx[0]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN HOTKEY
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Hotkey:   \n"; +echo "Status:   \n"; +echo "
\n"; +echo "

\n"; + + + +echo "

LEAD RECYCLING WITHIN THIS CAMPAIGN:   $NWB#vicidial_lead_recycle$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +echo "
STATUSATTEMPT DELAYATTEMPT MAXIMUMACTIVE DELETE
$rowx[2]
\n"; + echo "\n"; + echo "\n"; + echo "
DELETE
\n"; + +echo "
ADD NEW CAMPAIGN LEAD RECYCLE
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Attempt Delay: \n"; +echo "Attempt Maximum: \n"; +echo "
\n"; + +echo "

\n"; + +echo "LOG ALL AGENTS OUT OF THIS CAMPAIGN

\n"; + +if ($LOGdelete_campaigns > 0) + { + echo "

DELETE THIS CAMPAIGN\n"; + } + +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ($ADD==34) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Basic View | "; +echo "Detail View | "; +echo "Realtime Screen\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Web Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Script: $script_id
Get Call Launch: $get_call_launch
\n"; + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - HIDE

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - SHOW

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "Click here to see all CallBack Holds in this campaign

\n"; +echo "
\n"; + +echo "
\n"; + +echo "LOG ALL AGENTS OUT OF THIS CAMPAIGN

\n"; + + +if ($LOGdelete_campaigns > 0) + { + echo "

DELETE THIS CAMPAIGN\n"; + } + + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT * from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + +echo "
MODIFY A LISTS RECORD: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: $row[0]$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
Reset Lead-Called-Status for this list: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
STATUSES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + +echo "\n"; +echo "\n"; + +echo "
STATUSSTATUS NAMECALLEDNOT CALLED
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + +echo "
\n"; +echo "
TIME ZONES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + +echo "\n"; +echo "\n"; + +echo "
GMT OFFSET NOW (local time)CALLEDNOT CALLED
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
CALLED COUNTS WITHIN THIS LIST:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + +echo "
STATUSSTATUS NAME$firstSUBTOTAL
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
TOTAL$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +if ($LOGdelete_lists > 0) + { + echo "

DELETE THIS LIST\n"; + } + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_message = $row[15]; + $drop_exten = $row[16]; + +echo "
MODIFY A GROUPS RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +echo "\n"; +echo "
Group ID: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf Number 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf Number 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Drop Call Seconds: $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Use Drop Message: $NWB#vicidial_inbound_groups-drop_message$NWE
Drop Exten: $NWB#vicidial_inbound_groups-drop_exten$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +if ($LOGdelete_ingroups > 0) + { + echo "

DELETE THIS IN-GROUP\n"; + } + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + + +if ($LOGdelete_remote_agents > 0) + { + echo "

DELETE THIS REMOTE AGENT\n"; + } + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
MODIFY A USERS GROUP ENTRY\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +if ($LOGdelete_user_groups > 0) + { + echo "

DELETE THIS USER GROUP\n"; + } + +} + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = $row[3]; + $active = $row[4]; +echo ""; + +echo "
MODIFY A SCRIPT\n"; +echo "\n"; +echo "\n"; +echo "
Script ID: $script_id$NWB#vicidial_scripts-script_name$NWE
Script Name: (title of the script)$NWB#vicidial_scripts-script_name$NWE
Script Comments: $NWB#vicidial_scripts-script_comments$NWE
Active: $NWB#vicidial_scripts-active$NWE
Script Text:

Preview Script
$NWB#vicidial_scripts-script_text$NWE
\n"; + +if ($LOGdelete_scripts > 0) + { + echo "

DELETE THIS SCRIPT\n"; + } + +} + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = $row[3]; +echo ""; + +echo "
MODIFY A FILTER\n"; +echo "\n"; +echo "\n"; +echo "
Filter ID: $lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter Name: (short description of the filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter Comments: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + +echo "

"; +echo "
TEST ON CAMPAIGN:
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($LOGdelete_filters > 0) + { + echo "

DELETE THIS FILTER\n"; + } + +} + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) +{ +if ($LOGmodify_call_times==1) +{ + +if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "State Rule Added: $state_rule
\n"; + } +if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "State Rule Removed: $state_rule
\n"; + } + +$ADD=311111111; +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +$ct_srs=1; +$b=0; +$srs_SQL =''; +if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } +echo "\n"; +echo "\n"; +while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } +if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } +else + {$srs_SQL='';} +$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; +$rslt=mysql_query($stmt, $link); +$sct_to_print = mysql_num_rows($rslt); +$sct_list=''; + +$o=0; +while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; +} +echo "\n"; +echo "\n"; + +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + +echo ""; + +echo "
MODIFY A CALL TIME\n"; +echo "\n"; +echo "\n"; +echo "
Call Time ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Default Start: Default Stop: $NWB#vicidial_call_times-ct_default_start$NWE
Sunday Start: Sunday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Monday Start: Monday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Tuesday Start: Tuesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Wednesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Thursday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Friday Start: Friday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Saturday Start: Saturday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Active State Call Time Definitions for this Record:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Add state call time rule:


\n"; +echo "CAMPAIGNS USING THIS CALL TIME:
\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + $CT_camp_id = $row[1]; + $CT_camp_name = $row[2]; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

DELETE THIS CALL TIME DEFINITION\n"; + } +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + +echo ""; + +echo "
MODIFY A STATE CALL TIME
\n"; +echo "\n"; +echo "\n"; +echo "
Call Time ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
State Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
State Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Default Start: Default Stop: $NWB#vicidial_call_times-ct_default_start$NWE
Sunday Start: Sunday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Monday Start: Monday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Tuesday Start: Tuesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Wednesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Thursday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Friday Start: Friday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Saturday Start: Saturday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; +echo "CALL TIMES USING THIS STATE CALL TIME:
\n"; +echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

DELETE THIS STATE CALL TIME DEFINITION\n"; + } + +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo "
\n"; +echo ""; + +echo "
SEARCH FOR A USER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
User Number:
Full Name:
User Level:
User Group:
\n"; + +} + +###################### +# ADD=66 user search results +###################### + +if ($ADD==66) +{ +echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS | STATUS | TIME
\n"; + +} + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and user='$user' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
USER CALLBACK HOLD LISTINGS: $user\n"; +$ADD='82'; +} + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and campaign_id='$campaign_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN CALLBACK HOLD LISTINGS: $campaign_id\n"; +$ADD='82'; +} + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and list_id='$list_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; +$ADD='82'; +} + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) +{ +echo "
\n"; +echo "
\n"; +echo "\n"; + + $o=0; + while ($cb_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
LEADLISTCAMPAIGNENTRY DATECALLBACK DATEUSERRECIPIENTSTATUS
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS | STATUS | TIME
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
LIST LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  MODIFY
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
INBOUND GROUP LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  MODIFY
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
REMOTE AGENTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]MODIFY
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER GROUPS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) +{ +echo "\n";echo "\n";?> +
+
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SCRIPTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) +{ +echo "\r\n"; + } +} + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/listloader_super.pl b/agc_2-X/trunk/LANG_admin/vicidial/listloader_super.pl new file mode 100644 index 00000000..a36765d0 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/listloader_super.pl @@ -0,0 +1,691 @@ +#!/usr/bin/perl + +### listloader_super.pl +### +### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 +### +# +# +# CHANGES +# 60616-1548 - Added listID override feature to force all leads into same list +# - Added gmt_offset_now lookup for each lead +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + } + else + { + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + } +} +### end parsing run-time options ### + +use Spreadsheet::ParseExcel; +use Time::Local; +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$vars=$ARGV[0]; +@xls_fields=split(/\,/, $vars); + +$|=0; +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$pulldate="$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + + ### Grab Server values from the database + $stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + +$total=0; $good=0; $bad=0; +open(STMT_FILE, "> listloader_stmts.txt"); + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +my($iR, $iC, $oWkS, $oWkC); + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[0]]; + if ($oWkC) {$vendor_lead_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[1]]; + if ($oWkC) {$source_code=$oWkC->Value; } + $source_id=$source_code; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[2]]; + if ($oWkC) {$list_id=$oWkC->Value; } + $gmt_offset = '0'; + $called_since_last_reset='N'; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[3]]; + if ($oWkC) {$phone_code=$oWkC->Value; } + $phone_code=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[4]]; + if ($oWkC) {$phone_number=$oWkC->Value; } + $phone_number=~s/[^0-9]//g; + $USarea = substr($phone_number, 0, 3); + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[5]]; + if ($oWkC) {$title=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[6]]; + if ($oWkC) {$first_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[7]]; + if ($oWkC) {$middle_initial=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[8]]; + if ($oWkC) {$last_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[9]]; + if ($oWkC) {$address1=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[10]]; + if ($oWkC) {$address2=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[11]]; + if ($oWkC) {$address3=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[12]]; + if ($oWkC) {$city=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[13]]; + if ($oWkC) {$state=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[14]]; + if ($oWkC) {$province=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[15]]; + if ($oWkC) {$postal_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[16]]; + if ($oWkC) {$country_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[17]]; + if ($oWkC) {$gender=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[18]]; + if ($oWkC) {$date_of_birth=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[19]]; + if ($oWkC) {$alt_phone=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[20]]; + if ($oWkC) {$email=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[21]]; + if ($oWkC) {$security_phrase=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[22]]; + if ($oWkC) {$comments=$oWkC->Value; } + $comments=~s/^\s*(.*?)\s*$/$1/; + + if (length($phone_number)>8) { + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &USA_dstcalc; + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + sleep(1); +# flush(); + } + } +} + +if ($multi_insert_counter > 0) { + $stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; +} + +print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total"; + +exit; + + + + + + +sub USA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +#********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $USA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } + } else { + $USA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $USA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } + } else { + $USA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/LANG_admin/vicidial/log_test.php b/agc_2-X/trunk/LANG_admin/vicidial/log_test.php new file mode 100644 index 00000000..cd7a86b7 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/log_test.php @@ -0,0 +1,37 @@ + LICENSE: GPLv2 +# + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$fp = fopen ("./closer_SQL_updates.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + fwrite ($fp, "CLOSER SQL UPDATE|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + + +exit; + + + +?> + + +Hello + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/new_listloader_superL.php b/agc_2-X/trunk/LANG_admin/vicidial/new_listloader_superL.php new file mode 100644 index 00000000..6c0ac713 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/new_listloader_superL.php @@ -0,0 +1,1364 @@ + LICENSE: GPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '1.1.12-1'; +$build = '60619-1651'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +VICIDIAL ADMIN: Super Lead Loader + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + +
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LEAD FILTER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
CALL TIME LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[4] MODIFY
\n"; +} + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
STATE CALL TIME LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3] $row[4] MODIFY
\n"; +} + + + + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BUILD: $build
\n"; + + +?> + + +
+ + + +1) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "This campaign has $active_leads leads to be dialed in those lists\n"; + } + else + { + echo "no active lists selected for this campaign\n"; + } + } +else + { + echo "no active lists selected for this campaign\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/agc_2-X/trunk/LANG_admin/vicidial/admin_modify_lead.php b/agc_2-X/trunk/LANG_admin/vicidial/admin_modify_lead.php new file mode 100644 index 00000000..9dad4f62 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/admin_modify_lead.php @@ -0,0 +1,476 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + +### AST GUI database administration modify lead in vicidial_list +### admin_modify_lead.php + +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead + +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Lead record modification + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "information modified

\n"; + echo "\n"; + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + +} +else +{ + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + + + + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + +echo "

\n"; + +echo "
\n"; + +echo "CALLS TO THIS LEAD:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD
$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]
\n"; + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/admin_search_lead.php b/agc_2-X/trunk/LANG_admin/vicidial/admin_search_lead.php new file mode 100644 index 00000000..a727e3a1 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/admin_search_lead.php @@ -0,0 +1,224 @@ + LICENSE: GPLv2 +### +### AST GUI database administration search for lead info +### admin_modify_lead.php +# +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Lead Search + +Lead Lookup + + + +
\n"; + echo "
\n"; + echo "\n"; + echo "Please enter a:
Vendor ID(vendor lead code): or \n"; + echo "
a Home Phone Number: or\n"; + echo "
a lead ID:

\n"; + echo "
\n"; + echo "\n
\n"; + echo "\n"; + exit; + } + +else + { + + if ($vendor_id) + { + $stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000"; + } + else + { + if ($phone) + { + $stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000"; + } + else + { + if ($lead_id) + { + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query($stmt, $link); + $results_to_print = mysql_num_rows($rslt); + if ($results_to_print < 1) + { + echo date("l F j, Y G:i:s A"); + echo "\n

\n"; + echo "The search variables you entered are not active in the system

\n"; + echo "Please go back and double check the information you entered and submit again\n"; + echo "
\n"; + echo "\n"; + exit; + } + else + { + echo "RESULTS: $results_to_print

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD IDSTATUSVENDOR IDLAST AGENTLIST IDPHONENAMECITYSECURITYLAST CALL
$o$row[0]$row[3]$row[5]$row[4]$row[7]$row[11]$row[13] $row[15]$row[19]$row[28]$row[2]
\n"; + } + } + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\nNEW SEARCH"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; + + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/closer-fronter_popup.php b/agc_2-X/trunk/LANG_admin/vicidial/closer-fronter_popup.php new file mode 100644 index 00000000..53a1a41d --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/closer-fronter_popup.php @@ -0,0 +1,508 @@ + LICENSE: GPLv2 +### +# this is the closer popup of a specific call that starts recording the call and allows you to go and fetch info on that caller in the local CRM system. + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +# $ext_context = 'default'; defined in dbconnect file + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name from vicidial_users where user='$user' and pass='$pass'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + if ( (strlen($customer_zap_channel)>2) and (eregi('zap',$customer_zap_channel)) ) + { + echo "\n\n"; + echo "\n\n"; + + } + else + { + echo "Bad channel: $customer_zap_channel\n"; + echo "Make sure the Zap channel is live and try again\n"; + exit; + } + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "VICIDIAL FRONTER-CLOSER: Popup\n"; + +if (eregi('CL_UNIV',$channel_group)) + { + ?> + + \n"; + echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n"; + echo "\n"; + } +?> + + +
+ + 0) +{ + +# $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RZ$FILE_datetime$user"; + + ### insert a NEW record to the vicidial_manager table to be processed + + $channel = $customer_zap_channel; + $channel = eregi_replace('Zap/', "", $channel); + $SIPexten = eregi_replace('SIP/', "", $SIPexten); + $filename = "$REC_TIME$US$SIPexten"; + +# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: Zap/$channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + # Local/78600098@demo-6617,2 + + $stmt = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Originate','$DTqueryCID','Channel: $local_DEF$conf_silent_prefix$session_id$local_AMP$ext_context','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: $filename','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('Zap/$channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + + echo "Recording command sent for channel $channel - $filename - $recording_id       $NOW_TIME\n

\n"; + + $stmt="SELECT full_name from vicidial_users where user='$user'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "Call Referred by: $user - $full_name\n

\n"; + + $url = "http://10.10.99.2/vicidial/closer_dispo.php?lead_id=$lead_id&channel=$channel&server_ip=$server_ip&extension=$SIPexten&call_began=$STARTtime&parked_time=$parked_time&DB=$DB"; + + echo "View Customer Info and Disposition Call\n

\n"; + + + +# $stmt="UPDATE park_log set grab_time='$NOW_TIME',status='TALKING',extension='$extension',user='$user' where parked_time='$parked_time' and server_ip='$server_ip' and channel='$channel'"; +# if ($DB) {echo "|$stmt|\n";} +# $fp = fopen ("./closer_SQL_updates.txt", "a"); +# fwrite ($fp, "$date|$user|$stmt|\n"); +# fclose($fp); +# $rslt=mysql_query($stmt, $link); + +########################################################################################### +####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX +########################################################################################### +if (eregi('CL_TEST',$channel_group)) + { + echo "GALLERIA TEST CLOSER GROUP: $channel_group\n"; + + $stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $fronter=$row[0]; + $search_phone=$row[1]; + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ -- INTERNAL CALL GALLERIA FRONT --
\n"; + $group_color='#99FF99'; + } + if (eregi('CL_GALLER2',$channel_group)) + { + echo "
-- TouchAsia CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER3',$channel_group)) + { + echo "
-- DebitSupplies CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER4',$channel_group)) + { + echo "
-- Vishnu CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
New Search
Reservation Number:
Confirmation #:
Phone #:


Back
+ +
+ + + Close this window\n

\n"; +} +else +{ + echo "Record command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Please go back and try again\n

\n"; +# echo "
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/closer-fronter_popup2.php b/agc_2-X/trunk/LANG_admin/vicidial/closer-fronter_popup2.php new file mode 100644 index 00000000..2cbadf1a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/closer-fronter_popup2.php @@ -0,0 +1,423 @@ + LICENSE: GPLv2 +### +# this is the closer popup of a specific call that starts recording the call and allows you to go and fetch info on that caller in the local CRM system. + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +# $ext_context = 'default'; defined in dbconnect file +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if (!$auth) + { + if ( (strlen($PHP_AUTH_USER)>1) and ( (eregi("tsr",$PHP_AUTH_PW)) or (eregi("sales",$PHP_AUTH_PW)) ) ) + { + $auth=1; + $user = $PHP_AUTH_USER; + $pass = $PHP_AUTH_PW; + } + } + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER - $user - $PHP_AUTH_USER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name from vicidial_users where user='$user' and pass='$pass'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + if ( (strlen($customer_zap_channel)>2) and ( (eregi('zap',$customer_zap_channel)) or (eregi('iax',$customer_zap_channel)) ) ) + { + echo "\n\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + } + else + { + echo "Bad channel: $customer_zap_channel\n"; + echo "Make sure the Zap channel is live and try again\n"; + exit; + } + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "VICIDIAL FRONTER-CLOSER: Popup\n"; + +if (eregi('CL_UNIV',$channel_group)) + { + ?> + + \n"; + echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n"; + echo "\n"; + } +?> + + +
+ + 0) +{ + +# $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RZ$FILE_datetime$user"; + + ### insert a NEW record to the vicidial_manager table to be processed + + $channel = $customer_zap_channel; +# $channel = eregi_replace('Zap/', "", $channel); + $SIPexten = eregi_replace('SIP/', "", $SIPexten); + $filename = "$REC_TIME$US$SIPexten"; + +# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: Zap/$channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + # Local/78600098@demo-6617,2 + + $stmt = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Originate','$DTqueryCID','Channel: $local_DEF$conf_silent_prefix$session_id$local_AMP$ext_context','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: $filename','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + + echo "Recording command sent for channel $channel - $filename - $recording_id       $NOW_TIME\n

\n"; + + $stmt="SELECT full_name from vicidial_users where user='$fronter'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "Call Referred by: $fronter - $full_name\n

\n"; + + $url = "http://10.10.10.196/vicidial/closer_dispo.php?lead_id=$lead_id&channel=$channel&server_ip=$server_ip&extension=$SIPexten&call_began=$STARTtime&parked_time=$parked_time&DB=$DB"; + + echo "View Customer Info and Disposition Call\n

\n"; + + + $stmt="SELECT group_name,group_color from vicidial_inbound_groups where group_id='$channel_group'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $group_name = $row[0]; + $group_color = $row[1]; + + echo "
\n"; + echo "
$channel_group - $group_name

\n\n"; + +########################################################################################### +####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX +########################################################################################### + +if (eregi('CL',$channel_group)) + { + if (strlen($phone) > 9) {$search_phone = $phone;} + if ( (strlen($search_phone) < 10) or (strlen($fronter) < 1) ) + { + echo "\n"; + $stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($fronter) < 1) {$fronter=$row[0];} + if (strlen($search_phone) < 10) {$search_phone=$row[1];} + } + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
New Search
Reservation Number:
Confirmation #:
Phone #:


Back
+ +
+ + + Close this window\n

\n"; +} +else +{ + echo "Record command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Please go back and try again\n

\n"; +# echo "
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/closer.php b/agc_2-X/trunk/LANG_admin/vicidial/closer.php new file mode 100644 index 00000000..dbd9efe7 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/closer.php @@ -0,0 +1,345 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["group_selected"])) {$group_selected=$_GET["group_selected"];} + elseif (isset($_POST["group_selected"])) {$group_selected=$_POST["group_selected"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["groupselect"])) {$groupselect=$_GET["groupselect"];} + elseif (isset($_POST["groupselect"])) {$groupselect=$_POST["groupselect"];} +if (isset($_GET["PHONE_LOGIN"])) {$PHONE_LOGIN=$_GET["PHONE_LOGIN"];} + elseif (isset($_POST["PHONE_LOGIN"])) {$PHONE_LOGIN=$_POST["PHONE_LOGIN"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["debugvars"])) {$debugvars=$_GET["debugvars"];} + elseif (isset($_POST["debugvars"])) {$debugvars=$_POST["debugvars"];} +if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];} + elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './closer_popup.php'; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$color_class[0] = 'green'; +$color_class[1] = 'red'; +$color_class[2] = 'blue'; +$color_class[3] = 'purple'; +$color_class[4] = 'orange'; +$color_class[5] = 'green'; +$color_class[6] = 'red'; +$color_class[7] = 'blue'; +$color_class[8] = 'purple'; +$color_class[9] = 'orange'; +?> + + + + + +VICIDIAL CLOSER: Main + + +
+ + 0) + { + $stmt="SELECT dialplan_number,server_ip from phones where extension='$extension';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dialplan_number=$row[0]; + $server_ip=$row[1]; + + if (!$group_selected) + { + $stmt="select distinct channel_group from park_log;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $groups_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + echo "
Please select the groups you want to pick calls up from:
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Inbound Call Groups:
\n"; + $o=0; + while ($groups_to_print > $o) + { + $group_form_print = sprintf("%-20s", $groups[$o]); + echo "$group_form_print
\n"; + $o++; + } + echo "
\n"; + echo "\n"; + echo "


\n"; + } + else + { + $o=0; + while($o < $group_selected) + { + $form_groups = "$form_groups&groupselect[$o]=$groupselect[$o]"; + $o++; + } + + $stmt="INSERT INTO vicidial_user_log values('','$user','LOGIN','CLOSER','$NOW_TIME','$STARTtime');"; + $rslt=mysql_query($stmt, $link); + + echo"\n"; + echo"\n"; + + echo "extension found, forwarding you to closer page, please wait 3 seconds...
\n"; + } + + } + else + { + echo "The extension you entered does not exist, please try again
\n"; + echo "
Please enter your phone_ID: \n"; + echo "\n"; + echo "phone station ID:   \n"; + echo "\n"; + echo "


\n"; + } + + } + else + { + echo "
Please enter your phone_ID: \n"; + echo "\n"; + echo "phone station ID:   \n"; + echo "\n"; + echo "


\n"; + } + +exit; + +} + +$o=0; +while($o < $group_selected) +{ + $listen_groups = "$listen_groups     $groupselect[$o]"; + $form_groups = "$form_groups&groupselect[$o]=$groupselect[$o]"; + $o++; +} + + +echo"\n"; +echo"\n"; + +#CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME +#---------------------------------------------------------------------------------------------- +#Zap/73-1 10.10.11.11 IN_800_TPP_CS TPPpark 7275338730 2004-04-22 12:41:00 + + + +echo "$NOW_TIME           $PHP_AUTH_USER - $fullname - CALLS SENT TO: $dialplan_number

\n"; + +echo "Click on the channel below that you would like to have directed to your phone
\n"; + +echo "
\n";
+echo "CHANNEL    SERVER        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME         \n";
+echo "---------------------------------------------------------------------------------------------- \n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$server_ip'";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$server_ip' and channel_group LIKE \"CL_%\" order by channel_group,parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$park_extension =	sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		$G='';   $EG='';
+		$o=0;
+		$with_color=0;
+		while($o < $group_selected)
+			{
+				if (eregi("$groupselect[$o]",$channel_group))
+					{
+					$G=""; $EG='';
+					$with_color++;
+					}
+				$o++;
+			}
+		if ($with_color)
+			{
+			if (eregi('CL_GAL',$row[2]))
+				{
+				echo "$G$channel$server$channel_group$park_extension                     $parked_time $EG\n";
+				}
+			else
+				{
+				echo "$G$channel$server$channel_group$park_extension$parked_by$parked_time $EG\n";
+				}
+			}
+#	
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "********************************************************************************************** \n";
+	echo "********************************************************************************************** \n";
+	echo "*************************************** NO PARKED CALLS ************************************** \n";
+	echo "********************************************************************************************** \n";
+	echo "********************************************************************************************** \n";
+	}
+
+echo "  \n\n";
+echo "looking for calls on these groups:\n";
+$o=0;
+while($o < $group_selected)
+{
+	$group_print =		sprintf("%-20s", $groupselect[$o]);
+	echo "             - $group_print\n";
+	$o++;
+}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/closer_dispo.php b/agc_2-X/trunk/LANG_admin/vicidial/closer_dispo.php new file mode 100644 index 00000000..54e61219 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/closer_dispo.php @@ -0,0 +1,329 @@ + LICENSE: GPLv2 +### +# this is the closer disposition screen of a call that has been grabbed. This allows the closer to modify customer information and disposition the call +# CHANGES +# +# 60619-1641 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL CLOSER: Call Disposition +\n"; +?> + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from live_channels where server_ip='$server_ip' and channel='" . mysql_real_escape_string($channel) . "' and extension like \"%" . mysql_real_escape_string($extension) . "%\""; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $parked_count = $row[0]; + + if ($parked_count > 0) + { + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Hangup','$DTqueryCID','Channel: " . mysql_real_escape_string($channel) . "','','','','','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Hangup command sent for channel $channel       $NOW_TIME\n

\n"; + + echo "\n"; + } + else + { + echo "Hangup command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "
\n"; + } +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Campaign ID: $campaign_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/closer_popup.php b/agc_2-X/trunk/LANG_admin/vicidial/closer_popup.php new file mode 100644 index 00000000..6c1db90e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/closer_popup.php @@ -0,0 +1,445 @@ + LICENSE: GPLv2 +### +# this is the closer popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["group_selected"])) {$group_selected=$_GET["group_selected"];} + elseif (isset($_POST["group_selected"])) {$group_selected=$_POST["group_selected"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["groupselect"])) {$groupselect=$_GET["groupselect"];} + elseif (isset($_POST["groupselect"])) {$groupselect=$_POST["groupselect"];} +if (isset($_GET["PHONE_LOGIN"])) {$PHONE_LOGIN=$_GET["PHONE_LOGIN"];} + elseif (isset($_POST["PHONE_LOGIN"])) {$PHONE_LOGIN=$_POST["PHONE_LOGIN"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["debugvars"])) {$debugvars=$_GET["debugvars"];} + elseif (isset($_POST["debugvars"])) {$debugvars=$_POST["debugvars"];} +if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];} + elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB=1; +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "VICIDIAL CLOSER: Popup\n"; + +if (eregi('CL_UNIV',$channel_group)) + { + ?> + + \n"; + echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n"; + echo "\n"; + } +?> + + +
+ + 0) +{ + $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + + #$monitor_channel = eregi_replace('Zap/', "", $channel); + $monitor_channel = eregi_replace('-1', "", $channel); + $SIPexten = $extension; + $filename = "$REC_TIME$US$SIPexten"; + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + +# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: $monitor_channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + +# $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$monitor_channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + +# $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; +# $rslt=mysql_query($stmt, $link); +# if ($DB) {echo "$stmt\n";} +# $row=mysql_fetch_row($rslt); +# $recording_id = $row[0]; + +# echo "Recording command sent for channel $channel - $filename - $recording_id
\n"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: $channel','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for channel $channel       $NOW_TIME\n

\n"; + + $stmt="SELECT full_name from vicidial_users where user='$parked_by'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "Call Referred by: $parked_by - $full_name\n

\n"; + + $url = "http://10.10.10.196/vicidial/closer_dispo.php?lead_id=$parked_by&channel=$channel&server_ip=$server_ip&extension=$extension&call_began=$STARTtime&parked_time=$parked_time&DB=$DB"; + + echo "View Customer Info and Disposition Call\n

\n"; + + + + $stmt="UPDATE park_log set grab_time='$NOW_TIME',status='TALKING',extension='$extension',user='$PHP_AUTH_USER' where parked_time='$parked_time' and server_ip='$server_ip' and channel='$channel'"; + if ($DB) {echo "|$stmt|\n";} + $fp = fopen ("./closer_SQL_updates.txt", "a"); + fwrite ($fp, "$date|$PHP_AUTH_USER|$stmt|\n"); + fclose($fp); + + + $rslt=mysql_query($stmt, $link); + +########################################################################################### +####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX +########################################################################################### +if (eregi('CL_TEST',$channel_group)) + { + echo "GALLERIA TEST CLOSER GROUP: $channel_group\n"; + + $stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $fronter=$row[0]; + $search_phone=$row[1]; + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ -- INTERNAL CALL GALLERIA FRONT --
\n"; + $group_color='#99FF99'; + } + if (eregi('CL_GALLER2',$channel_group)) + { + echo "
-- TouchAsia CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER3',$channel_group)) + { + echo "
-- DebitSupplies CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER4',$channel_group)) + { + echo "
-- Vishnu CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
New Search
Reservation Number:
Confirmation #:
Phone #:


Back
+ +
+ + + Close this window\n

\n"; +} +else +{ + echo "Redirect command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/count.htm b/agc_2-X/trunk/LANG_admin/vicidial/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/count.htm @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/dbconnect.php b/agc_2-X/trunk/LANG_admin/vicidial/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/group_hourly_stats.php b/agc_2-X/trunk/LANG_admin/vicidial/group_hourly_stats.php new file mode 100644 index 00000000..b7eb1b31 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/group_hourly_stats.php @@ -0,0 +1,252 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: Group Hourly Stats +\n"; +?> + + +
+ + + + + += '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "
  VICIDIAL ADMIN: Group Hourly Stats  
\n"; + +echo "
\n"; + +echo "TSR HOUR COUNTS: $group | $status | $date_with_hour | $date_no_hour\n"; + +echo "
\n"; +echo "\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "\n"; + + +} + +echo "
TSR ID   $status   TOTAL CALLS   $status DAY    
$VDuser[$o] $VDname[$o] $VDcount[$o] $VDtotal[$o] $VDday[$o]MODIFY | STATS
TOTAL $status $hour_calls $total_calls $day_calls
\n"; +echo "

\n"; + + + echo "
Please enter the group you want to get hourly stats for:
\n"; + echo "\n"; + echo "group:
\n"; + echo "status:   (example: XFER)
\n"; + echo "date with hour:   (example: 2004-06-25 14)
\n"; + echo "\n"; + echo "


\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/help.gif b/agc_2-X/trunk/LANG_admin/vicidial/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/vicidial/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/vicidial/listloader.php b/agc_2-X/trunk/LANG_admin/vicidial/listloader.php new file mode 100644 index 00000000..920505a8 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/listloader.php @@ -0,0 +1,698 @@ + LICENSE: GPLv2 +# +# AST Web GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1006 - added listID override and gmt_offset lookup while loading +# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. +# + +$version = '1.1.12'; +$build = '60619-1652'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];} +$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB=1; +#$DBX=1; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('listloader.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +?> + + + + + + method=post enctype="multipart/form-data"> +
+ + + + + + + + + + + + + +
Load leads from this file:
List ID Override: (numbers only or leave blank for values in the file)
CLICK HERE TO GO TO THE SUPER LEAD LOADER (BETA VERSION)     BACK TO ADMIN
+ +document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + $pulldate=date("Y-m-d H:i:s"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("./vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city = $row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) + { + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $gmt_offset = '0'; + $called_since_last_reset='N'; + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + print ""; +} else if (filesize($leadfile)>8388608) { + print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/listloader.pl b/agc_2-X/trunk/LANG_admin/vicidial/listloader.pl new file mode 100644 index 00000000..753c31f7 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/listloader.pl @@ -0,0 +1,690 @@ +#!/usr/bin/perl + +### listloader.pl +### +### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 +### +# +# +# CHANGES +# 60616-1548 - Added listID override feature to force all leads into same list +# - Added gmt_offset_now lookup for each lead +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + } + else + { + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + } +} +### end parsing run-time options ### + + +use Spreadsheet::ParseExcel; +use Time::Local; +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$|=0; +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$pulldate="$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + + ### Grab Server values from the database + $stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + +$total=0; $good=0; $bad=0; +print "
Processing Excel file...\n"; +open(STMT_FILE, "> listloader_stmts.txt"); + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +my($iR, $iC, $oWkS, $oWkC); + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $oWkC = $oWkS->{Cells}[$iR][0]; + if ($oWkC) {$vendor_lead_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][1]; + if ($oWkC) {$source_code=$oWkC->Value; } + $source_id=$source_code; + $oWkC = $oWkS->{Cells}[$iR][2]; + if ($oWkC) {$list_id=$oWkC->Value; } + $gmt_offset = '0'; + $called_since_last_reset='N'; + $oWkC = $oWkS->{Cells}[$iR][3]; + if ($oWkC) {$phone_code=$oWkC->Value; } + $phone_code=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][4]; + if ($oWkC) {$phone_number=$oWkC->Value; } + $phone_number=~s/[^0-9]//g; + $USarea = substr($phone_number, 0, 3); + $oWkC = $oWkS->{Cells}[$iR][5]; + if ($oWkC) {$title=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][6]; + if ($oWkC) {$first_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][7]; + if ($oWkC) {$middle_initial=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][8]; + if ($oWkC) {$last_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][9]; + if ($oWkC) {$address1=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][10]; + if ($oWkC) {$address2=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][11]; + if ($oWkC) {$address3=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][12]; + if ($oWkC) {$city=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][13]; + if ($oWkC) {$state=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][14]; + if ($oWkC) {$province=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][15]; + if ($oWkC) {$postal_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][16]; + if ($oWkC) {$country=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][17]; + if ($oWkC) {$gender=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][18]; + if ($oWkC) {$date_of_birth=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][19]; + if ($oWkC) {$alt_phone=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][20]; + if ($oWkC) {$email=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][21]; + if ($oWkC) {$security_phrase=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][22]; + if ($oWkC) {$comments=$oWkC->Value; } + $comments=~s/^\s*(.*?)\s*$/$1/; + + if (length($phone_number)>8) { + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &USA_dstcalc; + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + sleep(1); +# flush(); + } + } +} + +if ($multi_insert_counter > 0) { + $stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; +} + +print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + +exit; + + + + + + +sub USA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +#********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $USA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } + } else { + $USA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $USA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } + } else { + $USA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/LANG_admin/vicidial/listloaderMAIN.php b/agc_2-X/trunk/LANG_admin/vicidial/listloaderMAIN.php new file mode 100644 index 00000000..67ee25bc --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/listloaderMAIN.php @@ -0,0 +1,79 @@ + LICENSE: GPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + +VICIDIAL: Lead Loader Module + + + + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/listloader_rowdisplay.pl b/agc_2-X/trunk/LANG_admin/vicidial/listloader_rowdisplay.pl new file mode 100644 index 00000000..ca0da8c5 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/listloader_rowdisplay.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use Spreadsheet::ParseExcel; +use Time::Local; +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +my($iR, $iC, $oWkS, $oWkC); +$var_str=""; + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { + $oWkC = $oWkS->{Cells}[0][$iC]; + if ($oWkC) { + $var_str.=$oWkC->Value."|"; + } else { + $var_str.="|"; + } + } +} + +@xls_row=split(/\|/, $var_str); + + +$dbhA->query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1"); + +if ($dbhA->has_selected_record) { + $rslt = $dbhA->create_record_iterator(); + my @row = $rslt->get_field_names(); + for ($i=0; $i\r\n"; + print "
".$field_name.": \r\n"; + print " \r\n"; + print "
+ + + + + + + + + + + + + + + + + +
Load leads from this file:
List ID Override: (numbers only or leave blank for values in the file)
File layout to use:Standard VICIDIAL    Custom layout
        
CLICK HERE TO GO TO THE BASIC LEAD LOADER         BACK TO ADMIN
SUPER LIST LOADER-     VERSION:     BUILD:
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Processing $delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + print "
Processing Excel file... \n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + # print "$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field"; + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile && filesize($LF_path)<=8388608) { + $total=0; $good=0; $bad=0; + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Processing $delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + $total=0; $good=0; $bad=0; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL ColumnFile data
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
        
\r\n"; + # } + print ""; + } +} else if (filesize($leadfile)>8388608) { + print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + + + + + + + + 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### MEXICO ### +if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### AUSTRALIA ### +if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### ALL OTHER COUNTRY CODES ### +if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/record_conf_1_hour.php b/agc_2-X/trunk/LANG_admin/vicidial/record_conf_1_hour.php new file mode 100644 index 00000000..59ae1f09 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/record_conf_1_hour.php @@ -0,0 +1,156 @@ + LICENSE: GPLv2 +### +# grab: $server_ip $station $session_id +# +# CHANGES +# +# 60620-1011 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["station"])) {$station=$_GET["station"];} + elseif (isset($_POST["station"])) {$station=$_POST["station"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["NEW_RECORDING"])) {$NEW_RECORDING=$_GET["NEW_RECORDING"];} + elseif (isset($_POST["NEW_RECORDING"])) {$NEW_RECORDING=$_POST["NEW_RECORDING"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$MYSQL_datetime = date("Y-m-d H:i:s"); +$FILE_datetime = date("Ymd-His_"); +$secX = $STARTtime; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL RECORD CONFERENCE: 1 hour +\n"; +?> + + +
+ + 8) && (strlen($session_id) > 3) && (strlen($station) > 3) ) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $conf_silent_prefix = '7'; + $ext_context = 'demo'; + + $stmt="INSERT INTO vicidial_manager values('','','$MYSQL_datetime','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Originate','RB$FILE_datetime" . mysql_real_escape_string($station) . "','Channel: $local_DEF$conf_silent_prefix" . mysql_real_escape_string($session_id) . "$local_AMP$ext_context','Context: $ext_context','Exten: 8309','Priority: 1','Callerid: $FILE_datetime" . mysql_real_escape_string($station) . "','','','','','')"; + echo "|$stmt|\n

\n"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('" . mysql_real_escape_string($session_id) . "','" . mysql_real_escape_string($server_ip) . "','" . mysql_real_escape_string($station) . "','$MYSQL_datetime','$secX','$FILE_datetime" . mysql_real_escape_string($station) . "')"; + echo "|$stmt|\n

\n"; + $rslt=mysql_query($stmt, $link); + + echo "Recording started\n

\n"; + echo "Back to main recording screen\n

\n"; + } + else + { + echo "ERROR!!!! Not all info entered properly\n

\n"; + echo "|$server_ip| |$session_id| |$station|\n

\n"; + echo "Back to main recording screen\n

\n"; + } +} +else +{ +echo "
Start recording a conference for 1 hour:
\n"; +echo "\n"; +echo "server_ip: | \n"; +echo "session_id: | \n"; +echo "station: | \n"; +echo "\n"; +echo "


\n"; + + + +} +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/remote_dispo.php b/agc_2-X/trunk/LANG_admin/vicidial/remote_dispo.php new file mode 100644 index 00000000..da249fba --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/remote_dispo.php @@ -0,0 +1,327 @@ + LICENSE: GPLv2 +### +# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call + +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL REMOTE: Call Disposition +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Call has been dispositioned       $NOW_TIME\n

\n"; + + echo "\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Campaign ID: $campaign_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/server_stats.php b/agc_2-X/trunk/LANG_admin/vicidial/server_stats.php new file mode 100644 index 00000000..a427f5c0 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/server_stats.php @@ -0,0 +1,96 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1037 - Added Link back to Admin section +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select * from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $i++; + } +?> + + + + + +VICIDIAL: Server Stats and Reports +VICIDIAL: Server Stats and Reports                           +BACK TO ADMIN

+ + +

+
+ $o)
+	{
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	$o++;
+	}
+
+?>
+
SERVERDESCRIPTIONIP ADDRESSACTIVEVDAD timeVDcall timePARK timeCLOSER/INBOUND time
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]LINKLINKLINKLINK
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/test.txt b/agc_2-X/trunk/LANG_admin/vicidial/test.txt new file mode 100644 index 00000000..70c379b6 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/test.txt @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial/user_stats.php b/agc_2-X/trunk/LANG_admin/vicidial/user_stats.php new file mode 100644 index 00000000..bdada227 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/user_stats.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: User Stats +\n"; +?> + + +
+ + + + + +\n"; +echo "
  VICIDIAL ADMIN: User Stats for  
  \n"; + +echo "
\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + +echo "
\n"; + +echo "TALK TIME AND STATUS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + +echo "\n"; +echo "
STATUSCOUNTHOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
TOTAL CALLS $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LOGIN/LOGOUT TIME:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours = ($event_seconds / 3600); + $event_hours = round($event_hours, 2); + $event_hours_int = intval("$event_hours"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours = ($total_login_time / 3600); +$total_login_hours = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
EVENT DATE CAMPAIGNHOURS:MINUTES
$row[0] $row[2] $row[3]
$row[0] $row[2] $row[3] $event_hours_int:$event_minutes_int
$row[0] $row[2] $row[3]
TOTAL $total_login_hours_int:$total_login_minutes_int
\n"; + + +echo "

\n"; + +echo "
\n"; + +echo "LAST 50 CALLS:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS PHONE CAMPAIGN LIST LEAD
$row[4] $row[7] $row[8] $row[10] $row[3] $row[2] $row[1]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/user_status.php b/agc_2-X/trunk/LANG_admin/vicidial/user_status.php new file mode 100644 index 00000000..8efe670f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/user_status.php @@ -0,0 +1,238 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $change_agent_campaign=$row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $i++; + } + + } + +$stmt="select * from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> + + +VICIDIAL ADMIN: User Status +\n"; +?> + + +
+
+ + + + +\n"; +echo "
  VICIDIAL ADMIN: User Status for  
  \n"; + +if ($stage == "live_campaign_change") +{ + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign
\n"; + + exit; +} + +if ($stage == "log_agent_out") +{ + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser
\n"; + + exit; +} + +if ($agents_to_print > 0) +{ + echo "
";
+	echo "Agent Logged in at server:  $Aserver_ip\n";
+	echo "               in session:  $Asession_id\n";
+	echo "               from phone:  $Aextension\n";
+	echo "Agent is in campaign:       $Acampaign\n";
+	echo "              status:       $Astatus\n";
+	echo " hungup last call at:       $Alast_call\n";
+	echo "       Closer groups:       $Acl_campaigns\n\n";
+
+	echo "
"; + + + if ($change_agent_campaign > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Current Campaign: \n"; + echo "
\n"; + + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } +} + +else +{ + echo "Agent is not logged in\n
"; + +} + + +echo "           $user - $full_name - \n"; + +echo "VICIDIAL Time Sheet\n"; + +echo "
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + +echo "|$stage|$group|"; + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial/vdremote.php b/agc_2-X/trunk/LANG_admin/vicidial/vdremote.php new file mode 100644 index 00000000..dfe11fa3 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial/vdremote.php @@ -0,0 +1,602 @@ + LICENSE: GPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time + +$version = '1.1.12'; +$build = '60619-1603'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +VICIDIAL REMOTE AGENTS: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Modify Remote Agents";} +if ($ADD==41111) {echo "Modify Remote Agents";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+
+ + + +
  VICIDIAL REMOTE AGENTS:   Logout  
  MODIFY | ">STATUS | ">INBOUND STATS
+"; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: $user_start
Number of Lines: (numbers only)
Server IP: $row[3]
External Extension: (number dialed to reach agents [i.e. 913125551212])
Status:
Campaign: $campaign_id
Inbound Groups: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + + } + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: $user_start
Number of Lines: (numbers only)
Server IP: $row[3]
External Extension: (number dialed to reach agents [i.e. 913125551212])
Status:
Campaign: $campaign_id
Inbound Groups: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) +{ + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]=' - WAITING - '; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i agents logged in on server $server_ip\n\n"; + + echo " - 5 minutes or more on call\n"; + echo " - Over 10 minutes on call\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* NO AGENTS ON CALLS *********************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) +{ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "VICIDIAL: Remote Agent inbound stats $NOW_TIME\n\n"; + echo "\n"; + echo "Total calls taken $query_date: $in_calls\n"; + echo "Total talk time on $query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Call list for $query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + # echo " $i agents logged in on server $server_ip\n\n"; + + # echo " - 5 minutes or more on call\n"; + # echo " - Over 10 minutes on call\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* NO CALLS ON THIS DAY *******************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_CLOSERstats.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_CLOSERstats.php new file mode 100644 index 00000000..e96e2319 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_CLOSERstats.php @@ -0,0 +1,396 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Genauerer Notfall\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ÄNDERN Sie | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "WÄHLEN Sie BITTE Eine KAMPAGNE Vor UND DATUM OBEN UND KLICKEN REICHTEin\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Automobil-Vorwahlknopf Genauerer Notfall                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Gesamtanrufe gesetzt von dieser Kampagne:                       $TOTALcalls\n";
+echo "Durchschnittliche Anruf-Länge für alle benennt in den Sekunden: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Gesamt-TROPFEN Anrufe:                                          $DROPcalls  $DROPpercent%\n";
+echo "Durchschnittliche Länge für TROPFEN Anrufe in den Sekunden:     $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| BENUTZER | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN DER GESAMTANRUFE GESETZTVON DIESER KAMPAGNE\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_VDADstats.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_VDADstats.php new file mode 100644 index 00000000..67764a49 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_VDADstats.php @@ -0,0 +1,417 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ÄNDERN Sie | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "WÄHLEN Sie BITTE Eine KAMPAGNE Vor UND DATUM OBEN UND KLICKEN REICHTEin\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Gesamtanrufe gesetzt von dieser Kampagne:                       $TOTALcalls\n";
+echo "Durchschnittliche Anruf-Länge für alle benennt in den Sekunden: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Gesamt-TROPFEN Anrufe:                                          $DROPcalls  $DROPpercent%\n";
+echo "Durchschnittliche Länge für TROPFEN Anrufe in den Sekunden:     $average_hold_seconds\n";
+
+echo "\n";
+echo "----------AUTO-DIAL KEINE ANTWORTEN\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$NAcalls =	sprintf("%10s", $row[0]);
+$NApercent = (($NAcalls / $TOTALcalls) * 100);
+$NApercent = round($NApercent, 0);
+
+$average_na_seconds = ($row[1] / $row[0]);
+$average_na_seconds = round($average_na_seconds, 0);
+$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+
+echo "Gesamt-Na benennt - beschäftigt, Trennung, BTvoicemail:         $NAcalls  $NApercent%\n";
+echo "Durchschnittliche Anruf-Länge für Na benennt in den Sekunden:   $average_na_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| BENUTZER | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "DIAGRAMM IN 15 MINUZIÖSEN STUFENSPRÜNGEN DER GESAMTANRUFE GESETZTVON DIESER KAMPAGNE\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..f6b51205 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,161 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Zufuhrbehälter-Liste\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           ÄNDERN Sie \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "WÄHLEN Sie BITTE Eine KAMPAGNE OBEN Vor UND KLICKEN REICHT Ein\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Gegenwärtige Zufuhrbehälter-Lebhaftliste                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+
+echo "Gesamtleitungen im Zufuhrbehälter im Augenblick:       $TOTALcalls\n";
+
+
+##############################
+#########  LEAD STATS
+
+echo "\n";
+echo "---------- LEADS IN HOPPER\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+echo "|      | LEAD_ID   | PHONE NUM  | STATE | STATUS | COUNT | GMT    |\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$FMT_i =		sprintf("%-4s", $i);
+	$lead_id =		sprintf("%-9s", $row[0]);
+	$phone_number =	sprintf("%-10s", $row[1]);
+	$state =		sprintf("%-5s", $row[2]);
+	$status =		sprintf("%-6s", $row[3]);
+	$count =		sprintf("%-5s", $row[4]);
+	$gmt =			sprintf("%-6s", $row[5]);
+
+	echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
+
+	$i++;
+	}
+
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_admin_log_display.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_admin_log_display.php new file mode 100644 index 00000000..c9fad01a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_admin_log_display.php @@ -0,0 +1,118 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date); + +# AST GUI database administration +# AST_admin_log_display.php +# +# CHANGES +# 50325-0932 - First build +# 51123-1443 - removed globals=on requirement +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '0.0.4'; +$build = '60620-1044'; + +$STARTtime = date("U"); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN LOG DISPLAY"; +echo "\n"; + +# Fri, 25 Mar 2005 + +$DAY_DATE = date("j"); +if ($DAY_DATE < 10) +# {$GREP_DATE = date("D, j M Y");} + {$GREP_DATE = date("D, 0j M Y");} +else + {$GREP_DATE = date("D, j M Y");} + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!$query_date) {$query_date = $GREP_DATE;} + +$Gquery_date = eregi_replace(" ",'\ ',$query_date); +echo "\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+echo "VICIDIAL ADMIN CHANGE LOG                             $NOW_TIME\n";
+
+#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
+passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_performance.php new file mode 100644 index 00000000..7947c17f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_performance.php @@ -0,0 +1,232 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Agent Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ÄNDERN Sie | REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A BEDIENERAND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_performance_detail.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_performance_detail.php
new file mode 100644
index 00000000..02a7c24a
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_performance_detail.php
@@ -0,0 +1,406 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ÄNDERN Sie | REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 03:45:00";   
+	$query_date_END = "$query_date 15:15:00";
+	$time_BEGIN = "03:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:15:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance Detail                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TIME   | PAUSE  | PAUSAVG| WAIT   | WAITAVG| TALK   | TALKAVG| DISPO  | DISPAVG| A    | B    | DC   | DNC  | N    | NI   | CB   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$TOTtotWAIT=($TOTtotWAIT + $row[7]);
+	$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
+	$TOTtotDISPO=($TOTtotDISPO + $row[9]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtime =	($row[1] + $row[5] + $row[7] + $row[9]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+	$USERtotPAUSE =	$row[5];
+	$USERavgPAUSE =	$row[6];
+	$USERtotWAIT =	$row[7];
+	$USERavgWAIT =	$row[8];
+	$USERtotDISPO =	$row[9];
+	$USERavgDISPO =	$row[10];
+
+	$USERtime_M = ($USERtime / 60);
+	$USERtime_M = round($USERtime_M, 2);
+	$USERtime_M_int = intval("$USERtime_M");
+	$USERtime_S = ($USERtime_M - $USERtime_M_int);
+	$USERtime_S = ($USERtime_S * 60);
+	$USERtime_S = round($USERtime_S, 0);
+	if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
+	$USERtime_MS = "$USERtime_M_int:$USERtime_S";
+	$pfUSERtime_MS[$i] =		sprintf("%7s", $USERtime_MS);
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+
+	$USERtotPAUSE_M = ($USERtotPAUSE / 60);
+	$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
+	$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
+	$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
+	$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
+	$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
+	if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
+	$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
+	$pfUSERtotPAUSE_MS[$i] =		sprintf("%6s", $USERtotPAUSE_MS);
+
+	$USERavgPAUSE_M = ($USERavgPAUSE / 60);
+	$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
+	$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
+	$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
+	$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
+	$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
+	if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
+	$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
+	$pfUSERavgPAUSE_MS[$i] =		sprintf("%6s", $USERavgPAUSE_MS);
+
+	$USERtotWAIT_M = ($USERtotWAIT / 60);
+	$USERtotWAIT_M = round($USERtotWAIT_M, 2);
+	$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
+	$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
+	$USERtotWAIT_S = ($USERtotWAIT_S * 60);
+	$USERtotWAIT_S = round($USERtotWAIT_S, 0);
+	if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
+	$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
+	$pfUSERtotWAIT_MS[$i] =		sprintf("%6s", $USERtotWAIT_MS);
+
+	$USERavgWAIT_M = ($USERavgWAIT / 60);
+	$USERavgWAIT_M = round($USERavgWAIT_M, 2);
+	$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
+	$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
+	$USERavgWAIT_S = ($USERavgWAIT_S * 60);
+	$USERavgWAIT_S = round($USERavgWAIT_S, 0);
+	if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
+	$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
+	$pfUSERavgWAIT_MS[$i] =		sprintf("%6s", $USERavgWAIT_MS);
+	
+	$USERtotDISPO_M = ($USERtotDISPO / 60);
+	$USERtotDISPO_M = round($USERtotDISPO_M, 2);
+	$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
+	$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
+	$USERtotDISPO_S = ($USERtotDISPO_S * 60);
+	$USERtotDISPO_S = round($USERtotDISPO_S, 0);
+	if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
+	$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
+	$pfUSERtotDISPO_MS[$i] =		sprintf("%6s", $USERtotDISPO_MS);
+
+	$USERavgDISPO_M = ($USERavgDISPO / 60);
+	$USERavgDISPO_M = round($USERavgDISPO_M, 2);
+	$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
+	$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
+	$USERavgDISPO_S = ($USERavgDISPO_S * 60);
+	$USERavgDISPO_S = round($USERavgDISPO_S, 0);
+	if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
+	$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
+	$pfUSERavgDISPO_MS[$i] =		sprintf("%6s", $USERavgDISPO_MS);
+
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; $ctCB[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]);	$TOT_CB = ($TOT_CB + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtime_M = ($TOTtime / 60);
+	$TOTtime_M = round($TOTtime_M, 2);
+	$TOTtime_M_int = intval("$TOTtime_M");
+	$TOTtime_S = ($TOTtime_M - $TOTtime_M_int);
+	$TOTtime_S = ($TOTtime_S * 60);
+	$TOTtime_S = round($TOTtime_S, 0);
+	if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
+	$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
+	$TOTtime_MS =		sprintf("%7s", $TOTtime_MS);
+		while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOTtotDISPO_M = ($TOTtotDISPO / 60);
+	$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
+	$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
+	$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
+	$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
+	$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
+	if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
+	$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
+	$TOTtotDISPO_MS =		sprintf("%7s", $TOTtotDISPO_MS);
+		while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+
+	$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
+	$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
+	$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
+	$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
+	if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
+	$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
+	$TOTtotPAUSE_MS =		sprintf("%7s", $TOTtotPAUSE_MS);
+		while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+
+	$TOTtotWAIT_M = ($TOTtotWAIT / 60);
+	$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
+	$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
+	$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
+	$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
+	$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
+	if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
+	$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
+	$TOTtotWAIT_MS =		sprintf("%7s", $TOTtotWAIT_MS);
+		while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+
+
+	$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
+	$TOTavgTALK_M = round($TOTavgTALK_M, 2);
+	$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
+	$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
+	$TOTavgTALK_S = ($TOTavgTALK_S * 60);
+	$TOTavgTALK_S = round($TOTavgTALK_S, 0);
+	if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
+	$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
+	$TOTavgTALK_MS =		sprintf("%6s", $TOTavgTALK_MS);
+		while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+
+	$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
+	$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
+	$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
+	$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
+	$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
+	$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
+	if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
+	$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
+	$TOTavgDISPO_MS =		sprintf("%6s", $TOTavgDISPO_MS);
+		while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+
+	$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
+	$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
+	$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
+	$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
+	if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
+	$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
+	$TOTavgPAUSE_MS =		sprintf("%6s", $TOTavgPAUSE_MS);
+		while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+
+	$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
+	$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
+	$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
+	$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
+	$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
+	$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
+	if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
+	$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
+	$TOTavgWAIT_MS =		sprintf("%6s", $TOTavgWAIT_MS);
+		while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+
+	
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_CB = sprintf("%-5s", $TOT_CB);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
+echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_time_sheet.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_time_sheet.php
new file mode 100644
index 00000000..ccc62e80
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_agent_time_sheet.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN MITTELID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- MITTELTIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "GESAMTANRUFETAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE MITTELTIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_server_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_server_performance.php
new file mode 100644
index 00000000..6331a75a
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_server_performance.php
@@ -0,0 +1,310 @@
+    LICENSE: GPLv2
+#
+# CHANGES
+#
+# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))	{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))	{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))	{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+# path from root to where ploticus files will be stored
+$DOCroot = "$WeBServeRRooT/vicidial/ploticus/";
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+if (!isset($group)) {$group = '';}
+
+$stmt="select server_ip from servers;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$servers_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $servers_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Server Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "             REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A BEDIENERAND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:32:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:32:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Server Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$HIGHload =	sprintf("%10s", $row[0]);
+$HIGHmulti = intval($HIGHload / 100);
+#$HIGHmulti = ($HIGHload / 100);
+
+$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$USEDram =	sprintf("%10s", $row[0]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average channels in use for server:       $AVGchannels\n";
+echo "Average load for server:                  $AVGload\n";
+echo "Peak load for server:                     $HIGHload\n";
+#echo "Peak used memory for server (in MB):      $USEDram\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 14 7\n";
+$HTMcontent .= "xscaletype: time hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHload\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc 30 minutes\n";
+$HTMcontent .= "minorticinc: 5 minutes\n";
+$HTMcontent .= "stubformat: hh:mm:ssa\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-2 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDAD.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDAD.php new file mode 100644 index 00000000..cc3fb242 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDAD.php @@ -0,0 +1,255 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Mittel Setzen Bei den Anrufen Zeit fest        $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL    | STATUS | START TIME          | MINUTES |\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	$agentcount=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WARTEND -';
+			$row[6]=$row[7];
+			}
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$sessionid =		sprintf("%-9s", $row[2]);
+		$channel =			sprintf("%-10s", $row[3]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[4]);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 5) {$G=''; $EG='';}
+		if ($call_time_M_int >= 10) {$G=''; $EG='';}
+		if (eregi("PAUSED",$row[4])) 
+			{
+			if ($call_time_M_int >= 1) 
+				{$i++; continue;} 
+			else
+				{$G=''; $EG='';}
+			}
+
+		$agentcount++;
+		echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+		echo "  $agentcount Mittel geloggt innen auf Bediener $server_ip\n\n";
+
+		echo "             - Pausierte Mittel\n";
+		echo "             - 5 Minuten oder mehr beim Anruf\n";
+		echo "             - Über 10 Minuten beim Anruf\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+echo "| CHANNEL    | STATUS | CAMPAIGN | PHONE NUMBER       | START TIME          | MINUTES |\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-8s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+		echo "  $i Anrufe, die auf Bediener gesetzt werden $server_ip\n\n";
+
+		echo "             - PHASENCANKLOPFEN\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************KEIN PHASENCANKLOPFEN*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDAD_closer.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDAD_closer.php new file mode 100644 index 00000000..b7e87d02 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDAD_closer.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Mittel Setzen Bei den Anrufen Zeit fest        $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPAIGN     | FRONT  |\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED|CLOSER",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WAIT -';
+			$row[6]=$row[7];
+			}
+		$extension[$i] =		sprintf("%-10s", $row[0]);
+		$user[$i] =				sprintf("%-6s", $row[1]);
+		$sessionid[$i] =		sprintf("%-9s", $row[2]);
+		$channel[$i] =			sprintf("%-19s", $row[3]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $row[4]);
+		$start_time[$i] =		sprintf("%-8s", $row[5]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$row[8];
+		$lead_id[$i] =			$row[9];
+		$closer[$i] =			$row[1];
+		$call_time_S[$i] = ($STARTtime - $row[6]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+		$i++;
+		}
+		$ext_count = $i;
+		$i=0;
+	while ($i < $ext_count)
+		{
+
+		$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$camp_to_print = mysql_num_rows($rslt);
+		if ($camp_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$campaign = sprintf("%-12s", $row[0]);
+			$camp_color = $row[0];
+			}
+		else
+			{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+		if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+			{$campaign = '            ';   	$camp_color = '';}
+
+		$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$xfer_to_print = mysql_num_rows($rslt);
+		if ($xfer_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$fronter = sprintf("%-6s", $row[0]);
+			}
+		else
+			{$fronter = '      ';}
+
+		$G = '';		$EG = '';
+		$G=""; $EG='';
+	#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+	#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+		echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i Mittel geloggt innen auf Bediener $server_ip\n\n";
+
+	#	echo "             - 5 Minuten oder mehr beim Anruf\n";
+	#	echo "             - Über 10 Minuten beim Anruf\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPAIGN     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i Anrufe, die auf Bediener gesetzt werden $server_ip\n\n";
+
+		echo "             - PHASENCANKLOPFEN\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************KEIN PHASENCANKLOPFEN*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDADall.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDADall.php new file mode 100644 index 00000000..4ad6fb65 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDADall.php @@ -0,0 +1,349 @@ + LICENSE: GPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($group)) {$group='';} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Kampagne: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Kampagne: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         ÄNDERN Sie | REPORTS \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo "KEIN PHASENCANKLOPFEN\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Kampagne: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | BEDIENERIP | CALL BEDIENERIP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n\n"; + + $Aecho .= " - Pausierte Mittel\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo "KEINE MITTEL BEI DEN ANRUFEN\n";
+	}
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDADall_SIPmonitor.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDADall_SIPmonitor.php new file mode 100644 index 00000000..dff474ef --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonVDADall_SIPmonitor.php @@ -0,0 +1,301 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala +# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];} +$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];} +$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];} +$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];} +$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];} +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!$RR) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VF DIALER: Time On VDAD Kampagne: $group\n"; +echo "
\n"; +echo "VF DIALER: Realtime Kampagne: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         ÄNDERN Sie | REPORTS \n"; +echo "\n\n"; + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); + +echo "
"; +echo "DIAL LEVEL: $row[0]         "; +echo "STATUSES: $row[1], $row[2], $row[3], $row[4], $row[5]         "; +echo "ORDER: $row[6]"; +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";} +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo "KEIN PHASENCANKLOPFEN\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VF DIALER: Agents Time On Calls Kampagne: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | BEDIENERIP | CALL BEDIENERIP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + $sessionid = trim($sessionid); + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n"; + + + $Aecho .= " - Pausierte Mittel\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo "KEINE MITTEL BEI DEN ANRUFEN\n";
+	}
+
+?>
+
+ + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeoncall.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeoncall.php new file mode 100644 index 00000000..4227f836 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeoncall.php @@ -0,0 +1,180 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Call\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Call                                          $NOW_TIME\n\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+echo "| STATION    | SESSIONID | CHANNEL   | NUMBER DIALED    | START TIME          | MINUTES |\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+
+$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="select extension from live_channels where server_ip='$server_ip';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$ext_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_zap_counter=0;
+	$sessions = '';
+	while ($i < $ext_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if (preg_match("/^8600/i",$row[0]))
+			{
+			$sessions .= "$row[0]|";
+			}
+		$i++;
+		}
+	$sessions = preg_replace("/\|$/",'',$sessions);
+
+	if ($DB) {echo "SESSIONS: -$sessions-\n";}
+
+	$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_calls_counter=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
+			{
+			if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
+			$session_id = '';
+			}
+		else 
+			{
+			if (preg_match("/$row[3]/i",$sessions))
+				{
+				if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
+				$session_id = $row[3];
+				$station = preg_replace("/SIP\//",'',$row[0]);
+				$station = preg_replace("/-.*/",'',$station);
+			
+				$LIVE_sessions[$live_calls_counter] =			"$session_id";
+				$LIVE_sessions_FORMAT[$live_calls_counter] =	sprintf("%-9s", $session_id);
+				$LIVE_stations[$live_calls_counter] =			"$station";
+				$LIVE_stations_FORMAT[$live_calls_counter] =	sprintf("%-10s", $station);
+
+		#		echo "| $station | $session_id | \n";
+
+				$live_calls_counter++;
+				}
+			else
+				{
+				if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
+				$session_id = '';
+				}
+			}
+
+		$i++;
+		}
+
+		if ($live_calls_counter > 0)
+		{
+		$i=0;
+		$LC_counter = $live_calls_counter;
+
+		while ($i < $live_calls_counter)
+			{
+			$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$parked_to_print = mysql_num_rows($rslt);
+			$row=mysql_fetch_row($rslt);
+
+			$channel =			sprintf("%-9s", $row[0]);
+			$number_dialed =	sprintf("%-16s", $row[2]);
+			$start_time =		sprintf("%-19s", $row[3]);
+			$call_time_S = ($STARTtime - $row[4]);
+
+			$call_time_M = ($call_time_S / 60);
+			$call_time_M = round($call_time_M, 2);
+			$call_time_M_int = intval("$call_time_M");
+			$call_time_SEC = ($call_time_M - $call_time_M_int);
+			$call_time_SEC = ($call_time_SEC * 60);
+			$call_time_SEC = round($call_time_SEC, 0);
+			if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+			$call_time_MS = "$call_time_M_int:$call_time_SEC";
+			$call_time_MS =		sprintf("%7s", $call_time_MS);
+			$G = '';		$EG = '';
+			if ($call_time_M_int >= 12) {$G=''; $EG='';}
+			if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+			echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+			$i++;
+			}
+
+		echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+		echo "  $i stations on live calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on live call\n";
+		echo "             - Over 30 minutes on live call\n";
+
+		}
+		else
+		{
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*************************************** NO LIVE STATIONS ********************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		}
+
+	}
+	else
+	{
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*************************************** NO LIVE STATIONS ********************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	}
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonpark.php b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonpark.php new file mode 100644 index 00000000..46aee71b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/AST_timeonpark.php @@ -0,0 +1,197 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park                       $NOW_TIME\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "********************KEIN PHASENCANKLOPFEN*********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/admin.php b/agc_2-X/trunk/LANG_admin/vicidial_de/admin.php new file mode 100644 index 00000000..67d396e3 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/admin.php @@ -0,0 +1,6514 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["safe_harbor_message"])) {$safe_harbor_message=$_GET["safe_harbor_message"];} + elseif (isset($_POST["safe_harbor_message"])) {$safe_harbor_message=$_POST["safe_harbor_message"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_message"])) {$drop_message=$_GET["drop_message"];} + elseif (isset($_POST["drop_message"])) {$drop_message=$_POST["drop_message"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS ONLY ### +$user_level = ereg_replace("[^0-9]","",$user_level); +$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); +$xferconf_a_number = ereg_replace("[^0-9]","",$xferconf_a_number); +$xferconf_b_number = ereg_replace("[^0-9]","",$xferconf_b_number); +$drop_call_seconds = ereg_replace("[^0-9]","",$drop_call_seconds); +$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); +$safe_harbor_exten = ereg_replace("[^0-9]","",$safe_harbor_exten); +$am_message_exten = ereg_replace("[^0-9]","",$am_message_exten); +$campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); +$campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); +$drop_exten = ereg_replace("[^0-9]","",$drop_exten); +$dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); +$park_ext = ereg_replace("[^0-9]","",$park_ext); +$hopper_level = ereg_replace("[^0-9]","",$hopper_level); +$agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); +$hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); +$agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); +$agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); +$vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); +$vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); +$closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); +$alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); +$delete_users = ereg_replace("[^0-9]","",$delete_users); +$delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); +$delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); +$delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); +$delete_lists = ereg_replace("[^0-9]","",$delete_lists); +$delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); +$delete_filters = ereg_replace("[^0-9]","",$delete_filters); +$delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); +$delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); +$load_leads = ereg_replace("[^0-9]","",$delete_call_times); +$campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); +$ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); +$ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); +$modify_leads = ereg_replace("[^0-9]","",$modify_leads); +$change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); +$modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); +$ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); +$ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); +$ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); +$ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); +$ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); +$ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); +$ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); +$ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); +$ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); +$ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); +$ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); +$ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); +$ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); +$ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); +$ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); +$ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); +$number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); +$user_start = ereg_replace("[^0-9]","",$user_start); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +$remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); +$attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); +$hotkey = ereg_replace("[^0-9]","",$hotkey); +$list_id = ereg_replace("[^0-9]","",$list_id); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); +$allow_closers = ereg_replace("[^NY]","",$allow_closers); +$reset_hopper = ereg_replace("[^NY]","",$reset_hopper); +$amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); +$alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); +$safe_harbor_message = ereg_replace("[^NY]","",$safe_harbor_message); +$selectable = ereg_replace("[^NY]","",$selectable); +$reset_list = ereg_replace("[^NY]","",$reset_list); +$fronter_display = ereg_replace("[^NY]","",$fronter_display); +$drop_message = ereg_replace("[^NY]","",$drop_message); +$use_internal_dnc = ereg_replace("[^NY]","",$use_internal_dnc); + +### ALPHA-NUMERIC ONLY ### +$user = ereg_replace("[^0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^0-9a-zA-Z]","",$pass); +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); +$submit = ereg_replace("[^0-9a-zA-Z]","",$submit); +$CoNfIrM = ereg_replace("[^0-9a-zA-Z]","",$CoNfIrM); +$campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); +$get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); +$campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); +$ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); +$dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); +$state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); +$scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + +### DIGITS and Dots +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + +### DIGITS and spaces and hash and star and comma +$xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_a_dtmf); +$xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_b_dtmf); + +### ALPHA-NUMERIC and underscore and dash +$dial_status_e = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_e); +$dial_status_d = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_d); +$dial_status_c = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_c); +$dial_status_b = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_b); +$dial_status_a = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_a); +$stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); +$lead_filter_id = ereg_replace("[^-\_0-9a-zA-Z]","",$lead_filter_id); +$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); +$old_campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_campaign_id); +$park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); +$next_agent_call = ereg_replace("[^-\_0-9a-zA-Z]","",$next_agent_call); +$local_call_time = ereg_replace("[^-\_0-9a-zA-Z]","",$local_call_time); +$call_time_id = ereg_replace("[^-\_0-9a-zA-Z]","",$call_time_id); +$phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); +$phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); +$group_id = ereg_replace("[^-\_0-9a-zA-Z]","",$group_id); +$user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$user_group); +$OLDuser_group = ereg_replace("[^-\_0-9a-zA-Z]","",$OLDuser_group); +$state_rule = ereg_replace("[^-\_0-9a-zA-Z]","",$state_rule); + +### ALPHA-NUMERIC and spaces +$lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); +### ALPHA-NUMERIC and hash +$group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); +$campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); +$HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); +$status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); +$script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); +$script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); +$list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); +$lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); +$lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); +$campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); +$call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); +$call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + +### remove semi-colons ### +$lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + +### VARIABLES TO BE mysql_real_escape_string ### +# $web_form_address +# $script_text + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# AST GUI database administration +# admin.php +# +# CHANGES +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug +# + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$version = '1.1.12-3'; +$build = '60623-1159'; + +$STARTtime = date("U"); + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Sie haben jetzt heraus geloggt. Danke\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGuser_level =$row[4]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD==1) {$hh='users'; echo "Addieren Sie Neuen Benutzer";} +if ($ADD==11) {$hh='campaigns'; echo "Addieren Sie Neue Kampagne";} +if ($ADD==111) {$hh='lists'; echo "Addieren Sie Neue Liste";} +if ($ADD==121) {$hh='lists'; echo "Addieren Sie Neues DNC";} +if ($ADD==1111) {$hh='ingroups'; echo "Addieren Sie Neue In-Gruppe";} +if ($ADD==11111) {$hh='remoteagent'; echo "Addieren Sie Neue Remotemittel";} +if ($ADD==111111) {$hh='usergroups'; echo "Addieren Sie Neue Benutzer-Gruppe";} +if ($ADD==1111111) {$hh='scripts'; echo "Addieren Sie Neuen Index";} +if ($ADD==11111111) {$hh='filters'; echo "Addieren Sie Neuen Filter";} +if ($ADD==111111111) {$hh='times'; echo "Füge neue Anrufzeit hinzu";} +if ($ADD==1111111111) {$hh='times'; echo "Füge neue landesspezifische Anrufzeit hinzu";} +if ($ADD==2) {$hh='users'; echo "Neue Benutzer-Hinzufügung";} +if ($ADD==21) {$hh='campaigns'; echo "Neue Kampagne Hinzufügung";} +if ($ADD==22) {$hh='campaigns'; echo "Neue Kampagne Status-Hinzufügung";} +if ($ADD==23) {$hh='campaigns'; echo "Neue Kampagne HotKey Hinzufügung";} +if ($ADD==25) {$hh='campaigns'; echo "Neue Kampagne Leitung Bereiten Hinzufügung Auf";} +if ($ADD==211) {$hh='lists'; echo "Neue Liste Hinzufügung";} +if ($ADD==2111) {$hh='ingroups'; echo "Neue In-Gruppe Hinzufügung";} +if ($ADD==21111) {$hh='remoteagent'; echo "Neue Remotemittel-Hinzufügung";} +if ($ADD==211111) {$hh='usergroups'; echo "Neue Benutzer-Gruppe Hinzufügung";} +if ($ADD==2111111) {$hh='scripts'; echo "Neue Index-Hinzufügung";} +if ($ADD==21111111) {$hh='filters'; echo "Neue Filter-Hinzufügung";} +if ($ADD==211111111) {$hh='times'; echo "Neue Anrufzeit hinzufügen";} +if ($ADD==2111111111) {$hh='times'; echo "Neue landesspezifische Anrufzeit hinzufügen";} +if ($ADD==3) {$hh='users'; echo "Ändern Sie Benutzer";} +if ($ADD==31) {$hh='campaigns'; echo "Ändern Sie Kampagne";} +if ($ADD==34) {$hh='campaigns'; echo "Ändern Sie Kampagne - Grundlegende Ansicht";} +if ($ADD==311) {$hh='lists'; echo "Ändern Sie Liste";} +if ($ADD==3111) {$hh='ingroups'; echo "Ändern Sie In-Gruppe";} +if ($ADD==31111) {$hh='remoteagent'; echo "Ändern Sie Remotemittel";} +if ($ADD==311111) {$hh='usergroups'; echo "Ändern Sie Benutzer-Gruppen";} +if ($ADD==3111111) {$hh='scripts'; echo "Ändern Sie Index";} +if ($ADD==31111111) {$hh='filters'; echo "Ändern Sie Filter";} +if ($ADD==311111111) {$hh='times'; echo "Bearbeite Anrufzeit";} +if ($ADD==321111111) {$hh='times'; echo "Bearbeite Anrufzeit Landdefinitions-Liste";} +if ($ADD==3111111111) {$hh='times'; echo "Bearbeite landesspezifische Anrufzeit";} +if ($ADD=="4A") {$hh='users'; echo "Ändern Sie Benutzer - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Ändern Sie Benutzer - Admin";} +if ($ADD==4) {$hh='users'; echo "Ändern Sie Benutzer";} +if ($ADD==41) {$hh='campaigns'; echo "Ändern Sie Kampagne";} +if ($ADD==42) {$hh='campaigns'; echo "Ändern Sie Kampagne Status";} +if ($ADD==43) {$hh='campaigns'; echo "Ändern Sie Kampagne HotKey";} +if ($ADD==44) {$hh='campaigns'; echo "Ändern Sie Kampagne - Grundlegende Ansicht";} +if ($ADD==45) {$hh='campaigns'; echo "Ändern Sie Kampagne Leitung Aufbereiten";} +if ($ADD==411) {$hh='lists'; echo "Ändern Sie Liste";} +if ($ADD==4111) {$hh='ingroups'; echo "Ändern Sie In-Gruppe";} +if ($ADD==41111) {$hh='remoteagent'; echo "Ändern Sie Remotemittel";} +if ($ADD==411111) {$hh='usergroups'; echo "Ändern Sie Benutzer-Gruppen";} +if ($ADD==4111111) {$hh='scripts'; echo "Ändern Sie Index";} +if ($ADD==41111111) {$hh='filters'; echo "Ändern Sie Filter";} +if ($ADD==411111111) {$hh='times'; echo "Bearbeite Anrufzeit";} +if ($ADD==4111111111) {$hh='times'; echo "Bearbeite landesspezifische Anrufzeit";} +if ($ADD==5) {$hh='users'; echo "Delete User";} +if ($ADD==51) {$hh='campaigns'; echo "Delete Kampagne";} +if ($ADD==52) {$hh='campaigns'; echo "Logout-Mittel";} +if ($ADD==511) {$hh='lists'; echo "Delete List";} +if ($ADD==5111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==51111) {$hh='remoteagent'; echo "Löschung-Direktübertragung Mittel";} +if ($ADD==511111) {$hh='usergroups'; echo "Löschung-Benutzer Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Löschung-Index";} +if ($ADD==51111111) {$hh='filters'; echo "Löschung-Filter";} +if ($ADD==511111111) {$hh='times'; echo "Lösche Anrufzeit";} +if ($ADD==5111111111) {$hh='times'; echo "Lösche landesspezifische Anrufzeit";} +if ($ADD==6) {$hh='users'; echo "Delete User";} +if ($ADD==61) {$hh='campaigns'; echo "Delete Kampagne";} +if ($ADD==62) {$hh='campaigns'; echo "Logout-Mittel";} +if ($ADD==65) {$hh='campaigns'; echo "Löschung-Leitung Bereiten Auf";} +if ($ADD==611) {$hh='lists'; echo "Delete List";} +if ($ADD==6111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==61111) {$hh='remoteagent'; echo "Löschung-Direktübertragung Mittel";} +if ($ADD==611111) {$hh='usergroups'; echo "Löschung-Benutzer Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Löschung-Index";} +if ($ADD==61111111) {$hh='filters'; echo "Löschung-Filter";} +if ($ADD==611111111) {$hh='times'; echo "Lösche Anrufzeit";} +if ($ADD==6111111111) {$hh='times'; echo "Lösche landesspezifische Anrufzeit";} +if ($ADD==73) {$hh='campaigns'; echo "Anzahl anrufbarer Anschlüsse";} +if ($ADD==7111111) {$hh='scripts'; echo "Vorbetrachtung-Index";} +if ($ADD==0) {$hh='users'; echo "Benutzer-Liste";} +if ($ADD==8) {$hh='users'; echo "Wiederholungsbesuche Innerhalb Des Mittels";} +if ($ADD==81) {$hh='campaigns'; echo "Wiederholungsbesuche Innerhalb Der Kampagne";} +if ($ADD==811) {$hh='campaigns'; echo "Wiederholungsbesuche Innerhalb Der Liste";} +if ($ADD==10) {$hh='campaigns'; echo "Kampagnen";} +if ($ADD==100) {$hh='lists'; echo "Listen";} +if ($ADD==1000) {$hh='ingroups'; echo "In-Gruppen";} +if ($ADD==10000) {$hh='remoteagent'; echo "Remotemittel";} +if ($ADD==100000) {$hh='usergroups'; echo "Benutzer-Gruppen";} +if ($ADD==1000000) {$hh='scripts'; echo "Indexe";} +if ($ADD==10000000) {$hh='filters'; echo "Filter";} +if ($ADD==100000000) {$hh='times'; echo "Anrufzeiten";} +if ($ADD==1000000000) {$hh='times'; echo "Landesspezische Anrufzeiten";} +if ($ADD==55) {$hh='users'; echo "Suchform";} +if ($ADD==66) {$hh='users'; echo "Suchresultate";} +if ($ADD==99999) {$hh='users'; echo "HILFE";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or ($ADD==21) or ($ADD==31) or ($ADD==41) or ($ADD=="4A") or ($ADD=="4B") ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ($ADD==31) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<100) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 Border=0 ALT=\"HILFE\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
VICIDIAL ADMIN: HILFE


\n"; + +?> +VICIDIAL_BENUTZERTABELLE

+ +
+Benutzernummer - Dieses fangen ist, wohin Sie dieVICIDIAL Benutzernummer Zahl setzen, kann bis 8 Stellen in der Längesein, muß mindestens 2 Buchstaben lang sein auf. + +
+
+
+Kennwort - Dieses fangen ist auf, wohin Sie das VICIDIALBenutzerkennwort setzen. Sein mindestens müssen 2 Buchstaben lang. + +
+
+
+Voller Name - Dieses fangen ist auf, wohin Sie den vollenNamen der VICIDIAL Benutzer setzen. Sein mindestens müssen 2Buchstaben lang. + +
+
+
+Benutzer-Niveau - Dieses Menü ist, wo Sie das VICIDIALBenutzer-Benutzerniveau vorwählen. Sein muß ein Niveau von inVICIDIAL zu loggen 1,, muß waagerecht ausgerichtet grösser sein, alsals genaueres innen zu loggen 2, Benutzerniveau 8 oder grösser seinmüssen, in admin Netzabschnitt zu erhalten. + +
+
+
+Benutzer-Gruppe - Dieses Menü ist, wo Sie die VICIDIALBenutzergruppe vorwählen, daß dieser Benutzer gehört. Dieses hatkeine Beschränkungen diesmal, ist dieses gerecht, Benutzer zuunterteilen und die zukünftigen Eigenschaften zuzulassen, die nachihm gegründet werden. + +
+
+
+Telefon-LOGON - Für hier ist, wo Sie einen RückstellungTelefon-LOGON-Wert wenn die Benutzermaschinenbordbücher invicidial.php einstellen können. Dieser Wert bevölkert dasphone_login automatisch wenn die Benutzermaschinenbordbücher innenmit ihrer Benutzer-überschreiten-Kampagne auf dem vicidial.phpLOGON-Schirm. + +
+
+
+Telefon-Durchlauf - Für hier ist, wo Sie einen RückstellungTelefon-Durchlaufwert wenn die Benutzermaschinenbordbücher invicidial.php einstellen können. Dieser Wert bevölkert die phone_passautomatisch wenn die Benutzermaschinenbordbücher innen mit ihrerBenutzer-überschreiten-Kampagne auf dem vicidial.php LOGON-Schirm. + +
+
+
+HotKeys aktiv - Diese Wahl, wenn Satz bis 1 dem Benutzer erlaubt,die HotKeys schnelle-dispositioning Funktion innen zu verwenden vicidial.php. + +
+
+
+Mittel wählen Ingroups - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, die ingroups zu wählen, denen sie Anrufe von wenn sie LOGONzu einer GENAUEREN oder INBOUND Kampagne empfangen. Andernfalls mußder Manager dieses auf ihrem Benutzersonderkommandoschirm der adminSeite einstellen. + +
+
+
+Inbound Gruppen - Ist hier, wo Sie die inbound Gruppen vorwählen,die Sie Anrufe von empfangen möchten, wenn Sie die GENAUERE Kampagnevorgewählt haben. + +
+
+
+Zeitlich geplante Wiederholungsbesuche - Diese Wahl erlaubt einemMittel zur Einteilung einen Anruf als CALLBK und wählt die Daten unddie Zeit, an denen die Leitung reaktiviert wird. + +
+
+
+Mittel-Nur Wiederholungsbesuche - Diese Wahl erlaubt einemVertreter, einen Wiederholungsbesuch einzustellen, damit sie daseinzige Mittel sind, das die Kunde Rückseite benennen kann. Dieseserlaubt auch dem Vertreter, ihre Wiederholungsbesuch Auflistungen zusehen und sie zurück zu benennen, immer wenn sie zu wünschen. + +
+
+
+Vertreter-Anruf-Handbuch - Diese Wahl erlaubt einem Vertreter,eine neue Leitung in das System manuell einzutragen und sie zubenennen. Dieses auch erlaubt das Benennen jeder möglicherTelefonnummer von ihrem vicidial Schirm und setzt diesen Anruf inihren Lernabschnitt. Verwenden Sie diese Wahl mit Vorsicht. + +
+
+
+Vicidial Aufnahme - Diese Wahl kann verhindern, daß ein Mittelalle mögliche Aufnahmen tut, nachdem sie innen in vicidialprotokollieren. Diese Wahl muß eingeschaltet sein, damit vicidial demKampagne Aufnahmelernabschnitt folgt. + +
+
+
+Vicidial Übertragungen - Diese Wahl kann verhindern, daß einMittel die Übertragung - Konferenzlernabschnitt von vicidial öffnet.Wenn dieses untauglich ist, kann das Mittel nicht dritterParteianruf, oder blinde Übertragung irgendeine benennt. + +
+
+
+Genauere Rückstellung gemischt - Diese Wahl fällt einfach dasgemischte checkbox auf einem GENAUEREN LOGON-Schirm zurück. + +
+
+
+Ändern Sie Mittel-Schnittstelle Wahlen - diese Wahl, wenn Satzbis 1 dem administrativen Benutzer erlaubt, die MittelschnittstelleWahlen in admin.php zu ändern. + +
+
+
+Löschung-Benutzer - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, andere Benutzer des Gleichgestellten oder wenigenBenutzerniveaus aus dem System zu löschen. + +
+
+
+Löschung-Benutzer-Gruppen - Diese Wahl, wenn Satz bis 1 demBenutzer erlaubt, Benutzergruppen aus dem System zu löschen. + +
+
+
+Löschung verzeichnet - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, vicidial Listen aus dem System zu löschen. + +
+
+
+Löschung wirbt - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, vicidial Kampagnen aus dem System zu löschen. + +
+
+
+Löschung In-Gruppen - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, vicidial In-Gruppen aus dem System zu löschen. + +
+
+
+Löschung-Remotemittel - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, vicidial Remotemittel aus dem System zu löschen. + +
+
+
+Last führt - Diese Wahl, wenn Satz bis 1 dem Benutzer erlaubt,vicidial Leitungen in die vicidial_list Tabelle über die Netzgegründete Leitung Ladevorrichtung zu laden. + +
+
+
+Kampagne Detail - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, die Kampagne Detail-Schirmelemente anzusehen und zu ändern. + +
+
+
+AGC Admin Zugang - Diese Wahl, wenn Satz bis 1 den Benutzer zumLOGON zu den astGUIclient admin Seiten erlaubt. + +
+
+
+AGC Löschung-Telefone - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, Telefoneintragungen in den astGUIclient admin Seiten zulöschen. + +
+
+
+Löschung-Indexe - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, Kampagne Indexe auf dem Indexänderung Schirm zu löschen. + +
+
+
+Ändern Sie Leitungen - Diese Wahl, wenn Satz bis 1 dem Benutzererlaubt, Leitungen in der admin Abschnittleitung Suchresultate Seitezu ändern. + +
+
+
+Ändern Sie Vertreter-Kampagne - Diese Wahl, wenn Satz bis 1 demBenutzer erlaubt, die Kampagne zu ändern, daß ein Mittel in geloggtwird, während sie in es geloggt werden. + +
+
+
+Löschung filtert - Diese Wahl erlaubt dem Benutzer, in der LagezuSEIN, vicidial Leitung Filter aus dem System zu löschen. + +
+
+
+Löschen Anrufzeiten - Diese Option erlaubt dem Nutzer die Vicidial Anrufzeiten Aufzeichnungen und Vicidial Status Anrufzeiten Aufzeichnungen vom System zu löschen. + +
+
+
+Ändere Anrufzeiten - Diese Option erlaubt dem Nutzer das Ansehen und Ändern der Anrufzeiten und Status Anrufzeiten Aufzeichnungen. Ein Nutzer braucht diese Option nicht aktiviert, wenn er nur die Anrufzeit Option auf der Kampagnen-Sicht ändern können muss. + + + + +



+ +VICIDIAL_KAMPAGNENTABELLE

+
+
+Kampagne Identifikation - Dieses ist der kurze Name der Kampagne,es ist nicht editable nach Ausgangsunterordnung, kann nicht Räumeenthalten und muß zwischen 2 und 8 Buchstaben im lengt seinh. + +
+
+
+Kampagne Name - Dieses ist die Beschreibung der Kampagne, muß eszwischen 6 und 40 Buchstaben lang sein. + +
+
+
+Aktiv - Dieses ist, wohin Sie die Kampagne auf aktives oderunaktiviertes einstellen. Wenn unaktiviert, kann noone in es loggen. + +
+
+
+Park-Verlängerung - Dieses ist, wo Sie besonders anfertigenkönnen auf-halten Musik für VICIDIAL. Stellen Sie sicher, daß dieVerlängerung im Platz im extensions.conf ist und das, das es auf denDateinamen unten zeigt. + +
+
+
+Park-Dateiname - Dieses ist, wo Sie besonders anfertigen könnenauf-halten Musik für VICIDIAL. Stellen Sie sicher, daß der Dateiname10 Buchstaben lang oder kleiner ist und daß die Akte im Platz im/var/lib/asterisk/sounds Verzeichnis ist. + +
+
+
+Netz-Form - Dieses ist, wo Sie die kundenspezifische Webseiteeinstellen können, die geöffnet ist, wenn der Benutzer an dieNETZ-FORM-Taste klickt. + +
+
+
+Erlauben Sie Closers - Dieses ist, wo Sie einstellen können, obdie Benutzer dieser Kampagne die Wahl haben, zum des Anrufs zu einemgenauerem zu schicken. + +
+
+
+Vorwahlknopf-Status - Dieses ist, wohin Sie die Status einstellen,die Sie an innerhalb der Listen wählen wünschen, die für dieKampagne unten aktiv sind + +
+
+
+Liste Auftrag - Dieses Menü ist, wo Sie vorwählen, wie dieLeitungen, die die Status zusammenbringen, die oben vorgewähltwerden, in den Leitung Zufuhrbehälter eingesetzt werden: +
  - DOWN: wählen Sie die ersten Leitungen vor, die in die vicidial_list Tabellegeladen werden +
  - UP: wählen Sie die letzten Leitungen vor, die in die vicidial_listTabelle geladen werden +
  - UP PHONE: wählen Sie die höchste Telefonnummer und die Arbeiten seine Weiseunten vor +
  - DOWN PHONE: wählen Sie die niedrigste Telefonnummer und die Arbeiten seine Weiseoben vor +
  - UP LAST NAME: Anfänge mit letzten Namen beginnend mit Z und Arbeiten seine Weiseunten +
  - DOWN LAST NAME: Anfänge mit letzten Namen beginnend mit A und Arbeiten seine Weiseoben +
  - UP COUNT: Anfänge mit benannten Leitungen und Arbeiten seine Weise unten +
  - DOWN COUNT: Anfänge mit wenigen benannten Leitungen und Arbeiten seine Weiseoben +
  - DOWN COUNT 2nd NEW: Anfänge mit wenigen benannten Leitungen und Arbeiten seine Weise, dieoben eine NEUE Leitung in jeder anderen Leitung einsetzt - dürfenNICHT NEUES haben vorgewählt in den Vorwahlknopfstatus +
  - DOWN COUNT 3nd NEW: Anfänge mit wenigen benannten Leitungen und Arbeiten seine Weise, dieoben eine NEUE Leitung in jeder dritten Leitung einsetzt - dürfenNICHT NEUES haben vorgewählt in den Vorwahlknopfstatus +
  - DOWN COUNT 4th NEW: Anfänge mit wenigen benannten Leitungen und Arbeiten seine Weise, dieoben eine NEUE Leitung in jedem einsetzt weiter, führen Sie - darfNICHT NEUES haben vorgewählt in den Vorwahlknopfstatus + +
+
+
+Zufuhrbehälter waagerecht ausgerichtet - Dieses ist, wieviele dieVDhopper Indexversuche führt, um in der vicidial_hopper Tabelle fürdiese Kampagne zu halten. Wenn Sie VDhopper Index jede Minute laufenlassen, bilden Sie dieses etwas grösser als die Zahl Leitungen, dieSie in eine Minute durchmachen. + +
+
+
+Leitung Filter - Dieses ist eine Methode der Entstörung IhrerLeitungen mit einem Fragment einer SQL Frage. Benutzen Sie dieseFunktion mit Vorsicht, es ist einfach mit, der geringfügigstenÄnderung zur SQL Aussage versehentlich zu wählen zu stoppen.Rückstellung ist KEINE. + +
+
+
+Kraft-Zurückstellen des Zufuhrbehälters - erlaubt dieses Ihnen,aus dem Zufuhrbehälterinhalt nach Formunterordnung abzuwischen. Essollte wieder gefüllt werden, wenn der VDhopper Index läuft. + +
+
+
+Selbstvorwahlknopf-Niveau - Dieses ist, wohin Sie einstellen,wieviele VICIDIAL sollte pro Mittel 0 verwenden des aktiven Mittelsnull zeichnet, Automobil, daswählen aus ist und die Mittel klicken,um jede Nummer zu wählen. Andernfalls hält VICIDIALWählverbindungen gleich den aktiven Mitteln, die mit demVorwahlknopfniveau multipliziert werden, um zu, wievielen Linien zukommen diese Kampagne auf jedem Bediener erlauben sollte. + +
+
+
+Folgender Vertreter-Anruf - Dieses stellt fest, welches Mittel denfolgenden Anruf empfängt, der vorhanden ist: +
  - random: Aufträge durch den gelegentlichen Updatewert in dervicidial_live_agents Tabelle +
  - oldest_call_start: Aufträge bis zum dem letzten Mal ein Mittel wurden einem Anrufgeschickt. Resultate in den Mitteln, die insgesamt ungefähr gleicheZahl von Anrufen empfangen. +
  - oldest_call_finish: Aufträge bis zum dem letzten Mal ein Mittel beendeten einen Anruf.Das AKA Mittel, das am längsten wartet, empfängt ersten Anruf. +
  - overall_user_level: Aufträge durch das user_level des Mittels, wie inden vicidial_users definiert legen ein höheres user_level empfangenmehr Anrufe ver. + +
+
+
+Ortsgespräch-Zeit - Dieses ist, wohin Sie während welcherStunden Sie wählen möchten, wie bis zum der lokalen Zeit infestgestellt sind einstellten in, welchem Sie benennen. Dieses wirddurch Ortsnetzkennzahl gesteuert und wird auf Tageslicht-SparungenZeit eingestellt, wenn anwendbar. Allgemeine Richtlinien in den USAfür Geschäft zum Geschäft ist 9am bis 5pm und Geschäft zu denVerbraucheranrufen ist 9am bis 9pm. + +
+
+
+Vorwahlknopf-Abschaltung - Wenn Sie, Anrufe, die normalerweiseHängezustand wurden, nachdem die Abschaltung, die in extensions.confanstatt Abschaltung an dieser Menge Sekunden definiert wurde wurde,wenn sie kleiner ist, als die extensions.conf Abschaltung definiertwerden. Dieses läßt schnell ändernde Vorwahlknopfabschaltungen vomBediener zum Bediener und zum Begrenzen der Effekte zu einer einzelnenKampagne zu. Wenn Sie eine Menge antwortende Maschine oder VoicemailAnrufe haben, können Sie diesen Wert, bis zwischen 21-26 zu ändernversuchen und sehen wünschen, wenn Resultate verbessern. + +
+
+
+Vorwahlknopf-Präfix - Dieses fangen zuläßt einen Wegdes Wählens leicht ändern auf, zum durch eine andere Methode zuerlöschen, ohne ein Umladen im Sternchen zu tun. Rückstellung ist 9gegründet nach einem 91NXXNXXXXXX im dialplan - extensions.conf. + +
+
+
+Kampagne CallerID - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. If you are using T1 or E1s to dial out this option is only available if you are using PRIs - ISDN T1s or E1s - that have the custom callerid feature turned on, this will not work with Robbed-bit service(RBS) circuits. This will also work through most VOIP(SIP or IAX trunks) providers that allow dynamic outbound callerID. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Kampagne VDAD Verlängerung - Dieses fangen zuläßt eineGewohnheit VDAD Übergangsverlängerung auf. Dieses erlaubt Ihnen,unterschiedliche VDADtransfer... agi Indexe zu benutzen, abhängendnach Ihrer Kampagne. Die Rückstellung Übertragung AGI - exten 8365agi-VDADtransfer.agi - gerade sendet sofort ersucht zu den Mitteln,sobald sie aufgehoben werden. Eine zusätzliches BeispielpolitischeÜbersicht AGI ist auch jetzt eingeschlossenes - 8366agi-VDADtransferSURVEY.agi - dieses Spiele eine Anzeige zurangerufenen Person und läßt sie eine Wahl treffen, indem sie Tastenbetätigt - effektiv Vorsiebung die Leitung -. Merken Sie bitte dasaußer Übersichten, politische Anrufe und Nächstenliebe diese Formdes Benennens ist in den Vereinigten Staaten ungültig. + +
+
+
+Kampagne Rec Verlängerung - Dieses fangen darf auf,damit eine kundenspezifische Aufnahmeverlängerung mit VICIDIALverwendet werden kann. Dieses erlaubt Ihnen, unterschiedlicheVerlängerungen zu verwenden, abhängend nach, wie lang Sie einemaximale Aufnahme erlauben möchten und welcher Art von Codec Sieinnen notieren möchten. Die Rückstellung exten ist 8309, die, wennSie folgen die SCRATCH_INSTALL Beispiele im WAV Format bis zu einerStunde lang notieren. Eine andere Wahl, die in den Beispieleneingeschlossen ist, ist 8310, die im G/M Format bis zu einer Stundelang notieren. + +
+
+
+Kampagne Aufnahme - Dieses Menü erlaubt Ihnen, zu wählen,welches Niveau der Aufnahme auf dieser Kampagne erlaubt wird. NIEsperrt Aufnahme auf dem Klienten. ONDEMAND ist die Rückstellung underlaubt dem Vertreter zu notieren zu beginnen und, zu stoppen, wiegebraucht. ALLCALLS beginnt Aufnahme auf dem Klienten, wann immer einAnruf zu einem Mittel geschickt wird. + +
+
+
+Kampagne Rec Dateiname - Dieses fangen erlaubt Ihnen, denNamen der Aufnahme besonders anzufertigen auf, wenn Kampagne AufnahmeONDEMAND oder ALLCALLS ist. Die erlaubten Variablen sind KAMPAGNECUSTPHONE FULLDATE TINYDATE EPOCHE-MITTEL. Die Rückstellung istFULLDATE_MITTELund würde wie dieses 20051020-103108_6666 aussehen.Ein anderes Beispiel ist CAMPAIGN_TINYDATE_CUSTPHONE, das wie diesesTESTCAMP_51020103108_3125551212 aussehen würde. 50 char max. + +
+
+
+Kampagne Index - Dieses Menü erlaubt Ihnen, den Index zu wählen,der auf dem Mittelschirm für diese Kampagne erscheint. Wählen SieKEINE vor, keinen Index für diese Kampagne zu zeigen. + +
+
+
+Erhalten Sie Anruf-Produkteinführung - Dieses Menü erlaubt Ihnenzu wählen, ob Sie Automobil-ausstoßen die Netz-Form Seite in einemunterschiedlichen Fenster, Auto-switch zum INDEX-Vorsprung oder tunnichts wünschen, wenn ein Anruf zum Mittel für diese Kampagnegeschickt wird. + +
+
+
+Antwortende Maschine Anzeige - Dieses fangen ist für dasHereinkommen auf, in eine Verlängerung, zum von von Übergangsanrufenzu blind zu machen, wenn das Mittel eine antwortende Maschine erhältund an die antwortende Maschine Anzeige Taste imÜbergangskonferenzrahmen klickt. Sie müssen dieses einstellen extenoben im dialplan - extensions.conf - und sicherstellen, daß esspielt, eine Audioakte dann oben hängt. + +
+
+
+AMD senden zu VM exten - erlaubt dieses Menü Ihnen zu definieren,ob eine Anzeige auf einer antwortenden Maschine gelassen wird, wennihr der Anruf wird sofort nachgeschickt zur Antworten-Maschine-AnzeigeVerlängerung ermittelt wird, wenn AMD aktiv ist und es festgestelltwird, daß der Anruf eine antwortende Maschine ist. + +
+
+
+Xfer-Conf DTMF - Diese vier fängt dürfen auf, damit Siezwei Sätze Übergangskonferenz und DTMF Voreinstellungen haben. Wennder Anruf oder die Kampagne geladen wird, stellt der vicidial.phpIndex dar, daß zwei Tasten auf dem Bringenkonferenz Rahmen und denZahl-zu-Vorwahlknopf und senden-dtmf Automobil-zu bevölkernauffängt, wenn sie betätigt werden. + +
+
+
+Numerisches Wählen des Mittel-Alt - erlaubt diese Wahl einemVertreter, die wechselnde Telefonnummer manuell zu wählen, oderaddress3 fangen auf, nachdem die Hauptzahl benannt wordenist. + +
+
+
+Zeitlich geplante Wiederholungsbesuche - Diese Wahl erlaubt einemMittel zur Einteilung einen Anruf als CALLBK und wählt die Daten unddie Zeit, an denen die Leitung reaktiviert wird. + +
+
+
+Sekunden zur Verbindung - Anzahl der Sekunden vom Abnehmen des Kunden bis zur Erkennung als Verbindung, betrifft nur abgehende Verbindungen. + +
+
+
+Voicemail - Wenn sie definiert werden, würden Anrufe, dienormalerweise FALLEN würden, anstatt auf diesen voicemail Kastenverwiesen, um eine Anzeige zu hören und zu lassen. + +
+
+
+Sicherheitsnachricht - Wenn auf Y gesetzt wird dem Kunden nach Ablauf der Sekunden zur Verbindung, ohne zu einem Agenten verbunden worden zu sein, eine Nachricht abgespielt. Diese Einstellung setzt die Option Senden zu einer Voicemail Kasten ausser Kraft, wenn diese auf Y steht. + +
+
+
+Sicherheitsnebenstelle - Dies ist die Wählplan Nebenstelle, wo sich die gewünschte Sicherheits-Audiodatei auf Ihrem Server befindet. + +
+
+
+Sekunden Nachbereitung - Anzahl der Sekunden, die ein Agent bis zum nächsten erhaltenen Anruf oder Wählen eines anderen Anrufs warten muss. Die Zeit beginnt, sobald ein Agent bei seinem Kunden aufgelegt hat - oder im Fall der alternativen Nummernwahl, wenn ein Agent das Telefonat beendet - Standard ist 0 Sekunden. Wenn die Zeit abgelaufen ist bevor der Agent den Anruf eingeordnet hat, wird der Agent dennoch nicht zum nächsten Anruf kommen, bevor er eine Einteilung gewählt hat. + +
+
+
+Nachbereitungsnachricht - Dies ist eine Kampagnen-spezifische Nachricht, die bei gesetzten Sekunden Nachbereitung auf dem Nachbereitungsbildschirm angezeigt wird. + +
+
+
+Nachbereitungsnachricht - Dies ist eine Kampagnen-spezifische Nachricht, die bei gesetzten Sekunden Nachbereitung auf dem Nachbereitungsbildschirm angezeigt wird. + +
+
+
+Interne DNC Liste des Gebrauch-- definiert dieses, ob dieseKampagne Leitungen gegen die interne DNC Liste filtern soll. Wenn esauf Y eingestellt wird, sucht der Zufuhrbehälter nach jederTelefonnummer in der DNC Liste, bevor er sie in den Zufuhrbehälterlegt. Wenn er in der DNC Liste ist, dann, das sie dieses führt Statuszu DNCL also ändert, kann sie nicht gewählt werden. Rückstellungist N. + +
+
+
+Gewährte Inbound Gruppen - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound/outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + + + +



+ +VICIDIAL_LISTENTABELLE

+
+
+Liste Identifikation - Dieses ist der numerische Name der Liste,es ist nicht editable nach Ausgangsunterordnung, muß nur Zahlenenthalten und muß zwischen 2 und 8 Buchstaben lang sein. + +
+
+
+Liste Name - This is the description of the list, it must be between 2 and 20 characters in length. + +
+
+
+Kampagne - This is the campaign that this list belongs to. A list can only be dialed on a single campaign at one time. + +
+
+
+Aktiv - Dieses definiert, ob die Liste an oder nicht gewähltwerden soll. + +
+
+
+Stellen Sie Führen-Benennen-Status für diese Liste - zurückstellt dieses alle Leitungen in dieser Liste zu N für das benannte\"not da letztes Zurückstellen \" zurück und bedeutet, daß jedemögliche Leitung jetzt benannt werden kann, wenn es der rechte Statusist, wie auf dem Kampagne Schirm definiert. + +
+
+
+VICIDIAL DNC Liste - Dieses benennen nicht Liste enthält jedeLeitung, die auf einen Status von DNC im System eingestellt wordenist. Durch die LISTEN - FÜGEN Sie ZAHL DNC Seite hinzu, die Sie inder LageSIND, eine Zahl dieser Liste manuell hinzuzufügen, damit sienicht durch Kampagnen benannt wird, die die interne DNC Listebenutzen. + + + +



+ +VICIDIAL_INBOUND_GROUPSTABELLE

+
+
+Gruppe Identifikation - Dieses ist der kurze Name der inboundGruppe, es ist nicht editable nach Ausgangsunterordnung, darf keineRäume enthalten und muß zwischen 2 und 20 Buchstaben lang sein. + +
+
+
+Gruppe Name - Dieses ist die Beschreibung der Gruppe, muß eszwischen 2 und 30 Buchstaben lang sein. Kann nicht Schläge, plussesoder Räume einschließen . + +
+
+
+Gruppe Farbe - Dieses ist die Farbe, die in der VICIDIAL KlientAPP anzeigt, wenn ein Anruf auf diese Gruppe hereinkommt. Es mußzwischen 2 und 7 Buchstaben lang sein. Wenn dieses eine HexagonfarbeDefinition ist, müssen Sie sich erinnern, sich a # am Anfang derZeichenkette zu setzen, oder VICIDIAL arbeitet nicht richtig. + +
+
+
+Aktiv - Dieses stellt fest, ob diese Gruppe oben imVorwählerkasten wenn Maschinenbordbücher eines VICIDIAL Mittelsinnen zeigen. + +
+
+
+Netz-Form - Dieses ist die kundenspezifische Adresse, die dasKlicken auf der NETZ-FORM-Taste in VICIDIAL Ihnen für zu den Anrufennimmt, die auf diese Gruppe hereinkommen. + +
+
+
+Folgender Vertreter-Anruf - Dieses stellt fest, welches Mittel denfolgenden Anruf empfängt, der vorhanden ist: +
  - random: Aufträge durch den gelegentlichen Updatewert in dervicidial_live_agents Tabelle +
  - oldest_call_start: Aufträge bis zum dem letzten Mal ein Mittel wurden einem Anrufgeschickt. Resultate in den Mitteln, die insgesamt ungefähr gleicheZahl von Anrufen empfangen. +
  - oldest_call_finish: Aufträge bis zum dem letzten Mal ein Mittel beendeten einen Anruf.Das AKA Mittel, das am längsten wartet, empfängt ersten Anruf. +
  - overall_user_level: Aufträge durch das user_level des Mittels, wie inden vicidial_users definiert legen ein höheres user_level empfangenmehr Anrufe ver. + +
+
+
+Fronter Anzeige - Dieses fangen feststellt auf, ob dasinbound VICIDIAL Mittel den fronter Namen - wenn es einen gibt -angezeigt im Status auffangen haben würde, wann der Anrufzum Mittel kommt. + +
+
+
+Kampagne Index - Dieses Menü erlaubt Ihnen, den Index zu wählen,der auf dem Mittelschirm für diese Kampagne erscheint. Wählen SieKEINE vor, keinen Index für diese Kampagne zu zeigen. + +
+
+
+Erhalten Sie Anruf-Produkteinführung - Dieses Menü erlaubt Ihnenzu wählen, ob Sie Automobil-ausstoßen die Netz-Form Seite in einemunterschiedlichen Fenster, Auto-switch zum INDEX-Vorsprung oder tunnichts wünschen, wenn ein Anruf zum Mittel für diese Kampagnegeschickt wird. + +
+
+
+Xfer-Conf DTMF - Diese vier fängt dürfen auf, damit Siezwei Sätze Übergangskonferenz und DTMF Voreinstellungen haben. Wennder Anruf oder die Kampagne geladen wird, stellt der vicidial.phpIndex dar, daß zwei Tasten auf dem Bringenkonferenz Rahmen und denZahl-zu-Vorwahlknopf und senden-dtmf Automobil-zu bevölkernauffängt, wenn sie betätigt werden. + +
+
+
+Sekunden zur Verbindung - Anzahl der Sekunden vom Abnehmen des Kunden bis zur Erkennung als Verbindung, betrifft nur abgehende Verbindungen. + +
+
+
+Voicemail - Wenn sie definiert werden, würden Anrufe, dienormalerweise FALLEN würden, anstatt auf diesen voicemail Kastenverwiesen, um eine Anzeige zu hören und zu lassen. + +
+
+
+Verbindungs-Nachricht- Wenn auf Y gesetzt wird dem Kunden nach Ablauf der Sekunden zur Verbindung, ohne zu einem Agenten verbunden worden zu sein, eine Nachricht abgespielt. Diese Einstellung setzt die Option Senden zu einer Voicemail Kasten ausser Kraft, wenn diese auf Y steht. + +
+
+
+Verbindungs-Nebenstelle - Dies ist die Wählplan-Nebenstelle, wo sich die gewünschte Audiodatei für die aufgebaute Verbindung auf Ihrem Server befindet. + + + +



+ +VICIDIAL_REMOTE_AGENTSTABELLE

+
+
+Benutzernummer Anfang - Dieses ist die beginnende Benutzernummer,die verwendet wird, wenn die Remotemitteleintragungen in das Systemeingesetzt werden. Wenn die Zeilenzahl in hohem Grade als 1eingestellt wird, wird diese Zahl durch eine erhöht, bis jede Linieeine Eintragung hat. Stellen Sie, ein neues VICIDIAL Benutzerkonto miteinem Benutzerniveau von 4 zu verursachen oder groß sicher, wenn Siesie in der LageSEIN wünschen, die vdremote.php Seite fürRemotenetzzugang dieses Kontos zu benutzen. + +
+
+
+Zeilenzahl - Dieses definiert, wievieles Remotemittel Eintragungendas System verursacht, und stellt fest, wieviele Linien es denkt, daßes zur Zahl unter sicher senden kann. + +
+
+
+Bediener IP - Eine Remotemitteleintragung ist für einenspezifischen Bediener, ist hier nur gut, wo Sie vorwählen, dasBediener Sie wünschen. + +
+
+
+Externe Verlängerung - Dieses ist die Zahl, daß Sie die Anrufewünschen, die zu nachgeschickt werden. Überprüfen Sie, ob es einevolle dialplan Zahl ist und daß, wenn Sie 9 am Anfang benötigen, Sieihn innen hier setzen. Prüfen Sie, indem Sie diese Nummer von einemTelefon auf dem System wählen. + +
+
+
+Status - Ist hier, wo Sie das Remotemittel an und abstellen.Sobald das Mittel aktiv ist, nimmt das System an, daß es Anrufe zuihm schicken kann. Es kann bis 30 Sekunden dauern, sobald Sie denStatus zu unaktiviertem ändern, um Anrufe, zu empfangen zu stoppen. + +
+
+
+Kampagne - Ist hier, wo Sie die Kampagne vorwählen, daß dieseRemotemittel in geloggt werden. Inbound Notwendigkeiten, die GENAUEREKampagne zu verwenden und die inbound Kampagnen unter dervorzuwählen, die Sie Anrufe von empfangen möchten. + +
+
+
+Inbound Gruppen - Ist hier, wo Sie die inbound Gruppen vorwählen,die Sie Anrufe von empfangen möchten, wenn Sie die GENAUERE Kampagnevorgewählt haben. + + +



+ +VICIDIAL_CAMPAIGN_LISTEN

+
+
+Die Listen innerhalb dieser Kampagne werden hier verzeichnet, ob siewerden bezeichnet durch das Y aktiv sind, oder N und Sie zum ListeSchirm gehen können, indem sie auf der Liste Identifikation in derersten Spalte klicken. + + +



+ +VICIDIAL_CAMPAIGN_STATUSESTABELLE

+
+
+Durch den Gebrauch von kundenspezifischen Kampagne Status, können SieStatus haben, die nur für eine spezifische Kampagne bestehen. DerStatus muß 1-8 Buchstaben lang sein, muß die Beschreibung 2-30Buchstaben lang sein und auswählbar definiert, ob es oben in VICIDIALals Einteilung zeigt. + + + +



+ +VICIDIAL_CAMPAIGN_HOTKEYSTABELLE

+
+
+Durch den Gebrauch von kundenspezifischen Kampagne hotkeys, benenntVertreter, die verwenden, der vicidial Netz-Klient Dose Hängezustandund Einteilung, gerade indem sie einen einzelnen Schlüssel auf ihrerTastatur betätigen. + + + + +



+ +VICIDIAL_LEAD_RECYCLETABELLE

+
+
+Durch den Gebrauch von Leitung aufbereitend, können Sie spezifischeStatus der Leitungen in einem spezifizierten Abstand wieder benennen,ohne die gesamte Liste zurückzustellen. Die Leitung Wiederverwertungist Kampagne-spezifisch und muß nicht ein vorgewählter dialableStatus in Ihrer Kampagne sein. Der Versuch verzögertauffangen ist die Zahl Sekunden, bis die Leitung in denZufuhrbehälter zurück gelegt sein kann, diese Zahl muß mindestens120 Sekunden sein. Das Versuch Maximum fangen ist dieHöchstzahl der Zeiten auf, die eine Leitung dieses Status versuchtwerden kann, bevor die Liste zurückgestellt werden muß, diese Zahlkann von 1 bis 10 sein. Sie können aktivieren und eine Leitung zuentaktivieren bereiten Sie Eintragung mit den zur Verfügunggestellten Verbindungen auf. Diese Eigenschaft arbeitet nur imAutomobil-Vorwahlknopf Modus, in dem Vorwahlknopfniveau grösser als 0ist. + + + + + +



+ +VICIDIAL_USER_GROUPSTABELLE

+
+
+Benutzer-Gruppe - Dieses ist der kurze Name einer VicidialBenutzergruppe, der Versuch, zum keiner Räume zu benutzen, oderInterpunktion für dieses fangen Maximum 20 Buchstaben,Minimum von 2 Buchstaben auf. + +
+
+
+Gruppe Name - Dieses ist die Beschreibung des vicidialBenutzergruppe Maximums von 40 Buchstaben. + + + + + +



+ +VICIDIAL_INDEXETABELLE

+
+
+Index Identifikation - Dieses ist der kurze Name eines VicidialIndexes. Dieser muß ein einzigartiger Bezeichner sein. Der Versuch,zum keiner Räume oder die Interpunktion für dieses zu benutzenfangen Maximum 10 Buchstaben, Minimum von 2 Buchstaben auf. + +
+
+Index-Name - Dieses ist der Titel einem Vicidial Index. Dieses isteine kurze Zusammenfassung der Indexmaximum 50 Buchstaben, Minimum von2 Buchstaben. Es sollte keine Räume geben, oder Interpunktionirgendwie der Art in den theis fangen auf. + +
+
+Index kommentiert - Dieses ist, wo Sie Anmerkungen für einenVicidial Index wie - geändert, um Aufsteigen an Sept. 23 freizugeben-. Maximum 255 Buchstaben setzen können, Minimum von 2 Buchstaben. + +
+
+Index-Text - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today? + +
+
+
+Aktiv - Dieses stellt fest, ob dieser Index vorgewählt werdenkann, durch eine Kampagne verwendet zu werden. + + + + + +



+ +VICIDIAL_LEAD_FILTERTABELLE

+
+
+Filter Identifikation - Dieses ist der kurze Name eines VicidialLeitung Filter. Dieser muß ein einzigartiger Bezeichner sein.Benutzen Sie keine Räume, oder Interpunktion für diesesfangen Maximum 10 Buchstaben, Minimum von 2 Buchstaben auf. + +
+
+Filter-Name - Dieses ist ein beschreibenderer Name des Filter.Dieses ist eine kurze Zusammenfassung der Filtermaximum 30 Buchstaben,Minimum von 2 Buchstaben. + +
+
+Filter kommentiert - Dieses ist, wo Sie Anmerkungen für einenVicidial Filter wie - Anrufe alle Kalifornien Leitungen -. Maximum 255Buchstaben setzen können, Minimum von 2 Buchstaben. + +
+
+Filter SQL - Dieses ist, wohin Sie das SQL Frage Fragment setzen,das Sie vorbei filtern möchten anfangen nicht, oder Ende mit UND, dasdurch den Zufuhrbehälter cron Index automatisch hinzugefügt wird.eine Beispiel SQL Frage, die hier arbeiten würde, ist called_count \4 und called_count \. + + + + + +



+ +VICIDIAL_AnrufzeitenTABELLE

+
+
+Anrufzeit ID - Dies ist der kurze Name von einer Vicidial Anrufzeit Definition. Es muss ein eindeutiger Bezeichner sein. Leerzeichen und Punkte sind in diesem Feld nicht erlaubt. Maximal 10 Zeichen, mindestens 2. + +
+
+Anrufzeit Name - Dies ist ein besser beschreibender Name für die Anrufzeit Definition. Es ist eine kurze Zusammenfassung der Anrufzeit Definition. Maximal 30 Zeichen, mindestens 2. + +
+
+Anrufzeit Kommentare - Hier können Sie Kommentare für eine Vicidial Anrufzeit Definition wie -10 bis 14 Uhr mit eigenen Beschränkungen für das angerufene Land- machen. Maximal 255 Zeichen. + +
+
+Standard Start and Stop Zeiten - Dies ist die Standardzeit, zu der Anrufe innerhalb der Anrufzeitdefinition gestartet oder gestoppt werden dürfen, wenn die Wochentag Startzeit nicht definiert ist. 0 ist Mitternacht. Um Anrufe komplett zu verhindern den Wert auf 2400 und die Standard Stopzeit ebenfalls auf 2400 setzen. Um Anrufe für 24 Stunden am Tag zu erlauben die Startzeit auf 0 und die Stopzeit auf 2400 setzen. + +
+
+Wochentag Start and Stop Zeit - Dies sind die speziellen Zeiten pro Tag, welche für die Anrufzeit Definition gesetzt werden können. Es gelten die selben Regeln wie für Start und Stop Zeiten. + +
+
+Land Anrufzeit Definition - Dies ist die Liste der landspezifischen Anrufzeit Definitionen, die von dieser Anrufzeit Definition beachtet werden. + +
+
+Landesspezifische Anrufzeit Definition - Dies ist der zwei Buchstaben Code für das Land, für das die Anrufzeit Definition gilt. Damit diese ausgeführt wird muss die in der Kampagne gesetzte lokale Anrufzeit diese landesspezifische Anrufzeit Aufzeichnung enthalten, genauso wie alle anzurufenden Anschlüsse den landesspezifischen zwei Buchstaben Code enthalten müssen . + + + + +



+ +VICIDIAL LISTE LADEVORRICHTUNG FUNKTIONALITÄT

+
+
+Die VICIDIAL grundlegende Netz-gegründete Leitung Ladevorrichtung isteinfach entworfen, um eine Leitung Akte zu nehmen - bis zu 8MB in derGröße - die entweder Vorsprung oder das abgegrenzte Rohr und es indie vicidial_list Tabelle zu laden ist. Es gibt auch eine neueBetaversionsuperleitung Ladevorrichtung, das auffangen dasWählen zuläßt und TXT- deutlich Text, CSV- Komma getrennte Werteund XLS- übertreffen Akte Formate. Die Leitung Ladevorrichtung tutnicht Datenprüfung, oder Überprüfung auf Duplikate in sich oder inanderen Listen, damit etwas Sie ist, muß vor Ihnen Last tun dieLeitungen. Auch überprüfen Sie, ob Sie die Liste erstellt haben,daß diese Leitungen darunter sein sollen, damit Sie sie benutzenkönnen. Es gibt auch die Angelegenheit der Zeit-Zone-Kodierung dieseLeitungen. Sie können die Frequenz erhöhen wünschen, daß dasADMIN_adjust_GMTnow_on_leads.pl in das cron auf IhremSternchenbediener gelaufen wird, damit alle mögliche geladenenLeitungen schneller kodiert werden können. Ist hier eine Liste vonauffängt in ihrem korrekten Auftrag für die Leitung Akten: +
    +
  1. Verkäufer-Leitung Code - zeigt oben im Verkäufer, den Identifikationvom GUI auffangen +
  2. Quellenprogramm - interner Gebrauch nur für admins und DBAs +
  3. Liste Identifikation - die Liste Zahl, die diese Leitungen obendarunter zeigen +
  4. Telefon-Code - das Präfix für die Telefonnummer - 1 für US, 01144für Großbritannien, 01161 für AUS, usw. +
  5. Telefonnummer - muß mindestens 8 Stellen lang sein +
  6. Titel - Titel dem Kunden - Herr Ms Mrs, usw.... +
  7. Vorname +
  8. Mittlere Initiale +
  9. Letzter Name +
  10. Adresse Linie 1 +
  11. Adresse Linie 2 +
  12. Adresse Linie 3 +
  13. Stadt +
  14. Zustand - begrenzt auf 2 Buchstaben +
  15. Provinz +
  16. Postcode +
  17. Land +
  18. Geschlecht +
  19. Geburtsdatum +
  20. Wechselnde Telefonnummer + Sicherheit Phrase +
  21. Anmerkungen +
+ +
ANMERKUNGEN: Die übertreffenleitung Ladevorrichtung Funktionalitätwird durch eine Reihe Perl Indexe ermöglicht und muß eine richtigzusammengebaute /home/cron/AST_SERVER_conf.pl Akte im Platz auf demweb server haben. Auch ein Paarperl Module müssen für sie, umaußerdem zu arbeiten - OLE-Storage_Lite-Storage_Lite undVerteilungsbogen-ParseExcel geladen werden. Sie können aufLaufzeitfehler in diesen überprüfen, indem Sie Ihre Apache error_logAkte betrachten. + +







+







+DAS ENDE +
+\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$dial_status_a = $row[3]; +$dial_status_b = $row[4]; +$dial_status_c = $row[5]; +$dial_status_d = $row[6]; +$dial_status_e = $row[7]; +$local_call_time = $row[16]; +if ($lead_filter_id=='') + { + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + +$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$camp_lists=''; +$o=0; +while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; +if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} +} +$camp_lists = eregi_replace(".$","",$camp_lists); + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + +echo "

\n"; +echo "Zeige Anzahl anrufbarer Anschlüsse -

\n"; +echo "CAMPAIGN: $campaign_id
\n"; +echo "LISTEN: $camp_lists
\n"; +echo "STATUSES: $dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e
\n"; +echo "FILTER: $lead_filter_id
\n"; +echo "CALL TIME: $local_call_time

\n"; + +### call function to calculate and print dialable leads +dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + +echo "

\n"; +echo "\n"; + +exit; +} + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) +{ + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDORLEADCODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551212'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[1]; +$script_text = $row[3]; + +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); +$script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); +$script_text = eregi_replace("\n","
",$script_text); + + +echo ""; + +echo "Vorbetrachtung-Index: $script_id
\n"; +echo "
\n"; +echo "
$script_name
\n"; +echo "$script_text\n"; +echo "
\n"; + +echo "\n"; + +exit; +} + + + + +######################### HTML HEADER BEGIN ####################################### +if ($hh=='users') {$users_hh='bgcolor ="#FFFF99"'; $users_fc='BLACK';} # yellow + else {$users_hh=''; $users_fc='WHITE';} +if ($hh=='campaigns') {$campaigns_hh='bgcolor ="#FFCC99"'; $campaigns_fc='BLACK';} # orange + else {$campaigns_hh=''; $campaigns_fc='WHITE';} +if ($hh=='lists') {$lists_hh='bgcolor ="#FFCCCC"'; $lists_fc='BLACK';} # red + else {$lists_hh=''; $lists_fc='WHITE';} +if ($hh=='ingroups') {$ingroups_hh='bgcolor ="#CC99FF"'; $ingroups_fc='BLACK';} # purple + else {$ingroups_hh=''; $ingroups_fc='WHITE';} +if ($hh=='remoteagent') {$remoteagent_hh='bgcolor ="#CCFFCC"'; $remoteagent_fc='BLACK';} # green + else {$remoteagent_hh=''; $remoteagent_fc='WHITE';} +if ($hh=='usergroups') {$usergroups_hh='bgcolor ="#CCFFFF"'; $usergroups_fc='BLACK';} # cyan + else {$usergroups_hh=''; $usergroups_fc='WHITE';} +if ($hh=='scripts') {$scripts_hh='bgcolor ="#99FFCC"'; $scripts_fc='BLACK';} # light teal + else {$scripts_hh=''; $scripts_fc='WHITE';} +if ($hh=='filters') {$filters_hh='bgcolor ="#CCCCCC"'; $filters_fc='BLACK';} # grey + else {$filters_hh=''; $filters_fc='WHITE';} +if ($hh=='times') {$times_hh='bgcolor ="#99FF33"'; $times_fc='BLACK';} # hard teal + else {$times_hh=''; $times_fc='WHITE';} + +?> + + + + +\n"; +echo "
English Deutsch
+ + + + + + + + + + + + + + + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + + + + +
  VICIDIAL ADMIN - Logout  
> SIZE=1> BENUTZER > SIZE=1> KAMPAGNEN > SIZE=1> LISTEN > SIZE=1> INDEXE > SIZE=1> FILTER > SIZE=1> IN-GROUPS > SIZE=1> Anrufzeiten > SIZE=1> BENUTZER-GRUPPEN > SIZE=1> REMOTEMITTEL > REPORTS
  LISTE BENUTZER     |     ADDIEREN Sie Einen NEUEN BENUTZER     |     SUCHE NACH Einem BENUTZER
  ADDIEREN SIE KAMPAGNE     |     LISTE KAMPAGNEN
  ZEIGEN SIE LISTEN     |     ADDIEREN SIE NEUE LISTE     |     SUCHE NACH Einer LEITUNG |     FÜGEN SIE ZAHL DNC HINZU           |     LAST NEUE LEITUNGEN
  ADDIEREN SIE INDEX     |     ANSICHT-INDEXE
  ADDIEREN SIE FILTER     |     ANSICHT-FILTER
  ZEIGEN SIE IN-GROUPS     |     ADDIEREN SIE NEUES IN-GROUP
  Zeige Anrufzeiten     |     Hinzufügen neuer Anrufzeiten     |     Zeige landesspezifische Anrufzeiten     |     Hinzufügen neuer landesspezifischer Anrufzeiten  
  ADDIEREN SIE BENUTZER-GRUPPE     |     LISTE BENUTZER-GRUPPEN     |     GRUPPE STÜNDLICH
  ZEIGEN SIE REMOTEMITTEL     |     ADDIEREN SIE NEUE REMOTEMITTEL
 
+
\n"; +echo ""; + +echo "
ADDIEREN Sie Einen NEUEN BENUTZER
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "$NWB#vicidial_users-user_group$NWE\n"; +echo "\n"; +echo "
Benutzer-Zahl: $NWB#vicidial_users-user$NWE
Kennwort:$NWB#vicidial_users-pass$NWE
Voller Name: $NWB#vicidial_users-full_name$NWE
Benutzer-Niveau: $NWB#vicidial_users-user_level$NWE
Benutzer-Gruppe:
Telefon-LOGON: $NWB#vicidial_users-phone_login$NWE
Telefon-Durchlauf: $NWB#vicidial_users-phone_pass$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo "
\n"; +echo ""; + +echo "
ADDIEREN Sie Eine NEUE KAMPAGNE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Kampagne Identifikation: $NWB#vicidial_campaigns-campaign_id$NWE
Kampagne Name: $NWB#vicidial_campaigns-campaign_name$NWE
Aktiv:$NWB#vicidial_campaigns-active$NWE
Park-Verlängerung: $NWB#vicidial_campaigns-park_ext$NWE
Park-Dateiname: $NWB#vicidial_campaigns-park_file_name$NWE
Netz-Form: $NWB#vicidial_campaigns-web_form_address$NWE
Erlauben Sie Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Zufuhrbehälter-Niveau: $NWB#vicidial_campaigns-hopper_level$NWE
Selbstvorwahlknopf-Niveau: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Folgender Vertreter-Anruf: $NWB#vicidial_campaigns-next_agent_call$NWE
Ortsgespräch-Zeit: $NWB#vicidial_campaigns-local_call_time$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Index: $NWB#vicidial_campaigns-campaign_script$NWE
Erhalten Sie Anruf-Produkteinführung: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Liste Identifikation: (nur Stellen)$NWB#vicidial_lists-list_id$NWE
Liste Name: $NWB#vicidial_lists-list_name$NWE
Kampagne: $NWB#vicidial_lists-campaign_id$NWE
Aktiv:$NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) +{ +echo "
\n"; +echo ""; + +if (strlen($phone_number) > 2) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DNC NICHT ADDIERT - diese Telefonnummer ist bereits in benennen nichtListe: $phone_number

\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');"; + $rslt=mysql_query($stmt, $link); + + echo "
DNC FÜGTE HINZU: $phone_number

\n"; + + ### LOG INSERTION TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW DNC NUMBER|$PHP_AUTH_USER|$ip|'$phone_number'|\n"); + fclose($fp); + } + } + } + +echo "
FÜGEN Sie Eine ZAHL Der DNC LISTE Hinzu\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
Telefonnummer: (nur Stellen)$NWB#vicidial_list-dnc$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo "
\n"; +echo ""; + +echo "
ADDIEREN Sie Eine NEUE INBOUND GRUPPE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Gruppe Identifikation: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Gruppe Name: $NWB#vicidial_inbound_groups-group_name$NWE
Gruppe Farbe: $NWB#vicidial_inbound_groups-group_color$NWE
Aktiv:$NWB#vicidial_inbound_groups-active$NWE
Netz-Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Folgender Vertreter-Anruf: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Anzeige: $NWB#vicidial_inbound_groups-fronter_display$NWE
Index: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Erhalten Sie Anruf-Produkteinführung: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo "
\n"; +echo ""; + +echo "
ADDIEREN SIE NEUE REMOTEMITTEL\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Benutzernummer Anfang: (nur Zahlen, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Zeilenzahl: (nur Zahlen)$NWB#vicidial_remote_agents-number_of_lines$NWE
Bediener IP: $NWB#vicidial_remote_agents-server_ip$NWE
Externe Verlängerung: (dialplan Zahl wählte, um Mittel zu erreichen)$NWB#vicidial_remote_agents-conf_exten$NWE
Status:$NWB#vicidial_remote_agents-status$NWE
Kampagne: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Gruppen: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "ANMERKUNG: Sie kann bis 30 Sekunden für die Änderungen dauern, dieauf diesem Schirm eingereicht werden, um Phasen zu gehen\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo "
\n"; +echo ""; + +echo "
ADDIEREN SIE NEUE BENUTZER-GRUPPE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Gruppe: (keine Räume oder Interpunktion)$NWB#vicidial_user_groups-user_group$NWE
Beschreibung: (Beschreibung der Gruppe)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW SCRIPT\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Index Identifikation: (keine Räume oder Interpunktion)$NWB#vicidial_scripts-script_id$NWE
Index-Name: (Titel dem Index)$NWB#vicidial_scripts-script_name$NWE
Index-Anmerkungen: $NWB#vicidial_scripts-script_comments$NWE
Aktiv:$NWB#vicidial_scripts-active$NWE
Index-Text: $NWB#vicidial_scripts-script_text$NWE
\n"; + +} + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) +{ +echo "
\n"; +echo ""; + +echo "
ADDIEREN SIE NEUEN FILTER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Filter Identifikation: (keine Räume oder Interpunktion)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter-Name: (kurze Beschreibung des Filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter-Anmerkungen: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter Sql: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; +} + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) +{ +echo "
\n"; +echo ""; + +echo "
Hinzufügen neuer Anrufzeiten\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Anrufzeit ID: (keine Räume oder Interpunktion)$NWB#vicidial_call_times-call_time_id$NWE
Anrufzeit Name: (Kurze Beschreibung der Anrufzeit)$NWB#vicidial_call_times-call_time_name$NWE
Anrufzeit Kommentare: $NWB#vicidial_call_times-call_time_comments$NWE
Datums und Zeitoptionen erscheinen, wenn die Anrufzeitdefinition angelegt wurde
\n"; +} + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) +{ +echo "
\n"; +echo ""; + +echo "
Hinzufügen neuer landesspezifischer Anrufzeiten\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Landesspezifische Anrufzeiten ID: (keine Räume oder Interpunktion)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (keine Räume oder Interpunktion)$NWB#vicidial_call_times-state_call_time_state$NWE
Landesspezifischer Anrufzeiten Name: (Kurze Beschreibung der Anrufzeit)$NWB#vicidial_call_times-call_time_name$NWE
Landesspezifischer Anrufzeiten Kommentar: $NWB#vicidial_call_times-call_time_comments$NWE
Datums und Zeitoptionen erscheinen, wenn die Anrufzeitdefinition angelegt wurde
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
BENUTZER NICHT ADDIERT - es gibt bereits einen Benutzer im System mitdieser Benutzerzahl\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
BENUTZER NICHT ADDIERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
Teilnehmerbezeichnung muß zwischen 2 und 8 Buchstaben lang sein\n"; + echo "
voller Name und Kennwort müssen mindestens 2 Buchstaben lang sein\n"; + } + else + { + echo "
BENUTZER FÜGTE HINZU: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass'|\n"); + fclose($fp); + } + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
KAMPAGNE NICHT ADDIERT - es gibt bereits eine Kampagne im System mitdieser Identifikation\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
KAMPAGNE NICHT ADDIERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
Kampagne Identifikation muß zwischen 2 und 8 Buchstaben lang sein\n"; + echo "
Kampagne Name muß zwischen 6 und 40 Buchstaben lang sein\n"; + } + else + { + echo "
KAMPAGNE ADDIERT: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('$campaign_id','$campaign_name','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo ""; + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADDIEREN Sie Eine NEUE KAMPAGNE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
KAMPAGNE STATUS NICHT ADDIERT - es gibt bereits einen Kampagne-Statusim System mit diesem Namen\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
KAMPAGNE STATUS NICHT ADDIERT - es gibt bereits einen Globalstatus imSystem mit diesem Namen\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
KAMPAGNE STATUS NICHT ADDIERT - gehen Sie bitte zurück und betrachtenSie die Daten, die Sie eingaben\n"; + echo "
Status muß zwischen 1 und 8 Buchstaben lang sein\n"; + echo "
Statusname muß zwischen 2 und 30 Buchstaben lang sein\n"; + } + else + { + echo "
KAMPAGNE STATUS ADDIERT: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADDIEREN Sie Eine NEUE KAMPAGNE STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } + } +$ADD=31; +} + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) +{ + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
KAMPAGNE HOTKEY NICHT ADDIERT worden - es gibt bereits eineKampagne-hotkey im System mit diesem hotkey\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
KAMPAGNE HOTKEY NICHT ADDIERT - gehen Sie bitte zurück und betrachtenSie die Daten, die Sie eingaben\n"; + echo "
hotkey muß ein einzelner Buchstabe zwischen 1 und 9 sein \n"; + echo "
Status muß zwischen 1 und 8 Buchstaben lang sein\n"; + } + else + { + echo "
KAMPAGNE HOTKEY FÜGTE HINZU: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADDIEREN Sie Eine NEUE KAMPAGNE HOTKEY |$PHP_AUTH_USER|$ip|'$status','$hotkey','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) +{ + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
KAMPAGNE LEITUNG BEREITEN NICHT HINZUGEFÜGT auf - es gibt bereitseine Führenwiederverwertung für diese Kampagne mit diesem Status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
KAMPAGNE LEITUNG BEREITEN NICHT HINZUGEFÜGT auf - gehen Sie bittezurück und betrachten Sie die Daten, die Sie eingaben\n"; + echo "
Status muß zwischen 1 und 6 Buchstaben lang sein\n"; + echo "
Versuch verzögert muß mindestens 120 Sekunden sein\n"; + echo "
maximale Versuche müssen von 1 bis 10 sein\n"; + } + else + { + echo "
KAMPAGNE LEITUNG BEREITEN HINZUGEFÜGT AUF: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LISTE NICHT ADDIERT - es gibt bereits eine Liste im System mit dieserIdentifikation\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
LISTE NICHT ADDIERT - gehen Sie bitte zurück und betrachten Sie dieDaten, die Sie eingaben\n"; + echo "
Liste Identifikation muß zwischen 2 und 8 Buchstaben lang sein\n"; + echo "
Liste Name muß mindestens 2 Buchstaben lang sein\n"; + } + else + { + echo "
LISTE ADDIERT: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + } + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GRUPPE NICHT ADDIERT - es gibt bereits eine Gruppe im System mitdieser Identifikation\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GRUPPE NICHT ADDIERT - gehen Sie bitte zurück und betrachten Sie dieDaten, die Sie eingaben\n"; + echo "
Gruppe Identifikation muß zwischen 2 und 20 Buchstaben lang sein undNr. enthalten ' -+'.\n"; + echo "
Gruppe Name und Gruppe Farbe muß mindestens 2 Buchstaben lang sein\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPPE FÜGTE HINZU: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
REMOTEMITTEL NICHT ADDIERT - es gibt bereits eineRemotemitteleintragung beginnend mit diesem userID\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTEMITTEL NICHT ADDIERT - gehen Sie bitte zurück und betrachtenSie die Daten, die Sie eingaben\n"; + echo "
Benutzernummer Anfang und externe Verlängerung müssen mindestens 2Buchstaben lang sein\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTEMITTEL FÜGTEN HINZU: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW REMOTEMITTEL ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + } + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
BENUTZER-GRUPPE NICHT ADDIERT - es gibt bereits eine BenutzergruppeEintragung mit diesem Namen\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
BENUTZER-GRUPPE NICHT ADDIERT - gehen Sie bitte zurück und betrachtenSie die Daten, die Sie eingaben\n"; + echo "
Gruppe Name und Beschreibung müssen mindestens 2 Buchstaben langsein\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
BENUTZER-GRUPPE ADDIERT: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADDIEREN Sie Einen NEUEN BENUTZER GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + } + } + } +$ADD=100000; +} + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
INDEX NICHT ADDIERT - es gibt bereits eine Indexeintragung mit diesem Namen\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
INDEX NICHT ADDIERT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Indexname, -beschreibung und -text müssen mindestens 2 Buchstabenlang sein\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + + echo "
INDEX FÜGTE HINZU: $script_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000000; +} + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
FILTER NICHT ADDIERT - es gibt bereits eine Filtereintragung mitdieser Identifikation\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NICHT ADDIERT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Filtern Sie Identifikation, Namen und SQL muß mindestens 2 Buchstabenlang sein\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='$lead_filter_sql';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER ADDIERT: $lead_filter_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=10000000; +} + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Anrufzeit Definition nicht hinzugefügt - Es existiert bereits ein Anrufzeiteintrag mit dieser ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
Anrufzeit Definition nicht hinzugefügt - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Anrufzeit ID und Name müssen mindestens 2 Zeichen Länge haben\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + + echo "
Anrufzeit hinzugefügt: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + } +$ADD=311111111; +} + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Landesspezifische Anrufzeitdefinition nicht hinzugefügt - Es existiert bereits ein Anrufzeiteintrag mit dieser ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
Landesspezifische Anrufzeitdefinition nicht hinzugefügt - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Landesspezifische Anrufzeit ID, Name und Land müssen mindestens 2 Zeichen Länge haben\n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + + echo "
landesspezifische Anrufzeiten hinzugefügt: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=3111111111; +} + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
BENUTZER NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
Kennwort und voller Name jedes Notwendigkeit ot sind mindestens 2Buchstaben lang\n"; + } + else + { + echo "
BENUTZER ÄNDERTE - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
BENUTZER NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
Kennwort und voller Name jedes Notwendigkeit ot sind mindestens 2Buchstaben lang\n"; + } + else + { + echo "
BENUTZER ÄNDERTE - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
BENUTZER NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
Kennwort und voller Name jedes Notwendigkeit ot sind mindestens 2Buchstaben lang\n"; + } + else + { + echo "
BENUTZER ÄNDERTE: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
KAMPAGNE NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
der Kampagne Name muß mindestens 6 Buchstaben lang sein\n"; + } + else + { + echo "
KAMPAGNE ÄNDERTE: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
ZURÜCKSTELLEN DES KAMPAGNE LEITUNG ZUFUHRBEHÄLTERS\n"; + echo "
- Wartezeit 1 Minute, bevor folgende Nummer gewählt wird\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
KAMPAGNE STATUS NICHT GEÄNDERT - gehen Sie bitte zurück undbetrachten Sie die Daten, die Sie eingaben\n"; + echo "
die Kampagne Kennzeichnung muß mindestens 2 Buchstaben lang sein\n"; + echo "
der Kampagne Status muß mindestens Buchstaben 1 lang sein\n"; + } + else + { + echo "
KUNDENSPEZIFISCHER KAMPAGNE STATUS GELÖSCHT: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
KAMPAGNE HOTKEY NICHT GEÄNDERT - gehen Sie bitte zurück undbetrachten Sie die Daten, die Sie eingaben\n"; + echo "
die Kampagne Kennzeichnung muß mindestens 2 Buchstaben lang sein\n"; + echo "
der Kampagne Status muß mindestens Buchstaben 1 lang sein\n"; + echo "
das Kampagne hotkey muß mindestens Buchstaben 1 lang sein\n"; + } + else + { + echo "
KUNDENSPEZIFISCHE KAMPAGNE HOTKEY LÖSCHTE: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
KAMPAGNE NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
der Kampagne Name muß mindestens 6 Buchstaben lang sein\n"; + } + else + { + echo "
KAMPAGNE ÄNDERTE: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level',lead_filter_id='$lead_filter_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
ZURÜCKSTELLEN DES KAMPAGNE LEITUNG ZUFUHRBEHÄLTERS\n"; + echo "
- Wartezeit 1 Minute, bevor folgende Nummer gewählt wird\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG HOPPER RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=34; # go to campaign modification form below +} + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Status muß zwischen 1 und 6 Buchstaben lang sein\n"; + echo "
Versuch verzögert muß mindestens 120 Sekunden sein\n"; + echo "
maximale Versuche müssen von 1 bis 10 sein\n"; + } + else + { + echo "
CAMPAIGN LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LISTE NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Sie dieDaten, die Sie eingaben\n"; + echo "
Liste Name muß mindestens 2 Buchstaben lang sein\n"; + } + else + { + echo "
LISTE ÄNDERTE: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
ZURÜCKSTELLEN VON VON LIST-CALLED-STATUS\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + } + if ($campaign_id != "$old_campaign_id") + { + echo "
ENTFERNEN DER LISTE ZUFUHRBEHÄLTER-LEITUNGEN VOM ALTEN KAMPAGNEZUFUHRBEHÄLTER ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + } + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GRUPPE NICHT GEÄNDERT - gehen Sie bitte zurück und betrachten Siedie Daten, die Sie eingaben\n"; + echo "
Gruppe Name und Gruppe Farbe muß mindestens 2 Buchstaben lang sein\n"; + } + else + { + echo "
GRUPPE GEÄNDERT: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_message='$drop_message',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111; # go to in-group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTEMITTEL NICHT GEÄNDERT - gehen Sie bitte zurück und betrachtenSie die Daten, die Sie eingaben\n"; + echo "
Benutzernummer Anfang und externe Verlängerung müssen mindestens 2Buchstaben lang sein\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTEMITTEL GEÄNDERT\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTEMITTEL ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
BENUTZER-GRUPPE NICHT GEÄNDERT - gehen Sie bitte zurück undbetrachten Sie die Daten, die Sie eingaben\n"; + echo "
Gruppe Name und Beschreibung müssen mindestens 2 Buchstaben langsein\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
BENUTZER-GRUPPE GEÄNDERT\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + } + } + +$ADD=311111; # go to user group modification form below +} + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
INDEX NICHT GEÄNDERT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Indexname, -beschreibung und -text müssen mindestens 2 Buchstabenlang sein\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
INDEX ÄNDERTE\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111; # go to script modification form below +} + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NICHT GEÄNDERT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Filtern Sie Identifikation, Namen und SQL muß mindestens 2 Buchstabenlang sein\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='$lead_filter_sql' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER GEÄNDERT\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31111111; # go to filter modification form below +} + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
Anrufzeit nicht geändert - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Anrufzeit ID und Name müssen mindestens 2 Zeichen Länge haben\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
Anrufzeit geändert\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + +$ADD=311111111; # go to call time modification form below +} + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
Landesspezifische Anrufzeit nicht geändert - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Landesspezifische Anrufzeit ID, Name und Land müssen mindestens 2 Zeichen Länge haben\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
Landesspezifische Anrufzeit geändert\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111111; # go to state call time modification form below +} + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
BENUTZER NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + echo "
BENUTZER-AUSLASSUNG BESTÄTIGUNG: $user\n"; + echo "

Klicken Sie hier, um Benutzer zu löschen $user


\n"; + } + +$ADD='3'; # go to user modification below +} + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
KAMPAGNE NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Kampagne_id be at least 2 characters in length\n"; + } + else + { + echo "
KAMPAGNE AUSLASSUNG BESTÄTIGUNG: $campaign_id\n"; + echo "

Klicken Sie hier, um Kampagne zu löschen $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
MITTEL GELOGGT NICHT AUS KAMPAGNE HERAUS - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Kampagne_id be at least 2 characters in length\n"; + } + else + { + echo "
MITTELLOGOUT-BESTÄTIGUNG: $campaign_id\n"; + echo "

Klicken Sie hier, um alle Mittel aus zu loggen $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) +{ + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
LISTE NICHT GELÖSCHT WORDEN - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
LISTE AUSLASSUNG BESTÄTIGUNG: $list_id\n"; + echo "

Klicken Sie hier, um Liste und alle seine Leitungen zu löschen $list_id


\n"; + } + +$ADD='311'; # go to campaign modification below +} + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
IN-GROUP AUSLASSUNG BESTÄTIGUNG: $group_id\n"; + echo "

Klicken Sie hier, um Ingruppe zu löschen $group_id


\n"; + } + +$ADD='3111'; # go to in-group modification below +} + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTEMITTEL NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
REMOTEMITTEL-AUSLASSUNG BESTÄTIGUNG: $remote_agent_id\n"; + echo "

Klicken Sie hier, um Remotemittel zu löschen $remote_agent_id


\n"; + } + +$ADD='31111'; # go to remote agent modification below +} + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
BENUTZER-GRUPPE NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + echo "
BENUTZER-GRUPPE AUSLASSUNG BESTÄTIGUNG: $user_group\n"; + echo "

Klicken Sie hier, um Benutzergruppe zu löschen $user_group


\n"; + } + +$ADD='311111'; # go to user group modification below +} + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
INDEX NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
INDEX-AUSLASSUNG BESTÄTIGUNG: $script_id\n"; + echo "

Klicken Sie hier, um Index zu löschen $script_id


\n"; + } + +$ADD='3111111'; # go to script modification below +} + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Filter Identifikation muß mindestens 2 Buchstaben lang sein\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Klicken Sie hier, um Filter zu löschen$lead_filter_id


\n"; + } + +$ADD='31111111'; # go to filter modification below +} + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Anrufzeit nicht gelöscht - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Anrufzeit ID muss mindestens 2 Zeichen lang sein\n"; + } + else + { + echo "
Löschen der Anrufzeit bestätigen: $call_time_id\n"; + echo "

Click here to delete call time $call_time_id


\n"; + } + +$ADD='311111111'; # go to call time modification below +} + +###################### +# ADD=5111111111 confirmation before deletion of call time record +###################### + +if ($ADD==5111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Landesspezifische Anrufzeit nicht gelöscht - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Anrufzeit ID muss mindestens 2 Zeichen lang sein\n"; + } + else + { + echo "
Löschen der landesspezifischen Anrufzeit bestätigen: $call_time_id\n"; + echo "

Click here to delete state call time $call_time_id


\n"; + } + +$ADD='3111111111'; # go to state call time modification below +} + + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
BENUTZER NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING USER!!!!|$PHP_AUTH_USER|$ip|user='$user'|\n"); + fclose($fp); + } + echo "
BENUTZER-AUSLASSUNG FÜHRTE DURCH: $user\n"; + echo "

\n"; + } + +$ADD='0'; # go to user list +} + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) +{ + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
KAMPAGNE NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Kampagne_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
ENTFERNEN DER LISTE ZUFUHRBEHÄLTER-LEITUNGEN VOM ALTEN KAMPAGNEZUFUHRBEHÄLTER ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!DELETING CAMPAIGN!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
KAMPAGNE AUSLASSUNG FÜHRTE DURCH: $campaign_id\n"; + echo "

\n"; + } + +$ADD='10'; # go to campaigns list +} + +###################### +# ADD=62 Logout all agents fro a campaign +###################### + +if ($ADD==62) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
MITTEL GELOGGT NICHT AUS KAMPAGNE HERAUS - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Kampagne_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!MITTELLOGOUT!!!!!!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
MITTELLOGOUT FÜHRTE DURCH: $campaign_id\n"; + echo "

\n"; + } + +$ADD='31'; # go to campaign modification below +} + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
KAMPAGNE LEITUNG BEREITEN NICHT GELÖSCHT AUF - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Status muß zwischen 1 und 6 Buchstaben lang sein\n"; + echo "
Versuch verzögert muß mindestens 120 Sekunden sein\n"; + echo "
maximale Versuche müssen von 1 bis 10 sein\n"; + } + else + { + echo "
KAMPAGNE LEITUNG BEREITEN GELÖSCHT AUF: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) +{ + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
LISTE NICHT GELÖSCHT WORDEN - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
ENTFERNEN DER LISTE ZUFUHRBEHÄLTER-LEITUNGEN VOM ALTEN KAMPAGNEZUFUHRBEHÄLTER ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
ENTFERNEN DER LISTE LEITUNGEN VON DER VICIDIAL_LIST TABELLE\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING LIST!!!!|$PHP_AUTH_USER|$ip|list_id='$list_id'|\n"); + fclose($fp); + } + echo "
LISTE AUSLASSUNG DURCHGEFÜHRT: $list_id\n"; + echo "

\n"; + } + +$ADD='100'; # go to lists list +} + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_groups where group_id='$group_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING IN-GROUP!!|$PHP_AUTH_USER|$ip|group_id='$group_id'|\n"); + fclose($fp); + } + echo "
IN-GROUP AUSLASSUNG FÜHRTE DURCH: $group_id\n"; + echo "

\n"; + } + +$ADD='1000'; # go to in-group list +} + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTEMITTEL NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING RMTAGENT!!|$PHP_AUTH_USER|$ip|remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + echo "
REMOTEMITTEL-AUSLASSUNG FÜHRTE DURCH: $remote_agent_id\n"; + echo "

\n"; + } + +$ADD='10000'; # go to remote agents list +} + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
BENUTZER-GRUPPE NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING USRGROUP!!|$PHP_AUTH_USER|$ip|user_group='$user_group'|\n"); + fclose($fp); + } + echo "
BENUTZER-GRUPPE AUSLASSUNG DURCHGEFÜHRT: $user_group\n"; + echo "

\n"; + } + +$ADD='100000'; # go to user group list +} + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
INDEX NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING SCRIPT!!!!|$PHP_AUTH_USER|$ip|script_id='$script_id'|\n"); + fclose($fp); + } + echo "
INDEX-AUSLASSUNG FÜHRTE DURCH: $script_id\n"; + echo "

\n"; + } + +$ADD='1000000'; # go to script list +} + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NICHT GELÖSCHT - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Filter Identifikation muß mindestens 2 Buchstaben lang sein\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING FILTER!!!!|$PHP_AUTH_USER|$ip|lead_filter_id='$lead_filter_id'|\n"); + fclose($fp); + } + echo "
FILTER-AUSLASSUNG DURCHGEFÜHRT: $lead_filter_id\n"; + echo "

\n"; + } + +$ADD='10000000'; # go to filter list +} + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Anrufzeit nicht gelöscht - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Anrufzeit ID muss mindestens 2 Zeichen lang sein\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
Löschen der Anrufzeiten beendet: $call_time_id\n"; + echo "

\n"; + } + +$ADD='100000000'; # go to call times list +} + + +###################### +# ADD=6111111111 delete call times record +###################### + +if ($ADD==6111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Landesspezifische Anrufzeit nicht gelöscht - Gehen Sie bitte zurück und betrachten Sie die Daten, die Sieeingaben\n"; + echo "
Anrufzeit ID muss mindestens 2 Zeichen lang sein\n"; + } + else + { + $stmt="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + + while ($sct_to_print > $o) { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "Landesrichlinie gelöscht: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|state_call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
Löschen der landesspezifischen Anrufzeit beendet: $call_time_id\n"; + echo "

\n"; + } + +$ADD='1000000000'; # go to call times list +} + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + +if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
Sie haben nicht Erlaubnis, diesen Benutzer zu ändern: $row[1]\n"; + } +else + { + echo "
ÄNDERN Sie Einen BENUTZER-SATZ: $row[1]\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($LOGuser_level > 8) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "
Benutzer-Zahl: $row[1]$NWB#vicidial_users-user$NWE
Kennwort:$NWB#vicidial_users-pass$NWE
Voller Name: $NWB#vicidial_users-full_name$NWE
Benutzer-Niveau: $NWB#vicidial_users-user_level$NWE
Benutzer-Gruppe: $NWB#vicidial_users-user_group$NWE
Telefon-LOGON: $NWB#vicidial_users-phone_login$NWE
Telefon-Durchlauf: $NWB#vicidial_users-phone_pass$NWE
MITTEL-SCHNITTSTELLE WAHLEN:
Mittel Wählen Ingroups: $NWB#vicidial_users-agent_choose_ingroups$NWE
HotKeys Aktiv: $NWB#vicidial_users-hotkeys_active$NWE
Zeitlich geplante Wiederholungsbesuche: $NWB#vicidial_users-scheduled_callbacks$NWE
Mittel-Nur Wiederholungsbesuche: $NWB#vicidial_users-agentonly_callbacks$NWE
Vertreter-Anruf-Handbuch: $NWB#vicidial_users-agentcall_manual$NWE
Vicidial Aufnahme: $NWB#vicidial_users-vicidial_recording$NWE
Vicidial Übertragungen: $NWB#vicidial_users-vicidial_transfers$NWE
Genauere Rückstellung Gemischt: $NWB#vicidial_users-closer_default_blended$NWE
Inbound Gruppen: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_users-closer_campaigns$NWE
ADMIN SCHNITTSTELLE WAHLEN:
Ändern Sie Mittel-Schnittstelle Wahlen:$NWB#vicidial_users-alter_agent_interface_options$NWE
Löschung-Benutzer: $NWB#vicidial_users-delete_users$NWE
Löschung-Benutzer-Gruppen: $NWB#vicidial_users-delete_user_groups$NWE
Löschung-Listen: $NWB#vicidial_users-delete_lists$NWE
Löschung-Kampagnen: $NWB#vicidial_users-delete_campaigns$NWE
Löschung In-Gruppen: $NWB#vicidial_users-delete_ingroups$NWE
Löschung-Direktübertragung Mittel: $NWB#vicidial_users-delete_remote_agents$NWE
Löschung-Indexs: $NWB#vicidial_users-delete_scripts$NWE
Last Leitungen: $NWB#vicidial_users-load_leads$NWE
Kampagne Detail: $NWB#vicidial_users-campaign_detail$NWE
AGC Admin Zugang: $NWB#vicidial_users-ast_admin_access$NWE
AGC Löschung-Telefone: $NWB#vicidial_users-ast_delete_phones$NWE
Ändern Sie Leitungen: $NWB#vicidial_users-modify_leads$NWE
Ändern Sie Vertreter-Kampagne: $NWB#vicidial_users-change_agent_campaign$NWE
Löschung-Filter: $NWB#vicidial_users-delete_filters$NWE
Lösche Anrufzeits: $NWB#vicidial_users-delete_call_times$NWE
Bearbeite Anrufzeits: $NWB#vicidial_users-modify_call_times$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

LÖSCHEN SIE DIESEN BENUTZER\n"; + } + echo "

Klicken Sie hier für Benutzerzeitblatt\n"; + echo "

Klicken Sie hier für Benutzerstatus\n"; + echo "

Klicken Sie hier für Benutzernotfall\n"; + echo "

Klicken Sie hier für Benutzer Wiederholungsbesuch Einflüsse\n"; + } + +} + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed + +if ($ADD==31) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $safe_harbor_message = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; +# $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + +echo "
ÄNDERN Sie Einen KAMPAGNEN SATZ: $row[0] - Grundlegende Ansicht"; +echo " | Detail-Ansicht | "; +echo "Echtzeit Bildschirm\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +if (eregi("CLOSER", $campaign_id)) + { + echo "\n"; + } + + + +echo "\n"; +echo "
Kampagne Identifikation: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Kampagne Name: $NWB#vicidial_campaigns-campaign_name$NWE
Aktiv:$NWB#vicidial_campaigns-active$NWE
Park-Verlängerung: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Netz-Form: $NWB#vicidial_campaigns-web_form_address$NWE
Erlauben Sie Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Vorwahlknopfstatus1: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus2: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus3: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus4: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus5: $NWB#vicidial_campaigns-dial_status$NWE
Liste Auftrag: $NWB#vicidial_campaigns-lead_order$NWE
Leitung Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Zufuhrbehälter-Niveau: $NWB#vicidial_campaigns-hopper_level$NWE
Kraft-Zurückstellen des Zufuhrbehälters: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Selbstvorwahlknopf-Niveau: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Folgender Vertreter-Anruf: $NWB#vicidial_campaigns-next_agent_call$NWE
Ortsgespräch-Zeit: $NWB#vicidial_campaigns-local_call_time$NWE
Vorwahlknopf-Abschaltung: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Vorwahlknopf-Präfix: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
Kampagne CallerID: $NWB#vicidial_campaigns-campaign_cid$NWE
Kampagne VDAD exten: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Kampagne Rec exten: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Kampagne Aufnahme: $NWB#vicidial_campaigns-campaign_recording$NWE
Kampagne Rec Dateiname: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Erhalten Sie Anruf-Produkteinführung: $NWB#vicidial_campaigns-get_call_launch$NWE
Antwortende Maschine Anzeige: $NWB#vicidial_campaigns-am_message_exten$NWE
AMD senden zu VM exten: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
BringenSie DTMF 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
BringenSie Zahl 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
BringenSie DTMF 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
BringenSie Zahl 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Alternative Nummer wählen: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Zeitlich geplante Wiederholungsbesuche: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Verbindungsaufbau Sekunden: $NWB#vicidial_campaigns-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Benutze Sicherheitsnachricht: $NWB#vicidial_campaigns-safe_harbor_message$NWE
Sicherheitsnebenstelle: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Nachbereitung Sekunden $NWB#vicidial_campaigns-wrapup_seconds$NWE
Nachbereitung Nachricht $NWB#vicidial_campaigns-wrapup_message$NWE
Benutzen Sie Interne DNC Liste: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Gewährte Inbound Gruppen:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
\n"; + +echo "
\n"; +echo "
LISTEN INNERHALB DIESER KAMPAGNE:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LISTE IDENTIFIKATIONLISTE NAMEAKTIV
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Diese Kampagne hat$active_lists aktive Listen und$inactive_lists unaktivierte Listen

\n"; + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - Verberge

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - Zeige

"; + } + + + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "Diese Kampagne hat$hopper_leads Leitungen im Vorwahlknopfzufuhrbehälter

\n"; +echo "Klicken Sie hier, um zu sehen, welche Leitungen im Zufuhrbehälter imAugenblick sind

\n"; +echo "Klicken Sie hier, um alle Wiederholungsbesuch Einflüsse in dieserKampagne zu sehen

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
KUNDENSPEZIFISCHE STATUS INNERHALB DIESER KAMPAGNE:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
STATUSBESCHREIBUNGAUSWÄHLBARLÖSCHUNG
$rowx[0]$rowx[1]$rowx[2]LÖSCHUNG
\n"; + +echo "
ADDIEREN SIE NEUEN KUNDENSPEZIFISCHEN KAMPAGNE STATUS
\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Beschreibung:   \n"; +echo "Auswählbar:   \n"; +echo "
\n"; + +echo "

\n"; + + + +echo "
GEWOHNHEIT HOTKEYS INNERHALB DIESER KAMPAGNE:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
HOTKEYSTATUSBESCHREIBUNGLÖSCHUNG
$rowx[1]$rowx[0]$rowx[2]LÖSCHUNG
\n"; + +echo "
ADDIEREN SIE NEUE KUNDENSPEZIFISCHE KAMPAGNE HOTKEY
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Hotkey:   \n"; +echo "Status:   \n"; +echo "
\n"; +echo "

\n"; + + + +echo "

LEITUNG, DIE INNERHALB DIESER KAMPAGNE AUFBEREITET:   $NWB#vicidial_lead_recycle$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +echo "
STATUSVERSUCH VERZÖGERTVERSUCH MAXIMUMAKTIV LÖSCHUNG
$rowx[2]
\n"; + echo "\n"; + echo "\n"; + echo "
LÖSCHUNG
\n"; + +echo "
ADDIEREN SIE NEUE KAMPAGNE LEITUNG AUFBEREITEN
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Versuch Verzögert: \n"; +echo "Versuch Maximum: \n"; +echo "
\n"; + +echo "

\n"; + +echo "LOGGEN SIE ALLE MITTEL AUS DIESER KAMPAGNE HERAUS

\n"; + +if ($LOGdelete_campaigns > 0) + { + echo "

LÖSCHEN SIE DIESE KAMPAGNE\n"; + } + +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ($ADD==34) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Grundlegende Ansicht | "; +echo "Detail-Ansicht | "; +echo "Echtzeit Bildschirm\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
Kampagne Identifikation: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Kampagne Name: $NWB#vicidial_campaigns-campaign_name$NWE
Aktiv:$NWB#vicidial_campaigns-active$NWE
Park-Verlängerung: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Netz-Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Erlauben Sie Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Vorwahlknopfstatus1: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus2: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus3: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus4: $NWB#vicidial_campaigns-dial_status$NWE
Vorwahlknopfstatus5: $NWB#vicidial_campaigns-dial_status$NWE
Liste Auftrag: $NWB#vicidial_campaigns-lead_order$NWE
Leitung Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Zufuhrbehälter-Niveau: $NWB#vicidial_campaigns-hopper_level$NWE
Kraft-Zurückstellen des Zufuhrbehälters: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Selbstvorwahlknopf-Niveau: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Script: $script_id
Erhalten Sie Anruf-Produkteinführung: $get_call_launch
\n"; + +echo "
\n"; +echo "
LISTEN INNERHALB DIESER KAMPAGNE:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LISTE IDENTIFIKATIONLISTE NAMEAKTIV
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Diese Kampagne hat$active_lists aktive Listen und$inactive_lists unaktivierte Listen

\n"; + + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - Verberge

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - Zeige

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "Diese Kampagne hat$hopper_leads Leitungen im Vorwahlknopfzufuhrbehälter

\n"; +echo "Klicken Sie hier, um zu sehen, welche Leitungen im Zufuhrbehälter imAugenblick sind

\n"; +echo "Klicken Sie hier, um alle Wiederholungsbesuch Einflüsse in dieserKampagne zu sehen

\n"; +echo "
\n"; + +echo "
\n"; + +echo "LOGGEN SIE ALLE MITTEL AUS DIESER KAMPAGNE HERAUS

\n"; + + +if ($LOGdelete_campaigns > 0) + { + echo "

LÖSCHEN SIE DIESE KAMPAGNE\n"; + } + + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT * from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + +echo "
ÄNDERN Sie Einen LISTEN SATZ: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Liste Identifikation: $row[0]$NWB#vicidial_lists-list_id$NWE
Liste Name: $NWB#vicidial_lists-list_name$NWE
Kampagne: $NWB#vicidial_lists-campaign_id$NWE
Aktiv:$NWB#vicidial_lists-active$NWE
Stellen Sie Führen-Benennen-Status für diese Liste zurück: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
STATUS INNERHALB DIESER LISTE:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + +echo "\n"; +echo "\n"; + +echo "
STATUSSTATUS-NAMEBENANNTNICHT BENANNT
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
TEILSUMMEN$lead_list[Y_count]$lead_list[N_count]
GESAMTMENGE$lead_list[count]

\n"; +unset($lead_list); + + + + + +echo "
\n"; +echo "
ZEIT-ZONEN INNERHALB DIESER LISTE:
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + +echo "\n"; +echo "\n"; + +echo "
GMT VERSETZTE JETZT (lokale Zeit)BENANNTNICHT BENANNT
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
TEILSUMMEN$lead_list[Y_count]$lead_list[N_count]
GESAMTMENGE$lead_list[count]

\n"; +unset($lead_list); + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
BENANNTE ZÄHLIMPULSE INNERHALB DIESER LISTE:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + +echo "
STATUSSTATUS-NAME$firstTEILSUMME
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
GESAMTMENGE$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +if ($LOGdelete_lists > 0) + { + echo "

LÖSCHEN SIE DIESE LISTE\n"; + } + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_message = $row[15]; + $drop_exten = $row[16]; + +echo "
ÄNDERN Sie Einen GRUPPEN SATZ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +echo "\n"; +echo "
Gruppe Identifikation: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Gruppe Name: $NWB#vicidial_inbound_groups-group_name$NWE
Gruppe Farbe: $NWB#vicidial_inbound_groups-group_color$NWE
Aktiv:$NWB#vicidial_inbound_groups-active$NWE
Netz-Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Folgender Vertreter-Anruf: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Anzeige: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Erhalten Sie Anruf-Produkteinführung: $NWB#vicidial_inbound_groups-get_call_launch$NWE
BringenSie DTMF 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
BringenSie Zahl 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
BringenSie DTMF 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
BringenSie Zahl 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Verbindungsaufbau Sekunden: $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Benutze Verbindungsaufbaunachricht: $NWB#vicidial_inbound_groups-drop_message$NWE
Verbindungsaufbaunebenstelle: $NWB#vicidial_inbound_groups-drop_exten$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +if ($LOGdelete_ingroups > 0) + { + echo "

LÖSCHEN SIE DIESES IN-GROUP\n"; + } + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
ÄNDERN Sie Eine REMOTEMITTEL-EINTRAGUNG: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Benutzernummer Anfang: (nur Zahlen, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Zeilenzahl: (nur Zahlen)$NWB#vicidial_remote_agents-number_of_lines$NWE
Bediener IP: $NWB#vicidial_remote_agents-server_ip$NWE
Externe Verlängerung: (dialplan Zahl wählte, um Mittel zu erreichen)$NWB#vicidial_remote_agents-conf_exten$NWE
Status:$NWB#vicidial_remote_agents-status$NWE
Kampagne: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Gruppen: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "ANMERKUNG: Sie kann bis 30 Sekunden für die Änderungen dauern, dieauf diesem Schirm eingereicht werden, um Phasen zu gehen\n"; + + +if ($LOGdelete_remote_agents > 0) + { + echo "

LÖSCHEN SIE DIESES REMOTEMITTEL\n"; + } + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
ÄNDERN Sie Eine BENUTZER-GRUPPE EINTRAGUNG\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Gruppe: (keine Räume oder Interpunktion)$NWB#vicidial_user_groups-user_group$NWE
Beschreibung: (Beschreibung der Gruppe)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +if ($LOGdelete_user_groups > 0) + { + echo "

LÖSCHEN SIE DIESE BENUTZER-GRUPPE\n"; + } + +} + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = $row[3]; + $active = $row[4]; +echo ""; + +echo "
ÄNDERN Sie Einen INDEX\n"; +echo "\n"; +echo "\n"; +echo "
Index Identifikation: $script_id$NWB#vicidial_scripts-script_name$NWE
Index-Name: (Titel dem Index)$NWB#vicidial_scripts-script_name$NWE
Index-Anmerkungen: $NWB#vicidial_scripts-script_comments$NWE
Aktiv:$NWB#vicidial_scripts-active$NWE
Index-Text:

Vorbetrachtung-Index
$NWB#vicidial_scripts-script_text$NWE
\n"; + +if ($LOGdelete_scripts > 0) + { + echo "

LÖSCHEN SIE DIESEN INDEX\n"; + } + +} + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = $row[3]; +echo ""; + +echo "
ÄNDERN Sie Einen FILTER\n"; +echo "\n"; +echo "\n"; +echo "
Filter Identifikation:$lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter-Name: (kurze Beschreibung des Filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter-Anmerkungen: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter Sql: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + +echo "

"; +echo "
Testen der Kampagne:
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($LOGdelete_filters > 0) + { + echo "

LÖSCHEN SIE DIESEN FILTER\n"; + } + +} + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) +{ +if ($LOGmodify_call_times==1) +{ + +if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Landesrichtlinie hinzugefügt: $state_rule
\n"; + } +if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Landesrichlinie gelöscht: $state_rule
\n"; + } + +$ADD=311111111; +} +else +{ +echo "Sie haben nicht die Rechte, um diese Seite anzusehen. Bitte zurück gehen."; +} + +} + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +$ct_srs=1; +$b=0; +$srs_SQL =''; +if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } +echo "\n"; +echo "\n"; +while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } +if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } +else + {$srs_SQL='';} +$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; +$rslt=mysql_query($stmt, $link); +$sct_to_print = mysql_num_rows($rslt); +$sct_list=''; + +$o=0; +while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; +} +echo "\n"; +echo "\n"; + +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + +echo ""; + +echo "
Bearbeite eine Anrufzeit\n"; +echo "\n"; +echo "\n"; +echo "
Anrufzeit ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Anrufzeit Name: (Kurze Beschreibung der Anrufzeit)$NWB#vicidial_call_times-call_time_name$NWE
Anrufzeit Kommentare: $NWB#vicidial_call_times-call_time_comments$NWE
Standard Start Standard Stop $NWB#vicidial_call_times-ct_default_start$NWE
Sonntag Start Sonntag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Montag Start Montag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Dienstag Start Dienstag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Mittwoch Start Mittwoch Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Donnerstag Start Donnerstag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Freitag Start Freitag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Sonnabend Start Sonnabend Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Aktive landesspezifische Anrufzeit Definitionen für diese Aufnahme:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Add state call time rule:


\n"; +echo "Kampagnen, die diese Anrufzeit nutzen:
\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + $CT_camp_id = $row[1]; + $CT_camp_name = $row[2]; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

Lösche diese Anrufzeit Definition\n"; + } +} +else +{ +echo "Sie haben nicht die Rechte, um diese Seite anzusehen. Bitte zurück gehen."; +} + +} + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + +echo ""; + +echo "
Bearbeite eine landesspezifische Anrufzeit
\n"; +echo "\n"; +echo "\n"; +echo "
Anrufzeit ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
Landesspezifischer Anrufzeiten Name: (Kurze Beschreibung der Anrufzeit)$NWB#vicidial_call_times-call_time_name$NWE
Landesspezifischer Anrufzeiten Kommentar: $NWB#vicidial_call_times-call_time_comments$NWE
Standard Start Standard Stop $NWB#vicidial_call_times-ct_default_start$NWE
Sonntag Start Sonntag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Montag Start Montag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Dienstag Start Dienstag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Mittwoch Start Mittwoch Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Donnerstag Start Donnerstag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Freitag Start Freitag Stop $NWB#vicidial_call_times-ct_sunday_start$NWE
Sonnabend Start Sonnabend Stop $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; +echo "Anrufzeiten, die diese landesspezifische Anrufzeit benutzen:
\n"; +echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

Diese landesspezifische Anrufzeitdefinition löschen\n"; + } + +} +else +{ +echo "Sie haben nicht die Rechte, um diese Seite anzusehen. Bitte zurück gehen."; +} + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo "
\n"; +echo ""; + +echo "
SUCHE NACH Einem BENUTZER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
Benutzer-Zahl:
Voller Name:
Benutzer-Niveau:
Benutzer-Gruppe:
\n"; + +} + +###################### +# ADD=66 user search results +###################### + +if ($ADD==66) +{ +echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SUCHRESULTATE:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]ÄNDERN Sie | Notfall | STATUS | TIME
\n"; + +} + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and user='$user' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
USER CALLBACK HOLD LISTINGS: $user\n"; +$ADD='82'; +} + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and campaign_id='$campaign_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN CALLBACK HOLD LISTINGS: $campaign_id\n"; +$ADD='82'; +} + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and list_id='$list_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; +$ADD='82'; +} + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) +{ +echo "
\n"; +echo "
\n"; +echo "\n"; + + $o=0; + while ($cb_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
LEADLISTCAMPAIGNENTRYDATUMCALLBACKDATUMUSERRECIPIENTSTATUS
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
BENUTZER-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]ÄNDERN Sie | Notfall | STATUS | TIME
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
KAMPAGNE AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  ÄNDERN Sie
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
LISTE AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  ÄNDERN Sie
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
INBOUND GRUPPE AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  ÄNDERN Sie
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
REMOTEMITTEL-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]ÄNDERN Sie
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
BENUTZER-GRUPPEN AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]ÄNDERN Sie
\n"; +} + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
INDEX-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]ÄNDERN Sie
\n"; +} + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) +{ +echo "\n";echo "\n";?> +
+
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LEITUNG FILTER-AUFLISTUNGEN:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]ÄNDERN Sie
\n"; +} + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
Anrufzeiten Liste:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[4] ÄNDERN Sie
\n"; +} + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
Liste der landesspezifische Anrufzeiten:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3] $row[4] ÄNDERN Sie
\n"; +} + + + + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BAU: $build
\n"; + + +?> + + +
+ + + +1) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday lokale Zeit + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday lokale Zeit + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday lokale Zeit + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday lokale Zeit + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday lokale Zeit + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday lokale Zeit + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday lokale Zeit + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday lokale Zeit + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday lokale Zeit + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday lokale Zeit + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday lokale Zeit + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday lokale Zeit + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday lokale Zeit + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday lokale Zeit + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "Diese Kampagne hat$active_leads führt, in jenen Listen gewählt zu werden\n"; + } + else + { + echo "Keine aktiven Listen für diese Kampagne gewählt\n"; + } + } +else + { + echo "Keine aktiven Listen für diese Kampagne gewählt\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/admin_modify_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_de/admin_modify_lead.php new file mode 100644 index 00000000..d3fd2386 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/admin_modify_lead.php @@ -0,0 +1,476 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + +### AST GUI database administration modify lead in vicidial_list +### admin_modify_lead.php + +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead + +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Leitung notieren Änderung + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Informationen geändert

\n"; + echo "\n"; + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + +} +else +{ + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Anrufinformationen: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     Liste Identifikation: $list_id
Vorname:   \n"; + echo " Letzter Name:
  \n"; + echo "Postcode:
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + + + + + } + else + { + echo "Leitung Nachschlagen FIEL für lead_id aus $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + +echo "

\n"; + +echo "
\n"; + +echo "ANRUFE ZU DIESEM LEITUNG:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS TSR KAMPAGNE LIST LEAD
$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]
\n"; + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/admin_search_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_de/admin_search_lead.php new file mode 100644 index 00000000..26e58758 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/admin_search_lead.php @@ -0,0 +1,224 @@ + LICENSE: GPLv2 +### +### AST GUI database administration search for lead info +### admin_modify_lead.php +# +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Leitung Suche + +Leitung Nachschlagen + + + +
\n"; + echo "
\n"; + echo "\n"; + echo "Tragen Sie bitte a ein:
Vendor ID(Verkäuferleitung Code): or \n"; + echo "
eine Haupttelefonnummer: or\n"; + echo "
eine Leitung Identifikation:

\n"; + echo "
\n"; + echo "\n
\n"; + echo "\n"; + exit; + } + +else + { + + if ($vendor_id) + { + $stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000"; + } + else + { + if ($phone) + { + $stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000"; + } + else + { + if ($lead_id) + { + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query($stmt, $link); + $results_to_print = mysql_num_rows($rslt); + if ($results_to_print < 1) + { + echo date("l F j, Y G:i:s A"); + echo "\n

\n"; + echo "Die Suchvariablen, die Sie eintrugen, sind nicht im System aktiv

\n"; + echo "Bitte zurück und verdoppeln Überprüfung gehen die Informationen,die Sie eintrugen und reichen wieder ein\n"; + echo "
\n"; + echo "\n"; + exit; + } + else + { + echo "RESULTS: $results_to_print

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD IDSTATUSVENDOR IDLAST AGENTLISTE IDENTIFIKATIONPHONENAMECITYSECURITYLAST CALL
$o$row[0]$row[3]$row[5]$row[4]$row[7]$row[11]$row[13] $row[15]$row[19]$row[28]$row[2]
\n"; + } + } + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\nNEUE SUCHE"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds"; + + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/count.htm b/agc_2-X/trunk/LANG_admin/vicidial_de/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/count.htm @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/dbconnect.php b/agc_2-X/trunk/LANG_admin/vicidial_de/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/group_hourly_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_de/group_hourly_stats.php new file mode 100644 index 00000000..954f159c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/group_hourly_stats.php @@ -0,0 +1,252 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: Gruppe Stündlicher Notfall +\n"; +?> + + +
+ + + + + += '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "
  VICIDIAL ADMIN: Gruppe Stündlicher Notfall  
\n"; + +echo "
\n"; + +echo "TSR STUNDE ZÄHLIMPULSE: $group | $status | $date_with_hour | $date_no_hour\n"; + +echo "
\n"; +echo "\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "\n"; + + +} + +echo "
TSR ID   $status   GESAMTANRUFE   $status DAY    
$VDuser[$o] $VDname[$o] $VDcount[$o] $VDtotal[$o] $VDday[$o]ÄNDERN Sie | Notfall
TOTAL $status $hour_calls $total_calls $day_calls
\n"; +echo "

\n"; + + + echo "
Melden Sie bitte die Gruppe an, die Sie stündlichen Notfall fürerhalten möchten:
\n"; + echo "\n"; + echo "group:
\n"; + echo "status:   (example: XFER)
\n"; + echo "date with hour:   (example: 2004-06-25 14)
\n"; + echo "\n"; + echo "


\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/help.gif b/agc_2-X/trunk/LANG_admin/vicidial_de/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/vicidial_de/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/listloader.php b/agc_2-X/trunk/LANG_admin/vicidial_de/listloader.php new file mode 100644 index 00000000..877ab1a4 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/listloader.php @@ -0,0 +1,698 @@ + LICENSE: GPLv2 +# +# AST Web GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1006 - added listID override and gmt_offset lookup while loading +# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. +# + +$version = '1.1.12'; +$build = '60619-1652'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];} +$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB=1; +#$DBX=1; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('listloader.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HILFE\""; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +?> + + + + + + method=post enctype="multipart/form-data"> +
+ + + + + + + + + + + + + +
Last Leitungen von dieser Akte:
Liste Identifikation Override: (nur Zahlen or leave blank for values in the file)
KLICKEN SIE HIER, UM ZUR SUPERLEITUNG LADEVORRICHTUNG ZU GEHEN (BETA VERSION)     ZURÜCK ZU ADMIN
+ +document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + $pulldate=date("Y-m-d H:i:s"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("./vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Verarbeitung$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city = $row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) + { + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $gmt_offset = '0'; + $called_since_last_reset='N'; + + if (strlen($list_id_override)>0) + { + # print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
STÖRUNG: Die Akte hat nicht die erforderliche Zahl vonauffängt, um sie zu verarbeiten.
"; + } + print ""; +} else if (filesize($leadfile)>8388608) { + print "
STÖRUNG: Akte übersteigt die Begrenzung 8MB.
"; +} +?> + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/listloaderMAIN.php b/agc_2-X/trunk/LANG_admin/vicidial_de/listloaderMAIN.php new file mode 100644 index 00000000..dc41a8b0 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/listloaderMAIN.php @@ -0,0 +1,79 @@ + LICENSE: GPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + +VICIDIAL: Leitung Ladevorrichtung Modul + + + + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/new_listloader_superL.php b/agc_2-X/trunk/LANG_admin/vicidial_de/new_listloader_superL.php new file mode 100644 index 00000000..2eb6171b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/new_listloader_superL.php @@ -0,0 +1,1364 @@ + LICENSE: GPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '1.1.12-1'; +$build = '60619-1651'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HILFE\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +VICIDIAL ADMIN: Super Lead Loader + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + + + + + + + + + + + + + + + + + + + +
Last Leitungen von dieser Akte:
Liste Identifikation Override: (nur Zahlen or leave blank for values in the file)
Zu verwenden Dateiaufbau:Standard-VICIDIAL    Kundenspezifischer Plan
        
KLICKEN SIE HIER, UM ZUR BASIC LEITUNG LADEVORRICHTUNG ZU GEHEN         ZURÜCK ZU ADMIN
SUPERLISTE LADEVORRICHTUNG-     VERSION:     BAU:
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Verarbeitung$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + + if (strlen($list_id_override)>0) + { + # print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
STÖRUNG: Die Akte hat nicht die erforderliche Zahl vonauffängt, um sie zu verarbeiten.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + print "
VerarbeitungExcel file... \n"; + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + # print "$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field"; + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
VerarbeitungCSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile && filesize($LF_path)<=8388608) { + $total=0; $good=0; $bad=0; + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Verarbeitung$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
STÖRUNG: Die Akte hat nicht die erforderliche Zahl vonauffängt, um sie zu verarbeiten.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
VerarbeitungCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Verarbeitung$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
VerarbeitungCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LISTE IDENTIFIKATION OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + $total=0; $good=0; $bad=0; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL SpalteAkte Daten
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
        
\r\n"; + # } + print ""; + } +} else if (filesize($leadfile)>8388608) { + print "
STÖRUNG: Akte übersteigt die Begrenzung 8MB.
"; +} +?> + + + + + + + + + 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### MEXICO ### +if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### AUSTRALIA ### +if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### ALL OTHER COUNTRY CODES ### +if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # lokale Zeit calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/remote_dispo.php b/agc_2-X/trunk/LANG_admin/vicidial_de/remote_dispo.php new file mode 100644 index 00000000..01d5eb2d --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/remote_dispo.php @@ -0,0 +1,327 @@ + LICENSE: GPLv2 +### +# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call + +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL DIREKTÜBERTRAGUNG: Anruf-Einteilung +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Anruf ist dispositioned gewesen       $NOW_TIME\n

\n"; + + echo "
\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Anrufinformationen: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Kampagne Identifikation: $campaign_id
Fronter: $tsr     Liste Identifikation: $list_id
Vorname:   \n"; + echo " Letzter Name:
  \n"; + echo "Postcode:
\n"; + echo "


\n"; + + } + else + { + echo "Leitung Nachschlagen FIEL für lead_id aus $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/server_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_de/server_stats.php new file mode 100644 index 00000000..eede94e1 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/server_stats.php @@ -0,0 +1,96 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1037 - Added Link back to Admin section +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select * from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $i++; + } +?> + + + + + +VICIDIAL: Bediener-Notfall and Reports +VICIDIAL: Bediener-Notfall and Reports                           +ZURÜCK ZU ADMIN

+ + +

+
+ $o)
+	{
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	$o++;
+	}
+
+?>
+
SERVERBESCHREIBUNGIP ADDRESSAKTIVVDAD timeVDcall timePARK timeCLOSER/INBOUND time
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]LINKLINKLINKLINK
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/user_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_de/user_stats.php new file mode 100644 index 00000000..a32851eb --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/user_stats.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: User Stats +\n"; +?> + + +
+ + + + + +\n"; +echo "
  VICIDIAL ADMIN: User Stats for  
  \n"; + +echo "
\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + +echo "
\n"; + +echo "GESPRÄCH ZEIT UND STATUS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + +echo "\n"; +echo "
STATUSZÄHLIMPULSHOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
GESAMTANRUFE $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LOGIN/LOGOUT ZEIT:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours = ($event_seconds / 3600); + $event_hours = round($event_hours, 2); + $event_hours_int = intval("$event_hours"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours = ($total_login_time / 3600); +$total_login_hours = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
FALL DATUM KAMPAGNEHOURS:MINUTES
$row[0] $row[2] $row[3]
$row[0] $row[2] $row[3] $event_hours_int:$event_minutes_int
$row[0] $row[2] $row[3]
GESAMTMENGE $total_login_hours_int:$total_login_minutes_int
\n"; + + +echo "

\n"; + +echo "
\n"; + +echo "ANRUFE DES LETZT-50:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS PHONE KAMPAGNE LIST LEAD
$row[4] $row[7] $row[8] $row[10] $row[3] $row[2] $row[1]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/user_status.php b/agc_2-X/trunk/LANG_admin/vicidial_de/user_status.php new file mode 100644 index 00000000..b92d57bb --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/user_status.php @@ -0,0 +1,238 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $change_agent_campaign=$row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $i++; + } + + } + +$stmt="select * from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> + + +VICIDIAL ADMIN: User Status +\n"; +?> + + +
+
+ + + + +\n"; +echo "
  VICIDIAL ADMIN: User Status for  
  \n"; + +if ($stage == "live_campaign_change") +{ + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign
\n"; + + exit; +} + +if ($stage == "log_agent_out") +{ + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser
\n"; + + exit; +} + +if ($agents_to_print > 0) +{ + echo "
";
+	echo "Agent Logged in at server:  $Aserver_ip\n";
+	echo "               in session:  $Asession_id\n";
+	echo "               from phone:  $Aextension\n";
+	echo "Agent is in campaign:       $Acampaign\n";
+	echo "              status:       $Astatus\n";
+	echo " hungup last call at:       $Alast_call\n";
+	echo "       Closer groups:       $Acl_campaigns\n\n";
+
+	echo "
"; + + + if ($change_agent_campaign > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Current Kampagne: \n"; + echo "
\n"; + + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } +} + +else +{ + echo "Agent is not logged in\n
"; + +} + + +echo "           $user - $full_name - \n"; + +echo "VICIDIAL Time Sheet\n"; + +echo "
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + +echo "|$stage|$group|"; + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_de/vdremote.php b/agc_2-X/trunk/LANG_admin/vicidial_de/vdremote.php new file mode 100644 index 00000000..58bcd035 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_de/vdremote.php @@ -0,0 +1,602 @@ + LICENSE: GPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time + +$version = '1.1.12'; +$build = '60619-1603'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Sie haben jetzt heraus geloggt. Danke\n"; + exit; +} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Unzulässiges Username/Kennwort:|$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +VICIDIAL DIREKTÜBERTRAGUNG MITTEL: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Ändern Sie Remotemittel";} +if ($ADD==41111) {echo "Ändern Sie Remotemittel";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+
+ + + +
  VICIDIAL DIREKTÜBERTRAGUNG MITTEL:   Logout  
  ÄNDERN Sie | ">STATUS | ">INBOUND NOTFALL
+"; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
ÄNDERN Sie Eine REMOTEMITTEL-EINTRAGUNG: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Benutzernummer Anfang: $user_start
Zeilenzahl: (nur Zahlen)
Bediener IP: $row[3]
Externe Verlängerung: (number dialed to reach agents [i.e. 913125551212])
Status:
Kampagne: $campaign_id
Inbound Gruppen: \n"; +echo "$groups_list"; +echo "
\n"; +echo "ANMERKUNG: Sie kann bis 30 Sekunden für die Änderungen dauern, dieauf diesem Schirm eingereicht werden, um Phasen zu gehen\n"; + +} + + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
REMOTEMITTEL NICHT GEÄNDERT - gehen Sie bitte zurück und betrachtenSie die Daten, die Sie eingaben\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
REMOTEMITTEL GEÄNDERT\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTEMITTEL ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + + } + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
ÄNDERN Sie Eine REMOTEMITTEL-EINTRAGUNG: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Benutzernummer Anfang: $user_start
Zeilenzahl: (nur Zahlen)
Bediener IP: $row[3]
Externe Verlängerung: (number dialed to reach agents [i.e. 913125551212])
Status:
Kampagne: $campaign_id
Inbound Gruppen: \n"; +echo "$groups_list"; +echo "
\n"; +echo "ANMERKUNG: Sie kann bis 30 Sekunden für die Änderungen dauern, dieauf diesem Schirm eingereicht werden, um Phasen zu gehen\n"; + +} + + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) +{ + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTEMITTEL-STÖRUNG - gehen Sie bitte zurück und betrachten Sie dieDaten, die Sie eingaben\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]='- WARTEND -'; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i Mittel geloggt innen auf Bediener $server_ip\n\n"; + + echo " - 5 Minuten oder mehr beim Anruf\n"; + echo " - Über 10 Minuten beim Anruf\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************KEINE MITTEL BEI DEN ANRUFEN*********************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) +{ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTEMITTEL-STÖRUNG - gehen Sie bitte zurück und betrachten Sie dieDaten, die Sie eingaben\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "VICIDIAL: Inbound Notfall des Remotemittels $NOW_TIME\n\n"; + echo "\n"; + echo "Gesamtanrufe genommen$query_date: $in_calls\n"; + echo "Gesamtgespräch Zeit an$query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Anrufliste für$query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + # echo " $i Mittel geloggt innen auf Bediener $server_ip\n\n"; + + # echo " - 5 Minuten oder mehr beim Anruf\n"; + # echo " - Über 10 Minuten beim Anruf\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************KEIN ERSUCHT UM DIESEN TAG*******************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nIndexlaufzeit: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_CLOSERstats.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_CLOSERstats.php new file mode 100644 index 00000000..b8f2479e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_CLOSERstats.php @@ -0,0 +1,396 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Στατιστικά VDAD Closer\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ΤΡΟΠΟΠΟΙΗΣΗ | ΑΝΑΦΟΡΕΣ \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΜΙΑ ΕΚΣΤΡΑΤΕΙΑ ΚΑΙ ΜΙΑ ΗΜΕΡΟΜΗΝΙΑ ΑΝΩΤΕΡΩ, ΚΑΙ ΠΑΤΗΣΤΕ ΕΠΙΒΕΒΑΙΩΣΗ\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Στατιστικά αυτόματης κλήσης Closer                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Συνολικά κλήσεις που τοποθετήθηκαν από την Εκστρατεία: $TOTALcalls\n";
+echo "Μέσος όρος σε δευτερόλεπτα για όλες τις κλήσεις: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- ΕΓΚΑΤΑΛ\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Συνολικά ΕΓΚΑΤΑΛΕΙΜΕΝΕΣ κλήσεις: $DROPcalls  $DROPpercent%\n";
+echo "Μέσος όρος σε δευτερόλεπτα για ΕΓΚΑΤΑΕΙΜΕΝΕΣ κλήσεις: $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΗΣΤΗ\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| ΧΡΗΣΤΗΣ                  | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΟΝΟΥ\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "ΓΡΑΦΙΚΗ ΠΑΡΑΣΤΑΣΗ ΜΕ 15ΛΕΠΤΕΣ ΑΥΞΗΣΕΙΣ ΤΩΝ ΣΥΝΟΛΙΚΩΝ ΚΛΗΣΕΩΝ ΠΟΥ ΤΟΠΟΘΕΤΟΥΝΤΑΙ ΑΠΟ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_VDADstats.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_VDADstats.php new file mode 100644 index 00000000..c94aa544 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_VDADstats.php @@ -0,0 +1,417 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ΤΡΟΠΟΠΟΙΗΣΗ | ΑΝΑΦΟΡΕΣ \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΜΙΑ ΕΚΣΤΡΑΤΕΙΑ ΚΑΙ ΜΙΑ ΗΜΕΡΟΜΗΝΙΑ ΑΝΩΤΕΡΩ, ΚΑΙ ΠΑΤΗΣΤΕ ΕΠΙΒΕΒΑΙΩΣΗ\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Συνολικά κλήσεις που τοποθετήθηκαν από την Εκστρατεία: $TOTALcalls\n";
+echo "Μέσος όρος σε δευτερόλεπτα για όλες τις κλήσεις: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- ΕΓΚΑΤΑΛ\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Συνολικά ΕΓΚΑΤΑΛΕΙΜΕΝΕΣ κλήσεις: $DROPcalls  $DROPpercent%\n";
+echo "Μέσος όρος σε δευτερόλεπτα για ΕΓΚΑΤΑΕΙΜΕΝΕΣ κλήσεις: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- ΜΗ ΑΠΑΝΤΗΜΕΝΕΣ ΑΥΤΟΜΑΤΕΣ ΚΛΗΣΕΙΣ\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$NAcalls =	sprintf("%10s", $row[0]);
+$NApercent = (($NAcalls / $TOTALcalls) * 100);
+$NApercent = round($NApercent, 0);
+
+$average_na_seconds = ($row[1] / $row[0]);
+$average_na_seconds = round($average_na_seconds, 0);
+$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+
+echo "Συνολικά ΝΑ κλήσεις -Busy,Disconnect,BTvoicemail: $NAcalls  $NApercent%\n";
+echo "Μέσος όρος σε δευτερόλεπτα για ΝΑ κλήσεις: $average_na_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΗΣΤΗ\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| ΧΡΗΣΤΗΣ                  | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- ΣΤΑΤΙΣΤΙΚΑ ΧΡΟΝΟΥ\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "ΓΡΑΦΙΚΗ ΠΑΡΑΣΤΑΣΗ ΜΕ 15ΛΕΠΤΕΣ ΑΥΞΗΣΕΙΣ ΤΩΝ ΣΥΝΟΛΙΚΩΝ ΚΛΗΣΕΩΝ ΠΟΥ ΤΟΠΟΘΕΤΟΥΝΤΑΙ ΑΠΟ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..015b382b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,161 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Λίστα Hopper\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           ΤΡΟΠΟΠΟΙΗΣΗ \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "ΠΑΡΑΚΑΛΩ ΕΠΙΛΕΞΤΕ ΜΙΑ ΕΚΣΤΡΑΤΕΙΑ ΑΝΩΤΕΡΩ ΚΑΙ ΠΑΤΗΣΤΕ ΕΠΙΒΕΒΑΙΩΣΗ\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Ενεργή Λίστα στον Hopper                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+
+echo "Αριθμός οδηγών στον hopper τώρα::       $TOTALcalls\n";
+
+
+##############################
+#########  LEAD STATS
+
+echo "\n";
+echo "---------- LEADS IN HOPPER\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+echo "|      | LEAD_ID   | PHONE NUM  | STATE | STATUS | COUNT | GMT    |\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$FMT_i =		sprintf("%-4s", $i);
+	$lead_id =		sprintf("%-9s", $row[0]);
+	$phone_number =	sprintf("%-10s", $row[1]);
+	$state =		sprintf("%-5s", $row[2]);
+	$status =		sprintf("%-6s", $row[3]);
+	$count =		sprintf("%-5s", $row[4]);
+	$gmt =			sprintf("%-6s", $row[5]);
+
+	echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
+
+	$i++;
+	}
+
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_admin_log_display.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_admin_log_display.php new file mode 100644 index 00000000..aab85960 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_admin_log_display.php @@ -0,0 +1,118 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date); + +# AST GUI database administration +# AST_admin_log_display.php +# +# CHANGES +# 50325-0932 - First build +# 51123-1443 - removed globals=on requirement +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '0.0.4'; +$build = '60620-1044'; + +$STARTtime = date("U"); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "ΔΙΑΧΕΙΡΙΣΗ LOG DISPLAY"; +echo "\n"; + +# Fri, 25 Mar 2005 + +$DAY_DATE = date("j"); +if ($DAY_DATE < 10) +# {$GREP_DATE = date("D, j M Y");} + {$GREP_DATE = date("D, 0j M Y");} +else + {$GREP_DATE = date("D, j M Y");} + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!$query_date) {$query_date = $GREP_DATE;} + +$Gquery_date = eregi_replace(" ",'\ ',$query_date); +echo "\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+echo "ΔΙΑΧΕΙΡΙΣΗ CHANGE LOG                             $NOW_TIME\n";
+
+#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
+passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_performance.php new file mode 100644 index 00000000..5ddd508c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_performance.php @@ -0,0 +1,232 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Agent Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ΤΡΟΠΟΠΟΙΗΣΗ | ΑΝΑΦΟΡΕΣ \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A ΔΙΑΚΟΜΙΣΤΗΣ AND DATE-TIME ABOVE AND CLICK ΕΠΙΒΕΒΑΙΩΣΗ\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_performance_detail.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_performance_detail.php
new file mode 100644
index 00000000..b342c85f
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_performance_detail.php
@@ -0,0 +1,406 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]))				{$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
+	elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"]))		{$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           ΤΡΟΠΟΠΟΙΗΣΗ | ΑΝΑΦΟΡΕΣ \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK ΕΠΙΒΕΒΑΙΩΣΗ\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 03:45:00";   
+	$query_date_END = "$query_date 15:15:00";
+	$time_BEGIN = "03:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:15:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance Detail                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TIME   | PAUSE  | PAUSAVG| WAIT   | WAITAVG| TALK   | TALKAVG| DISPO  | DISPAVG| A    | B    | DC   | DNC  | N    | NI   | CB   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$TOTtotWAIT=($TOTtotWAIT + $row[7]);
+	$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
+	$TOTtotDISPO=($TOTtotDISPO + $row[9]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtime =	($row[1] + $row[5] + $row[7] + $row[9]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+	$USERtotPAUSE =	$row[5];
+	$USERavgPAUSE =	$row[6];
+	$USERtotWAIT =	$row[7];
+	$USERavgWAIT =	$row[8];
+	$USERtotDISPO =	$row[9];
+	$USERavgDISPO =	$row[10];
+
+	$USERtime_M = ($USERtime / 60);
+	$USERtime_M = round($USERtime_M, 2);
+	$USERtime_M_int = intval("$USERtime_M");
+	$USERtime_S = ($USERtime_M - $USERtime_M_int);
+	$USERtime_S = ($USERtime_S * 60);
+	$USERtime_S = round($USERtime_S, 0);
+	if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
+	$USERtime_MS = "$USERtime_M_int:$USERtime_S";
+	$pfUSERtime_MS[$i] =		sprintf("%7s", $USERtime_MS);
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+
+	$USERtotPAUSE_M = ($USERtotPAUSE / 60);
+	$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
+	$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
+	$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
+	$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
+	$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
+	if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
+	$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
+	$pfUSERtotPAUSE_MS[$i] =		sprintf("%6s", $USERtotPAUSE_MS);
+
+	$USERavgPAUSE_M = ($USERavgPAUSE / 60);
+	$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
+	$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
+	$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
+	$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
+	$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
+	if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
+	$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
+	$pfUSERavgPAUSE_MS[$i] =		sprintf("%6s", $USERavgPAUSE_MS);
+
+	$USERtotWAIT_M = ($USERtotWAIT / 60);
+	$USERtotWAIT_M = round($USERtotWAIT_M, 2);
+	$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
+	$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
+	$USERtotWAIT_S = ($USERtotWAIT_S * 60);
+	$USERtotWAIT_S = round($USERtotWAIT_S, 0);
+	if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
+	$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
+	$pfUSERtotWAIT_MS[$i] =		sprintf("%6s", $USERtotWAIT_MS);
+
+	$USERavgWAIT_M = ($USERavgWAIT / 60);
+	$USERavgWAIT_M = round($USERavgWAIT_M, 2);
+	$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
+	$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
+	$USERavgWAIT_S = ($USERavgWAIT_S * 60);
+	$USERavgWAIT_S = round($USERavgWAIT_S, 0);
+	if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
+	$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
+	$pfUSERavgWAIT_MS[$i] =		sprintf("%6s", $USERavgWAIT_MS);
+	
+	$USERtotDISPO_M = ($USERtotDISPO / 60);
+	$USERtotDISPO_M = round($USERtotDISPO_M, 2);
+	$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
+	$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
+	$USERtotDISPO_S = ($USERtotDISPO_S * 60);
+	$USERtotDISPO_S = round($USERtotDISPO_S, 0);
+	if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
+	$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
+	$pfUSERtotDISPO_MS[$i] =		sprintf("%6s", $USERtotDISPO_MS);
+
+	$USERavgDISPO_M = ($USERavgDISPO / 60);
+	$USERavgDISPO_M = round($USERavgDISPO_M, 2);
+	$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
+	$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
+	$USERavgDISPO_S = ($USERavgDISPO_S * 60);
+	$USERavgDISPO_S = round($USERavgDISPO_S, 0);
+	if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
+	$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
+	$pfUSERavgDISPO_MS[$i] =		sprintf("%6s", $USERavgDISPO_MS);
+
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; $ctCB[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]);	$TOT_CB = ($TOT_CB + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtime_M = ($TOTtime / 60);
+	$TOTtime_M = round($TOTtime_M, 2);
+	$TOTtime_M_int = intval("$TOTtime_M");
+	$TOTtime_S = ($TOTtime_M - $TOTtime_M_int);
+	$TOTtime_S = ($TOTtime_S * 60);
+	$TOTtime_S = round($TOTtime_S, 0);
+	if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
+	$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
+	$TOTtime_MS =		sprintf("%7s", $TOTtime_MS);
+		while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOTtotDISPO_M = ($TOTtotDISPO / 60);
+	$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
+	$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
+	$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
+	$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
+	$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
+	if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
+	$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
+	$TOTtotDISPO_MS =		sprintf("%7s", $TOTtotDISPO_MS);
+		while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+
+	$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
+	$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
+	$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
+	$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
+	if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
+	$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
+	$TOTtotPAUSE_MS =		sprintf("%7s", $TOTtotPAUSE_MS);
+		while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+
+	$TOTtotWAIT_M = ($TOTtotWAIT / 60);
+	$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
+	$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
+	$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
+	$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
+	$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
+	if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
+	$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
+	$TOTtotWAIT_MS =		sprintf("%7s", $TOTtotWAIT_MS);
+		while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+
+
+	$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
+	$TOTavgTALK_M = round($TOTavgTALK_M, 2);
+	$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
+	$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
+	$TOTavgTALK_S = ($TOTavgTALK_S * 60);
+	$TOTavgTALK_S = round($TOTavgTALK_S, 0);
+	if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
+	$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
+	$TOTavgTALK_MS =		sprintf("%6s", $TOTavgTALK_MS);
+		while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+
+	$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
+	$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
+	$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
+	$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
+	$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
+	$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
+	if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
+	$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
+	$TOTavgDISPO_MS =		sprintf("%6s", $TOTavgDISPO_MS);
+		while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+
+	$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
+	$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
+	$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
+	$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
+	if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
+	$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
+	$TOTavgPAUSE_MS =		sprintf("%6s", $TOTavgPAUSE_MS);
+		while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+
+	$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
+	$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
+	$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
+	$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
+	$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
+	$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
+	if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
+	$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
+	$TOTavgWAIT_MS =		sprintf("%6s", $TOTavgWAIT_MS);
+		while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+
+	
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_CB = sprintf("%-5s", $TOT_CB);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
+echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_time_sheet.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_time_sheet.php
new file mode 100644
index 00000000..75c707af
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_agent_time_sheet.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]))				{$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
+	elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"]))		{$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN ΧΕΙΡΙΣΤΗΣID AND DATE-TIME ABOVE AND CLICK ΕΠΙΒΕΒΑΙΩΣΗ\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- ΧΕΙΡΙΣΤΗΣTIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "ΣΥΝΟΛΙΚΕΣ ΚΛΗΣΕΙΣTAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE ΧΕΙΡΙΣΤΗΣTIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_server_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_server_performance.php
new file mode 100644
index 00000000..0a266f00
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_server_performance.php
@@ -0,0 +1,310 @@
+    LICENSE: GPLv2
+#
+# CHANGES
+#
+# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))	{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))	{$submit=$_POST["submit"];}
+if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]))				{$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];}
+	elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"]))	{$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+# path from root to where ploticus files will be stored
+$DOCroot = "$WeBServeRRooT/vicidial/ploticus/";
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+if (!isset($group)) {$group = '';}
+
+$stmt="select server_ip from servers;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$servers_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $servers_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Server Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "             ΑΝΑΦΟΡΕΣ \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A ΔΙΑΚΟΜΙΣΤΗΣ AND DATE-TIME ABOVE AND CLICK ΕΠΙΒΕΒΑΙΩΣΗ\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:32:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:32:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Server Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$HIGHload =	sprintf("%10s", $row[0]);
+$HIGHmulti = intval($HIGHload / 100);
+#$HIGHmulti = ($HIGHload / 100);
+
+$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$USEDram =	sprintf("%10s", $row[0]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average channels in use for server:       $AVGchannels\n";
+echo "Average load for server:                  $AVGload\n";
+echo "Peak load for server:                     $HIGHload\n";
+#echo "Peak used memory for server (in MB):      $USEDram\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 14 7\n";
+$HTMcontent .= "xscaletype: time hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHload\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc 30 minutes\n";
+$HTMcontent .= "minorticinc: 5 minutes\n";
+$HTMcontent .= "stubformat: hh:mm:ssa\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-2 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDAD.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDAD.php new file mode 100644 index 00000000..6414148b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDAD.php @@ -0,0 +1,255 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Χρόνος Χειριστών σε κλήσεις        $NOW_TIME    ΑΝΑΦΟΡΕΣ\n\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL    | STATUS | START TIME          | MINUTES |\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	$agentcount=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- ΑΝΑΜΟΝΗ -';
+			$row[6]=$row[7];
+			}
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$sessionid =		sprintf("%-9s", $row[2]);
+		$channel =			sprintf("%-10s", $row[3]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[4]);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 5) {$G=''; $EG='';}
+		if ($call_time_M_int >= 10) {$G=''; $EG='';}
+		if (eregi("PAUSED",$row[4])) 
+			{
+			if ($call_time_M_int >= 1) 
+				{$i++; continue;} 
+			else
+				{$G=''; $EG='';}
+			}
+
+		$agentcount++;
+		echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+		echo "  $agentcount Χειριστές συνδεμένοι στον διακομιστή $server_ip\n\n";
+
+		echo "             - Χειριστές σε παύση\n";
+		echo "             - 5 λεπτά ή παραπάνω σε κλήση\n";
+		echo "             - Πάνω από 10 λεπτά σε κλήση\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* ΚΑΝΕΝΑΣ ΧΕΙΡΙΣΤΗΣ ΣΕ ΚΛΗΣΕΙΣ*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+echo "| CHANNEL    | STATUS | CAMPAIGN | PHONE NUMBER       | START TIME          | MINUTES |\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-8s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+		echo "  $i κλήσεις που τοποθετήθηκαν στον διακομιστή $server_ip\n\n";
+
+		echo "             - ΑΝΑΜΟΝΗ ΕΝΕΡΓΗΣ ΚΛΗΣΗΣ\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************ΔΕΝ ΥΠΑΡΧΟΥΝ ΕΝΕΡΓΕΣ ΚΛΗΣΕΙΣ ΣΕ ΑΝΑΜΟΝΗ*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDAD_closer.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDAD_closer.php new file mode 100644 index 00000000..07234545 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDAD_closer.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Χρόνος Χειριστών σε κλήσεις        $NOW_TIME    ΑΝΑΦΟΡΕΣ\n\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPAIGN     | FRONT  |\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED|CLOSER",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WAIT -';
+			$row[6]=$row[7];
+			}
+		$extension[$i] =		sprintf("%-10s", $row[0]);
+		$user[$i] =				sprintf("%-6s", $row[1]);
+		$sessionid[$i] =		sprintf("%-9s", $row[2]);
+		$channel[$i] =			sprintf("%-19s", $row[3]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $row[4]);
+		$start_time[$i] =		sprintf("%-8s", $row[5]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$row[8];
+		$lead_id[$i] =			$row[9];
+		$closer[$i] =			$row[1];
+		$call_time_S[$i] = ($STARTtime - $row[6]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+		$i++;
+		}
+		$ext_count = $i;
+		$i=0;
+	while ($i < $ext_count)
+		{
+
+		$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$camp_to_print = mysql_num_rows($rslt);
+		if ($camp_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$campaign = sprintf("%-12s", $row[0]);
+			$camp_color = $row[0];
+			}
+		else
+			{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+		if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+			{$campaign = '            ';   	$camp_color = '';}
+
+		$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$xfer_to_print = mysql_num_rows($rslt);
+		if ($xfer_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$fronter = sprintf("%-6s", $row[0]);
+			}
+		else
+			{$fronter = '      ';}
+
+		$G = '';		$EG = '';
+		$G=""; $EG='';
+	#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+	#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+		echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i Χειριστές συνδεμένοι στον διακομιστή $server_ip\n\n";
+
+	#	echo "             - 5 λεπτά ή παραπάνω σε κλήση\n";
+	#	echo "             - Πάνω από 10 λεπτά σε κλήση\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* ΚΑΝΕΝΑΣ ΧΕΙΡΙΣΤΗΣ ΣΕ ΚΛΗΣΕΙΣ*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPAIGN     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i κλήσεις που τοποθετήθηκαν στον διακομιστή $server_ip\n\n";
+
+		echo "             - ΑΝΑΜΟΝΗ ΕΝΕΡΓΗΣ ΚΛΗΣΗΣ\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************ΔΕΝ ΥΠΑΡΧΟΥΝ ΕΝΕΡΓΕΣ ΚΛΗΣΕΙΣ ΣΕ ΑΝΑΜΟΝΗ*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDADall.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDADall.php new file mode 100644 index 00000000..ac70cbdc --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDADall.php @@ -0,0 +1,349 @@ + LICENSE: GPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +if (!isset($group)) {$group='';} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Εκστρατεία: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Εκστρατεία: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         ΤΡΟΠΟΠΟΙΗΣΗ | ΑΝΑΦΟΡΕΣ \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo "ΔΕΝ ΥΠΑΡΧΟΥΝ ΕΝΕΡΓΕΣ ΚΛΗΣΕΙΣ ΣΕ ΑΝΑΜΟΝΗ\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Εκστρατεία: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | ΔΙΑΚΟΜΙΣΤΗΣ IP | CALL ΔΙΑΚΟΜΙΣΤΗΣ IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n\n"; + + $Aecho .= " - Χειριστές σε παύση\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " ΚΑΝΕΝΑΣ ΧΕΙΡΙΣΤΗΣ ΣΕ ΚΛΗΣΕΙΣ\n";
+	}
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDADall_SIPmonitor.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDADall_SIPmonitor.php new file mode 100644 index 00000000..7bcf0cde --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonVDADall_SIPmonitor.php @@ -0,0 +1,282 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala +# +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];} +$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];} +$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];} +$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];} +$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];} +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$ΥΠΟΒΑΛΛΩ=$_GET["ΥΠΟΒΑΛΛΩ"]; if (!$ΥΠΟΒΑΛΛΩ) {$ΥΠΟΒΑΛΛΩ=$_POST["ΥΠΟΒΑΛΛΩ"];} + + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!$RR) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VF DIALER: Time On VDAD Εκστρατείας: $group\n"; +echo "
\n"; +echo "VF DIALER: Realtime Εκστρατείας: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "                   \n"; +echo "STOP | GO \n"; +echo "\n\n"; + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='$group';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); + +echo "
"; +echo "DIAL LEVEL: $row[0]         "; +echo "STATUSES: $row[1], $row[2], $row[3], $row[4], $row[5]         "; +echo "ORDER: $row[6]"; +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='$group' or campaign_id LIKE \"CL_%\");";} +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='$group';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo "ΔΕΝ ΥΠΑΡΧΟΥΝ ΕΝΕΡΓΕΣ ΚΛΗΣΕΙΣ ΣΕ ΑΝΑΜΟΝΗ\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VF DIALER: Agents Time On Calls Εκστρατείας: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | ΚΕΝΤΡΙΚΟΣΥΠΟΛΟΓΙΣΤΉΣ IP | CALL ΚΕΝΤΡΙΚΟΣΥΠΟΛΟΓΙΣΤΉΣ IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='$group' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + $sessionid = trim($sessionid); + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n"; + + + $Aecho .= " - Χρήστες σε παύση\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " ΚΑΝΕΝΑΣ ΧΡΗΣΤΗΣ ΣΕ ΚΛΗΣΕΙΣ\n";
+	}
+
+?>
+
+ + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeoncall.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeoncall.php new file mode 100644 index 00000000..7c648199 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeoncall.php @@ -0,0 +1,180 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΥΠΟΒΑΛΛΩ"])) {$ΥΠΟΒΑΛΛΩ=$_GET["ΥΠΟΒΑΛΛΩ"];} + elseif (isset($_POST["ΥΠΟΒΑΛΛΩ"])) {$ΥΠΟΒΑΛΛΩ=$_POST["ΥΠΟΒΑΛΛΩ"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Call\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Call                                          $NOW_TIME\n\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+echo "| STATION    | SESSIONID | CHANNEL   | NUMBER DIALED    | START TIME          | MINUTES |\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+
+$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="select extension from live_channels where server_ip='$server_ip';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$ext_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_zap_counter=0;
+	$sessions = '';
+	while ($i < $ext_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if (preg_match("/^8600/i",$row[0]))
+			{
+			$sessions .= "$row[0]|";
+			}
+		$i++;
+		}
+	$sessions = preg_replace("/\|$/",'',$sessions);
+
+	if ($DB) {echo "SESSIONS: -$sessions-\n";}
+
+	$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_calls_counter=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
+			{
+			if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
+			$session_id = '';
+			}
+		else 
+			{
+			if (preg_match("/$row[3]/i",$sessions))
+				{
+				if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
+				$session_id = $row[3];
+				$station = preg_replace("/SIP\//",'',$row[0]);
+				$station = preg_replace("/-.*/",'',$station);
+			
+				$LIVE_sessions[$live_calls_counter] =			"$session_id";
+				$LIVE_sessions_FORMAT[$live_calls_counter] =	sprintf("%-9s", $session_id);
+				$LIVE_stations[$live_calls_counter] =			"$station";
+				$LIVE_stations_FORMAT[$live_calls_counter] =	sprintf("%-10s", $station);
+
+		#		echo "| $station | $session_id | \n";
+
+				$live_calls_counter++;
+				}
+			else
+				{
+				if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
+				$session_id = '';
+				}
+			}
+
+		$i++;
+		}
+
+		if ($live_calls_counter > 0)
+		{
+		$i=0;
+		$LC_counter = $live_calls_counter;
+
+		while ($i < $live_calls_counter)
+			{
+			$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$parked_to_print = mysql_num_rows($rslt);
+			$row=mysql_fetch_row($rslt);
+
+			$channel =			sprintf("%-9s", $row[0]);
+			$number_dialed =	sprintf("%-16s", $row[2]);
+			$start_time =		sprintf("%-19s", $row[3]);
+			$call_time_S = ($STARTtime - $row[4]);
+
+			$call_time_M = ($call_time_S / 60);
+			$call_time_M = round($call_time_M, 2);
+			$call_time_M_int = intval("$call_time_M");
+			$call_time_SEC = ($call_time_M - $call_time_M_int);
+			$call_time_SEC = ($call_time_SEC * 60);
+			$call_time_SEC = round($call_time_SEC, 0);
+			if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+			$call_time_MS = "$call_time_M_int:$call_time_SEC";
+			$call_time_MS =		sprintf("%7s", $call_time_MS);
+			$G = '';		$EG = '';
+			if ($call_time_M_int >= 12) {$G=''; $EG='';}
+			if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+			echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+			$i++;
+			}
+
+		echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+		echo "  $i stations on live calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on live call\n";
+		echo "             - Over 30 minutes on live call\n";
+
+		}
+		else
+		{
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*************************************** NO LIVE STATIONS ********************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		}
+
+	}
+	else
+	{
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*************************************** NO LIVE STATIONS ********************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	}
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonpark.php b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonpark.php new file mode 100644 index 00000000..8aabf8a5 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/AST_timeonpark.php @@ -0,0 +1,197 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΥΠΟΒΑΛΛΩ"])) {$ΥΠΟΒΑΛΛΩ=$_GET["ΥΠΟΒΑΛΛΩ"];} + elseif (isset($_POST["ΥΠΟΒΑΛΛΩ"])) {$ΥΠΟΒΑΛΛΩ=$_POST["ΥΠΟΒΑΛΛΩ"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park                       $NOW_TIME\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "********************ΔΕΝ ΥΠΑΡΧΟΥΝ ΕΝΕΡΓΕΣ ΚΛΗΣΕΙΣ ΣΕ ΑΝΑΜΟΝΗ*********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* ΚΑΝΕΝΑΣ ΧΡΗΣΤΗΣ ΣΕ ΚΛΗΣΕΙΣ*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/admin.php b/agc_2-X/trunk/LANG_admin/vicidial_el/admin.php new file mode 100644 index 00000000..1419fe6e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/admin.php @@ -0,0 +1,6514 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["safe_harbor_message"])) {$safe_harbor_message=$_GET["safe_harbor_message"];} + elseif (isset($_POST["safe_harbor_message"])) {$safe_harbor_message=$_POST["safe_harbor_message"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_message"])) {$drop_message=$_GET["drop_message"];} + elseif (isset($_POST["drop_message"])) {$drop_message=$_POST["drop_message"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS ONLY ### +$user_level = ereg_replace("[^0-9]","",$user_level); +$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); +$xferconf_a_number = ereg_replace("[^0-9]","",$xferconf_a_number); +$xferconf_b_number = ereg_replace("[^0-9]","",$xferconf_b_number); +$drop_call_seconds = ereg_replace("[^0-9]","",$drop_call_seconds); +$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); +$safe_harbor_exten = ereg_replace("[^0-9]","",$safe_harbor_exten); +$am_message_exten = ereg_replace("[^0-9]","",$am_message_exten); +$campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); +$campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); +$drop_exten = ereg_replace("[^0-9]","",$drop_exten); +$dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); +$park_ext = ereg_replace("[^0-9]","",$park_ext); +$hopper_level = ereg_replace("[^0-9]","",$hopper_level); +$agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); +$hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); +$agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); +$agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); +$vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); +$vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); +$closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); +$alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); +$delete_users = ereg_replace("[^0-9]","",$delete_users); +$delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); +$delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); +$delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); +$delete_lists = ereg_replace("[^0-9]","",$delete_lists); +$delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); +$delete_filters = ereg_replace("[^0-9]","",$delete_filters); +$delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); +$delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); +$load_leads = ereg_replace("[^0-9]","",$delete_call_times); +$campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); +$ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); +$ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); +$modify_leads = ereg_replace("[^0-9]","",$modify_leads); +$change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); +$modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); +$ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); +$ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); +$ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); +$ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); +$ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); +$ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); +$ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); +$ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); +$ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); +$ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); +$ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); +$ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); +$ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); +$ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); +$ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); +$ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); +$number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); +$user_start = ereg_replace("[^0-9]","",$user_start); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +$remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); +$attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); +$hotkey = ereg_replace("[^0-9]","",$hotkey); +$list_id = ereg_replace("[^0-9]","",$list_id); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); +$allow_closers = ereg_replace("[^NY]","",$allow_closers); +$reset_hopper = ereg_replace("[^NY]","",$reset_hopper); +$amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); +$alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); +$safe_harbor_message = ereg_replace("[^NY]","",$safe_harbor_message); +$selectable = ereg_replace("[^NY]","",$selectable); +$reset_list = ereg_replace("[^NY]","",$reset_list); +$fronter_display = ereg_replace("[^NY]","",$fronter_display); +$drop_message = ereg_replace("[^NY]","",$drop_message); +$use_internal_dnc = ereg_replace("[^NY]","",$use_internal_dnc); + +### ALPHA-NUMERIC ONLY ### +$user = ereg_replace("[^0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^0-9a-zA-Z]","",$pass); +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); +$submit = ereg_replace("[^0-9a-zA-Z]","",$submit); +$CoNfIrM = ereg_replace("[^0-9a-zA-Z]","",$CoNfIrM); +$campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); +$get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); +$campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); +$ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); +$dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); +$state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); +$scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + +### DIGITS and Dots +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + +### DIGITS and spaces and hash and star and comma +$xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_a_dtmf); +$xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_b_dtmf); + +### ALPHA-NUMERIC and underscore and dash +$dial_status_e = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_e); +$dial_status_d = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_d); +$dial_status_c = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_c); +$dial_status_b = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_b); +$dial_status_a = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_a); +$stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); +$lead_filter_id = ereg_replace("[^-\_0-9a-zA-Z]","",$lead_filter_id); +$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); +$old_campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_campaign_id); +$park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); +$next_agent_call = ereg_replace("[^-\_0-9a-zA-Z]","",$next_agent_call); +$local_call_time = ereg_replace("[^-\_0-9a-zA-Z]","",$local_call_time); +$call_time_id = ereg_replace("[^-\_0-9a-zA-Z]","",$call_time_id); +$phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); +$phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); +$group_id = ereg_replace("[^-\_0-9a-zA-Z]","",$group_id); +$user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$user_group); +$OLDuser_group = ereg_replace("[^-\_0-9a-zA-Z]","",$OLDuser_group); +$state_rule = ereg_replace("[^-\_0-9a-zA-Z]","",$state_rule); + +### ALPHA-NUMERIC and spaces +$lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); +### ALPHA-NUMERIC and hash +$group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); +$campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); +$HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); +$status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); +$script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); +$script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); +$list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); +$lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); +$lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); +$campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); +$call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); +$call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + +### remove semi-colons ### +$lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + +### VARIABLES TO BE mysql_real_escape_string ### +# $web_form_address +# $script_text + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# AST GUI database administration +# admin.php +# +# CHANGES +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug +# + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$version = '1.1.12-3'; +$build = '60623-1159'; + +$STARTtime = date("U"); + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Έχετε αποσυνδεθεί. Σας ευχαριστούμε\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGuser_level =$row[4]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "ΔΙΑΧΕΙΡΙΣΗ: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD==1) {$hh='users'; echo "Πρόσθεσε Νέο Χρήστη";} +if ($ADD==11) {$hh='campaigns'; echo "Πρόσθεσε Νέα Εκστρατεία";} +if ($ADD==111) {$hh='lists'; echo "Πρόσθεσε Νέα Λίστα";} +if ($ADD==121) {$hh='lists'; echo "Προσθέστε νέο DNC";} +if ($ADD==1111) {$hh='ingroups'; echo "Πρόσθεσε Νέα Εισ-Ομάδα";} +if ($ADD==11111) {$hh='remoteagent'; echo "Πρόσθεσε Νέους Απομακρυσμένους Χειριστές";} +if ($ADD==111111) {$hh='usergroups'; echo "Πρόσθεσε Νέα Ομάδα Χρηστών";} +if ($ADD==1111111) {$hh='scripts'; echo "Πρόσθεσε Νέο Βοηθό";} +if ($ADD==11111111) {$hh='filters'; echo "Πρόσθεσε Φίλτρο";} +if ($ADD==111111111) {$hh='times'; echo "Πρόσθεσε Νέο Χρόνο Κλήσης";} +if ($ADD==1111111111) {$hh='times'; echo "Πρόσθεσε Νέο Χρόνο Κλήσης Κατάστασης";} +if ($ADD==2) {$hh='users'; echo "Προσθήκη Νέου Χρήστη";} +if ($ADD==21) {$hh='campaigns'; echo "Προσθήκη Νέας Εκστρατείας";} +if ($ADD==22) {$hh='campaigns'; echo "Προσθήκη Νέας Κατάστασης Εκστρατείας";} +if ($ADD==23) {$hh='campaigns'; echo "Προσθήκη Νέου Κλειδιού Εκστρατείας";} +if ($ADD==25) {$hh='campaigns'; echo "Νέα ανακύκλωσης προσθήκη μολύβδου εκστρατείας";} +if ($ADD==211) {$hh='lists'; echo "Προσθήκη Νέας Λίστας";} +if ($ADD==2111) {$hh='ingroups'; echo "Προσθήκη Νέας Εισ-Ομάδας";} +if ($ADD==21111) {$hh='remoteagent'; echo "Προσθήκη Νέων Απομακρυσμένων Χειριστών";} +if ($ADD==211111) {$hh='usergroups'; echo "Προσθήκη Νέας Ομάδας Χρηστών";} +if ($ADD==2111111) {$hh='scripts'; echo "Νέα προσθήκη Βοηθού";} +if ($ADD==21111111) {$hh='filters'; echo "Προσθήκη Νέου Φίλτρου";} +if ($ADD==211111111) {$hh='times'; echo "Προσθήκη Νέου Χρόνου Κλήσης";} +if ($ADD==2111111111) {$hh='times'; echo "Προσθήκη Νέου Χρόνου Κλήσης Κατάστασης";} +if ($ADD==3) {$hh='users'; echo "Τροποποίηση Χρήστη";} +if ($ADD==31) {$hh='campaigns'; echo "Τροποποίηση Εκστρατείας";} +if ($ADD==34) {$hh='campaigns'; echo "Τροποποίηση Εκστρατείας - Βασική Επισκόπηση";} +if ($ADD==311) {$hh='lists'; echo "Τροποποίηση Λίστας";} +if ($ADD==3111) {$hh='ingroups'; echo "Τροποποίηση Εισ-Ομάδων";} +if ($ADD==31111) {$hh='remoteagent'; echo "Τροποποίηση Απομακρυσμένων Χειριστών";} +if ($ADD==311111) {$hh='usergroups'; echo "Τροποποίηση Ομάδων Χρηστών";} +if ($ADD==3111111) {$hh='scripts'; echo "Τροποποιήστε τον Βοηθό";} +if ($ADD==31111111) {$hh='filters'; echo "Τροποποίηση Φίλτρου";} +if ($ADD==311111111) {$hh='times'; echo "Τροποποίηση Χρόνου Κλήσης";} +if ($ADD==321111111) {$hh='times'; echo "Τροποποίηση Λίστας Ορισμών Χρόνου Κλήσης Κατάστασης ";} +if ($ADD==3111111111) {$hh='times'; echo "Τροποπίηση Χρόνου Κλήσης Κατάστασης";} +if ($ADD=="4A") {$hh='users'; echo "Τροποποίηση Χρήστη - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Τροποποίηση Χρήστη - Admin";} +if ($ADD==4) {$hh='users'; echo "Τροποποίηση Χρήστη";} +if ($ADD==41) {$hh='campaigns'; echo "Τροποποίηση Εκστρατείας";} +if ($ADD==42) {$hh='campaigns'; echo "Τροποποίηση Εκστρατείας Status";} +if ($ADD==43) {$hh='campaigns'; echo "Τροποποίηση Εκστρατείας HotKey";} +if ($ADD==44) {$hh='campaigns'; echo "Τροποποίηση Εκστρατείας - Βασική Επισκόπηση";} +if ($ADD==45) {$hh='campaigns'; echo "Τροποποιήστε το μόλυβδο εκστρατείας ανακύκλωσης";} +if ($ADD==411) {$hh='lists'; echo "Τροποποίηση Λίστας";} +if ($ADD==4111) {$hh='ingroups'; echo "Τροποποίηση Εισ-Ομάδων";} +if ($ADD==41111) {$hh='remoteagent'; echo "Τροποποίηση Απομακρυσμένων Χειριστών";} +if ($ADD==411111) {$hh='usergroups'; echo "Τροποποίηση Ομάδων Χρηστών";} +if ($ADD==4111111) {$hh='scripts'; echo "Τροποποιήστε τον Βοηθό";} +if ($ADD==41111111) {$hh='filters'; echo "Τροποποίηση Φίλτρου";} +if ($ADD==411111111) {$hh='times'; echo "Τροποποίηση Χρόνου Κλήσης";} +if ($ADD==4111111111) {$hh='times'; echo "Τροποπίηση Χρόνου Κλήσης Κατάστασης";} +if ($ADD==5) {$hh='users'; echo "Delete User";} +if ($ADD==51) {$hh='campaigns'; echo "Delete Εκστρατεία";} +if ($ADD==52) {$hh='campaigns'; echo "Αποσυνδεμένοι Χειριστές";} +if ($ADD==511) {$hh='lists'; echo "Delete List";} +if ($ADD==5111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==51111) {$hh='remoteagent'; echo "Διάγραψε τους Απομακρυσμένους Χειριστές";} +if ($ADD==511111) {$hh='usergroups'; echo "Διάγραψε τους χρήστες Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Διάγραψε τον Βοηθό";} +if ($ADD==51111111) {$hh='filters'; echo "Διαγραφή Φίλτρου";} +if ($ADD==511111111) {$hh='times'; echo "Διαγραφή Χρόνου Κλήσης";} +if ($ADD==5111111111) {$hh='times'; echo "Διαγραφή Χρόνου Κλήσης Κατάστασης";} +if ($ADD==6) {$hh='users'; echo "Delete User";} +if ($ADD==61) {$hh='campaigns'; echo "Delete Εκστρατεία";} +if ($ADD==62) {$hh='campaigns'; echo "Αποσυνδεμένοι Χειριστές";} +if ($ADD==65) {$hh='campaigns'; echo "Διαγράψτε το μόλυβδο ανακύκλωσης";} +if ($ADD==611) {$hh='lists'; echo "Delete List";} +if ($ADD==6111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==61111) {$hh='remoteagent'; echo "Διάγραψε τους Απομακρυσμένους Χειριστές";} +if ($ADD==611111) {$hh='usergroups'; echo "Διάγραψε τους χρήστες Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Διάγραψε τον Βοηθό";} +if ($ADD==61111111) {$hh='filters'; echo "Διαγραφή Φίλτρου";} +if ($ADD==611111111) {$hh='times'; echo "Διαγραφή Χρόνου Κλήσης";} +if ($ADD==6111111111) {$hh='times'; echo "Διαγραφή Χρόνου Κλήσης Κατάστασης";} +if ($ADD==73) {$hh='campaigns'; echo "Μετρητής Κληθέντων Οδηγών";} +if ($ADD==7111111) {$hh='scripts'; echo "Προεπισκόπιση Βοηθού";} +if ($ADD==0) {$hh='users'; echo "Λίστα Χρηστών";} +if ($ADD==8) {$hh='users'; echo "Επανακλήσεις μέσα στον χειριστή";} +if ($ADD==81) {$hh='campaigns'; echo "Επανακλήσεις μέσα στην εκστρατεία";} +if ($ADD==811) {$hh='campaigns'; echo "Επανακλήσεις μέσα στην λίστα";} +if ($ADD==10) {$hh='campaigns'; echo "Εκστρατείες";} +if ($ADD==100) {$hh='lists'; echo "Λίστες";} +if ($ADD==1000) {$hh='ingroups'; echo "Εισ-Ομάδες";} +if ($ADD==10000) {$hh='remoteagent'; echo "Απομακρυσμένοι Χειριστές";} +if ($ADD==100000) {$hh='usergroups'; echo "Ομάδες Χρήστη";} +if ($ADD==1000000) {$hh='scripts'; echo "Βοηθοί";} +if ($ADD==10000000) {$hh='filters'; echo "Φίλτρα";} +if ($ADD==100000000) {$hh='times'; echo "Χρόνοι Κλήσεων";} +if ($ADD==1000000000) {$hh='times'; echo "";} +if ($ADD==55) {$hh='users'; echo "Φόρμα Αναζήτησης";} +if ($ADD==66) {$hh='users'; echo "Αποτελέσματα Αναζήτησης";} +if ($ADD==99999) {$hh='users'; echo "ΒΟΗΘΕΙΑ";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or ($ADD==21) or ($ADD==31) or ($ADD==41) or ($ADD=="4A") or ($ADD=="4B") ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ($ADD==31) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<100) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 Border=0 ALT=\"ΒΟΗΘΕΙΑ\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ΔΙΑΧΕΙΡΙΣΗ: ΒΟΗΘΕΙΑ


\n"; + +?> +VICIDIAL_ΧΡΗΣΤΕΣ ΠΙΝΑΚΑΣ

+ +
+ID Χρήστη - Σε αυτό το πεδίο τοποθετείται ο αριθμός ID του χρήστη, μπορεί να είναι μεταξύ 2 και 8 ψηφία. + +
+
+
+Κωδικός - Σε αυτό το πεδίο τοποθετείται ο κωδικός του χρήστη στο VICIDIAL. Πρέπει να είναι τουλάχιστον 2 χαρακτήρες. + +
+
+
+Πλήρες Ονομα - Αυτό το πεδίο είναι που μπορείτε να ορίσετε το πλήρες όνομα των χρηστών VICIDIAL. Πρέπει να είναι τουλάχιστον 2 χαρακτήρες. + +
+
+
+Επίπεδο Χρήστη - Αυτός ο κατάλογος επιλογών είναι που μπορείτε να επιλέξετε το επίπεδο χρήστη των VICIDIAL χρηστών. Πρέπει να έχει επίπεδο 1 για να συνδεθεί στο σύστημα. Πρέπει να έχει επίπεδο μεγαλύτερο από 2 για να συνδεθεί ως closer. Πρέπει να έχει επίπεδο 8 ή μεγαλύερο για ενέργειες διαχειριστή. + +
+
+
+Ομάδα Χρήστη - Αυτός ο κατάλογος επιλογών είναι που μπορείτε να επιλέξετε την ομάδα χρηστών που ανήκει ο χρήστης. + +
+
+
+Σύνδεση Τηλεφώνου - εδώ μπορείτε να θέσετε μία προκαθορισμένη σύνδεση τηλεφώνου κατά την είσοδο του χειριστή στο vicidial.php. + +
+
+
+Κωδικός Τηλεφώνου - εδώ μπορείτε να θέσετε ένα προκαθορισμένο κωδικό τηλεφώνου κατά την είσοδο του χειριστή στο vicidial.php. + +
+
+
+HotKeys ενεργός - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να χρησιμοποιήσει τα πλήκτρα γρήγορου τερματισμού vicidial.php. + +
+
+
+Ο πράκτορας επιλέγει Ingroups - εάν θέσετε σε 1 αυτή την επιλογή επιτρέπει στο χρήστη να επιλέξει τις εισ-ομάδες που θα λάβουν τις κλήσεις. Διαφορετικά ο Manager θα πρέπει να το θέσει αυτό στην σελίδα διαχείρισης. + +
+
+
+Εισερχόμενες Ομάδες - Εδώ μπορείτε να επιλέξετε τις εισερχόμενες ομάδες που θέλετε να λαμβάνουν τις κλήσεις , εάν έχετε επιλέξει την εκστρατεία CLOSER. + +
+
+
+Προγραμματισμένες Επανακλήσεις - Αυτή η επιλογή επιτρέπει στον χειριστή να τερματίσει μία κλήση ως CALLBK και να επιλέξει τα δεδομένα και την ώρα κατά την οποία ο οδηγός θα ξανα-ενεργοποιηθεί. + +
+
+
+Μόνο του Χρήστη Επανακλήσεις- Αυτή η επιλογή επιτρέπει στον χρήστη να θέσει μία επανάκληση με τέτοιο τρόπο, ώστε μόνο αυτός να μπορεί να καλέσει τον πελάτη. Επίσης, επιτρέπει στον χρήστη να δει τις λίστες των επανακλήσεων και να τις καλέσει οποιαδήποτε στιγμή. + +
+
+
+Χειροκίνητη Κλήση Χρήστη - Αυτή η επιλογή επιτρέπει στον χειριστή να καταχωρήσει χειροκίνητα ένα νέο οδηγό στο σύστημα και να τον καλέσει. + +
+
+
+Ηχογράφηση - Αυτή η επιλογή μπορεί να απαγορεύσει σε έναν χειριστή να κάνει ηχογραφήσεις και θα πρέπει να ακολουθεί την διαδικασία ηχογράφησης της εκστρατείας. + +
+
+
+Μεταφορές- Αυτή η επιλογή μπορεί να απαγορεύσει σε έναν χειριστή να ανοίξει την διαδικασία μεταφορά-συνδιάσκεψη. Αν είναι απενεργοποιημένη, ο χρήστης δεν μπορεί να μεταφέρει κλήσεις ή να κάνει κλήση σε τρίτο. + +
+
+
+Πιό στενή προεπιλογή που συνδυάζεται - αυτή η επιλογή προκαθορίζει απλά το συνδυασμένο τετραγωνίδιο σε μια ΠΙΟ ΣΤΕΝΉ οθόνη σύνδεσης. + +
+
+
+Αλλάξτε τις επιλογές διεπαφών Χειριστών - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο διαχειριστή να τροποποιήσει τις επιλογές διεπαφών χειριστών στην admin.php. + +
+
+
+Διαγραφή Χρηστών - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει άλλους χρήστες ίσου ή μικρότερου επιπέδου από το σύστημα. + +
+
+
+Διαγραφή Ομάδων Χρηστών - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τις ομάδες χρηστών από το σύστημα. + +
+
+
+Διαγραφή Λιστών - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τις λίστες από το σύστημα. + +
+
+
+Διαγραφή Εκστρατειών - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τις εκστρατείες από το σύστημα. + +
+
+
+Διαγραφή Εισ-Ομάδων - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τις Εισ-Ομάδες από το σύστημα. + +
+
+
+Διαγράψτε τους Απομακρυσμένους Χειριστές - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τους απομακρυσμένους χειριστές από το σύστημα. + +
+
+
+Εισαγωγή Οδηγών - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να εισάγει τους οδηγούς στον πίνακα vicidial_list μέσω του βασισμένου σε Ιστοσελίδα Εισαγωγέα οδηγών. + +
+
+
+Λεπτομέρειες Εκστρατείας - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να δει και να τροποποιήσει τα λεπτομερή στοιχεία της εκστρατείας. + +
+
+
+AGC Πρόσβαση Διαχειριστή - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να συνδεθεί στις σελίδες του astGUIclient ως διαχειριστής. + +
+
+
+AGC διαγραφή τηλεφώνων - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τα τηλέφωνα στις σελίδες του διαχειριστή του astGUIclient. + +
+
+
+Διαγραφή Βοηθού - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να διαγράψει τους οδηγούς της εκστρατείας . + +
+
+
+Τροποποιήστε τους οδηγούς - αυτή η επιλογή εάν τη θέσετε σε 1, επιτρέπει στο χρήστη να τροποποιήσει τους οδηγούς στη σελίδα αποτελεσμάτων αναζήτησης οδηγών. + +
+
+
+Αλλαγή Εκστρατείας Χειριστού - εάν θέσετε σε 1 αυτή την επιλογή, επιτρέπει στο χρήστη να αλλάξει την εκτρατεία όπου ένας πράκτορας έχει συνδεθεί . + +
+
+
+Διαγραφή Φίλτρων - Αυτή η επιλογή επιτρέπει στον χειριστή να διαγράφει φίλτρα από το σύστημα. + +
+
+
+Διαγραφή Χρόνων Κλήσεων - Αυτή η επιλογή επιτρέπει στον χρήστη να διαγράφει εγγραφές χρόνων κλήσεων και καταστάσεων από το σύστημα. + +
+
+
+Τροποποίηση Χρόνων Κλήσεων - Αυτή η επιλογή επιτρέπει στον χρήστη εμφανίσει και να τροποποιήσει τους χρόνους κλήσεων και τις εγγραφές χρόνων κλήσεων κατάστασης. Δεν χρειάζεται να είναι ενεργή αυτή η επιλογή εάν μόνο χρειάζεται η αλλαγή της επιλογής των χρόνων κλήσεων στην οθόνη των εκστρατειών. + + + + +



+ +VICIDIAL_ΕΚΣΤΡΑΤΕΙΕΣ ΠΙΝΑΚΑΣ

+
+
+ID Εκστρατείας - Αυτό είναι το σύντομο όνομα της εκστρατείας, δεν μπορεί να διορθωθεί μετά από την αρχική παράδοση, δεν μπορεί να περιέχει κενά και πρέπει να είναι μεταξύ 2 και 8 χαρακτήρεςh. + +
+
+
+Ονομα Εκστρατείας - Αυτό είναι η περιγραφή της εκστρατείας, πρέπει να είναι μεταξύ 6 και 40 χαρακτήρες. + +
+
+
+Ενεργοποίηση - Εδώ μπορείτε να θέσετε την εκστρατεία ενεργή ή μη ενεργή. Εάν είναι μη ενεργή, κανένας δεν μπορεί να συνδεθεί σε αυτήν. + +
+
+
+Τηλ.Σύνδεση Στάθμευσης - Εδώ μπορείτε να ορίσετε την μουσική αναμονής για το VICIDIAL. Επιβεβαιώστε, ότι η εσωτ.σύνδεση βρίσκεται στο extensions.conf και ότι δείχνει το αρχείο παρακάτω. + +
+
+
+ν Αρχείου Στάθμευσης - Εδώ μπορείτε να προσαρμόσετε την μουσική αναμονής για το VICIDIAL. Επιβεβαιώστε ότι το αρχείο έχει 10 χαρακτήρες ή λιγότερους και ότι το αρχείο βρίσκεται στον κατάλογο /var/lib/asterisk/sounds. + +
+
+
+Ιστοσελίδα - Αυτή είναι η προσαρμοσμένη διεύθυνση που θα σας κατευθύνει για κλήσεις που έρχονται σε αυτήν την ομάδα. + +
+
+
+Επιτρέπει τους Closers - Εδώ ορίζετε εάν οι χρήστες της εκστρατείας θα έχουν την επιλογή να στείλουν την κλήση σε έναν closer. + +
+
+
+Κατάσταση Κλήσης - Εδώ ορίζετε τις καταστάσεις που θέλετε να κληθούν μέσα στις λίστες, οι οποίες είναι ενεργές για την εκστρατεία παρακάτω + +
+
+
+Ταξινόμηση Λίστας - Σε αυτόν τον κατάλογο επιλογών μπορείτε να επιλέξετε πώς οι οδηγοί, που ταιριάζουν με τις καταστάσεις που επιλέξατε παραπάνω, θα τοποθετηθούν στον hopper: +
  - DOWN: επιλογή των πρώτων οδηγών που εισήχθησαν στον πίνακα vicidial_list +
  - UP: επιλογή των τελευταίων οδηγών που εισήχθησαν στον πίνακα vicidial_list +
  - UP PHONE: επιλογή του υψηλότερου τηλεφωνικού αριθμού και συνεχίζει προς τα κάτω +
  - DOWN PHONE: επιλογή του χαμηλότερου τηλεφωνικού αριθμού και συνεχίζει προς τα πάνω +
  - UP LAST NAME: έναρξη με τα επίθετα να ξεκινάνε με Ζ και συνεχίζει προς τα κάτω +
  - DOWN LAST NAME: έναρξη με τα επίθετα να ξεκινάνε με Α και συνεχίζει προς τα πάνω +
  - UP COUNT: έναρξη με τους λιγότερους σε κλήση οδηγούς και συνεχίζει προς τα κάτω +
  - DOWN COUNT: έναρξη με τους λιγότερους σε κλήση οδηγούς και συνεχίζει +
  - DOWN COUNT 2nd NEW: έναρξη με τους λιγότερους σε κλήση οδηγούς και συνεχίζει προς τα πάνω με την εισαγωγή ενός ΝΕΟΥ οδηγού για κάθε άλλο οδηγό - Πρέπει να ΜΗΝ έχει νέα επιλεγμένα στις καταστάσεις κλήσεων +
  - DOWN COUNT 3nd NEW: έναρξη με τους λιγότερους σε κλήση οδηγούς και συνεχίζει προς τα πάνω με την εισαγωγή ενός ΝΕΟΥ οδηγού για κάθε τρίτο οδηγό - Πρέπει να ΜΗΝ έχει νέα επιλεγμένα στις καταστάσεις κλήσεων +
  - DOWN COUNT 4th NEW: έναρξη με τους λιγότερους σε κλήση οδηγούς και συνεχίζει προς τα πάνω με την εισαγωγή ενός ΝΕΟΥ οδηγού για κάθε τέταρτο οδηγό - Πρέπει να ΜΗΝ έχει νέα επιλεγμένα στις καταστάσεις κλήσεων + +
+
+
+Επίπεδο Hopper - Αυτό είναι το πόσους οδηγούς η διαδικασία VDhopper, προσπαθεί να διατηρήσει στον πίνακα vicidial_hopper για αυτήν την εκστρατεία. Εάν η διαδικασία VDhopper τρέχει κάθε λεπτό, ρυθμίστε αυτό λίγο περισσότερο από τον αριθμό των οδηγών που περνούν σε ένα λεπτό. + +
+
+
+Φίλτρο Οδηγοιύ - αυτή είναι μία μέθοδος για να δημιουργήτε φίλτρα για την SQL ερώτηση. Χρησιμοποιήστε αυτό το χαρακτηριστικό με προσοχή, είναι εύκολο να σταματήσει το σύστημα με μία μικρή αλλαγή στη δήλωση SQL. Η προεπιλογή είναι ΚΑΜΙΑ. + +
+
+
+Υποχρεωτική Επαναφορά του Hopper - Αυτό σας επιτρέπει καθαρίσετε τα περιεχόμενα κατά την επιβεβαίωση της φόρμας. Αυτό θα συμβεί πάλι όταν η διαδικασία VDhopper θα τρέξει. + +
+
+
+Επίπεδο Αυτόματης Κλήσης - Εδώ είναι που καθορίζεται πόσες γραμμές θα χρησιμοποιούνται ανά ενεργό χρήστη. Μηδέν (0) σημαίνει ότι η αυτόματη κλήση είναι μη ενεργή και οι χρήστες πατούν το πλήκτρο για την κλήση κάθε αριθμού. Διαφορετικά, το σύστημα καλεί γραμμές ίσες με τους ενεργούς χρήστες, πολλαπλασιασμένους με το επίπεδο κλήσης και σύμφωνα με το πόσες γραμμές η εκστρατεία σε κάθε διακομιστή επιτρέπει. + +
+
+
+Επόμενη Κλήση Χρήστη - Αυτό προσδιορίζει ποιος χρήστης λαμβάνει την επόμενη κλήση που είναι διαθέσιμη: +
  - random: ταξινομημένο με τυχαία τιμή ενημέρωσης στον πίνακα vicidial_live_agents +
  - oldest_call_start: ταξινομημένο με την τελευταία φορά που σε ένα χρήστη στάλθηκε μία κλήση. Με αποτέλεσμα, ο χρήστης να λαμβάνει συνολικά το ίδιο αριθό κλήσεων. +
  - oldest_call_finish: ταξινομημένο με την τελευταία φορά που ένας χρήστης τελείωσε μία κλήση. Ο χρήστης που περιμένει περισσότερο λαμβάνει την πρώτη κλήση. +
  - overall_user_level: οι διαταγές από το user_level του χειριστή όπως καθορίζεται στα vicidial_users παρουσιάζουν ένα υψηλότερο user_level θα άβουν περισσότερες κλήσεις. + +
+
+
+Τοπική Ωρα Κλήσης - Εδώ, μπορείτε να ορίσετε τις ώρες που θα θέλατε να γίνουν οι κλήσεις. Αυτό ελέγχετε από τον κωδικό περις και ρυθμίζεται για Daylight Savings εάν είναι εφαρμόσιμο. + +
+
+
+Κλήση Εκτός Χρόνου - Εάν έχει οριστεί, οι κλήσεις που φυσιολογικά θα έκλειναν μετά το χρόνο που έχει οριστεί στο extensions.conf, θα κλείσουν σε αυτόν τον χρόνο εάν είναι μικρότερος του extensions.conf. Αυτό επιτρέπει στην γρήγορη αλλαγή των χρόνων από διακομιστή σε διακομιστή και περιορίζοντας τα αοτελέσματα σε μία εκστρατεία. Εάν έχετε πολλές κλήσεις με Αυτόματους Τηλεφωνητές ή Φωνητικών Ταχυδρομείων, μπορείτε να αλλάξετε αυτή την τιμή μεταξύ 21-26 και να δείτε αν τα αποτελέσματα είναι καλύτερα. + +
+
+
+Πρόθεμα Κλήσης - Αυτό το ο επιτρέπει την πιο εύκολη αλλαγή της διαδρομής της κλήσης να βγει έξω μέσω διαφορετικής μεθόδου, χωρίς να γίνει επαναφόρτωση στο Asterisk. Προκαθορισμένο είναι το 9 βασισμένο σύμφωνα με το 91NXXNXXXXXX στο σχέδιο κλήσεων - extensions.conf. + +
+
+
+CallerID Εκστρατείας - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. If you are using T1 or E1s to dial out this option is only available if you are using PRIs - ISDN T1s or E1s - that have the custom callerid feature turned on, this will not work with Robbed-bit service(RBS) circuits. This will also work through most VOIP(SIP or IAX trunks) providers that allow dynamic outbound callerID. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Τηλ.Σύνδεση Εκστρατείας VDAD - Αυτό το πεδίο επιτρέπει γαι μία προσαρμόσιμη VDAD εσωτ.σύνδεση μεταφοράς. Αυτό σας επιτρέπει να χρησιμοποιήσετε διαφορετικές διαδικασίες VDADtransfer.agi, σύμφωνα με την εκστρατεία. Η προκαθορισμένη AGI μεταφορά - εσωτ.σύνδ. 8365 agi VDADtransfer.agi - στέλνει αμέσως τις κλήσεις στον χρήστη, μόλις το σηκώσουν. Ενα πρόσθετο AGI παράεα πολιτικής έρευνας συμπεριλαμβάνεται - 8366 agi - VDADtransferSURVEY.agi - όπου παίζει ένα μήνυμα στο κληθέν πρόσωπο και επιτρέπει να κάνουν επιλογές με τα πλήκτρα. + +
+
+
+Τηλ.Επέκταση εκστρατείας Ηχογρ - αυτό το πεδίο επιτρέπει να ορίσετε μία επέκταση ηχογράφησης που χρησιμοποιείται με το VICIDIAL. Αυτό επιτρέπει να χρησιμοποιήσετε διαφορετικές επεκτάσεις ανάλογα με πόσο χρόνο θέλετε να επιτρέψετε μία ηχογράφηση και ποιο τύπος κωδικοποιητή-αποκωδικοποιητή θα χρησιμοποιηθεί. Η προεπιλογή είναι 8309 και θα καταγράψει με το σχήμα WAV μέχρι μια ώρα. Μια άλλη επιλογή που περιλαμβάνεται στα παραδείγματα είναι 8310 που θα καταγράψουν με το σχήμα GSM για μέχρι μια ώρα. + +
+
+
+Ηχογράφηση εκστρατείας - αυτή η επιλογή επιτρέπει να επιλέξετε το επίπεδο ηχογράφησης σε αυτήν την εκστρατεία. NEVER θα θέσει εκτός λειτουργίας την ηχογράφηση στον πελάτη. ONDEMAND είναι η προεπιλογή και επιτρέπει στον χειριστή να αρχίσει και να σταματήσει όπως απαιτείται. ALLCALLS θα αρχίσει την καταγραφή στον πελάτη όποτε μια κλήση στέλνεται σε έναν χειριστή. + +
+
+
+Όνομα αρχείου ηχογρ εκστρατείας - αυτό το πεδίο επιτρέπει να προσαρμόσετε το όνομα της ηχογράφησης, όταν η ηχογράφηση της εκστρατείας είναι ONDEMAND ή ALLCALLS. Οι μεταβλητές είναι CAMPAIGN CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. Η προεπιλογή είναι FULLDATE_ΧΕΙΡΙΣΤΗΣκαι θα μοιάζει με το 20051020-103108_6666. Ένα άλλο παράδειγμα είναι CAMPAIGN_TINYDATE_CUSTPHONE που θα μοιάζει με το TESTCAMP_51020103108_3125551212. 50 char max. + +
+
+
+Βοηθός εκστρατείας - αυτές οι επιλογές επιτρέπουν να επιλέξετε τον Βοηθό που θα εμφανιστεί στην οθόνη των χειριστών για αυτήν την εκστρατεία. Επιλέξτε NONE για να μην παρουσιάσετε κανένα χειρόγραφο για αυτήν την εκστρατεία. + +
+
+
+Κατά την έναρξη κλήσης - αυτές οι επιλογές επιτρέπουν να επιλέξετε εάν θέλετε την αυτόματη έναρξη μίας ιστο σελίδας σε ένα διαφορετικό παράθυρο, αυτόματη μετάβαση στον Βοηθό ή τίποτα. + +
+
+
+Μήνυμα αυτόματου τηλεφωνητού - αυτός το πεδίο χρησιμοποιείτε για τις τυφλές κλήσεις μεταφοράς όταν παίρνει ο χειριστής έναν αυτόματο τηλεφωνητή και χτυπά στο πλήκτρο μηνυμάτων αυτόματων τηλεφωνητών στο πλαίσιο διασκέψεων μεταφοράς. Πρέπει το θέσετε αυτό στο dialplan - extensions.conf - και σιγουρευτείτε ότι παίζει ένα αρχείο μουσικής κατόπιν κλείνει το τηλέφωνο. + +
+
+
+AMD στέλνει στο VM - αυτές οι επιλογές επιτρέπουν να καθορίσετε εάν ένα μήνυμα αφήνεται σε έναν αυτόματο τηλεφωνητή όταν ανιχνεύεται ότι η κλήση είναι ένας αυτόματος τηλεφωνητής και εάν το AMD είναι ενεργό. + +
+
+
+Xfer- Συνδ DTMF - αυτά τα τέσσερα πεδία επιτρέπουν να έχετε δύο σύνολα συνδιάσκεψης μεταφοράς και DTMF. Όταν η κλήση ή η εκστρατεία φορτώνεται, ο Βοηθός θα παρουσιάσει δύο πλήκτρα στο πλαίσιο μεταφορά-διασκέψεων και αυτόματα θα παρουσιάσει τα πεδία αριθμό για κλήση και στείλε DTMF όταν πατηθεί. + +
+
+
+Κλήση Εναλ Αρ Χρήστη - Αυτή η επιλογή επιτρέπει στον χειριστή να κάνει χειροκίνητη κλήση του εναλλακτικού αριθμού τηλεφώνου ή το πεδίο address3 μετά την κλήση του κυρίου αριθμού. + +
+
+
+Προγραμματισμένες Επανακλήσεις - Αυτή η επιλογή επιτρέπει στον χειριστή να τερματίσει μία κλήση ως CALLBK και να επιλέξει τα δεδομένα και την ώρα κατά την οποία ο οδηγός θα ξανα-ενεργοποιηθεί. + +
+
+
+Δευτερ. Εγκαταλ. Κλήσης - Ο αριθμός των δευτερολέπτων από την στιγμή που ο πελάτης σηκώνει το τηλ μέχρι η κλήση να θεωρηθεί εγκαταλειμένη. Μόνο για εξερχόμενες κλήσεις . + +
+
+
+Φωνητικό Ταχυδρομείο - Εάν έχει οριστεί, οι κλήσεις που φυσιολογικά θα ΕΓΚΑΤΑΛΕΙΠΟΝΤΑΝ, θα κατευθυνθούν σε αυό το φωνητικό ταχυδρομείο, ώστε να ακούσετε και να αφήσετε ένα μήνυμα. + +
+
+
+Μήνυμα Ασφαλούς Φύλαξης - Εάν είναι Υ θα παίξει ένα μήνυμα στον πελάτη μετά το πέρας των δευτερολέπτων ασφαλούς εγκατάλειψης, χωρίς να μεταφερθεί σε έναν χειριστή. Αυτή η επιλογή υπερβαίνει την αποστολή σε θυρίδα ηχητικού μηνύματος εάν είναι Υ. + +
+
+
+Εσωτ.σύνδεση Ασφαλούς Φύλαξης - Αυτή είναι η εσωτ.σύνδεση του πλάνου κλήσεων, όπου βρίσκεται το ηχητικό αρχείο της Ασφαλής Φύλαξης στον διακομιστή. + +
+
+
+Δευτερ. Τυλίγματος - Ο αριθμός των δευτερολέπτων που αναγκάζει έναν χειριστή να περιμένει πριν του επιτραπεί να λάβει ή να κάνει άλλη κλήση. Ο χρόνος ξεκινάει μόλις τερματίσει μία κλήση. Προκαθορισμένα είναι 0 δευτερ. Αν ο χρόνος περάσει πριν ο χειριστής τερματίσει την κλήση, δεν θα μετακινηθεί στην άλλη κλήση πριν συμβεί αυτό. + +
+
+
+Μήνυμα Τυλίγματος - Αυτό είναι ένα συγκεκριμένο μήνυμα εκστρατείας που εμφανίζεται στην οθόνη τυλίγματος όταν έχει οριστεί ο χρόνος τυλίγματος. + +
+
+
+Μήνυμα Τυλίγματος - Αυτό είναι ένα συγκεκριμένο μήνυμα εκστρατείας που εμφανίζεται στην οθόνη τυλίγματος όταν έχει οριστεί ο χρόνος τυλίγματος. + +
+
+
+Εσωτερικός κατάλογος DNC χρήσης - αυτό καθορίζει εάν αυτή ηεκστρατεία είναι στους μολύβδους φίλτρων ενάντια στον εσωτερικόκατάλογο DNC. Εάν τίθεται το Υ, η χοάνη θα ψάξει κάθετηλεφωνικό αριθμό στον κατάλογο DNC πρίν τοποθετεί τον στηχοάνη. Εάν είναι στον κατάλογο DNC έπειτα θα αλλάξει ότιθέση μολύβδου σε DNCL έτσι που δεν μπορεί να σχηματιστεί. Ηπροεπιλογή είναι ν. + +
+
+
+Εισερχόμενες ομάδες - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound/outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + + + +



+ +VICIDIAL_ΛΙΣΤΕΣ ΠΙΝΑΚΑΣ

+
+
+ID Λίστας - Αυτό είναι το αριθμητικό όνομα της λίστας, δεν μπορεί να διορθωθεί μετά από την αρχική εισαγωγή, πρέπει να περιέχει μόνο αριθμούς και πρέπει να είναι μεταξύ 2 και 8 χαρακτήρες. + +
+
+
+Ονομα Λίστας - Αυτή είναι η περιγραφή της λίστας, πρέπει να είναι μεταξύ 2 και 20 χαρακτήρες. + +
+
+
+Εκστρατεία - Αυτή είναι η εκστρατεία όπου ανήκει η λίστα. Μία λίστα μπορεί μόνο να κληθεί από μία εκστρατεία κάθε φορά. + +
+
+
+Ενεργή - Αυτό ορίζει κατά πόσον η λίστα πρόκειται να κληθεί ή όχι. + +
+
+
+Επαναφορά Κατάστασης-Κλήσης-Καθοδήγησης για την λίστα - Αυτό επαναφέρει τους οδηγούς σε αυτή την λίστα στο Ν σε \"μη κληθέντα από την τελευταία επαναφορά\" και σημαίνει ότι για οποιαδήποτε καθοδήγηση μπορεί να γίνει κλήση εάν είναι η σωστή κατάσταση, όπως ορίσθηκε στην οθόνη τις εκστρατείας. + +
+
+
+Κατάλογος VICIDIAL DNC - αυτό δεν καλεί τον κατάλογοπεριέχει κάθε μόλυβδο που έχει τεθεί μια θέση DNC στοσύστημα. Μέσω των ΚΑΤΑΛΟΓΩΝ - ΠΡΟΣΘΕΣΤΕ τον ΑΡΙΘΜΟ στη σελίδαDNC που είστε σε θέση να προσθέσετε με το χέρι έναν αριθμό σεαυτόν τον κατάλογο έτσι ώστε δεν θα κληθεί από τις εκστρατείεςπου χρησιμοποιούν τον εσωτερικό κατάλογο DNC. + + + +



+ +VICIDIAL_INBOUND_GROUPS ΠΙΝΑΚΑΣ

+
+
+ID Ομάδας - Αυτό είναι το σύντομο όνομα της εισερχόμενης ομάδας, δεν μπορεί να διορθωθεί μετά από την αρχική παράδοση, δεν μπορεί να περιέχει κενά και πρέπει να είναι μεταξύ 2 και 20χαρακτήρες. + +
+
+
+Ονομα Ομάδας - Αυτή είναι η περιγραφή της ομάδας, πρέπει να είναι μεταξύ 2 και 30 χαρακτήρες. Δεν μπορεί να συμπεριαμβάνει παύλες, συν ή κενά . + +
+
+
+Χρώμα Ομάδας - Αυτό είναι το χρώμα που εμφανίζεται στην VICIDIAL εφαρμογή όταν η κλήση έρχεται σε αυτή την ομάδα. Πρέπει να είναι μεταξύ 2 και 7 χαρακτήρες. Εάν αυτό είναι ορισμένο ως hex , θα πρέπει να τοποθετήσετε ένα # στην αρχή του κειμένου ή το VICIDIAL δεν θα δουλεύει σωστά. + +
+
+
+Ενεργοποίηση - Αυτό καθορίζει κατά πόσον αυτή η ομάδα εμφανίζεται στο κουτί επιλογής όταν ένας χρήστης συνδέεται. + +
+
+
+Ιστοσελίδα - Αυτή είναι η προσαρμοσμένη διεύθυνση που θα σας κατευθύνει για κλήσεις που έρχονται σε αυ την ομάδα. + +
+
+
+Επόμενη Κλήση Χρήστη - Αυτό προσδιορίζει ποιος χρήστης λαμβάνει την επόμενη κλήση που είναι διαθέσιμη: +
  - random: ταξινομημένο με τυχαία τιμή ενημέρωσης στον πίνακα vicidial_live_agents +
  - oldest_call_start: ταξινομημένο με την τελευταία φορά που σε ένα χρήστη στάλθηκε μία κλήση. Με αποτέλεσμα, ο χρήστης να λαμβάνει συνολικά το ίδιο αριθό κλήσεων. +
  - oldest_call_finish: ταξινομημένο με την τελευταία φορά που ένας χρήστης τελείωσε μία κλήση. Ο χρήστης που περιμένει περισσότερο λαμβάνει την πρώτη κλήση. +
  - overall_user_level: οι διαταγές από το user_level του χειριστή όπως καθορίζεται στα vicidial_users παρουσιάζουν ένα υψηλότερο user_level θα άβουν περισσότερες κλήσεις. + +
+
+
+Οθόνη Μπροστινού - Αυτό το πεδίο καθορίζει κατά πόσον στον VICIDIAL χόμενος χρήστης θα εμφανίζεται το όνομα του μπροστινού - εάν υπάρχει κάποιο - στο πεδίο κατάστασης όταν η κλήση έρχεται στον χρήστη. + +
+
+
+Βοηθός εκστρατείας - αυτές οι επιλογές επιτρέπουν να επιλέξετε τον Βοηθό που θα εμφανιστεί στην οθόνη των χειριστών για αυτήν την εκστρατεία. Επιλέξτε NONE για να μην παρουσιάσετε κανένα χειρόγραφο για αυτήν την εκστρατεία. + +
+
+
+Κατά την έναρξη κλήσης - αυτές οι επιλογές επιτρέπουν να επιλέξετε εάν θέλετε την αυτόματη έναρξη μίας ιστο σελίδας σε ένα διαφορετικό παράθυρο, αυτόματη μετάβαση στον Βοηθό ή τίποτα. + +
+
+
+Xfer- Συνδ DTMF - αυτά τα τέσσερα πεδία επιτρέπουν να έχετε δύο σύνολα συνδιάσκεψης μεταφοράς και DTMF. Όταν η κλήση ή η εκστρατεία φορτώνεται, ο Βοηθός θα παρουσιάσει δύο πλήκτρα στο πλαίσιο μεταφορά-διασκέψεων και αυτόματα θα παρουσιάσει τα πεδία αριθμό για κλήση και στείλε DTMF όταν πατηθεί. + +
+
+
+Δευτερ. Εγκαταλ. Κλήσης - Ο αριθμός των δευτερολέπτων από την στιγμή που ο πελάτης σηκώνει το τηλ μέχρι η κλήση να θεωρηθεί εγκαταλειμένη. Μόνο για εξερχόμενες κλήσεις . + +
+
+
+Φωνητικό Ταχυδρομείο - Εάν έχει οριστεί, οι κλήσεις που φυσιολογικά θα ΕΓΚΑΤΑΛΕΙΠΟΝΤΑΝ, θα κατευθυνθούν σε αυό το φωνητικό ταχυδρομείο, ώστε να ακούσετε και να αφήσετε ένα μήνυμα. + +
+
+
+Μήνυμα Εγκατάλειψης - Εάν είναι Υ θα παίξει ένα μήνυμα στον πελάτη μετά το πέρας των δευτερολέπτων Εγκατάλειψης, χωρίς να μεταφερθεί σε έναν χειριστή. Αυτή η επιλογή υπερβαίνει την αποστολή σε θυρίδα ηχητικού μηνύματος εάν είναι Υ. + +
+
+
+Εσωτ.Σύνδεση Εγκατάλειψης - Αυτή είναι η εσωτ.σύνδεση του πλάνου κλήσεων, όπου βρίσκεται το ηχητικό αρχείο της Εγκατάλειψης στον διακομιστή. + + + +



+ +VICIDIAL_REMOTE_AGENTS ΠΙΝΑΚΑΣ

+
+
+Αρχή ID Χρήστη - Αυτό είναι η αρχή του ID Χρήστη που χρησιμοποιείται όταν οι καταχωρήσεις των απομακρυσμένων χρηστών παρεμβάλλονται στο σύστημα. Εάν ο αριθμός των γραμμών είναι μεγαλύτερος από 1, αυτός ο αριθμός αυξάνει κατά ένα μέχρι κάθε γραμμή να έχει μία καταχώρηση. Επιβεβαιώστε, ότι δημιουργήσατε ένα νέο VICIDIAL λογαριασμό η με επίπεδο χρήσης 4 ή μεγαλύτερο, εάν θέλετε να μπορεί να χρησιμοποιήσει την σελίδα vdremote για απομακρυσμένη πρόσβαση του λογαριασμού του. + +
+
+
+Αριθμός Γραμμών - Αυτό ορίζει πόσες καταχωρήσεις απομακρυσμένων χρηστών το σύστημα δημιουρ, και καθορίζει πόσες γραμμές μπορεί με ασφάλεια να στείλει στον αριθμό παρακάτω. + +
+
+
+IP Διακομιστή - Μία καταχώρηση απομακρυσμένου χρήστη είναι μόνο καλό για ένα συγκεκριμένο διακομιστή, εδώ επιλέγετε τον διακομιστή που ανήκει. + +
+
+
+Εξωτερική Τηλ.Σύνδεση - Αυτός είναι ο αριθμός που θέλετε οι κλήσεις να προωθούνται. Επιβεβαιώστε ότι είναι ένας πλήρης αριθμός από το σχέδιο κλήσεων και εάν θέλετε ένα 9 στην αρχή το βάζετε εδώ. Κάντε μία δοκιμή καλώντας αυτόν τον αριθμό από ένα τηλέφωνο του συστήματος. + +
+
+
+Κτάσταση - Εδώ μπορείτε να θέσετε τον απομακρυσμένο χρήστη σε ενεργό και μη ενεργό. Μόλις ο χρήστης γίνει ενεργός το σύστημα μπορεί να στείλει κλήσεις σε αυτόν. Μπορεί να διαρκέσει μέχρι 30 δευτερόλεπτα μετά την αλλαγή της κατάστασης σε μη ενεργός, ώστε να σταματήσει να δέχεται κ. + +
+
+
+Εκστρατεία - Εδώ μπορείτε να επιλέξετε την εκστρατεία όπου οι απομακρυσμένοι χρήστες θα συνδεθούν. Για εισερχόμενες πρέπει να χρησιμοποιηθεί η εκστρατεία CLOSER και επιλέξτε τις εισερχόμενες εκστρατείες παρακάτω, από που θέλετε να λαμβάνεται τις κλήσεις. + +
+
+
+Εισερχόμενες Ομάδες - Εδώ μπορείτε να επιλέξετε τις εισερχόμενες ομάδες που θέλετε να λαμβάνουν τις κλήσεις , εάν έχετε επιλέξει την εκστρατεία CLOSER. + + +



+ +VICIDIAL_CAMPAIGN_ΛΙΣΤΕΣ

+
+
+Οι λίστες της εκστρατείας παρουσιάζονται εδώ, και εάν είναι ενεργές (Υ ή Ν) μπορείτε να πάτε στην οθόνη λίστας με το να πατήσετε στο ID λίστας, στην πρώτη στήλη. + + +



+ +VICIDIAL_CAMPAIGN_STATUSES ΠΙΝΑΚΑΣ

+
+
+Με την χρήση προσαρμοσμένων καταστάσεων εκστρατείας, μπορείτε να έχετε καταστάσεις μόνο για συγκεκριμένες εκστρατείες. Η κατάσταση πρέπει να είναι 1-8 χαρακτήρες, η περιγραφή 2-30 χαρακτήρες και Επιλέξιμα καθορίζεται αν εμφανίζεται στο VICIDIAL ως τερματισμός. + + + +



+ +VICIDIAL_CAMPAIGN_HOTKEYS ΠΙΝΑΚΑΣ

+
+
+Με την χρήση προσαρμοσμένων κλειδιών εκστρατείας, οι χρήστες που χρησιμοποιούν την εφαρμογή vicidial μπορούν να κλείσουν και να τερματίσουν την κλήση, με ένα μόνο πάτημα πλήκτρου. + + + + +



+ +VICIDIAL_LEAD_RECYCLE ΠΙΝΑΚΑΣ

+
+
+Μέσω της χρήσης της ανακύκλωσης μολύβδου, μπορείτε να καλέσετετις συγκεκριμένες θέσεις των μολύβδων πάλι σε ένα διευκρινισμένοδιάστημα χωρίς επαναρύθμιση του ολόκληρου καταλόγου. Ηανακύκλωση μολύβδου είναι εκστρατεία-συγκεκριμένη και δεν ειναιαπαραίτητο να είναι μια επιλεγμένη dialable θέση στηνεκστρατεία σας. Ο τομέας καθυστέρησης προσπάθειας είναι οαριθμός δευτερολέπτων έως ότου μπορεί ο μόλυβδος να τοποθετηθείπίσω στη χοάνη, αυτός ο αριθμός πρέπει να είναι τουλάχιστον120 δευτερόλεπτα. Ο μέγιστος τομέας προσπάθειας είναι ομέγιστος αριθμός χρόνων ότι ένας μόλυβδος αυτής της θέσηςμπορεί να προσπαθηθεί προτού να πρέπει να επαναρυθμιστεί οκατάλογος, αυτός ο αριθμός μπορεί να είναι από 1 έως 10.Μπορείτε να ενεργοποιήσετε και να απενεργοποιήσετε μια ανακύκλωσηςείσοδο μολύβδου με τις παρεχόμενες συνδέσεις. Αυτό τοχαρακτηριστικό γνώρισμα λειτουργεί μόνο στον τρόποαυτόματος-πινάκων, όπου το επίπεδο πινάκων είναι μεγαλύτεροαπό 0. + + + + + +



+ +VICIDIAL_USER_GROUPS ΠΙΝΑΚΑΣ

+
+
+Ομάδα Χρήστη - Αυτό είναι το σύντομο όνομα της Vicidial ομάδας χρήστη, πρσπαθήστε να μην χρησιμοποιήσετε κενά ή στίξεις για αυτό το πεδίο. Από 2 μέχρι 20 χαρακτήρες. + +
+
+
+Ονομα Ομάδας- Αυτή είναι η περιγραφή της vicidial ομάδας χρήστη μέχρι 40 χαρακτήρες. + + + + + +



+ +VICIDIAL_ΒΟΗΘΟΙ ΠΙΝΑΚΑΣ

+
+
+Ταυτότητα Βοηθού - αυτό είναι το σύντομο όνομα ενός Βοπηθού. Πρέπει να είναι ένα μοναδικό προσδιοριστικό. Προσπαθήστε να μην χρησιμοποιήσετε οποιαδήποτε διαστήμα ή στίξη για τους 10 χαρακτήρες αυτού του πεδίου, ελάχιστο 2 χαρακτήρων. + +
+
+Όνομα Βοηθού - αυτός είναι ο τίτλος ενός Βοηθού. Αυτή είναι μια σύντομη περίληψη. 2-50 χαρακτήρες. Δεν πρέπει να υπάρξουν διάστηματα ή στίξεις σε αυτό το πεδίο. + +
+
+Σχόλια Βοηθού - εδώ μπορείτε να τοποθετήσετε τα σχόλια για έναν Βοηθό. 2-255 χαρακτήρες . + +
+
+Κείμενο χειρόγραφου - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today? + +
+
+
+Ενεργός - αυτό καθορίζει εάν αυτός ο οδηγός μπορεί να επιλεχτεί για να χρησιμοποιηθεί από μια εκστρατεία. + + + + + +



+ +VICIDIAL_LEAD_ΦΙΛΤΡΑ ΠΙΝΑΚΑΣ

+
+
+ID Φίλτρου - Αυτό είναι το σύντομο όνομα ενός Φίλτρου Οδηγού. Πρέπει να είναι ένας μοναδικός κωδικός. Μην χρησιμοποιήσετε κενά ή στίξη για αυτό το πεδίο. Χαρακτήρες 2 με 10. + +
+
+Ονομα Φίλτρου - Αυτό είναι ένα πιο περιγραφικό όνομα για το Φίλτρο. Είναι μία σύντομη περιγρφή του φίλτρου. Χαρακτήρες 2 με 30. + +
+
+Σχόλια Φίλτρου - Εδώ μπορείτε σχολιάσετε το φίλτρο. Χαρακτήρες 2 με 255. + +
+
+SQL Φίλτρου - Εδώ μπορείτε να ορίσετε SQL ερώτημα για το φίλτρο. Μην ξεκινήσετε ή τελειώσετε με ένα AND, αυτό θα γίνει αυτόματα από τον hopper. Ένα παράδειγμα είναι- called_count > 4 and called_count < 8 -. + + + + + +



+ +VICIDIAL_ΧΡΟΝΟΙ ΚΛΗΣΕΩΝ ΠΙΝΑΚΑΣ

+
+
+ID Χρόνου Κλήσης - Αυτό είναι το σύντομο όνομα του Ορισμού Χρόνου Κλήσης. Πρέπει να είναι ένα μοναδικό στοιχείο. Μην χρησιμοποιηθούν διαστήματα ή στίξεις. 2-10 χαρακτήρες. + +
+
+Ονομα Χρόνου Κλήσης - Αυτό είναι ένα πιο περιγραφικό όνομα του Ορισμού Χρόνου Κλήσης. Είναι μία σύντομη περιγραφή. 2-30 χαρακτήρεςΣχόλια Χρόνου Κλήσης - This is where you can place comments for a Vicidial Call Time Definition such as -10am to 4pm with extra call state restrictions-. max 255 characters. + +
+
+Σχόλια Χρόνου Κλήσης - This is where you can place comments for a Vicidial Call Time Definition such as -10am to 4pm with extra call state restrictions-. max 255 characters. + +
+
+Προκαθορισμένοι Χρόνοι Εκκίνησης και Παύσης - Αυτός είναι ο προκαθορισμένος χρόνος όπου θα επιτρέπετε οι κλήσεις εάν δεν έχει οριστεί ο χρόνος εκκίνησης της ημέρας-της-εβδομάδας. 0 είναι μεσάνυχτα. Εάν δεν θέλετε καμία κλήση θέστε αυτό το πεδίο σε 2400 και το προκαθορισμένο χρόνο Παύσης σε 2400. Για να επιτρέψετε την 24ωρη κλήση την ημέρα θέστε σε 0 τον χρόνο εκκίνησης και σε 2400 τον χρόνο παύσηςWeekday Start and Stop Times -
These are the custom times per day that can be set for the call time definition. same rules apply as with the Default start and stop times. + +
+
+Weekday Start and Stop Times - These are the custom times per day that can be set for the call time definition. same rules apply as with the Default start and stop times. + +
+
+Ορισμοί Χρόνων Κλήσεων Καταστάσεων - Είναι η λίστα συγκεκριμένων Ορισμών Χρόνων Κλήσεων Καταστάσεων. + +
+
+Κατάσταση Χρόνου Κλήσης Κατάστασης - Αυτό είναι ο δύο γραμμάτων κωδικός για την κατάσταση όπου ο ορισμός χρόνου κλήσης είναι για. Θα πρέπει και οι Οδηγοί της εκστρατείας να έχουν δύο γράμματα κωδικούς κατάστασης για τον χρόνο κλήσης κατάστασης. + + + + +



+ +ΛΕΙΤΟΥΡΓΙΑ ΕΙΣΑΓΩΓΗΣ ΛΙΣΤΑΣ

+
+
+Ο VICIDIAL εισαγωγέας οδηγών είναι απλά σχεδιασμένος, ώστε να παίρνει ένα αρχείο - μέχρι 8ΜΒ - που είναι διαχωρισμένο με tab ή pipe και να το φορτώνει στον πίνακα vicidial_list. Υπάρχει επίσης ένας νέος βήτα φορτωτής οδηγών έκδοσης έξοχος που επιτρέπει τον τομέα επιλέγοντας και TXT - σαφές κείμενο, CSV - κόμμα χώρισε τις τιμέ και XLS - σχήματα αρχείων Excel. Ο φορτωτής δεν κάνει εξακρίβωση δεδομένων ή έλεγχο σε διπλές καταχωρήσεις, το οποί είναι κάτι που πρέπει να κάνετε πριν την φόρτωση. Επίσης, διευκρινίστε ότι έχετε δημιουργήσει την λίστα όπου οι οδηγοί θα είναι από κάτω, ώστε να τους χρησιμοποιήστε.Υπάρχει επίσης το θέμα με τις ζώνες κωδικοποίησης χρόνου των οδηγών. Μπορεί να θέλετε να αυξήσετε την συχνότητα όπου το ADMIN_adjust_GMTnow_on_leads.pl τρέχει στον cron, ώστε οποιαδήποτε φόρτωση οδηγών να κωδικοποιείται πιο γρήγορα. Εδώ είναι μία λίστα από πεδία στην πρέπουσα ταξινόμηση για τα αρχεία καθοδήγησης.: +
    +
  1. Κωδικός Οδηγού Προμηθευτού +
  2. Πηγαίος Κώδικας - εσωτερική χρήση μόνο από διαχειριστές και DBAs +
  3. ID λίστας - ο αριθμός λίστας που οι οδηγοί θα παρουσιαστούν κάτω από +
  4. Κωδικός τηλεφώνου - το πρόθεμα του τηλεφωνικού αριθμού (1 για ΗΠΑ, 01144 για Βρετανία κλπ) +
  5. Ο αριθμός τηλεφώνου - πρέπει να είναι τουλάχιστον 8 ψηφία +
  6. Τίτλος - ο τίτλος του πελάτη (κος. κα. κλπ) +
  7. Ονομα +
  8. Μεσαίο Αρχικό +
  9. Επίθετο +
  10. 1 Γραμμή Διεύθυνσης +
  11. 2 Γραμμή Διεύθυνσης +
  12. 3 Γραμμή Διεύθυνσης +
  13. Πόλη +
  14. Κράτος - περιορισμός σε 2 χαρακτήρες +
  15. Επαρχία +
  16. Ταχ.Κωδ. +
  17. Χώρα +
  18. Φύλο +
  19. Ημερ. Γέννησης +
  20. Εναλ. Αριθμός Τηλ. +
  21. Διεύθυνση Ηλεκτρ.Ταχυδρομείου +
  22. Φράση Ασφαλείας +
  23. Σχόλια +
+ +
ΣΗΜΕΙΩΣΕΙΣ: Η λειτουργία εισαγωγής οδηγών Excel επιτρέπεται από μια σειρά προγραμμάτων και πρέπει να έχει κατάλληλα διαμορφωμένο ένα αρχείο home/cron/AST_SERVER_conf.pl στον κεντρικό υπολογιστή δικτύου. Επίσης, κάποια υπο-προγράμματα πρέπει να φορτωθούν για να εργαστούν επίσης - OLE- τα Storage_Lite και Spreadsheet-ParseExcel. Μπορείτε να ελέγξετε για λάθη χρόνου εκτέλεσης στο αρχείο error_log του apache σας . + +







+







+ΤΕΛΟΣ +
+\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$dial_status_a = $row[3]; +$dial_status_b = $row[4]; +$dial_status_c = $row[5]; +$dial_status_d = $row[6]; +$dial_status_e = $row[7]; +$local_call_time = $row[16]; +if ($lead_filter_id=='') + { + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + +$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$camp_lists=''; +$o=0; +while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; +if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} +} +$camp_lists = eregi_replace(".$","",$camp_lists); + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + +echo "

\n"; +echo "Εμφάνιση Μετρητή Κληθέντων Οδηγών -

\n"; +echo "CAMPAIGN: $campaign_id
\n"; +echo "ΛΙΣΤΕΣ: $camp_lists
\n"; +echo "STATUSES: $dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e
\n"; +echo "FILTER: $lead_filter_id
\n"; +echo "CALL TIME: $local_call_time

\n"; + +### call function to calculate and print dialable leads +dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + +echo "

\n"; +echo "\n"; + +exit; +} + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) +{ + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDORLEADCODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551212'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[1]; +$script_text = $row[3]; + +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); +$script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); +$script_text = eregi_replace("\n","
",$script_text); + + +echo ""; + +echo "Προεπισκόπιση Βοηθού: $script_id
\n"; +echo "
\n"; +echo "
$script_name
\n"; +echo "$script_text\n"; +echo "
\n"; + +echo "\n"; + +exit; +} + + + + +######################### HTML HEADER BEGIN ####################################### +if ($hh=='users') {$users_hh='bgcolor ="#FFFF99"'; $users_fc='BLACK';} # yellow + else {$users_hh=''; $users_fc='WHITE';} +if ($hh=='campaigns') {$campaigns_hh='bgcolor ="#FFCC99"'; $campaigns_fc='BLACK';} # orange + else {$campaigns_hh=''; $campaigns_fc='WHITE';} +if ($hh=='lists') {$lists_hh='bgcolor ="#FFCCCC"'; $lists_fc='BLACK';} # red + else {$lists_hh=''; $lists_fc='WHITE';} +if ($hh=='ingroups') {$ingroups_hh='bgcolor ="#CC99FF"'; $ingroups_fc='BLACK';} # purple + else {$ingroups_hh=''; $ingroups_fc='WHITE';} +if ($hh=='remoteagent') {$remoteagent_hh='bgcolor ="#CCFFCC"'; $remoteagent_fc='BLACK';} # green + else {$remoteagent_hh=''; $remoteagent_fc='WHITE';} +if ($hh=='usergroups') {$usergroups_hh='bgcolor ="#CCFFFF"'; $usergroups_fc='BLACK';} # cyan + else {$usergroups_hh=''; $usergroups_fc='WHITE';} +if ($hh=='scripts') {$scripts_hh='bgcolor ="#99FFCC"'; $scripts_fc='BLACK';} # light teal + else {$scripts_hh=''; $scripts_fc='WHITE';} +if ($hh=='filters') {$filters_hh='bgcolor ="#CCCCCC"'; $filters_fc='BLACK';} # grey + else {$filters_hh=''; $filters_fc='WHITE';} +if ($hh=='times') {$times_hh='bgcolor ="#99FF33"'; $times_fc='BLACK';} # hard teal + else {$times_hh=''; $times_fc='WHITE';} + +?> + + + + +\n"; +echo "
English Ελληνικά
+ + + + + + + + + + + + + + + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + + + + +
  ΔΙΑΧΕΙΡΙΣΗ - Αποσύνδεση  
> SIZE=1> ΧΡΗΣΤΕΣ > SIZE=1> ΕΚΣΤΡΑΤΕΙΕΣ > SIZE=1> ΛΙΣΤΕΣ > SIZE=1> ΒΟΗΘΟΙ > SIZE=1> ΦΙΛΤΡΑ > SIZE=1> ΕΙΣΕΡΧΟΜΕΝΕΣ ΟΜΑΔΕΣ > SIZE=1> ΧΡΟΝΟΙ ΚΛΗΣΕΩΝ > SIZE=1> ΟΜΑΔΕΣ ΧΡΗΣΤΗ > SIZE=1> ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ > ΑΝΑΦΟΡΕΣ
  ΛΙΣΤΑ ΧΡΗΣΤΩΝ     |     ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΗΣΤΗ     |     ΑΝΑΖΗΤΗΣΗ ΧΡΗΣΤΗ
  ΠΡΟΣΘΗΚΗ ΕΚΣΤΡΑΤΕΙΑΣ     |     ΛΙΣΤΑ ΕΚΣΤΡΑΤΕΙΩΝ
  ΕΜΦΑΝΙΣΗ ΛΙΣΤΩΝ     |     ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΛΙΣΤΑΣ     |     ΑΝΑΖΗΤΗΣΗ ΟΔΗΓΟΥ |     ΠΡΟΣΘΕΣΤΕ ΤΟΝ ΑΡΙΘΜΟ ΣΕ DNC           |     ΕΙΣΑΓΩΓΗ ΝΕΩΝ ΟΔΗΓΩΝ
  ΠΡΟΣΘΕΣΕ ΒΟΗΘΟ     |     ΕΜΦΑΝΙΣΗ ΒΟΗΘΩΝ
  ΠΡΟΣΘΕΣΕ ΦΙΛΤΡΟ     |     ΕΜΦΑΝΙΣΗ ΦΙΛΤΡΩΝ
  ΕΜΦΑΝΙΣΗ ΕΙΣΕΡΧΟΜΕΝΩΝ ΟΜΑΔΩΝ     |     ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΕΙΣΕΡΜΟΜΕΝΗΣ ΟΜΑΔΑΣ
  ΕΜΦΑΝΙΣΗ ΧΡΟΝΩΝ ΚΛΗΣΕΩΝ     |     ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΟΝΟΥ ΚΛΗΣΗΣ     |     ΕΜΦΑΝΙΣΗ ΧΡΟΝΩΝ ΚΛΗΣΕΩΝ ΚΑΤΑΣΤΑΣΕΩΝ     |     ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ  
  ΠΡΟΣΘΗΚΗ ΟΜΑΔΑΣ ΧΡΗΣΤΗ     |     ΛΙΣΤΑ ΟΜΑΔΩΝ ΧΡΗΣΤΗ     |     ΩΡΙΑΙΑ ΟΜΔΟΠΟΙΗΣΗ
  ΕΜΦΑΝΙΣΗ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ     |     ΠΡΟΣΘΗΚΗ ΝΕΩΝ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ
 
+
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΗΣΤΗ
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "$NWB#vicidial_users-user_group$NWE\n"; +echo "\n"; +echo "
Αριθμός Χρήστη: $NWB#vicidial_users-user$NWE
Κωδικός:$NWB#vicidial_users-pass$NWE
Πλήρες Ονομα: $NWB#vicidial_users-full_name$NWE
Επίπεδο Χρήστη: $NWB#vicidial_users-user_level$NWE
Ομάδα Χρήστη:
Τηλέφωνο Σύνδεσης: $NWB#vicidial_users-phone_login$NWE
Κωδικός Πρόσβασης Τηλεφώνου: $NWB#vicidial_users-phone_pass$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΕΚΣΤΡΑΤΕΙΑΣ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Εκστρατείας: $NWB#vicidial_campaigns-campaign_id$NWE
Ονομα Εκστρατείας: $NWB#vicidial_campaigns-campaign_name$NWE
Ενεργή:$NWB#vicidial_campaigns-active$NWE
Τηλ.σύνδ. Στάθμευσης: $NWB#vicidial_campaigns-park_ext$NWE
Ονομα Αρχείου Στάθμευσης: $NWB#vicidial_campaigns-park_file_name$NWE
Ιστο-σελίδα: $NWB#vicidial_campaigns-web_form_address$NWE
Επιτρέπω τους Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Επίπεδο Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
ΕΠΙΠΕΔΟ ΑΥΤΟΜΑΤΗΣ ΚΛΗΣΗΣ: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Επόμενη Κλήση Χειριστή: $NWB#vicidial_campaigns-next_agent_call$NWE
Χρόνος Τοπικής Κλήσης: $NWB#vicidial_campaigns-local_call_time$NWE
ΦΩΝΗΤΙΚΟ ΤΑΧΥΔΡΟΜΕΙΟ: $NWB#vicidial_campaigns-voicemail_ext$NWE
Βοηθός: $NWB#vicidial_campaigns-campaign_script$NWE
Κατά την έναρξη κλήσης: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Λίστας: (μόνο αριθμοί)$NWB#vicidial_lists-list_id$NWE
Ονομα Λίστας: $NWB#vicidial_lists-list_name$NWE
Εκστρατεία: $NWB#vicidial_lists-campaign_id$NWE
Ενεργή:$NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) +{ +echo "
\n"; +echo ""; + +if (strlen($phone_number) > 2) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DNC ΠΡΟΣΤΙΘΈΜΕΝΟ - αυτός ο τηλεφωνικός αριθμός είναι ήδη δενκαλεί τον κατάλογο: $phone_number

\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');"; + $rslt=mysql_query($stmt, $link); + + echo "
DNC ΠΡΟΣΤΙΘΈΜΕΝΟ: $phone_number

\n"; + + ### LOG INSERTION TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW DNC NUMBER|$PHP_AUTH_USER|$ip|'$phone_number'|\n"); + fclose($fp); + } + } + } + +echo "
ΠΡΟΣΘΕΣΤΕ έναν ΑΡΙΘΜΟ στον ΚΑΤΑΛΟΓΟ DNC\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
Τηλεφωνικός αριθμός: (μόνο αριθμοί)$NWB#vicidial_list-dnc$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΕΙΣΕΡΧΟΜΕΝΗΣ ΟΜΑΔΑΣ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Ομάδας: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Ονομα Ομάδας: $NWB#vicidial_inbound_groups-group_name$NWE
Χρώμα Ομάδας: $NWB#vicidial_inbound_groups-group_color$NWE
Ενεργή:$NWB#vicidial_inbound_groups-active$NWE
Ιστο-σελίδα: $NWB#vicidial_inbound_groups-web_form_address$NWE
ΦΩΝΗΤΙΚΟ ΤΑΧΥΔΡΟΜΕΙΟ: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Επόμενη Κλήση Χειριστή: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Μπροστινή Οθόνη: $NWB#vicidial_inbound_groups-fronter_display$NWE
Βοηθός: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Κατά την έναρξη κλήσης: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΩΝ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Χρήστη Ξεκινά: (μόνο αριθμοί, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Αριθμός Γραμμών: (μόνο αριθμοί)$NWB#vicidial_remote_agents-number_of_lines$NWE
IP Διακομιστή: $NWB#vicidial_remote_agents-server_ip$NWE
Εξωτερική Τηλ. Σύνδεση: (ο αριθμός που κλήθηκε από το πλάνο κλήσεων για να καλέσει τους χειριστές)$NWB#vicidial_remote_agents-conf_exten$NWE
Κατάσταση:$NWB#vicidial_remote_agents-status$NWE
Εκστρατεία: $NWB#vicidial_remote_agents-campaign_id$NWE
Εισερχόμενες Ομάδες: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "ΣΗΜΕΙΩΣΗ: Μπορεί να διαρκέσει και 30 δευτερόλεπτα για να καταχωρηθούν οι αλλαγές της οθόνης\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΟΜΑΔΑΣ ΧΡΗΣΤΩΝ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Ομάδα: (όχι κενά ή στίξη)$NWB#vicidial_user_groups-user_group$NWE
Περιγραφή: (περιγραφή ομάδας)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW SCRIPT\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Ταυτότητα χειρογράφων:: (όχι κενά ή στίξη)$NWB#vicidial_scripts-script_id$NWE
Όνομα χειρογράφων: (τίτλος του βοηθού)$NWB#vicidial_scripts-script_name$NWE
Σχόλια χειρόγραφου: $NWB#vicidial_scripts-script_comments$NWE
Ενεργή:$NWB#vicidial_scripts-active$NWE
Κείμενο χειρόγραφου: $NWB#vicidial_scripts-script_text$NWE
\n"; + +} + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΕΣΕ ΦΙΛΤΡΟ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Φίλτρου: (όχι κενά ή στίξη)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Όνομα Φίλτρου: (σύντομη περιγραφή του φίλτρου)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Σχόλια Φίλτρου: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
SQL Φίλτρου: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; +} + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΟΝΟΥ ΚΛΗΣΗΣ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
ID Χρόνου Κλήσης: (όχι κενά ή στίξη)$NWB#vicidial_call_times-call_time_id$NWE
Ονομα Χρόνου Κλήσης: (σύντομη περιγραφή του χρόνου κλήσης)$NWB#vicidial_call_times-call_time_name$NWE
Σχόλια Χρόνου Κλήσης: $NWB#vicidial_call_times-call_time_comments$NWE
Οι επιλογές Ημέρας και ώρας θα εμφανιστούν όταν θα δημιουργήσετε τον Ορισμό Χρόνου Κλήσης
\n"; +} + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) +{ +echo "
\n"; +echo ""; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
ID Χρόνου Κλήσης Κατάστασης: (όχι κενά ή στίξη)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (όχι κενά ή στίξη)$NWB#vicidial_call_times-state_call_time_state$NWE
Ονομα Χρόνου Κλήσης Κατάτασης: (σύντομη περιγραφή του χρόνου κλήσης)$NWB#vicidial_call_times-call_time_name$NWE
Σχόλια Χρόνου Κλήσης Κατάστασης: $NWB#vicidial_call_times-call_time_comments$NWE
Οι επιλογές Ημέρας και ώρας θα εμφανιστούν όταν θα δημιουργήσετε τον Ορισμό Χρόνου Κλήσης
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Ο ΧΡΗΣΤΗΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη ένας χρήστης με αυτό τον αριθμό\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
Ο ΧΡΗΣΤΗΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το id χρήστη πρέπει να είναι μεταξύ 2 και 8 χαρακτήρες\n"; + echo "
το πλήρες όνομα και κωδικός πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + echo "
ΧΡΗΣΤΗΣ ΠΡΟΣΤΕΘΗΚΕ: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass'|\n"); + fclose($fp); + } + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Η ΕΚΣΤΡΑΤΕΙΑ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μία εκστρατεία με αυτό το ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
Η ΕΚΣΤΡΑΤΕΙΑ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το ID της εκστρατείας πρέπει να είναι μεταξύ 2 και 8 χαρακτήρες\n"; + echo "
το όνομα της εκστρατείας πρέπει να είναι μεταξύ 6 και 40 χαρακτήρες\n"; + } + else + { + echo "
ΕΚΣΤΡΑΤΕΙΑ ΠΡΟΣΤΕΘΗΚΕ: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('$campaign_id','$campaign_name','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo ""; + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΕΚΣΤΡΑΤΕΙΑΣ |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Η ΚΑΤΑΣΤΑΣΗ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη κατάσταση-εκστρατείας με αυτό το όνομα\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Η ΚΑΤΑΣΤΑΣΗ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μία καθολική-κατάσταση με αυτό το όνομα\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
Η ΚΑΤΑΣΤΑΣΗ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
η κατάσταση πρέπει να είναι μεταξύ 1 και 8 χαρακτήρρες\n"; + echo "
το όνομα της κατάστασης πρέπει να είναι μεταξύ 2 και 30 χαρακτήρρες\n"; + } + else + { + echo "
ΚΑΤΑΣΤΑΣΗ ΕΚΣΤΡΑΤΕΙΑΣ ΠΡΟΣΤΕΘΗΚΕ: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΕΚΣΤΡΑΤΕΙΑΣ STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } + } +$ADD=31; +} + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) +{ + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ΤΟ ΚΛΕΙΔΙ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη ένα κλειδί-εκστρατείας με αυτό το κλειδί\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
ΤΟ ΚΛΕΙΔΙ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το κλειδί πρέπει να είναι ένας χαρακτηράς μεταξύ 1 και 9 \n"; + echo "
η κατάσταση πρέπει να είναι μεταξύ 1 και 8 χαρακτήρρες\n"; + } + else + { + echo "
ΚΛΕΙΔΙ ΕΚΣΤΡΑΤΕΙΑΣ ΠΡΟΣΤΕΘΗΚΕ: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΕΚΣΤΡΑΤΕΙΑΣ HOTKEY |$PHP_AUTH_USER|$ip|'$status','$hotkey','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) +{ + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ΑΝΑΚΥΚΛΩΣΗΣ ΜΟΛΥΒΔΟΥ ΕΚΣΤΡΑΤΕΙΑΣ ΠΡΟΣΤΙΘΕΜΕΝΟΣ - υπάρχει ήδη έναςμόλυβδος-ανακύκλωσης για αυτήν την εκστρατεία με αυτήν την θέση\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
ΑΝΑΚΥΚΛΩΣΗΣ ΜΟΛΥΒΔΟΥ ΕΚΣΤΡΑΤΕΙΑΣ ΠΡΟΣΤΙΘΕΜΕΝΟΣ - παρακαλώ επιστρέψτεκαι εξετάστε τα στοιχεία που εισαγάγατε\n"; + echo "
η θέση πρέπει να είναι μεταξύ 1 και 6 χαρακτήρων στο μήκος\n"; + echo "
η καθυστέρηση προσπάθειας πρέπει να είναι τουλάχιστον 120δευτερόλεπτα\n"; + echo "
οι μέγιστες προσπάθειες πρέπει να είναι από 1 έως 10\n"; + } + else + { + echo "
ΑΝΑΚΥΚΛΩΣΗΣ ΜΟΛΥΒΔΟΥ ΕΚΣΤΡΑΤΕΙΑΣ ΠΡΟΣΤΙΘΕΜΕΝΟΣ: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Η ΛΙΣΤΑ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μία λίστα με αυτό το ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
Η ΛΙΣΤΑ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Το ID λίστας πρέπει να είναι μεταξύ 2 και 8 χαρακτήρες\n"; + echo "
Το όνομα λίστας πρέπει να είναι 2 χαρακτήρες\n"; + } + else + { + echo "
ΛΙΣΤΑ ΠΡΟΣΤΕΘΗΚΕ: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + } + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Η ΟΜΑΔΑ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μία ομάδα με αυτό το ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
Η ΟΜΑΔΑ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Το ID ομάδας πρέπει να είναι μεταξύ 2 και 20 χαρακτήρες ' -+'.\n"; + echo "
Το όνομα και χρώμα ομάδας πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + echo "
ΟΜΑΔΑ ΠΡΟΣΤΕΘΗΚΕ: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ΟΙ ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΑΝ - υπάρχει ήδη καταχώρηση απομακρυσμένων χειριστών που ξεκινάει με αυτό το ID χρήστη\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
ΟΙ ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΑΝ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Το ID χρήστη και η εξωτερική εσωτ.σύνδεση πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΠΡΟΣΤΕΘΗΚΑΝ: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + } + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ Η ΟΜΑΔΑ ΧΡΗΣΤΗ - υπάρχει ήδη μία καταχώρηση ομάδας χρήστη με αυτό το όνομα\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ Η ΟΜΑΔΑ ΧΡΗΣΤΗ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Η ομάδα και η περιγραφή πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
ΟΜΑΔΑ ΧΡΗΣΤΗ ΠΡΟΣΤΕΘΗΚΕ: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΧΡΗΣΤΗ GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + } + } + } +$ADD=100000; +} + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Ο ΒΟΗΘΟΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μια είσοδος χειρογράφων με αυτό το όνομα\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
Ο ΒΟΗΘΟΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το όνομα, η περιγραφή και το κείμενο χειρογράφων πρέπει να είναι τουλάχιστον 2 χαρακτήρες στο μήκος\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + + echo "
Ο ΒΟΗΘΟΣ ΠΡΟΣΤΕΘΗΚΕ: $script_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000000; +} + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ΤΟ ΦΙΛΤΡΟ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη ένα φίλτρο με αυτό το ID\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
ΤΟ ΦΙΛΤΡΟ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
ID φίλτρου, όνομα και SQL πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='$lead_filter_sql';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΤΟ ΦΙΛΤΡΟ ΠΡΟΣΤΕΘΗΚΕ: $lead_filter_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=10000000; +} + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Ο ΟΡΙΣΜΟΣ ΧΡΟΝΟΥ ΚΛΗΣΗ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - υπάρχει ήδη μία εγγραφή χρόνου κλήσης με αυτό το ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
Ο ΟΡΙΣΜΟΣ ΧΡΟΝΟΥ ΚΛΗΣΗ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID Χρόνου Κλήσης και το όνομα πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΠΡΟΣΘΗΚΗ ΧΡΟΝΟΥ ΚΛΗΣΗΣ: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + } +$ADD=311111111; +} + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
Ο ΟΡΙΣΜΟΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - υπάρχει ήδη μία εγγραφή χρόνου κλήσης με αυτό το ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
Ο ΟΡΙΣΜΟΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ ΔΕΝ ΠΡΟΣΤΕΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID Χρόνου Κλήσης Κατάστασης, το όνομα και η κατάσταση πρέπει να είναι τουλάχιστον 2 χαρακτήρες \n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΠΡΟΣΘΗΚΗ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=3111111111; +} + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
Ο ΧΡΗΣΤΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Ο κωδικός και το πλήρες όνομα πρέπει να είναι τουλάχιστον 2 χαρακτήρες το κάθε ένα\n"; + } + else + { + echo "
ΧΡΗΣΤΗΣ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
Ο ΧΡΗΣΤΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Ο κωδικός και το πλήρες όνομα πρέπει να είναι τουλάχιστον 2 χαρακτήρες το κάθε ένα\n"; + } + else + { + echo "
ΧΡΗΣΤΗΣ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
Ο ΧΡΗΣΤΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Ο κωδικός και το πλήρες όνομα πρέπει να είναι τουλάχιστον 2 χαρακτήρες το κάθε ένα\n"; + } + else + { + echo "
ΧΡΗΣΤΗΣ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
Η ΕΚΣΤΡΑΤΕΙΑ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το όνομα της εκστρατείας πρέπει να είναι τουλάχιστον 6 χαρακτήρες\n"; + } + else + { + echo "
ΕΣΤΡΑΤΕΙΑ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
ΕΠΑΝΑΦΟΡΑ ΚΑΘΟΘΗΓΗΤΗ ΕΚΣΤΡΑΤΕΙΑΣ HOPPER\n"; + echo "
- Αναμονή 1 λεπτού πριν την κλήση του επόμενου αριθμού\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
Η ΚΑΤΑΣΤΑΣΗ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το ID της εκστρατείας πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + echo "
η κατάσταση της εκστρατείας πρέπει να είναι τουλάχιστον 1 χαρακτήρας\n"; + } + else + { + echo "
ΔΙΑΓΡΑΦΗΚΕ Η ΠΡΟΣΑΡΜΟΣΜΕΝΗ ΚΑΤΑΣΤΑΣΗ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
ΤΟ ΚΛΕΙΔΙ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το ID της εκστρατείας πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + echo "
η κατάσταση της εκστρατείας πρέπει να είναι τουλάχιστον 1 χαρακτήρας\n"; + echo "
το κλειδί της εκστρατείας πρέπει να είναι τουλάχιστον 1 χαρακτήρας\n"; + } + else + { + echo "
ΔΙΑΦΡΑΦΗΚΕ ΤΟ ΠΡΟΣΑΡΜΟΣΜΕΝΟ ΚΛΕΙΔΙ ΤΗΣ ΕΚΣΤΡΑΤΕΙΑΣ: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
Η ΕΚΣΤΡΑΤΕΙΑ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το όνομα της εκστρατείας πρέπει να είναι τουλάχιστον 6 χαρακτήρες\n"; + } + else + { + echo "
ΕΣΤΡΑΤΕΙΑ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level',lead_filter_id='$lead_filter_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
ΕΠΑΝΑΦΟΡΑ ΚΑΘΟΘΗΓΗΤΗ ΕΚΣΤΡΑΤΕΙΑΣ HOPPER\n"; + echo "
- Αναμονή 1 λεπτού πριν την κλήση του επόμενου αριθμού\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG HOPPER RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=34; # go to campaign modification form below +} + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
η θέση πρέπει να είναι μεταξύ 1 και 6 χαρακτήρων στο μήκος\n"; + echo "
η καθυστέρηση προσπάθειας πρέπει να είναι τουλάχιστον 120δευτερόλεπτα\n"; + echo "
οι μέγιστες προσπάθειες πρέπει να είναι από 1 έως 10\n"; + } + else + { + echo "
CAMPAIGN LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
Η ΛΙΣΤΑ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
η λίστα πρέπει να είναι τουλαχιστον 2 χαρακτήρες\n"; + } + else + { + echo "
ΛΙΣΤΑ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
ΕΠΑΝΑΦΟΡΑ ΚΑΤΑΣΤΑΣΗΣ ΚΛΗΣΗΣ ΛΙΣΤΑΣ\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + } + if ($campaign_id != "$old_campaign_id") + { + echo "
ΑΠΟΜΑΚΡΥΝΣΗ ΚΑΘΟΔΗΓΗΤΩΝ ΛΙΣΤΑΣ HOPPER ΑΠΟ ΠΑΛΑΙΑ HOPPER ΕΚΣΤΡΑΤΕΙΑ ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + } + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
Η ΟΜΑΔΑ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
το όνομα και χρώμα ομάδας πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + echo "
ΟΜΑΔΑ ΤΡΟΠΟΠΟΙΗΘΗΚΕ: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_message='$drop_message',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111; # go to in-group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΑΝ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Το ID του χρήστη και η εξωτερική εσωτ.σύνδεση πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΤΡΟΠΟΠΟΙΗΘΗΚΑΝ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
Η ΟΜΑΔΑ ΧΡΗΣΤΗ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n"; + echo "
Η ομάδα και η περιγραφή πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΟΜΑΔΑ ΧΡΗΣΤΗ ΤΡΟΠΟΠΟΙΗΘΗΚΕ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + } + } + +$ADD=311111; # go to user group modification form below +} + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
Ο ΒΟΗΘΟΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το όνομα, η περιγραφή και το κείμενο χειρογράφων πρέπει να είναι τουλάχιστον 2 χαρακτήρες στο μήκος\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
Ο ΒΟΗΘΟΣ ΤΡΟΠΟΠΟΙΗΘΗΚΕ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111; # go to script modification form below +} + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
ΤΟ ΦΙΛΤΡΟ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
ID φίλτρου, όνομα και SQL πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='$lead_filter_sql' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΤΟ ΦΙΛΤΡΟ ΤΡΟΠΟΠΟΙΗΘΗΚΕ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31111111; # go to filter modification form below +} + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
ΧΟΝΟΣ ΚΛΗΣΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID Χρόνου Κλήσης και το όνομα πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΤΡΟΠΟΠΟΙΗΘΗΚΕ ΧΡΟΝΟΣ ΚΛΗΣΗΣ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + +$ADD=311111111; # go to call time modification form below +} + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
ΧΡΟΝΟΣ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID Χρόνου Κλήσης Κατάστασης, το όνομα και η κατάσταση πρέπει να είναι τουλάχιστον 2 χαρακτήρες \n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΤΡΟΠΟΠΟΙΗΘΗΚΕ ΧΡΟΝΟΣ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111111; # go to state call time modification form below +} + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
ΧΡΗΣΤΗΣ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΧΡΗΣΤΗ: $user\n"; + echo "

Χτυπήστε εδώ για να διαγράψετε το χρήστη $user


\n"; + } + +$ADD='3'; # go to user modification below +} + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
ΕΚΣΤΡΑΤΕΙΑ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Εκστρατεία_id be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΕΚΣΤΡΑΤΕΙΑΣ: $campaign_id\n"; + echo "

Χτυπήστε εδώ για να διαγράψετε την εκστρατεία $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
ΧΕΙΡΙΣΤΕΣ ΠΟΥ ΔΕΝ ΕΙΝΑΙ ΑΠΟΣΥΝΔΕΜΕΝΟΙ ΑΠΟ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Εκστρατεία_id be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΑΠΟΣΥΝΔΕΣΗΣ ΧΕΙΡΙΣΤΩΝ: $campaign_id\n"; + echo "

Επιλέξτε εδώ για να αποσυνδέσετε όλους τους χειριστές από $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) +{ + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
ΛΙΣΤΑ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΛΙΣΤΑΣ: $list_id\n"; + echo "

Χτυπήστε εδώ για να διαγράψετε τον κατάλογο και όλους τους οδηγούς του $list_id


\n"; + } + +$ADD='311'; # go to campaign modification below +} + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
ΕΙΣ-ΟΜΑΔΑ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΕΙΣ-ΟΜΑΔΑΣ: $group_id\n"; + echo "

Χτυπήστε εδώ για να διαγράψετε την-ΟΜΑΔΑ $group_id


\n"; + } + +$ADD='3111'; # go to in-group modification below +} + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΣ ΧΕΙΡΙΣΤΗΣ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ : $remote_agent_id\n"; + echo "

Επιλέξτε εδώ για να διαγράψετε τον απομακρυσμένο χειριστή $remote_agent_id


\n"; + } + +$ADD='31111'; # go to remote agent modification below +} + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
ΟΜΑΔΑ ΧΡΗΣΤΗ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΟΜΑΔΑΣ ΧΡΗΣΤΩΝ: $user_group\n"; + echo "

Χτυπήστε εδώ για να διαγράψετε την ομάδα χρηστών $user_group


\n"; + } + +$ADD='311111'; # go to user group modification below +} + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ Ο ΒΟΗΘΟΣ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΒΟΗΘΟΥ: $script_id\n"; + echo "

επιλέξτε εδώ για να διαγράψετε τον βοηθό $script_id


\n"; + } + +$ADD='3111111'; # go to script modification below +} + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
ΤΟ ΦΙΛΤΡΟ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
To ID φίλτρου πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Πατήστε εδώ για διαγραφή του φίλτρου$lead_filter_id


\n"; + } + +$ADD='31111111'; # go to filter modification below +} + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Ο ΧΡΟΝΟΣ ΚΛΗΣΗΣ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID χρόνου κλήσης πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ: $call_time_id\n"; + echo "

Click here to delete call time $call_time_id


\n"; + } + +$ADD='311111111'; # go to call time modification below +} + +###################### +# ADD=5111111111 confirmation before deletion of call time record +###################### + +if ($ADD==5111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Ο ΧΡΟΝΟΣ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID χρόνου κλήσης πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + echo "
ΕΠΙΒΕΒΑΙΩΣΗ ΔΙΑΓΡΑΦΗΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ: $call_time_id\n"; + echo "

Click here to delete state call time $call_time_id


\n"; + } + +$ADD='3111111111'; # go to state call time modification below +} + + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
ΧΡΗΣΤΗΣ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING USER!!!!|$PHP_AUTH_USER|$ip|user='$user'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΧΡΗΣΤΗ ΟΛΟΚΛΗΡΩΘΗΚΕ: $user\n"; + echo "

\n"; + } + +$ADD='0'; # go to user list +} + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) +{ + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
ΕΚΣΤΡΑΤΕΙΑ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Εκστρατεία_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
ΑΠΟΜΑΚΡΥΝΣΗ ΚΑΘΟΔΗΓΗΤΩΝ ΛΙΣΤΑΣ HOPPER ΑΠΟ ΠΑΛΑΙΑ HOPPER ΕΚΣΤΡΑΤΕΙΑ ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!DELETING CAMPAIGN!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΕΚΣΤΡΑΤΕΙΑΣ ΟΛΟΚΛΗΡΩΘΗΚΕ: $campaign_id\n"; + echo "

\n"; + } + +$ADD='10'; # go to campaigns list +} + +###################### +# ADD=62 Logout all agents fro a campaign +###################### + +if ($ADD==62) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
ΧΕΙΡΙΣΤΕΣ ΠΟΥ ΔΕΝ ΕΙΝΑΙ ΑΠΟΣΥΝΔΕΜΕΝΟΙ ΑΠΟ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Εκστρατεία_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!ΧΕΙΡΙΣΤΗΣLOGOUT!!!!!!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
ΑΠΟΣΥΝΔΕΣΗ ΧΕΙΡΙΣΤΩΝ ΟΛΟΚΛΗΡΩΘΗΚΕ: $campaign_id\n"; + echo "

\n"; + } + +$ADD='31'; # go to campaign modification below +} + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
ΑΝΑΚΥΚΛΩΣΗΣ ΜΟΛΥΒΔΟΥ ΕΚΣΤΡΑΤΕΙΑΣ ΠΟΥ ΔΕΝ ΔΙΑΓΡΑΦΕΤΑΙ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
η θέση πρέπει να είναι μεταξύ 1 και 6 χαρακτήρων στο μήκος\n"; + echo "
η καθυστέρηση προσπάθειας πρέπει να είναι τουλάχιστον 120δευτερόλεπτα\n"; + echo "
οι μέγιστες προσπάθειες πρέπει να είναι από 1 έως 10\n"; + } + else + { + echo "
ΑΝΑΚΥΚΛΩΣΗΣ ΜΟΛΥΒΔΟΥ ΕΚΣΤΡΑΤΕΙΑΣ ΠΟΥ ΔΙΑΓΡΑΦΕΤΑΙ: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) +{ + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
ΛΙΣΤΑ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
ΑΠΟΜΑΚΡΥΝΣΗ ΚΑΘΟΔΗΓΗΤΩΝ ΛΙΣΤΑΣ HOPPER ΑΠΟ ΠΑΛΑΙΑ HOPPER ΕΚΣΤΡΑΤΕΙΑ ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
ΑΦΑΙΡΕΣΗ ΤΩΝ ΜΟΛΥΒΔΩΝ ΚΑΤΑΛΟΓΩΝ ΑΠΟ ΤΟΝ ΠΊΝΑΚΑ VICIDIAL_LIST\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING LIST!!!!|$PHP_AUTH_USER|$ip|list_id='$list_id'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΛΙΣΤΑΣ ΟΛΟΚΛΗΡΩΘΗΚΕ: $list_id\n"; + echo "

\n"; + } + +$ADD='100'; # go to lists list +} + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
ΕΙΣ-ΟΜΑΔΑ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_groups where group_id='$group_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING IN-GROUP!!|$PHP_AUTH_USER|$ip|group_id='$group_id'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΕΙΣ-ΟΜΑΔΑΣ ΟΛΟΚΛΗΡΩΘΗΚΕ: $group_id\n"; + echo "

\n"; + } + +$ADD='1000'; # go to in-group list +} + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΣ ΧΕΙΡΙΣΤΗΣ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING RMTAGENT!!|$PHP_AUTH_USER|$ip|remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ ΟΛΟΚΛΗΡΩΘΗΚΕ: $remote_agent_id\n"; + echo "

\n"; + } + +$ADD='10000'; # go to remote agents list +} + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
ΟΜΑΔΑ ΧΡΗΣΤΗ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING USRGROUP!!|$PHP_AUTH_USER|$ip|user_group='$user_group'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΟΜΑΔΑΣ ΧΡΗΣΤΩΝ ΟΛΟΚΛΗΡΩΘΗΚΕ: $user_group\n"; + echo "

\n"; + } + +$ADD='100000'; # go to user group list +} + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ Ο ΒΟΗΘΟΣ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING SCRIPT!!!!|$PHP_AUTH_USER|$ip|script_id='$script_id'|\n"); + fclose($fp); + } + echo "
ΔΙΑΓΡΑΦΗ ΒΟΗΘΟΥ ΟΛΟΚΛΗΡΩΘΗΚΕ: $script_id\n"; + echo "

\n"; + } + +$ADD='1000000'; # go to script list +} + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
ΤΟ ΦΙΛΤΡΟ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
To ID φίλτρου πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING FILTER!!!!|$PHP_AUTH_USER|$ip|lead_filter_id='$lead_filter_id'|\n"); + fclose($fp); + } + echo "
Η ΔΙΑΓΡΑΦΗ ΤΟΥ ΦΙΛΤΡΟΥ ΟΛΟΚΛΗΡΩΘΗΚΕ: $lead_filter_id\n"; + echo "

\n"; + } + +$ADD='10000000'; # go to filter list +} + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Ο ΧΡΟΝΟΣ ΚΛΗΣΗΣ ΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID χρόνου κλήσης πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
ΟΛΟΚΛΗΡΩΣΗ ΔΙΑΓΡΑΦΗΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ: $call_time_id\n"; + echo "

\n"; + } + +$ADD='100000000'; # go to call times list +} + + +###################### +# ADD=6111111111 delete call times record +###################### + +if ($ADD==6111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
Ο ΧΡΟΝΟΣ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣΔΕΝ ΔΙΑΓΡΑΦΗΚΕ - Παρακαλώ επιστρέψτε πίσω και κάνετε έλεγχο των δεδομένων που καταχωρήσατε\n"; + echo "
Το ID χρόνου κλήσης πρέπει να είναι τουλάχιστον 2 χαρακτήρες\n"; + } + else + { + $stmt="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + + while ($sct_to_print > $o) { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "Απομάκρυνση Κανόνα Κατάστασης: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|state_call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
ΟΛΟΚΛΗΡΩΣΗ ΔΙΑΓΡΑΦΗΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ: $call_time_id\n"; + echo "

\n"; + } + +$ADD='1000000000'; # go to call times list +} + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + +if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
Δεν έχετε τις άδειες να τροποποιήσετε αυτόν τον χρήστη: $row[1]\n"; + } +else + { + echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΧΡΗΣΤΩΝ: $row[1]\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($LOGuser_level > 8) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "
Αριθμός Χρήστη: $row[1]$NWB#vicidial_users-user$NWE
Κωδικός:$NWB#vicidial_users-pass$NWE
Πλήρες Ονομα: $NWB#vicidial_users-full_name$NWE
Επίπεδο Χρήστη: $NWB#vicidial_users-user_level$NWE
Ομάδα Χρήστη: $NWB#vicidial_users-user_group$NWE
Τηλέφωνο Σύνδεσης: $NWB#vicidial_users-phone_login$NWE
Κωδικός Πρόσβασης Τηλεφώνου: $NWB#vicidial_users-phone_pass$NWE
ΕΠΙΛΟΓΕΣ ΕΠΙΦΑΝΕΙΑΣ ΕΡΓΑΣΙΑΣ ΧΕΙΡΙΣΤΩΝ:
Ο χειριστής επιλέγει Εισ.Ομάδες: $NWB#vicidial_users-agent_choose_ingroups$NWE
Ενεργά Κλειδιά: $NWB#vicidial_users-hotkeys_active$NWE
Προγραμματισμένες Επανακλήσεις: $NWB#vicidial_users-scheduled_callbacks$NWE
Μόνο του Χειριστή Επανακλήσεις: $NWB#vicidial_users-agentonly_callbacks$NWE
Εγχειρίδιο κλήσεων Χειριστή: $NWB#vicidial_users-agentcall_manual$NWE
Καταγραφή: $NWB#vicidial_users-vicidial_recording$NWE
Μεταφορές: $NWB#vicidial_users-vicidial_transfers$NWE
Η πιό στενή προεπιλογή συνδύασε: $NWB#vicidial_users-closer_default_blended$NWE
Εισερχόμενες Ομάδες: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_users-closer_campaigns$NWE
ΕΠΙΛΟΓΈΣ ΕΠΙΦΑΝΕΙΑΣ ΕΡΓΑΣΙΑΣ ΔΙΑΧ:
Αλλάξτε τις επιλογές επιφάνειας εργασίας των χειριστών: $NWB#vicidial_users-alter_agent_interface_options$NWE
Διάγραψε τους χρήστες: $NWB#vicidial_users-delete_users$NWE
Διάγραψε τις ομάδες χρηστών: $NWB#vicidial_users-delete_user_groups$NWE
Διάγραψε τις Λίστες: $NWB#vicidial_users-delete_lists$NWE
Διάγραψε τις εκστρατείες: $NWB#vicidial_users-delete_campaigns$NWE
Διάγραψε τις Εισ-ΟΜΑΔΕΣ: $NWB#vicidial_users-delete_ingroups$NWE
Διάγραψε τους Απομακρυσμένους Χειριστές: $NWB#vicidial_users-delete_remote_agents$NWE
Διάγραψε τον Βοηθόs: $NWB#vicidial_users-delete_scripts$NWE
Εισαγωγή Οδηγών: $NWB#vicidial_users-load_leads$NWE
Λεπτομέρειες εκστρατείας: $NWB#vicidial_users-campaign_detail$NWE
Πρόσβαση AGC Admin: $NWB#vicidial_users-ast_admin_access$NWE
Το AGC διαγράφει τα τηλέφωνα: $NWB#vicidial_users-ast_delete_phones$NWE
Τροποποίηση Οδηγών: $NWB#vicidial_users-modify_leads$NWE
Αλλαγή Εκστρατείας Χειριστή: $NWB#vicidial_users-change_agent_campaign$NWE
Διαγραφή Φίλτρουs: $NWB#vicidial_users-delete_filters$NWE
Διαγραφή Χρόνου Κλήσηςs: $NWB#vicidial_users-delete_call_times$NWE
Τροποποίηση Χρόνου Κλήσηςs: $NWB#vicidial_users-modify_call_times$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΟΝ ΤΟΝ ΧΡΗΣΤΗ\n"; + } + echo "

Επιλέξτε εδώ για την σελίδα με τους χρόνους χρήσης\n"; + echo "

Επιλέξτε εδώ για τη κατάσταση του χρήστη\n"; + echo "

Πατήστε εδώ για στατιστικά χρήστη\n"; + echo "

Επιλέξτε εδώ για τις Επανακλήσεις του χρήστη που κρατήθηκαν\n"; + } + +} + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed + +if ($ADD==31) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $safe_harbor_message = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; +# $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΕΚΣΤΡΑΤΕΙΩΝ: $row[0] - Βασική Επισκόπηση"; +echo " | Αναλυτική Επισκόπηση | "; +echo "Πραγματικού Χρόνου Οθόνη\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +if (eregi("CLOSER", $campaign_id)) + { + echo "\n"; + } + + + +echo "\n"; +echo "
ID Εκστρατείας: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Ονομα Εκστρατείας: $NWB#vicidial_campaigns-campaign_name$NWE
Ενεργή:$NWB#vicidial_campaigns-active$NWE
Τηλ.σύνδ. Στάθμευσης: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Ιστο-σελίδα: $NWB#vicidial_campaigns-web_form_address$NWE
Επιτρέπω τους Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Κατάσταση κλήσης1: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης2: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης3: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης4: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης5: $NWB#vicidial_campaigns-dial_status$NWE
Σειρά Λίστας: $NWB#vicidial_campaigns-lead_order$NWE
Φίλτρο Οδηγού: $NWB#vicidial_campaigns-lead_filter_id$NWE
Επίπεδο Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Αναγκαστική Επαναφορά του Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
ΕΠΙΠΕΔΟ ΑΥΤΟΜΑΤΗΣ ΚΛΗΣΗΣ: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Επόμενη Κλήση Χειριστή: $NWB#vicidial_campaigns-next_agent_call$NWE
Χρόνος Τοπικής Κλήσης: $NWB#vicidial_campaigns-local_call_time$NWE
Κλήση εκτός χρόνου: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Πρόθεμα Κλήσης: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
CallerID Εκστρατείας: $NWB#vicidial_campaigns-campaign_cid$NWE
Εκστρατείας VDAD εσωτ.σύνδεση: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Επέκταση εκστρατείας Ηχογρ: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Ηχογράφηση εκστρατείας: $NWB#vicidial_campaigns-campaign_recording$NWE
Όνομα αρχείου εκστρατείας Ηχογρ: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Κατά την έναρξη κλήσης: $NWB#vicidial_campaigns-get_call_launch$NWE
Μήνυμα Αυτόματου Τηλεφωνητή: $NWB#vicidial_campaigns-am_message_exten$NWE
AMD στέλνει στο VM: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
DTMF Μεταφοράς-Συνδ 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Αριθμός Μεταφοράς-Συνδ 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
DTMF Μεταφοράς-Συνδ 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Αριθμός Μεταφοράς-Συνδ 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Κλήση Εναλ Αριθμού: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Προγραμματισμένες Επανακλήσεις: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Δευτερ. Εγκαταλ. Κλήσης: $NWB#vicidial_campaigns-drop_call_seconds$NWE
ΦΩΝΗΤΙΚΟ ΤΑΧΥΔΡΟΜΕΙΟ: $NWB#vicidial_campaigns-voicemail_ext$NWE
Χρήση μηνύματος Ασφαλούς Φιλοξενίας: $NWB#vicidial_campaigns-safe_harbor_message$NWE
Εσωτ.Σύνδεση Ασφαλούς Φιλοξενίας: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Δευτερ Τυλίγματος: $NWB#vicidial_campaigns-wrapup_seconds$NWE
Μήνυμα Τυλίγματος: $NWB#vicidial_campaigns-wrapup_message$NWE
Εσωτερικός κατάλογος DNC χρήσης: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Εισερχόμενες ομάδες:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
\n"; + +echo "
\n"; +echo "
ΛΙΣΤΕΣ ΣΤΗΝ ΕΚΣΤΡΑΤΕΙΑ:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ID ΛΙΣΤΑΣΟΝΟΜΑ ΛΙΣΤΑΣΕΝΕΡΓΑ
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Αυτή η εκστρατεία έχει$active_lists ενεργές λίστες και$inactive_lists Μη ενεργές λίστες

\n"; + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - ΑΠΟΚΡΥΨΗ

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - ΕΜΦΑΝΙΣΗ

"; + } + + + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "Αυτή η εκστρατεία έχει$hopper_leads >οδηγοί στον hopper κλήσεων<

\n"; +echo "Πατήστε εδώ για να δείτε ποιοι οδηγοί είναι στον hopper τώρα

\n"; +echo "Επιλέξτε εδώ για να δείτε τις κρατειμένες Επανακλήσεις σε αυτήν την εκστρατεία

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
ΠΡΟΣΑΡΜΟΣΜΕΝΕΣ ΚΑΤΑΣΤΑΣΕΙΣ ΣΤΗΝ ΕΚΣΤΡΑΤΕΙΑ:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ΚΑΤΑΣΤΑΣΗΠΕΡΙΓΡΑΦΗΕΠΙΛΕΞΙΜΟΔΙΑΓΡΑΦΗ
$rowx[0]$rowx[1]$rowx[2]ΔΙΑΓΡΑΦΗ
\n"; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΑΣ ΠΡΟΣΑΡΜΟΣΜΕΝΗΣ ΚΑΤΑΣΤΑΣΗΣ ΣΤΗΝ ΕΚΣΤΡΑΤΕΙΑ
\n"; +echo "\n"; +echo "\n"; +echo "Κατάσταση:   \n"; +echo "Περιγραφή:   \n"; +echo "Επιλέξιμο:   \n"; +echo "
\n"; + +echo "

\n"; + + + +echo "
ΠΡΟΣΑΡΜΟΣΜΕΝΑ ΚΛΕΙΔΙΑ ΣΤΗΝ ΕΚΣΤΡΑΤΕΙΑ:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ΚΛΕΙΔΙΚΑΤΑΣΤΑΣΗΠΕΡΙΓΡΑΦΗΔΙΑΓΡΑΦΗ
$rowx[1]$rowx[0]$rowx[2]ΔΙΑΓΡΑΦΗ
\n"; + +echo "
ΠΡΟΣΘΗΚΗ ΝΕΟΥ ΠΡΟΣΑΡΜΟΣΜΕΝΟΥ ΚΛΕΙΔΙΟΥ ΕΚΣΤΡΑΤΕΙΑΣ
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Κλειδί:   \n"; +echo "Κατάσταση:   \n"; +echo "
\n"; +echo "

\n"; + + + +echo "

ΑΝΑΚΥΚΛΩΣΗ ΜΟΛΥΒΔΟΥ ΜΕΣΑ ΣΕ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ:   $NWB#vicidial_lead_recycle$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +echo "
ΚΑΤΑΣΤΑΣΗΚΑΘΥΣΤΕΡΗΣΗ ΠΡΟΣΠΑΘΕΙΑΣΜΕΓΙΣΤΟ ΠΡΟΣΠΑΘΕΙΑΣΕΝΕΡΓΑ ΔΙΑΓΡΑΦΗ
$rowx[2]
\n"; + echo "\n"; + echo "\n"; + echo "
ΔΙΑΓΡΑΦΗ
\n"; + +echo "
ΠΡΟΣΘΕΣΤΕ ΤΟ ΝΕΟ ΜΟΛΥΒΔΟ ΕΚΣΤΡΑΤΕΙΑΣ ΑΝΑΚΥΚΛΩΣΗΣ
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Κατάσταση:   \n"; +echo "Καθυστέρηση προσπάθειας: \n"; +echo "Μέγιστο προσπάθειας: \n"; +echo "
\n"; + +echo "

\n"; + +echo "ΑΠΟΣΥΝΔΕΣΗ ΟΛΩΝ ΤΩΝ ΧΕΙΡΙΣΤΩΝ ΑΠΟ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ

\n"; + +if ($LOGdelete_campaigns > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ\n"; + } + +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ($ADD==34) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Βασική Επισκόπηση | "; +echo "Αναλυτική Επισκόπηση | "; +echo "Πραγματικού Χρόνου Οθόνη\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
ID Εκστρατείας: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Ονομα Εκστρατείας: $NWB#vicidial_campaigns-campaign_name$NWE
Ενεργή:$NWB#vicidial_campaigns-active$NWE
Τηλ.σύνδ. Στάθμευσης: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Ιστο-σελίδα: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Επιτρέπω τους Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Κατάσταση κλήσης1: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης2: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης3: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης4: $NWB#vicidial_campaigns-dial_status$NWE
Κατάσταση κλήσης5: $NWB#vicidial_campaigns-dial_status$NWE
Σειρά Λίστας: $NWB#vicidial_campaigns-lead_order$NWE
Φίλτρο Οδηγού: $NWB#vicidial_campaigns-lead_filter_id$NWE
Επίπεδο Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Αναγκαστική Επαναφορά του Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
ΕΠΙΠΕΔΟ ΑΥΤΟΜΑΤΗΣ ΚΛΗΣΗΣ: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Script: $script_id
Κατά την έναρξη κλήσης: $get_call_launch
\n"; + +echo "
\n"; +echo "
ΛΙΣΤΕΣ ΣΤΗΝ ΕΚΣΤΡΑΤΕΙΑ:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ID ΛΙΣΤΑΣΟΝΟΜΑ ΛΙΣΤΑΣΕΝΕΡΓΑ
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Αυτή η εκστρατεία έχει$active_lists ενεργές λίστες και$inactive_lists Μη ενεργές λίστες

\n"; + + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - ΑΠΟΚΡΥΨΗ

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - ΕΜΦΑΝΙΣΗ

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "Αυτή η εκστρατεία έχει$hopper_leads >οδηγοί στον hopper κλήσεων<

\n"; +echo "Πατήστε εδώ για να δείτε ποιοι οδηγοί είναι στον hopper τώρα

\n"; +echo "Επιλέξτε εδώ για να δείτε τις κρατειμένες Επανακλήσεις σε αυτήν την εκστρατεία

\n"; +echo "
\n"; + +echo "
\n"; + +echo "ΑΠΟΣΥΝΔΕΣΗ ΟΛΩΝ ΤΩΝ ΧΕΙΡΙΣΤΩΝ ΑΠΟ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ

\n"; + + +if ($LOGdelete_campaigns > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΗΝ ΤΗΝ ΕΚΣΤΡΑΤΕΙΑ\n"; + } + + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT * from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΛΙΣΤΑΣ: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Λίστας: $row[0]$NWB#vicidial_lists-list_id$NWE
Ονομα Λίστας: $NWB#vicidial_lists-list_name$NWE
Εκστρατεία: $NWB#vicidial_lists-campaign_id$NWE
Ενεργή:$NWB#vicidial_lists-active$NWE
ΕΠΑΝΑΦΟΡΑ ΚΑΤΑΣΤΑΣΗΣ ΚΛΗΣΗΣ ΟΔΗΓΟΥ ΓΙΑ ΤΗΝ ΛΙΣΤΑ: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
ΚΑΤΑΣΤΑΣΕΙΣ ΣΤΗΝ ΛΙΣΤΑ:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + +echo "\n"; +echo "\n"; + +echo "
ΚΑΤΑΣΤΑΣΗΟΝΟΜΑ ΚΑΤΑΣΤΑΣΗΣΚΛΗΘΕΝΤΑΜΗ ΚΛΗΘΕΝΤΑ
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
ΥΠΟΣΥΝΟΛΑ$lead_list[Y_count]$lead_list[N_count]
ΣΥΝΟΛΙΚΑ$lead_list[count]

\n"; +unset($lead_list); + + + + + +echo "
\n"; +echo "
ΖΩΝΕΣ ΩΡΑΣ ΣΤΗΝ ΛΙΣΤΑ:
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + +echo "\n"; +echo "\n"; + +echo "
GMT OFFSET (τοπικός χρόνος)ΚΛΗΘΕΝΤΑΜΗ ΚΛΗΘΕΝΤΑ
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
ΥΠΟΣΥΝΟΛΑ$lead_list[Y_count]$lead_list[N_count]
ΣΥΝΟΛΙΚΑ$lead_list[count]

\n"; +unset($lead_list); + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
ΜΕΤΡΗΣΗ ΚΛΗΣΕΩΝ ΣΤΗΝ ΛΙΣΤΑ:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + +echo "
ΚΑΤΑΣΤΑΣΗΟΝΟΜΑ ΚΑΤΑΣΤΑΣΗΣ$firstΥΠΟΣΥΝΟΛΟ
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
ΣΥΝΟΛΙΚΑ$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +if ($LOGdelete_lists > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΗ ΤΗΝ ΛΙΣΤΑ\n"; + } + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_message = $row[15]; + $drop_exten = $row[16]; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΓΓΡΑΦΗΣ ΟΜΑΔΩΝ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +echo "\n"; +echo "
ID Ομάδας: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Ονομα Ομάδας: $NWB#vicidial_inbound_groups-group_name$NWE
Χρώμα Ομάδας: $NWB#vicidial_inbound_groups-group_color$NWE
Ενεργή:$NWB#vicidial_inbound_groups-active$NWE
Ιστο-σελίδα: $NWB#vicidial_inbound_groups-web_form_address$NWE
Επόμενη Κλήση Χειριστή: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Μπροστινή Οθόνη: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Κατά την έναρξη κλήσης: $NWB#vicidial_inbound_groups-get_call_launch$NWE
DTMF Μεταφοράς-Συνδ 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Αριθμός Μεταφοράς-Συνδ 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
DTMF Μεταφοράς-Συνδ 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Αριθμός Μεταφοράς-Συνδ 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Δευτερ. Εγκαταλ. Κλήσης: $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
ΦΩΝΗΤΙΚΟ ΤΑΧΥΔΡΟΜΕΙΟ: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Χρήση μηνύματος Εγκατάλειψης: $NWB#vicidial_inbound_groups-drop_message$NWE
Εσωτ. Σύνδεση Εγκατάλειψης: $NWB#vicidial_inbound_groups-drop_exten$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +if ($LOGdelete_ingroups > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΗΝ ΤΗΝ ΕΙΣ-ΟΜΑΔΑ\n"; + } + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΚΑΤΑΧΩΡΗΣΗΣ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Χρήστη Ξεκινά: (μόνο αριθμοί, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Αριθμός Γραμμών: (μόνο αριθμοί)$NWB#vicidial_remote_agents-number_of_lines$NWE
IP Διακομιστή: $NWB#vicidial_remote_agents-server_ip$NWE
Εξωτερική Τηλ. Σύνδεση: (ο αριθμός που κλήθηκε από το πλάνο κλήσεων για να καλέσει τους χειριστές)$NWB#vicidial_remote_agents-conf_exten$NWE
Κατάσταση:$NWB#vicidial_remote_agents-status$NWE
Εκστρατεία: $NWB#vicidial_remote_agents-campaign_id$NWE
Εισερχόμενες Ομάδες: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "ΣΗΜΕΙΩΣΗ: Μπορεί να διαρκέσει και 30 δευτερόλεπτα για να καταχωρηθούν οι αλλαγές της οθόνης\n"; + + +if ($LOGdelete_remote_agents > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΟΝ ΤΟΝ ΑΠΟΜΑΚΡΥΣΜΕΝΟ ΧΕΙΡΙΣΤΗ\n"; + } + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΚΑΤΑΧΩΡΗΣΗΣ ΟΜΑΔΑΣ ΧΡΗΣΤΩΝ\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Ομάδα: (όχι κενά ή στίξη)$NWB#vicidial_user_groups-user_group$NWE
Περιγραφή: (περιγραφή ομάδας)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +if ($LOGdelete_user_groups > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΗΝ ΤΗΝ ΟΜΑΔΑ ΧΡΗΣΤΩΝ\n"; + } + +} + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = $row[3]; + $active = $row[4]; +echo ""; + +echo "
ΤΡΟΠΟΠΟΙΗΣΤΕ ΕΝΑΝ ΒΟΗΘΟ\n"; +echo "\n"; +echo "\n"; +echo "
Ταυτότητα χειρογράφων:: $script_id$NWB#vicidial_scripts-script_name$NWE
Όνομα χειρογράφων: (τίτλος του βοηθού)$NWB#vicidial_scripts-script_name$NWE
Σχόλια χειρόγραφου: $NWB#vicidial_scripts-script_comments$NWE
Ενεργή:$NWB#vicidial_scripts-active$NWE
Κείμενο χειρόγραφου:

Προεπισκόπιση Βοηθού
$NWB#vicidial_scripts-script_text$NWE
\n"; + +if ($LOGdelete_scripts > 0) + { + echo "

ΔΙΑΓΡΑΨΕ ΑΥΤΟΝ ΤΟΝ ΒΟΗΘΟ\n"; + } + +} + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = $row[3]; +echo ""; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΕΝΟΣ ΦΙΛΤΡΟΥ\n"; +echo "\n"; +echo "\n"; +echo "
ID Φίλτρου: $lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Όνομα Φίλτρου: (σύντομη περιγραφή του φίλτρου)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Σχόλια Φίλτρου: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
SQL Φίλτρου: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + +echo "

"; +echo "
ΕΛΕΓΧΟΣ ΣΤΗΝ ΕΚΣΤΡΑΤΕΙΑ:
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($LOGdelete_filters > 0) + { + echo "

ΔΙΑΓΡΑΦΗ ΤΟΥ ΦΙΛΤΡΟΥ\n"; + } + +} + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) +{ +if ($LOGmodify_call_times==1) +{ + +if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Προσθήκη Κανόνα Κατάστασης: $state_rule
\n"; + } +if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Απομάκρυνση Κανόνα Κατάστασης: $state_rule
\n"; + } + +$ADD=311111111; +} +else +{ +echo "Δεν έχετε το δικαίωμα για να δείτε την σελίδα. Παρακαλώ επιστρέψτε."; +} + +} + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +$ct_srs=1; +$b=0; +$srs_SQL =''; +if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } +echo "\n"; +echo "\n"; +while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } +if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } +else + {$srs_SQL='';} +$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; +$rslt=mysql_query($stmt, $link); +$sct_to_print = mysql_num_rows($rslt); +$sct_list=''; + +$o=0; +while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; +} +echo "\n"; +echo "\n"; + +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + +echo ""; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΧΡΟΝΟΥ ΚΛΗΣΗΣ\n"; +echo "\n"; +echo "\n"; +echo "
ID Χρόνου Κλήσης: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Ονομα Χρόνου Κλήσης: (σύντομη περιγραφή του χρόνου κλήσης)$NWB#vicidial_call_times-call_time_name$NWE
Σχόλια Χρόνου Κλήσης: $NWB#vicidial_call_times-call_time_comments$NWE
Προκαθορσμένη Εκκίνηση Προκαθορσμένη Παύση: $NWB#vicidial_call_times-ct_default_start$NWE
Κυριακή Εκκίνηση: Κυριακή Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Δευτέρα Εκκίνηση: Δευτέρα Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Τρίτη Εκκίνηση: Τρίτη Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Τετάρτη Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Πέμπτη Εκκίνηση: Πέμπτη Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Παρασκευή Εκκίνηση: Παρασκευή Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Σάββατο Εκκίνηση: Σάββατο Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Ενεργοί Ορισμοί Χρόνου Κλήσης Κατάστασης για αυτή την Εγγραφή:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Add state call time rule:


\n"; +echo "ΕΚΣΤΑΤΕΙΕΣ ΠΟΥ ΧΡΗΣΙΜΟΠΟΙΟΥΝ ΑΥΤΟ ΤΟΝ ΧΡΟΝΟ ΚΛΗΣΗΣ:
\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + $CT_camp_id = $row[1]; + $CT_camp_name = $row[2]; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

ΔΙΑΓΡΑΦΗ ΟΡΙΣΜΟΥ ΧΡΟΝΟΥ ΚΛΗΣΗΣ\n"; + } +} +else +{ +echo "Δεν έχετε το δικαίωμα για να δείτε την σελίδα. Παρακαλώ επιστρέψτε."; +} + +} + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + +echo ""; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ
\n"; +echo "\n"; +echo "\n"; +echo "
ID Χρόνου Κλήσης: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
Ονομα Χρόνου Κλήσης Κατάτασης: (σύντομη περιγραφή του χρόνου κλήσης)$NWB#vicidial_call_times-call_time_name$NWE
Σχόλια Χρόνου Κλήσης Κατάστασης: $NWB#vicidial_call_times-call_time_comments$NWE
Προκαθορσμένη Εκκίνηση Προκαθορσμένη Παύση: $NWB#vicidial_call_times-ct_default_start$NWE
Κυριακή Εκκίνηση: Κυριακή Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Δευτέρα Εκκίνηση: Δευτέρα Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Τρίτη Εκκίνηση: Τρίτη Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Τετάρτη Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Πέμπτη Εκκίνηση: Πέμπτη Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Παρασκευή Εκκίνηση: Παρασκευή Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE
Σάββατο Εκκίνηση: Σάββατο Παύση: $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; +echo "ΧΡΟΝΟΙ ΚΛΗΣΕΩΝ ΠΟΥ ΧΡΗΣΙΜΟΠΟΙΟΥΝ ΑΥΤΟ ΤΟΝ ΧΡΟΝΟ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ:
\n"; +echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

ΔΙΑΓΡΑΦΗ ΟΡΙΣΜΟΥ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ\n"; + } + +} +else +{ +echo "Δεν έχετε το δικαίωμα για να δείτε την σελίδα. Παρακαλώ επιστρέψτε."; +} + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo "
\n"; +echo ""; + +echo "
ΑΝΑΖΗΤΗΣΗ ΧΡΗΣΤΗ\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
Αριθμός Χρήστη:
Πλήρες Ονομα:
Επίπεδο Χρήστη:
Ομάδα Χρήστη:
\n"; + +} + +###################### +# ADD=66 user search results +###################### + +if ($ADD==66) +{ +echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΑΝΑΖΗΤΗΣΗ ΑΠΟΤΕΛΕΣΜΑΤΩΝ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]ΤΡΟΠΟΠΟΙΗΣΗ | ΣΤΑΤΙΣΤΙΚΑ | ΚΑΤΑΣΤΑΣΗ | TIME
\n"; + +} + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and user='$user' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
USER CALLBACK HOLD LISTINGS: $user\n"; +$ADD='82'; +} + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and campaign_id='$campaign_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN CALLBACK HOLD LISTINGS: $campaign_id\n"; +$ADD='82'; +} + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and list_id='$list_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; +$ADD='82'; +} + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) +{ +echo "
\n"; +echo "
\n"; +echo "\n"; + + $o=0; + while ($cb_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
LEADLISTCAMPAIGNENTRY ΗΜΕΡΑCALLBACK ΗΜΕΡΑUSERRECIPIENTΚΑΤΑΣΤΑΣΗ
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΛΙΣΤΕΣ ΧΡΗΣΤΗ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]ΤΡΟΠΟΠΟΙΗΣΗ | ΣΤΑΤΙΣΤΙΚΑ | ΚΑΤΑΣΤΑΣΗ | TIME
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΕΣ ΕΚΣΤΡΑΤΕΙΕΣ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΕΣ ΛΙΣΤΕΣ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΕΣ ΕΙΣΕΡΧΟΜΕΝΕΣ ΟΜΑΔΕΣ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΟΙ ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΕΝΤΑΓΜΕΝΕΣ ΟΜΑΔΕΣ ΧΡΗΣΤΗ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ΛΙΣΤΕΣ ΒΟΗΘΩΝ:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) +{ +echo "\n";echo "\n";?> +
+
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
ΛΙΣΤΕΣ ΟΔΗΓΟΥ ΦΙΛΤΡΟΥ:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
ΛΙΣΤΕΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[4] ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
ΛΙΣΤΕΣ ΧΡΟΝΟΥ ΚΛΗΣΗΣ ΚΑΤΑΣΤΑΣΗΣ:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3] $row[4] ΤΡΟΠΟΠΟΙΗΣΗ
\n"; +} + + + + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds"; +echo "             ΕΚΔΟΣΗ: $version"; +echo "             ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + + +?> + + +
+ + + +1) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday τοπικός χρόνος + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday τοπικός χρόνος + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday τοπικός χρόνος + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday τοπικός χρόνος + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday τοπικός χρόνος + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday τοπικός χρόνος + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday τοπικός χρόνος + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday τοπικός χρόνος + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday τοπικός χρόνος + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday τοπικός χρόνος + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday τοπικός χρόνος + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday τοπικός χρόνος + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday τοπικός χρόνος + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday τοπικός χρόνος + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "Αυτή η εκστρατεία έχει$active_leads οδηγοί που καλούντε στις λίστες\n"; + } + else + { + echo "δεν έχουν επιλεχθεί ενεργές λίστες για την εκστρατεία\n"; + } + } +else + { + echo "δεν έχουν επιλεχθεί ενεργές λίστες για την εκστρατεία\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/admin_modify_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_el/admin_modify_lead.php new file mode 100644 index 00000000..73160d10 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/admin_modify_lead.php @@ -0,0 +1,476 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + +### AST GUI database administration modify lead in vicidial_list +### admin_modify_lead.php + +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead + +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +ΔΙΑΧΕΙΡΙΣΗ: Τροποποίηση οδηγού + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "οι πληροφορίες τροποποιήθηκαν

\n"; + echo "\n"; + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + +} +else +{ + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Πληροφορίες Κλήσης: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     ID Λίστας: $list_id
Ονομα:   \n"; + echo " Επίθετο:
Διεύθυνση 1 :
Διεύθυνση 2 :
Διεύθυνση 3 :
Πόλη :
Κράτος:   \n"; + echo "Ταχ.Κωδ.
Χώρα :
Εναλ Τηλέφωνο :
Ασφάλεια :
Σχόλια :
Τερματισμός:
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + + + + + } + else + { + echo "ΑΠΟΤΥΧΙΑ ψαξίματος καθοδήγησης για lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + +echo "

\n"; + +echo "
\n"; + +echo "Κλήσεις για αυτόν τον οδηγό:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS TSRΕΚΣΤΡΑΤΕΙΑ LIST LEAD
$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]
\n"; + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/admin_search_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_el/admin_search_lead.php new file mode 100644 index 00000000..c1903336 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/admin_search_lead.php @@ -0,0 +1,224 @@ + LICENSE: GPLv2 +### +### AST GUI database administration search for lead info +### admin_modify_lead.php +# +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +ΔΙΑΧΕΙΡΙΣΗ: Αναζήτηση Οδηγού + +Ψάξιμο Καθοδήγησης + + + +
\n"; + echo "
\n"; + echo "\n"; + echo "Παρακαλώ καταχωρήστε:
Vendor ID(αυτόματος κωδικός καθοδήγησης): or \n"; + echo "
ένας αριθμός τηλεφώνου σπιτιού or\n"; + echo "
ID οδηγού

\n"; + echo "
\n"; + echo "\n
\n"; + echo "\n"; + exit; + } + +else + { + + if ($vendor_id) + { + $stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000"; + } + else + { + if ($phone) + { + $stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000"; + } + else + { + if ($lead_id) + { + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query($stmt, $link); + $results_to_print = mysql_num_rows($rslt); + if ($results_to_print < 1) + { + echo date("l F j, Y G:i:s A"); + echo "\n

\n"; + echo "Οι μεταβλητές αναζήτησης που καταχωρήσατε δεν είναι ενεργές στο σύστημα

\n"; + echo "Παρακαλώ, επιστρέψτε πίσω και ελέγξτε τις πληροφορίες που καταχωρήσατε και προσπαθήστε πάλι\n"; + echo "
\n"; + echo "\n"; + exit; + } + else + { + echo "RESULTS: $results_to_print

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD IDΚΑΤΑΣΤΑΣΗVENDOR IDLAST AGENTID ΛΙΣΤΑΣPHONEΟΝΟΜΑCITYSECURITYLAST CALL
$o$row[0]$row[3]$row[5]$row[4]$row[7]$row[11]$row[13] $row[15]$row[19]$row[28]$row[2]
\n"; + } + } + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\nΝΕΑ ΑΝΑΖΗΤΗΣΗ"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds"; + + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/count.htm b/agc_2-X/trunk/LANG_admin/vicidial_el/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/count.htm @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/dbconnect.php b/agc_2-X/trunk/LANG_admin/vicidial_el/dbconnect.php new file mode 100644 index 00000000..fb6d5917 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/dbconnect.php @@ -0,0 +1,16 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/group_hourly_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_el/group_hourly_stats.php new file mode 100644 index 00000000..fa64248e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/group_hourly_stats.php @@ -0,0 +1,252 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + +ΔΙΑΧΕΙΡΙΣΗ: Ομαδοποιημένα Ωριαία Στατιστικά +\n"; +?> + + +
+ + + + + += '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "
  ΔΙΑΧΕΙΡΙΣΗ: Ομαδοποιημένα Ωριαία Στατιστικά  
\n"; + +echo "
\n"; + +echo "ΜΕΤΡΗΣΗ ΩΡΩΝ TSR: $group | $status | $date_with_hour | $date_no_hour\n"; + +echo "
\n"; +echo "\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "\n"; + + +} + +echo "
TSR ID   $status   ΣΥΝΟΛΙΚΕΣ ΚΛΗΣΕΙΣ   $status DAY    
$VDuser[$o] $VDname[$o] $VDcount[$o] $VDtotal[$o] $VDday[$o]ΤΡΟΠΟΠΟΙΗΣΗ | ΣΤΑΤΙΣΤΙΚΑ
TOTAL $status $hour_calls $total_calls $day_calls
\n"; +echo "

\n"; + + + echo "
Παρακαλώ, καταχωρήστε την ομάδα για την οποία θέλετε στατιστικά ανά ώρα:
\n"; + echo "\n"; + echo "group:
\n"; + echo "status:   (example: XFER)
\n"; + echo "date with hour:   (example: 2004-06-25 14)
\n"; + echo "\n"; + echo "


\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/help.gif b/agc_2-X/trunk/LANG_admin/vicidial_el/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/vicidial_el/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/htglobalize.php b/agc_2-X/trunk/LANG_admin/vicidial_el/htglobalize.php new file mode 100644 index 00000000..72a10e1f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/htglobalize.php @@ -0,0 +1,23 @@ + $value){ + ${$key} = $value; + global ${$key};// = $value; + } + +} +array_conv($_GET); +array_conv($_POST); +array_conv($_SERVER); + +?> \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/listloader.php b/agc_2-X/trunk/LANG_admin/vicidial_el/listloader.php new file mode 100644 index 00000000..2005942c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/listloader.php @@ -0,0 +1,698 @@ + LICENSE: GPLv2 +# +# AST Web GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1006 - added listID override and gmt_offset lookup while loading +# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. +# + +$version = '1.1.12'; +$build = '60619-1652'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];} +$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"]; if (!$ΕΠΙΒΕΒΑΙΩΣΗ) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + + +#$DB=1; +#$DBX=1; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('listloader.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"ΒΟΗΘΕΙΑ\""; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +?> + + + + + + method=post enctype="multipart/form-data"> +
+ + + + + + + + + + + + + +
Εισαγωγή οδηγών από αυτό το αρχείο:
ID Λίστας Override: (μόνο αριθμοί or leave blank for values in the file)
ΕΠΙΛΕΞΤΕ ΕΔΩ ΓΙΑ ΝΑ ΠΑΤΕ ΣΤΟΝ ΠΡΟΗΓΜΕΝΟ ΕΙΣΑΓΩΓΕΑ ΟΔΗΓΩΝ (BETA ΕΚΔΟΣΗ)     ΠΙΣΩ ΣΤΗ ΔΙΑΧΕΙΡΙΣΗ
+ +document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + $pulldate=date("Y-m-d H:i:s"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("./vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Επεξεργασία$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city = $row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) + { + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $gmt_offset = '0'; + $called_since_last_reset='N'; + + if (strlen($list_id_override)>0) + { + # print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
Λάθος: Το αρχείο δεν έχει τον απαιτούμενο αριθμό πεδίων.
"; + } + print ""; +} else if (filesize($leadfile)>8388608) { + print "
Λάθος: Το αρχείο ξεπέρασε το όριο των 8ΜΒ.
"; +} +?> + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/listloaderMAIN.php b/agc_2-X/trunk/LANG_admin/vicidial_el/listloaderMAIN.php new file mode 100644 index 00000000..6960cfa6 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/listloaderMAIN.php @@ -0,0 +1,79 @@ + LICENSE: GPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + +VICIDIAL: Υπομονάδα εισαγωγής οδηγών + + + + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/listloader_stmts.txt b/agc_2-X/trunk/LANG_admin/vicidial_el/listloader_stmts.txt new file mode 100644 index 00000000..e69de29b diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/new_listloader_superL.php b/agc_2-X/trunk/LANG_admin/vicidial_el/new_listloader_superL.php new file mode 100644 index 00000000..4796e269 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/new_listloader_superL.php @@ -0,0 +1,1364 @@ + LICENSE: GPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '1.1.12-1'; +$build = '60619-1651'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"ΒΟΗΘΕΙΑ\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +ΔΙΑΧΕΙΡΙΣΗ: Super Lead Loader + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + + + + + + + + + + + + + + + + + + + +
Εισαγωγή οδηγών από αυτό το αρχείο:
ID Λίστας Override: (μόνο αριθμοί or leave blank for values in the file)
Μορφή αρχείων για χρήση:Τυποποιημένο VICIDIAL    Εμφάνιση συνήθειας
        
ΕΠΙΛΕΞΤΕ ΕΔΩ ΓΙΑ ΝΑ ΠΑΤΕ ΣΤΟ ΒΑΣΙΚΟ ΕΙΣΑΓΩΓΕΑ ΟΔΗΓΩΝ         ΠΙΣΩ ΣΤΗ ΔΙΑΧΕΙΡΙΣΗ
ΠΡΟΗΓΜΕΝΟΣ ΕΙΣΑΓΩΓΕΑΣ ΛΙΣΤΩΝ-     ΕΚΔΟΣΗ:     ΔΗΜΙΟΥΡΓΙΑ:
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Επεξεργασία$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + + if (strlen($list_id_override)>0) + { + # print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
Λάθος: Το αρχείο δεν έχει τον απαιτούμενο αριθμό πεδίων.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + print "
ΕπεξεργασίαExcel file... \n"; + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + # print "$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field"; + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
ΕπεξεργασίαCSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile && filesize($LF_path)<=8388608) { + $total=0; $good=0; $bad=0; + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Επεξεργασία$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
Λάθος: Το αρχείο δεν έχει τον απαιτούμενο αριθμό πεδίων.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
ΕπεξεργασίαCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Επεξεργασία$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
ΕπεξεργασίαCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

ID ΛΙΣΤΑΣ OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + $total=0; $good=0; $bad=0; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL ΣτήληΑρχεία δεδομένων
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
        
\r\n"; + # } + print ""; + } +} else if (filesize($leadfile)>8388608) { + print "
Λάθος: Το αρχείο ξεπέρασε το όριο των 8ΜΒ.
"; +} +?> + + + + + + + + + 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### MEXICO ### +if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### AUSTRALIA ### +if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### ALL OTHER COUNTRY CODES ### +if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # τοπικός χρόνος calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/project_auth_entries.txt b/agc_2-X/trunk/LANG_admin/vicidial_el/project_auth_entries.txt new file mode 100644 index 00000000..805a9ec1 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/project_auth_entries.txt @@ -0,0 +1,114 @@ +VICIDIAL|GOOD|Tue, 22 Nov 2005 14:58:40 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:02:51 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:03:00 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:03:10 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:03:12 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:05:07 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:05:10 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:28:49 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:30:11 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:30:15 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:06:49 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:07:13 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:07:17 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:07:21 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Fri, 23 Dec 2005 14:39:30 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:43 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:45 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:46 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 03 Mar 2006 16:14:21 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:03:10 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:03:15 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:03:33 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:04:19 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:04:24 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:04:28 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:11:04 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:11:08 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:11:45 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:11:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:15:54 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:15:56 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +LIST_LOAD|GOOD|Thu, 27 Apr 2006 17:18:51 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:18:56 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:19:07 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:19:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:21:55 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:23:16 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:23:21 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:23:23 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:23:29 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:24:23 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:24:25 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:25:31 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:25:41 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:25:43 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:25:45 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:25:46 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:26:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:26:50 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:26:52 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:32 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:38 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:39 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:41 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:43 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:48 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:54 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:55 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:57 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:33:58 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:00:48 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:00:50 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:00:58 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:03 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:17 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:19 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:29 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:42 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:43 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:47 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:52 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:54 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:01:59 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:01 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:03 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:05 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:11 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:12 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:15 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:16 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:26 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:28 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:02:32 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:07:52 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:13 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:17 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:20 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:22 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:24 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:25 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:27 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:08:28 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:33 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:35 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:37 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:44 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:46 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:47 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:51 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:21:00 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:21:17 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:21:23 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +LIST_LOAD|GOOD|Thu, 27 Apr 2006 22:22:17 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +LIST_LOAD|GOOD|Thu, 27 Apr 2006 22:25:37 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +LIST_LOAD|GOOD|Thu, 27 Apr 2006 22:27:54 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +LIST_LOAD|GOOD|Thu, 27 Apr 2006 22:34:07 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:40:50 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:35:20 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:35:23 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:35:26 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:35:31 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/remote_dispo.php b/agc_2-X/trunk/LANG_admin/vicidial_el/remote_dispo.php new file mode 100644 index 00000000..3f45251b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/remote_dispo.php @@ -0,0 +1,327 @@ + LICENSE: GPLv2 +### +# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call + +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +Απομακρυσμένο: Τερματισμός Κλήσης +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Η κλήση έχει τερματίσει       $NOW_TIME\n

\n"; + + echo "
\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Πληροφορίες Κλήσης: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     ID Εκστρατείας: $campaign_id
Fronter: $tsr     ID Λίστας: $list_id
Ονομα:   \n"; + echo " Επίθετο:
Διεύθυνση 1 :
Διεύθυνση 2 :
Διεύθυνση 3 :
Πόλη :
Κράτος:   \n"; + echo "Ταχ.Κωδ.
Χώρα :
Εναλ Τηλέφωνο :
Ασφάλεια :
Σχόλια :
Τερματισμός:
\n"; + echo "


\n"; + + } + else + { + echo "ΑΠΟΤΥΧΙΑ ψαξίματος καθοδήγησης για lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/server_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_el/server_stats.php new file mode 100644 index 00000000..d08bccbb --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/server_stats.php @@ -0,0 +1,96 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1037 - Added Link back to Admin section +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select * from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $i++; + } +?> + + + + + +VICIDIAL: Στατιστικά Διακομιστή and Reports +VICIDIAL: Στατιστικά Διακομιστή and Reports                           +ΠΙΣΩ ΣΤΗ ΔΙΑΧΕΙΡΙΣΗ

+ + +

+
+ $o)
+	{
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	$o++;
+	}
+
+?>
+
SERVERΠΕΡΙΓΡΑΦΗIP ADDRESSΕΝΕΡΓΑVDAD timeVDcall timePARK timeCLOSER/INBOUND time
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]LINKLINKLINKLINK
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/user_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_el/user_stats.php new file mode 100644 index 00000000..a48b56fd --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/user_stats.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +ΔΙΑΧΕΙΡΙΣΗ: User Stats +\n"; +?> + + +
+ + + + + +\n"; +echo "
  ΔΙΑΧΕΙΡΙΣΗ: User Stats for  
  \n"; + +echo "
\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + +echo "
\n"; + +echo "ΧΡΟΝΟΣ ΟΜΙΛΙΑΣ ΚΑΙ ΚΑΤΑΣΤΑΣΗ:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + +echo "\n"; +echo "
ΚΑΤΑΣΤΑΣΗΚΑΤΑΜΕΤΡΗΣΗΩΡΕΣ:ΛΕΠΤΑ
$row[1] $row[0] $call_hours_int:$call_minutes_int
ΣΥΝΟΛΙΚΕΣ ΚΛΗΣΕΙΣ $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo " ΧΡΟΝΟΣ ΣYΝΔΕΣΗΣ/ΑΠΟΣΥΝΔΕΣΗΣ:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours = ($event_seconds / 3600); + $event_hours = round($event_hours, 2); + $event_hours_int = intval("$event_hours"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours = ($total_login_time / 3600); +$total_login_hours = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
ΣΥΜΒΑΝ ΗΜΕΡΑΕΚΣΤΡΑΤΕΙΑΩΡΕΣ:ΛΕΠΤΑ
$row[0] $row[2] $row[3]
$row[0] $row[2] $row[3] $event_hours_int:$event_minutes_int
$row[0] $row[2] $row[3]
ΣΥΝΟΛΙΚΑ $total_login_hours_int:$total_login_minutes_int
\n"; + + +echo "

\n"; + +echo "
\n"; + +echo "Τελευταίες 50 Κλήσεις:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS PHONEΕΚΣΤΡΑΤΕΙΑ LIST LEAD
$row[4] $row[7] $row[8] $row[10] $row[3] $row[2] $row[1]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/user_status.php b/agc_2-X/trunk/LANG_admin/vicidial_el/user_status.php new file mode 100644 index 00000000..6b8aaaa8 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/user_status.php @@ -0,0 +1,238 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $change_agent_campaign=$row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $i++; + } + + } + +$stmt="select * from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> + + +ΔΙΑΧΕΙΡΙΣΗ: User Status +\n"; +?> + + +
+
+ + + + +\n"; +echo "
  ΔΙΑΧΕΙΡΙΣΗ: User Status for  
  \n"; + +if ($stage == "live_campaign_change") +{ + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign
\n"; + + exit; +} + +if ($stage == "log_agent_out") +{ + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser
\n"; + + exit; +} + +if ($agents_to_print > 0) +{ + echo "
";
+	echo "Agent Logged in at server:  $Aserver_ip\n";
+	echo "               in session:  $Asession_id\n";
+	echo "               from phone:  $Aextension\n";
+	echo "Agent is in campaign:       $Acampaign\n";
+	echo "              status:       $Astatus\n";
+	echo " hungup last call at:       $Alast_call\n";
+	echo "       Closer groups:       $Acl_campaigns\n\n";
+
+	echo "
"; + + + if ($change_agent_campaign > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Current Εκστρατεία: \n"; + echo "
\n"; + + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } +} + +else +{ + echo "Agent is not logged in\n
"; + +} + + +echo "           $user - $full_name - \n"; + +echo "VICIDIAL Time Sheet\n"; + +echo "
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + +echo "|$stage|$group|"; + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_el/vdremote.php b/agc_2-X/trunk/LANG_admin/vicidial_el/vdremote.php new file mode 100644 index 00000000..0061a097 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_el/vdremote.php @@ -0,0 +1,602 @@ + LICENSE: GPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time + +$version = '1.1.12'; +$build = '60619-1603'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_GET["ΕΠΙΒΕΒΑΙΩΣΗ"];} + elseif (isset($_POST["ΕΠΙΒΕΒΑΙΩΣΗ"])) {$ΕΠΙΒΕΒΑΙΩΣΗ=$_POST["ΕΠΙΒΕΒΑΙΩΣΗ"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Έχετε αποσυνδεθεί. Σας ευχαριστούμε\n"; + exit; +} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Ακυρο Ονομα Χρήστη/Κωδικός Πρόσβασης: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Τροποποίηση Απομακρυσμένων Χειριστών";} +if ($ADD==41111) {echo "Τροποποίηση Απομακρυσμένων Χειριστών";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+
+ + + +
  ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ:   Αποσύνδεση  
  ΤΡΟΠΟΠΟΙΗΣΗ | ">ΚΑΤΑΣΤΑΣΗ | ">ΣΤΑΤΙΣΤΙΚΑ ΕΙΣΕΡΧΟΜΕΝΩΝ
+"; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΚΑΤΑΧΩΡΗΣΗΣ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Χρήστη Ξεκινά: $user_start
Αριθμός Γραμμών: (μόνο αριθμοί)
IP Διακομιστή: $row[3]
Εξωτερική Τηλ. Σύνδεση: (number dialed to reach agents [i.e. 913125551212])
Κατάσταση:
Εκστρατεία: $campaign_id
Εισερχόμενες Ομάδες: \n"; +echo "$groups_list"; +echo "
\n"; +echo "ΣΗΜΕΙΩΣΗ: Μπορεί να διαρκέσει και 30 δευτερόλεπτα για να καταχωρηθούν οι αλλαγές της οθόνης\n"; + +} + + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΔΕΝ ΤΡΟΠΟΠΟΙΗΘΗΚΑΝ - Παρακαλώ ελέγξτε τα δεδομένα που καταχωρήσατε\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ΤΡΟΠΟΠΟΙΗΘΗΚΑΝ\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY ΑΠΟΜΑΚΡΥΣΜΕΝΟΙ ΧΕΙΡΙΣΤΕΣ ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + + } + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
ΤΡΟΠΟΠΟΙΗΣΗ ΚΑΤΑΧΩΡΗΣΗΣ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID Χρήστη Ξεκινά: $user_start
Αριθμός Γραμμών: (μόνο αριθμοί)
IP Διακομιστή: $row[3]
Εξωτερική Τηλ. Σύνδεση: (number dialed to reach agents [i.e. 913125551212])
Κατάσταση:
Εκστρατεία: $campaign_id
Εισερχόμενες Ομάδες: \n"; +echo "$groups_list"; +echo "
\n"; +echo "ΣΗΜΕΙΩΣΗ: Μπορεί να διαρκέσει και 30 δευτερόλεπτα για να καταχωρηθούν οι αλλαγές της οθόνης\n"; + +} + + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) +{ + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
ΛΑΘΟΣ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]='- ΑΝΑΜΟΝΗ -'; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i Χειριστές συνδεμένοι στον διακομιστή $server_ip\n\n"; + + echo " - 5 λεπτά ή παραπάνω σε κλήση\n"; + echo " - Πάνω από 10 λεπτά σε κλήση\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* ΚΑΝΕΝΑΣ ΧΕΙΡΙΣΤΗΣ ΣΕ ΚΛΗΣΕΙΣ*********************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) +{ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
ΛΑΘΟΣ ΑΠΟΜΑΚΡΥΣΜΕΝΩΝ ΧΕΙΡΙΣΤΩΝ\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "VICIDIAL: Στατιστικά εισερχομένων απομακρυσμένου χειριστή $NOW_TIME\n\n"; + echo "\n"; + echo "Συνολικές κλήσεις που διακομίστηκαν$query_date: $in_calls\n"; + echo "Συνολικός χρόνος ομιλίας σε$query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Λίστα Κλήσεων για$query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + # echo " $i Χειριστές συνδεμένοι στον διακομιστή $server_ip\n\n"; + + # echo " - 5 λεπτά ή παραπάνω σε κλήση\n"; + # echo " - Πάνω από 10 λεπτά σε κλήση\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************ΔΕΝ ΥΠΑΡΧΟΥΝ ΚΛΗΣΕΙΣ ΓΙΑ ΑΥΤΗ ΤΗΝ ΗΜΕΡΑ*******************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nχρόνος εκτέλεσης διαδικασίας: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_CLOSERstats.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_CLOSERstats.php new file mode 100644 index 00000000..b7a7bb8c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_CLOSERstats.php @@ -0,0 +1,396 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Closer Stats\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Closer Stats                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls placed from this Campaign:        $TOTALcalls\n";
+echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls:                             $DROPcalls  $DROPpercent%\n";
+echo "Average Length for DROP Calls in seconds:     $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_VDADstats.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_VDADstats.php new file mode 100644 index 00000000..9ac17006 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_VDADstats.php @@ -0,0 +1,417 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls placed from this Campaign:        $TOTALcalls\n";
+echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls:                             $DROPcalls  $DROPpercent%\n";
+echo "Average Length for DROP Calls in seconds:     $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- AUTO-DIAL NO ANSWERS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$NAcalls =	sprintf("%10s", $row[0]);
+$NApercent = (($NAcalls / $TOTALcalls) * 100);
+$NApercent = round($NApercent, 0);
+
+$average_na_seconds = ($row[1] / $row[0]);
+$average_na_seconds = round($average_na_seconds, 0);
+$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+
+echo "Total NA calls -Busy,Disconnect,BTvoicemail:  $NAcalls  $NApercent%\n";
+echo "Average Call Length for NA Calls in seconds:  $average_na_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..1824a939 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,161 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Hopper List\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Live Current Hopper List                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+
+echo "Total leads in hopper right now:       $TOTALcalls\n";
+
+
+##############################
+#########  LEAD STATS
+
+echo "\n";
+echo "---------- LEADS IN HOPPER\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+echo "|      | LEAD_ID   | PHONE NUM  | STATE | STATUS | COUNT | GMT    |\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$FMT_i =		sprintf("%-4s", $i);
+	$lead_id =		sprintf("%-9s", $row[0]);
+	$phone_number =	sprintf("%-10s", $row[1]);
+	$state =		sprintf("%-5s", $row[2]);
+	$status =		sprintf("%-6s", $row[3]);
+	$count =		sprintf("%-5s", $row[4]);
+	$gmt =			sprintf("%-6s", $row[5]);
+
+	echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
+
+	$i++;
+	}
+
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_admin_log_display.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_admin_log_display.php new file mode 100644 index 00000000..b5286873 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_admin_log_display.php @@ -0,0 +1,118 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date); + +# AST GUI database administration +# AST_admin_log_display.php +# +# CHANGES +# 50325-0932 - First build +# 51123-1443 - removed globals=on requirement +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '0.0.4'; +$build = '60620-1044'; + +$STARTtime = date("U"); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN LOG DISPLAY"; +echo "\n"; + +# Fri, 25 Mar 2005 + +$DAY_DATE = date("j"); +if ($DAY_DATE < 10) +# {$GREP_DATE = date("D, j M Y");} + {$GREP_DATE = date("D, 0j M Y");} +else + {$GREP_DATE = date("D, j M Y");} + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!$query_date) {$query_date = $GREP_DATE;} + +$Gquery_date = eregi_replace(" ",'\ ',$query_date); +echo "\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+echo "VICIDIAL ADMIN CHANGE LOG                             $NOW_TIME\n";
+
+#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
+passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_performance.php new file mode 100644 index 00000000..a489bc7d --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_performance.php @@ -0,0 +1,232 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Agent Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_performance_detail.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_performance_detail.php
new file mode 100644
index 00000000..2dd3dc5e
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_performance_detail.php
@@ -0,0 +1,406 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 03:45:00";   
+	$query_date_END = "$query_date 15:15:00";
+	$time_BEGIN = "03:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:15:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance Detail                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TIME   | PAUSE  | PAUSAVG| WAIT   | WAITAVG| TALK   | TALKAVG| DISPO  | DISPAVG| A    | B    | DC   | DNC  | N    | NI   | CB   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$TOTtotWAIT=($TOTtotWAIT + $row[7]);
+	$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
+	$TOTtotDISPO=($TOTtotDISPO + $row[9]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtime =	($row[1] + $row[5] + $row[7] + $row[9]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+	$USERtotPAUSE =	$row[5];
+	$USERavgPAUSE =	$row[6];
+	$USERtotWAIT =	$row[7];
+	$USERavgWAIT =	$row[8];
+	$USERtotDISPO =	$row[9];
+	$USERavgDISPO =	$row[10];
+
+	$USERtime_M = ($USERtime / 60);
+	$USERtime_M = round($USERtime_M, 2);
+	$USERtime_M_int = intval("$USERtime_M");
+	$USERtime_S = ($USERtime_M - $USERtime_M_int);
+	$USERtime_S = ($USERtime_S * 60);
+	$USERtime_S = round($USERtime_S, 0);
+	if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
+	$USERtime_MS = "$USERtime_M_int:$USERtime_S";
+	$pfUSERtime_MS[$i] =		sprintf("%7s", $USERtime_MS);
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+
+	$USERtotPAUSE_M = ($USERtotPAUSE / 60);
+	$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
+	$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
+	$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
+	$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
+	$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
+	if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
+	$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
+	$pfUSERtotPAUSE_MS[$i] =		sprintf("%6s", $USERtotPAUSE_MS);
+
+	$USERavgPAUSE_M = ($USERavgPAUSE / 60);
+	$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
+	$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
+	$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
+	$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
+	$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
+	if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
+	$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
+	$pfUSERavgPAUSE_MS[$i] =		sprintf("%6s", $USERavgPAUSE_MS);
+
+	$USERtotWAIT_M = ($USERtotWAIT / 60);
+	$USERtotWAIT_M = round($USERtotWAIT_M, 2);
+	$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
+	$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
+	$USERtotWAIT_S = ($USERtotWAIT_S * 60);
+	$USERtotWAIT_S = round($USERtotWAIT_S, 0);
+	if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
+	$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
+	$pfUSERtotWAIT_MS[$i] =		sprintf("%6s", $USERtotWAIT_MS);
+
+	$USERavgWAIT_M = ($USERavgWAIT / 60);
+	$USERavgWAIT_M = round($USERavgWAIT_M, 2);
+	$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
+	$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
+	$USERavgWAIT_S = ($USERavgWAIT_S * 60);
+	$USERavgWAIT_S = round($USERavgWAIT_S, 0);
+	if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
+	$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
+	$pfUSERavgWAIT_MS[$i] =		sprintf("%6s", $USERavgWAIT_MS);
+	
+	$USERtotDISPO_M = ($USERtotDISPO / 60);
+	$USERtotDISPO_M = round($USERtotDISPO_M, 2);
+	$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
+	$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
+	$USERtotDISPO_S = ($USERtotDISPO_S * 60);
+	$USERtotDISPO_S = round($USERtotDISPO_S, 0);
+	if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
+	$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
+	$pfUSERtotDISPO_MS[$i] =		sprintf("%6s", $USERtotDISPO_MS);
+
+	$USERavgDISPO_M = ($USERavgDISPO / 60);
+	$USERavgDISPO_M = round($USERavgDISPO_M, 2);
+	$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
+	$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
+	$USERavgDISPO_S = ($USERavgDISPO_S * 60);
+	$USERavgDISPO_S = round($USERavgDISPO_S, 0);
+	if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
+	$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
+	$pfUSERavgDISPO_MS[$i] =		sprintf("%6s", $USERavgDISPO_MS);
+
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; $ctCB[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]);	$TOT_CB = ($TOT_CB + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtime_M = ($TOTtime / 60);
+	$TOTtime_M = round($TOTtime_M, 2);
+	$TOTtime_M_int = intval("$TOTtime_M");
+	$TOTtime_S = ($TOTtime_M - $TOTtime_M_int);
+	$TOTtime_S = ($TOTtime_S * 60);
+	$TOTtime_S = round($TOTtime_S, 0);
+	if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
+	$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
+	$TOTtime_MS =		sprintf("%7s", $TOTtime_MS);
+		while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOTtotDISPO_M = ($TOTtotDISPO / 60);
+	$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
+	$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
+	$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
+	$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
+	$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
+	if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
+	$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
+	$TOTtotDISPO_MS =		sprintf("%7s", $TOTtotDISPO_MS);
+		while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+
+	$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
+	$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
+	$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
+	$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
+	if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
+	$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
+	$TOTtotPAUSE_MS =		sprintf("%7s", $TOTtotPAUSE_MS);
+		while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+
+	$TOTtotWAIT_M = ($TOTtotWAIT / 60);
+	$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
+	$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
+	$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
+	$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
+	$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
+	if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
+	$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
+	$TOTtotWAIT_MS =		sprintf("%7s", $TOTtotWAIT_MS);
+		while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+
+
+	$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
+	$TOTavgTALK_M = round($TOTavgTALK_M, 2);
+	$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
+	$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
+	$TOTavgTALK_S = ($TOTavgTALK_S * 60);
+	$TOTavgTALK_S = round($TOTavgTALK_S, 0);
+	if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
+	$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
+	$TOTavgTALK_MS =		sprintf("%6s", $TOTavgTALK_MS);
+		while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+
+	$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
+	$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
+	$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
+	$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
+	$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
+	$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
+	if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
+	$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
+	$TOTavgDISPO_MS =		sprintf("%6s", $TOTavgDISPO_MS);
+		while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+
+	$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
+	$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
+	$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
+	$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
+	if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
+	$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
+	$TOTavgPAUSE_MS =		sprintf("%6s", $TOTavgPAUSE_MS);
+		while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+
+	$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
+	$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
+	$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
+	$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
+	$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
+	$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
+	if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
+	$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
+	$TOTavgWAIT_MS =		sprintf("%6s", $TOTavgWAIT_MS);
+		while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+
+	
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_CB = sprintf("%-5s", $TOT_CB);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
+echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_time_sheet.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_time_sheet.php
new file mode 100644
index 00000000..46659eb6
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_agent_time_sheet.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "TOTAL CALLS TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_server_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_server_performance.php
new file mode 100644
index 00000000..fdedb9d9
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_server_performance.php
@@ -0,0 +1,310 @@
+    LICENSE: GPLv2
+#
+# CHANGES
+#
+# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))	{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))	{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))	{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+# path from root to where ploticus files will be stored
+$DOCroot = "$WeBServeRRooT/vicidial/ploticus/";
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+if (!isset($group)) {$group = '';}
+
+$stmt="select server_ip from servers;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$servers_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $servers_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Server Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "             REPORTS \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:32:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:32:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Server Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$HIGHload =	sprintf("%10s", $row[0]);
+$HIGHmulti = intval($HIGHload / 100);
+#$HIGHmulti = ($HIGHload / 100);
+
+$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$USEDram =	sprintf("%10s", $row[0]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average channels in use for server:       $AVGchannels\n";
+echo "Average load for server:                  $AVGload\n";
+echo "Peak load for server:                     $HIGHload\n";
+#echo "Peak used memory for server (in MB):      $USEDram\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 14 7\n";
+$HTMcontent .= "xscaletype: time hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHload\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc 30 minutes\n";
+$HTMcontent .= "minorticinc: 5 minutes\n";
+$HTMcontent .= "stubformat: hh:mm:ssa\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-2 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDAD.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDAD.php new file mode 100644 index 00000000..52efd9cc --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDAD.php @@ -0,0 +1,255 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Agents Time On Calls                         $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL    | STATUS | START TIME          | MINUTES |\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	$agentcount=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED",$row[4]))
+			{
+			$row[3]='';
+			$row[5]=' - WAITING - ';
+			$row[6]=$row[7];
+			}
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$sessionid =		sprintf("%-9s", $row[2]);
+		$channel =			sprintf("%-10s", $row[3]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[4]);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 5) {$G=''; $EG='';}
+		if ($call_time_M_int >= 10) {$G=''; $EG='';}
+		if (eregi("PAUSED",$row[4])) 
+			{
+			if ($call_time_M_int >= 1) 
+				{$i++; continue;} 
+			else
+				{$G=''; $EG='';}
+			}
+
+		$agentcount++;
+		echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+		echo "  $agentcount agents logged in on server $server_ip\n\n";
+
+		echo "             - Paused agents\n";
+		echo "             - 5 minutes or more on call\n";
+		echo "             - Over 10 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+echo "| CHANNEL    | STATUS | CAMPAIGN | PHONE NUMBER       | START TIME          | MINUTES |\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-8s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+		echo "  $i calls being placed on server $server_ip\n\n";
+
+		echo "             - LIVE CALL WAITING\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "******************************* NO LIVE CALLS WAITING *********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDAD_closer.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDAD_closer.php new file mode 100644 index 00000000..eb7d3c39 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDAD_closer.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Agents Time On Calls                         $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPAIGN     | FRONT  |\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED|CLOSER",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WAIT -';
+			$row[6]=$row[7];
+			}
+		$extension[$i] =		sprintf("%-10s", $row[0]);
+		$user[$i] =				sprintf("%-6s", $row[1]);
+		$sessionid[$i] =		sprintf("%-9s", $row[2]);
+		$channel[$i] =			sprintf("%-19s", $row[3]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $row[4]);
+		$start_time[$i] =		sprintf("%-8s", $row[5]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$row[8];
+		$lead_id[$i] =			$row[9];
+		$closer[$i] =			$row[1];
+		$call_time_S[$i] = ($STARTtime - $row[6]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+		$i++;
+		}
+		$ext_count = $i;
+		$i=0;
+	while ($i < $ext_count)
+		{
+
+		$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$camp_to_print = mysql_num_rows($rslt);
+		if ($camp_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$campaign = sprintf("%-12s", $row[0]);
+			$camp_color = $row[0];
+			}
+		else
+			{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+		if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+			{$campaign = '            ';   	$camp_color = '';}
+
+		$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$xfer_to_print = mysql_num_rows($rslt);
+		if ($xfer_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$fronter = sprintf("%-6s", $row[0]);
+			}
+		else
+			{$fronter = '      ';}
+
+		$G = '';		$EG = '';
+		$G=""; $EG='';
+	#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+	#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+		echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i agents logged in on server $server_ip\n\n";
+
+	#	echo "             - 5 minutes or more on call\n";
+	#	echo "             - Over 10 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPAIGN     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i calls being placed on server $server_ip\n\n";
+
+		echo "             - LIVE CALL WAITING\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "******************************* NO LIVE CALLS WAITING *********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDADall.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDADall.php new file mode 100644 index 00000000..540a5eb6 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDADall.php @@ -0,0 +1,349 @@ + LICENSE: GPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($group)) {$group='';} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Campaign: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Campaign: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFY | REPORTS \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo " NO LIVE CALLS WAITING \n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n\n"; + + $Aecho .= " - Paused agents\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS \n";
+	}
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDADall_SIPmonitor.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDADall_SIPmonitor.php new file mode 100644 index 00000000..0b24f82e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonVDADall_SIPmonitor.php @@ -0,0 +1,301 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala +# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];} +$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];} +$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];} +$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];} +$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];} +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!$RR) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VF DIALER: Time On VDAD Campaign: $group\n"; +echo "
\n"; +echo "VF DIALER: Realtime Campaign: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFY | REPORTS \n"; +echo "\n\n"; + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); + +echo "
"; +echo "DIAL LEVEL: $row[0]         "; +echo "STATUSES: $row[1], $row[2], $row[3], $row[4], $row[5]         "; +echo "ORDER: $row[6]"; +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";} +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo " NO LIVE CALLS WAITING \n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VF DIALER: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + $sessionid = trim($sessionid); + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n"; + + + $Aecho .= " - Paused agents\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS \n";
+	}
+
+?>
+
+ + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeoncall.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeoncall.php new file mode 100644 index 00000000..4227f836 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeoncall.php @@ -0,0 +1,180 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Call\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Call                                          $NOW_TIME\n\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+echo "| STATION    | SESSIONID | CHANNEL   | NUMBER DIALED    | START TIME          | MINUTES |\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+
+$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="select extension from live_channels where server_ip='$server_ip';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$ext_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_zap_counter=0;
+	$sessions = '';
+	while ($i < $ext_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if (preg_match("/^8600/i",$row[0]))
+			{
+			$sessions .= "$row[0]|";
+			}
+		$i++;
+		}
+	$sessions = preg_replace("/\|$/",'',$sessions);
+
+	if ($DB) {echo "SESSIONS: -$sessions-\n";}
+
+	$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_calls_counter=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
+			{
+			if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
+			$session_id = '';
+			}
+		else 
+			{
+			if (preg_match("/$row[3]/i",$sessions))
+				{
+				if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
+				$session_id = $row[3];
+				$station = preg_replace("/SIP\//",'',$row[0]);
+				$station = preg_replace("/-.*/",'',$station);
+			
+				$LIVE_sessions[$live_calls_counter] =			"$session_id";
+				$LIVE_sessions_FORMAT[$live_calls_counter] =	sprintf("%-9s", $session_id);
+				$LIVE_stations[$live_calls_counter] =			"$station";
+				$LIVE_stations_FORMAT[$live_calls_counter] =	sprintf("%-10s", $station);
+
+		#		echo "| $station | $session_id | \n";
+
+				$live_calls_counter++;
+				}
+			else
+				{
+				if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
+				$session_id = '';
+				}
+			}
+
+		$i++;
+		}
+
+		if ($live_calls_counter > 0)
+		{
+		$i=0;
+		$LC_counter = $live_calls_counter;
+
+		while ($i < $live_calls_counter)
+			{
+			$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$parked_to_print = mysql_num_rows($rslt);
+			$row=mysql_fetch_row($rslt);
+
+			$channel =			sprintf("%-9s", $row[0]);
+			$number_dialed =	sprintf("%-16s", $row[2]);
+			$start_time =		sprintf("%-19s", $row[3]);
+			$call_time_S = ($STARTtime - $row[4]);
+
+			$call_time_M = ($call_time_S / 60);
+			$call_time_M = round($call_time_M, 2);
+			$call_time_M_int = intval("$call_time_M");
+			$call_time_SEC = ($call_time_M - $call_time_M_int);
+			$call_time_SEC = ($call_time_SEC * 60);
+			$call_time_SEC = round($call_time_SEC, 0);
+			if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+			$call_time_MS = "$call_time_M_int:$call_time_SEC";
+			$call_time_MS =		sprintf("%7s", $call_time_MS);
+			$G = '';		$EG = '';
+			if ($call_time_M_int >= 12) {$G=''; $EG='';}
+			if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+			echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+			$i++;
+			}
+
+		echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+		echo "  $i stations on live calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on live call\n";
+		echo "             - Over 30 minutes on live call\n";
+
+		}
+		else
+		{
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*************************************** NO LIVE STATIONS ********************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		}
+
+	}
+	else
+	{
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*************************************** NO LIVE STATIONS ********************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	}
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonpark.php b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonpark.php new file mode 100644 index 00000000..78caf4dc --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/AST_timeonpark.php @@ -0,0 +1,197 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park                       $NOW_TIME\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "******************** NO LIVE CALLS WAITING *********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/admin.php b/agc_2-X/trunk/LANG_admin/vicidial_en/admin.php new file mode 100644 index 00000000..85bf7eae --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/admin.php @@ -0,0 +1,6514 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["safe_harbor_message"])) {$safe_harbor_message=$_GET["safe_harbor_message"];} + elseif (isset($_POST["safe_harbor_message"])) {$safe_harbor_message=$_POST["safe_harbor_message"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_message"])) {$drop_message=$_GET["drop_message"];} + elseif (isset($_POST["drop_message"])) {$drop_message=$_POST["drop_message"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS ONLY ### +$user_level = ereg_replace("[^0-9]","",$user_level); +$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); +$xferconf_a_number = ereg_replace("[^0-9]","",$xferconf_a_number); +$xferconf_b_number = ereg_replace("[^0-9]","",$xferconf_b_number); +$drop_call_seconds = ereg_replace("[^0-9]","",$drop_call_seconds); +$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); +$safe_harbor_exten = ereg_replace("[^0-9]","",$safe_harbor_exten); +$am_message_exten = ereg_replace("[^0-9]","",$am_message_exten); +$campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); +$campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); +$drop_exten = ereg_replace("[^0-9]","",$drop_exten); +$dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); +$park_ext = ereg_replace("[^0-9]","",$park_ext); +$hopper_level = ereg_replace("[^0-9]","",$hopper_level); +$agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); +$hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); +$agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); +$agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); +$vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); +$vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); +$closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); +$alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); +$delete_users = ereg_replace("[^0-9]","",$delete_users); +$delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); +$delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); +$delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); +$delete_lists = ereg_replace("[^0-9]","",$delete_lists); +$delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); +$delete_filters = ereg_replace("[^0-9]","",$delete_filters); +$delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); +$delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); +$load_leads = ereg_replace("[^0-9]","",$delete_call_times); +$campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); +$ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); +$ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); +$modify_leads = ereg_replace("[^0-9]","",$modify_leads); +$change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); +$modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); +$ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); +$ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); +$ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); +$ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); +$ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); +$ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); +$ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); +$ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); +$ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); +$ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); +$ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); +$ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); +$ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); +$ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); +$ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); +$ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); +$number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); +$user_start = ereg_replace("[^0-9]","",$user_start); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +$remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); +$attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); +$hotkey = ereg_replace("[^0-9]","",$hotkey); +$list_id = ereg_replace("[^0-9]","",$list_id); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); +$allow_closers = ereg_replace("[^NY]","",$allow_closers); +$reset_hopper = ereg_replace("[^NY]","",$reset_hopper); +$amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); +$alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); +$safe_harbor_message = ereg_replace("[^NY]","",$safe_harbor_message); +$selectable = ereg_replace("[^NY]","",$selectable); +$reset_list = ereg_replace("[^NY]","",$reset_list); +$fronter_display = ereg_replace("[^NY]","",$fronter_display); +$drop_message = ereg_replace("[^NY]","",$drop_message); +$use_internal_dnc = ereg_replace("[^NY]","",$use_internal_dnc); + +### ALPHA-NUMERIC ONLY ### +$user = ereg_replace("[^0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^0-9a-zA-Z]","",$pass); +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); +$submit = ereg_replace("[^0-9a-zA-Z]","",$submit); +$CoNfIrM = ereg_replace("[^0-9a-zA-Z]","",$CoNfIrM); +$campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); +$get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); +$campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); +$ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); +$dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); +$state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); +$scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + +### DIGITS and Dots +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + +### DIGITS and spaces and hash and star and comma +$xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_a_dtmf); +$xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_b_dtmf); + +### ALPHA-NUMERIC and underscore and dash +$dial_status_e = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_e); +$dial_status_d = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_d); +$dial_status_c = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_c); +$dial_status_b = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_b); +$dial_status_a = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_a); +$stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); +$lead_filter_id = ereg_replace("[^-\_0-9a-zA-Z]","",$lead_filter_id); +$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); +$old_campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_campaign_id); +$park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); +$next_agent_call = ereg_replace("[^-\_0-9a-zA-Z]","",$next_agent_call); +$local_call_time = ereg_replace("[^-\_0-9a-zA-Z]","",$local_call_time); +$call_time_id = ereg_replace("[^-\_0-9a-zA-Z]","",$call_time_id); +$phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); +$phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); +$group_id = ereg_replace("[^-\_0-9a-zA-Z]","",$group_id); +$user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$user_group); +$OLDuser_group = ereg_replace("[^-\_0-9a-zA-Z]","",$OLDuser_group); +$state_rule = ereg_replace("[^-\_0-9a-zA-Z]","",$state_rule); + +### ALPHA-NUMERIC and spaces +$lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); +### ALPHA-NUMERIC and hash +$group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); +$campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); +$HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); +$status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); +$script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); +$script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); +$list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); +$lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); +$lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); +$campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); +$call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); +$call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + +### remove semi-colons ### +$lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + +### VARIABLES TO BE mysql_real_escape_string ### +# $web_form_address +# $script_text + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# AST GUI database administration +# admin.php +# +# CHANGES +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug +# + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$version = '1.1.12-3'; +$build = '60623-1159'; + +$STARTtime = date("U"); + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGuser_level =$row[4]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD==1) {$hh='users'; echo "Add New User";} +if ($ADD==11) {$hh='campaigns'; echo "Add New Campaign";} +if ($ADD==111) {$hh='lists'; echo "Add New List";} +if ($ADD==121) {$hh='lists'; echo "Add New DNC";} +if ($ADD==1111) {$hh='ingroups'; echo "Add New In-Group";} +if ($ADD==11111) {$hh='remoteagent'; echo "Add New Remote Agents";} +if ($ADD==111111) {$hh='usergroups'; echo "Add New Users Group";} +if ($ADD==1111111) {$hh='scripts'; echo "Add New Script";} +if ($ADD==11111111) {$hh='filters'; echo "Add New Filter";} +if ($ADD==111111111) {$hh='times'; echo "Add New Call Time";} +if ($ADD==1111111111) {$hh='times'; echo "Add New State Call Time";} +if ($ADD==2) {$hh='users'; echo "New User Addition";} +if ($ADD==21) {$hh='campaigns'; echo "New Campaign Addition";} +if ($ADD==22) {$hh='campaigns'; echo "New Campaign Status Addition";} +if ($ADD==23) {$hh='campaigns'; echo "New Campaign HotKey Addition";} +if ($ADD==25) {$hh='campaigns'; echo "New Campaign Lead Recycle Addition";} +if ($ADD==211) {$hh='lists'; echo "New List Addition";} +if ($ADD==2111) {$hh='ingroups'; echo "New In-Group Addition";} +if ($ADD==21111) {$hh='remoteagent'; echo "New Remote Agents Addition";} +if ($ADD==211111) {$hh='usergroups'; echo "New Users Group Addition";} +if ($ADD==2111111) {$hh='scripts'; echo "New Script Addition";} +if ($ADD==21111111) {$hh='filters'; echo "New Filter Addition";} +if ($ADD==211111111) {$hh='times'; echo "New Call Time Addition";} +if ($ADD==2111111111) {$hh='times'; echo "New State Call Time Addition";} +if ($ADD==3) {$hh='users'; echo "Modify User";} +if ($ADD==31) {$hh='campaigns'; echo "Modify Campaign";} +if ($ADD==34) {$hh='campaigns'; echo "Modify Campaign - Basic View";} +if ($ADD==311) {$hh='lists'; echo "Modify List";} +if ($ADD==3111) {$hh='ingroups'; echo "Modify In-Group";} +if ($ADD==31111) {$hh='remoteagent'; echo "Modify Remote Agents";} +if ($ADD==311111) {$hh='usergroups'; echo "Modify Users Groups";} +if ($ADD==3111111) {$hh='scripts'; echo "Modify Script";} +if ($ADD==31111111) {$hh='filters'; echo "Modify Filter";} +if ($ADD==311111111) {$hh='times'; echo "Modify Call Time";} +if ($ADD==321111111) {$hh='times'; echo "Modify Call Time State Definitions List";} +if ($ADD==3111111111) {$hh='times'; echo "Modify State Call Time";} +if ($ADD=="4A") {$hh='users'; echo "Modify User - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Modify User - Admin";} +if ($ADD==4) {$hh='users'; echo "Modify User";} +if ($ADD==41) {$hh='campaigns'; echo "Modify Campaign";} +if ($ADD==42) {$hh='campaigns'; echo "Modify Campaign Status";} +if ($ADD==43) {$hh='campaigns'; echo "Modify Campaign HotKey";} +if ($ADD==44) {$hh='campaigns'; echo "Modify Campaign - Basic View";} +if ($ADD==45) {$hh='campaigns'; echo "Modify Campaign Lead Recycle";} +if ($ADD==411) {$hh='lists'; echo "Modify List";} +if ($ADD==4111) {$hh='ingroups'; echo "Modify In-Group";} +if ($ADD==41111) {$hh='remoteagent'; echo "Modify Remote Agents";} +if ($ADD==411111) {$hh='usergroups'; echo "Modify Users Groups";} +if ($ADD==4111111) {$hh='scripts'; echo "Modify Script";} +if ($ADD==41111111) {$hh='filters'; echo "Modify Filter";} +if ($ADD==411111111) {$hh='times'; echo "Modify Call Time";} +if ($ADD==4111111111) {$hh='times'; echo "Modify State Call Time";} +if ($ADD==5) {$hh='users'; echo "Delete User";} +if ($ADD==51) {$hh='campaigns'; echo "Delete Campaign";} +if ($ADD==52) {$hh='campaigns'; echo "Logout Agents";} +if ($ADD==511) {$hh='lists'; echo "Delete List";} +if ($ADD==5111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==51111) {$hh='remoteagent'; echo "Delete Remote Agents";} +if ($ADD==511111) {$hh='usergroups'; echo "Delete Users Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Delete Script";} +if ($ADD==51111111) {$hh='filters'; echo "Delete Filter";} +if ($ADD==511111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==5111111111) {$hh='times'; echo "Delete State Call Time";} +if ($ADD==6) {$hh='users'; echo "Delete User";} +if ($ADD==61) {$hh='campaigns'; echo "Delete Campaign";} +if ($ADD==62) {$hh='campaigns'; echo "Logout Agents";} +if ($ADD==65) {$hh='campaigns'; echo "Delete Lead Recycle";} +if ($ADD==611) {$hh='lists'; echo "Delete List";} +if ($ADD==6111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==61111) {$hh='remoteagent'; echo "Delete Remote Agents";} +if ($ADD==611111) {$hh='usergroups'; echo "Delete Users Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Delete Script";} +if ($ADD==61111111) {$hh='filters'; echo "Delete Filter";} +if ($ADD==611111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==6111111111) {$hh='times'; echo "Delete State Call Time";} +if ($ADD==73) {$hh='campaigns'; echo "Dialable Lead Count";} +if ($ADD==7111111) {$hh='scripts'; echo "Preview Script";} +if ($ADD==0) {$hh='users'; echo "Users List";} +if ($ADD==8) {$hh='users'; echo "CallBacks Within Agent";} +if ($ADD==81) {$hh='campaigns'; echo "CallBacks Within Campaign";} +if ($ADD==811) {$hh='campaigns'; echo "CallBacks Within List";} +if ($ADD==10) {$hh='campaigns'; echo "Campaigns";} +if ($ADD==100) {$hh='lists'; echo "Lists";} +if ($ADD==1000) {$hh='ingroups'; echo "In-Groups";} +if ($ADD==10000) {$hh='remoteagent'; echo "Remote Agents";} +if ($ADD==100000) {$hh='usergroups'; echo "User Groups";} +if ($ADD==1000000) {$hh='scripts'; echo "Scripts";} +if ($ADD==10000000) {$hh='filters'; echo "Filters";} +if ($ADD==100000000) {$hh='times'; echo "Call Times";} +if ($ADD==1000000000) {$hh='times'; echo "State Call Times";} +if ($ADD==55) {$hh='users'; echo "Search Form";} +if ($ADD==66) {$hh='users'; echo "Search Results";} +if ($ADD==99999) {$hh='users'; echo "HELP";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or ($ADD==21) or ($ADD==31) or ($ADD==41) or ($ADD=="4A") or ($ADD=="4B") ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ($ADD==31) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<100) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"../astguiclient/help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
VICIDIAL ADMIN: HELP


\n"; + +?> +VICIDIAL_USERS TABLE

+ +
+User ID - This field is where you put the VICIDIAL users ID number, can be up to 8 digits in length, Must be at least 2 characters in length. + +
+
+
+Password - This field is where you put the VICIDIAL users password. Must be at least 2 characters in length. + +
+
+
+Full Name - This field is where you put the VICIDIAL users full name. Must be at least 2 characters in length. + +
+
+
+User Level - This menu is where you select the VICIDIAL users user level. Must be a level of 1 to log into VICIDIAL, Must be level greater than 2 to log in as a closer, Must be user level 8 or greater to get into admin web section. + +
+
+
+User Group - This menu is where you select the VICIDIAL users group that this user will belong to. This does not have any restrictions at this time, this is just to subdivide users and allow for future features based upon it. + +
+
+
+Phone Login - Here is where you can set a default phone login value for when the user logs into vicidial.php. This value will populate the phone_login automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. + +
+
+
+Phone Pass - Here is where you can set a default phone pass value for when the user logs into vicidial.php. This value will populate the phone_pass automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. + +
+
+
+HotKeys Active - This option if set to 1 allows the user to use the HotKeys quick-dispositioning function in vicidial.php. + +
+
+
+Agent Choose Ingroups - This option if set to 1 allows the user to choose the ingroups that they will receive calls from when they login to a CLOSER or INBOUND campaign. Otherwise the Manager will need to set this in their user detail screen of the admin page. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + +
+
+
+Scheduled Callbacks - This option allows an agent to disposition a call as CALLBK and choose the data and time at which the lead will be re-activated. + +
+
+
+Agent-Only Callbacks - This option allows an agent to set a callback so that they are the only Agent that can call the customer back. This also allows the agent to see their callback listings and call them back any time they want to. + +
+
+
+Agent Call Manual - This option allows an agent to manually enter a new lead into the system and call them. This also allows the calling of any phone number from their vicidial screen and puts that call into their session. Use this option with caution. + +
+
+
+Vicidial Recording - This option can prevent an agent from doing any recordings after they log in to vicidial. This option must be on for vicidial to follow the campaign recording session. + +
+
+
+Vicidial Transfers - This option can prevent an agent from opening the transfer - conference session of vicidial. If this is disabled, the agent cannot third party call or blind transfer any calls. + +
+
+
+Closer Default Blended - This option simply defaults the Blended checkbox on a CLOSER login screen. + +
+
+
+Alter Agent Interface Options - This option if set to 1 allows the administrative user to modify the Agents interface options in admin.php. + +
+
+
+Delete Users - This option if set to 1 allows the user to delete other users of equal or lesser user level from the system. + +
+
+
+Delete User Groups - This option if set to 1 allows the user to delete user groups from the system. + +
+
+
+Delete Lists - This option if set to 1 allows the user to delete vicidial lists from the system. + +
+
+
+Delete Campaigns - This option if set to 1 allows the user to delete vicidial campaigns from the system. + +
+
+
+Delete In-Groups - This option if set to 1 allows the user to delete vicidial In-Groups from the system. + +
+
+
+Delete Remote Agents - This option if set to 1 allows the user to delete vicidial remote agents from the system. + +
+
+
+Load Leads - This option if set to 1 allows the user to load vicidial leads into the vicidial_list table by way of the web based lead loader. + +
+
+
+Campaign Detail - This option if set to 1 allows the user to view and modify the campaign detail screen elements. + +
+
+
+AGC Admin Access - This option if set to 1 allows the user to login to the astGUIclient admin pages. + +
+
+
+AGC Delete Phones - This option if set to 1 allows the user to delete phone entries in the astGUIclient admin pages. + +
+
+
+Delete Scripts - This option if set to 1 allows the user to delete Campaign scripts in the script modification screen. + +
+
+
+Modify Leads - This option if set to 1 allows the user to modify leads in the admin section lead search results page. + +
+
+
+Change Agent Campaign - This option if set to 1 allows the user to alter the campaign that an agent is logged into while they are logged into it. + +
+
+
+Delete Filters - This option allows the user to be able to delete vicidial lead filters from the system. + +
+
+
+Delete Call Times - This option allows the user to be able to delete vicidial call times records and vicidial state call times records from the system. + +
+
+
+Modify Call Times - This option allows the user to view and modify the call times and state call times records. A user doesn't need this option enabled if they only need to change the call times option on the campaigns screen. + + + + +



+ +VICIDIAL_CAMPAIGNS TABLE

+
+
+Campaign ID - This is the short name of the campaign, it is not editable after initial submission, cannot contain spaces and must be between 2 and 8 characters in length. + +
+
+
+Campaign Name - This is the description of the campaign, it must be between 6 and 40 characters in length. + +
+
+
+Active - This is where you set the campaign to Active or Inactive. If Inactive, noone can log into it. + +
+
+
+Park Extension - This is where you can customize the on-hold music for VICIDIAL. Make sure the extension is in place in the extensions.conf and that it points to the filename below. + +
+
+
+Park File Name - This is where you can customize the on-hold music for VICIDIAL. Make sure the filename is 10 characters in length or less and that the file is in place in the /var/lib/asterisk/sounds directory. + +
+
+
+Web Form - This is where you can set the custom web page that will be opened when the user clicks on the WEB FORM button. + +
+
+
+Allow Closers - This is where you can set whether the users of this campaign will have the option to send the call to a closer. + +
+
+
+Dial Status - This is where you set the statuses that you are wanting to dial on within the lists that are active for the campaign below + +
+
+
+List Order - This menu is where you select how the leads that match the statuses selected above will be put in the lead hopper: +
  - DOWN: select the first leads loaded into the vicidial_list table +
  - UP: select the last leads loaded into the vicidial_list table +
  - UP PHONE: select the highest phone number and works its way down +
  - DOWN PHONE: select the lowest phone number and works its way up +
  - UP LAST NAME: starts with last names starting with Z and works its way down +
  - DOWN LAST NAME: starts with last names starting with A and works its way up +
  - UP COUNT: starts with most called leads and works its way down +
  - DOWN COUNT: starts with least called leads and works its way up +
  - DOWN COUNT 2nd NEW: starts with least called leads and works its way up inserting a NEW lead in every other lead - Must NOT have NEW selected in the dial statuses +
  - DOWN COUNT 3nd NEW: starts with least called leads and works its way up inserting a NEW lead in every third lead - Must NOT have NEW selected in the dial statuses +
  - DOWN COUNT 4th NEW: starts with least called leads and works its way up inserting a NEW lead in every forth lead - Must NOT have NEW selected in the dial statuses + +
+
+
+Hopper Level - This is how many leads the VDhopper script tries to keep in the vicidial_hopper table for this campaign. If running VDhopper script every minute, make this slightly greater than the number of leads you go through in a minute. + +
+
+
+Lead Filter - This is a method of filtering your leads using a fragment of a SQL query. Use this feature with caution, it is easy to stop dialing accidentally with the slightest alteration to the SQL statement. Default is NONE. + +
+
+
+Force Reset of Hopper - This allows you to wipe out the hopper contents upon form submission. It should be filled again when the VDhopper script runs. + +
+
+
+Auto Dial Level - This is where you set how many lines VICIDIAL should use per active agent. zero 0 means auto dialing is off and the agents will click to dial each number. Otherwise VICIDIAL will keep dialing lines equal to active agents multiplied by the dial level to arrive at how many lines this campaign on each server should allow. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. +
  - overall_user_level: orders by the user_level of the agent as defined in the vicidial_users table a higher user_level will receive more calls. + +
+
+
+Local Call Time - This is where you set during which hours you would like to dial, as determined by the local time in the are in which you are calling. This is controlled by area code and is adjusted for Daylight Savings time if applicable. General Guidelines in the USA for Business to Business is 9am to 5pm and Business to Consumer calls is 9am to 9pm. + +
+
+
+Dial Timeout - If defined, calls that would normally hangup after the timeout defined in extensions.conf would instead timeout at this amount of seconds if it is less than the extensions.conf timeout. This allows for quickly changing dial timeouts from server to server and limiting the effects to a single campaign. If you are having a lot of Answering Machine or Voicemail calls you may want to try changing this value to between 21-26 and see if results improve. + +
+
+
+Dial Prefix - This field allows for more easily changing a path of dialing to go out through a different method without doing a reload in Asterisk. Default is 9 based upon a 91NXXNXXXXXX in the dialplan - extensions.conf. + +
+
+
+Campaign CallerID - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. If you are using T1 or E1s to dial out this option is only available if you are using PRIs - ISDN T1s or E1s - that have the custom callerid feature turned on, this will not work with Robbed-bit service(RBS) circuits. This will also work through most VOIP(SIP or IAX trunks) providers that allow dynamic outbound callerID. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Campaign VDAD extension - This field allows for a custom VDAD transfer extension. This allows you to use different VDADtransfer...agi scripts depending upon your campaign. The default transfer AGI - exten 8365 agi-VDADtransfer.agi - just immediately sends the calls on to agents as soon as they are picked up. An additional sample political survey AGI is also now included - 8366 agi-VDADtransferSURVEY.agi - that plays a message to the called person and allows them to make a choice by pressing buttons - effectively pre-screening the lead - . Please note that except for surveys, political calls and charities this form of calling is illegal in the United States. + +
+
+
+Campaign Rec extension - This field allows for a custom recording extension to be used with VICIDIAL. This allows you to use different extensions depending upon how long you want to allow a maximum recording and what type of codec you want to record in. The default exten is 8309 which if you follow the SCRATCH_INSTALL examples will record in the WAV format for upto one hour. Another option included in the examples is 8310 which will record in GSM format for upto one hour. + +
+
+
+Campaign Recording - This menu allows you to choose what level of recording is allowed on this campaign. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. + +
+
+
+Campaign Rec Filename - This field allows you to customize the name of the recording when Campaign recording is ONDEMAND or ALLCALLS. The allowed variables are CAMPAIGN CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. The default is FULLDATE_AGENT and would look like this 20051020-103108_6666. Another example is CAMPAIGN_TINYDATE_CUSTPHONE which would look like this TESTCAMP_51020103108_3125551212. 50 char max. + +
+
+
+Campaign Script - This menu allows you to choose the script that will appear on the agents screen for this campaign. Select NONE to show no script for this campaign. + +
+
+
+Get Call Launch - This menu allows you to choose whether you want to auto-launch the web-form page in a separate window, auto-switch to the SCRIPT tab or do nothing when a call is sent to the agent for this campaign. + +
+
+
+Answering Machine Message - This field is for entering in an extension to blind transfer calls to when the agent gets an answering machine and clicks on the Answering Machine Message button in the transfer conference frame. You must set this exten up in the dialplan - extensions.conf - and make sure it plays an audio file then hangs up. + +
+
+
+AMD send to vm exten - This menu allows you to define whether a message is left on an answering machine when it is detected. the call will be immediately forwarded to the Answering-Machine-Message extension if AMD is active and it is determined that the call is an answering machine. + +
+
+
+Xfer-Conf DTMF - These four fields allow for you to have two sets of Transfer Conference and DTMF presets. When the call or campaign is loaded, the vicidial.php script will show two buttons on the transfer-conference frame and auto-populate the number-to-dial and the send-dtmf fields when pressed. + +
+
+
+Agent Alt Num Dialing - This option allows an agent to manually dial the alternate phone number or address3 field after the main number has been called. + +
+
+
+Scheduled Callbacks - This option allows an agent to disposition a call as CALLBK and choose the data and time at which the lead will be re-activated. + +
+
+
+Drop Call Seconds - The number of seconds from the time the customer line is picked up until the call is considered a DROP, only applies to outbound calls. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Safe Harbor Message - If set to Y will play a message to customer after the Drop Call Seconds timeout is reached without being transferred to an agent. This setting will override sending to a voicemail box if this is set to Y. + +
+
+
+Safe Harbor Exten - This is the dialplan extension that the desired Safe Harbor audio file is located at on your server. + +
+
+
+Wrapup Seconds - The number of seconds to force an agent to wait before allowing them to receive or dial another call. The timer begins as soon as an agent hangs up on their customer - or in the case of alternate number dialing when the agent finishes the lead - Default is 0 seconds. If the timer runs out before the agent has dispositioned the call, the agent still will NOT move on to the next call until they select a disposition. + +
+
+
+Wrapup Message - This is a campaign-specific message to be displayed on the wrapup screen if wrapup seconds is set. + +
+
+
+Wrapup Message - This is a campaign-specific message to be displayed on the wrapup screen if wrapup seconds is set. + +
+
+
+Use Internal DNC List - This defines whether this campaign is to filter leads against the Internal DNC list. If it is set to Y, the hopper will look for each phone number in the DNC list before placing it in the hopper. If it is in the DNC list then it will change that lead status to DNCL so it cannot be dialed. Default is N. + +
+
+
+Allowed Inbound Groups - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound/outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + + + +



+ +VICIDIAL_LISTS TABLE

+
+
+List ID - This is the numerical name of the list, it is not editable after initial submission, must contain only numbers and must be between 2 and 8 characters in length. + +
+
+
+List Name - This is the description of the list, it must be between 2 and 20 characters in length. + +
+
+
+Campaign - This is the campaign that this list belongs to. A list can only be dialed on a single campaign at one time. + +
+
+
+Active - This defines whether the list is to be dialed on or not. + +
+
+
+Reset Lead-Called-Status for this list - This resets all leads in this list to N for "not called since last reset" and means that any lead can now be called if it is the right status as defined in the campaign screen. + +
+
+
+VICIDIAL DNC List - This Do Not Call list contains every lead that has been set to a status of DNC in the system. Through the LISTS - ADD NUMBER TO DNC page you are able to manually add a number to this list so that it will not be called by campaigns that use the internal DNC list. + + + +



+ +VICIDIAL_INBOUND_GROUPS TABLE

+
+
+Group ID - This is the short name of the inbound group, it is not editable after initial submission, must not contain any spaces and must be between 2 and 20 characters in length. + +
+
+
+Group Name - This is the description of the group, it must be between 2 and 30 characters in length. Cannot include dashes, plusses or spaces . + +
+
+
+Group Color - This is the color that displays in the VICIDIAL client app when a call comes in on this group. It must be between 2 and 7 characters long. If this is a hex color definition you must remember to put a # at the beginning of the string or VICIDIAL will not work properly. + +
+
+
+Active - This determines whether this group show up in the selection box when a VICIDIAL agent logs in. + +
+
+
+Web Form - This is the custom address that clicking on the WEB FORM button in VICIDIAL will take you to for calls that come in on this group. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. +
  - overall_user_level: orders by the user_level of the agent as defined in the vicidial_users table a higher user_level will receive more calls. + +
+
+
+Fronter Display - This field determines whether the inbound VICIDIAL agent would have the fronter name - if there is one - displayed in the Status field when the call comes to the agent. + +
+
+
+Campaign Script - This menu allows you to choose the script that will appear on the agents screen for this campaign. Select NONE to show no script for this campaign. + +
+
+
+Get Call Launch - This menu allows you to choose whether you want to auto-launch the web-form page in a separate window, auto-switch to the SCRIPT tab or do nothing when a call is sent to the agent for this campaign. + +
+
+
+Xfer-Conf DTMF - These four fields allow for you to have two sets of Transfer Conference and DTMF presets. When the call or campaign is loaded, the vicidial.php script will show two buttons on the transfer-conference frame and auto-populate the number-to-dial and the send-dtmf fields when pressed. + +
+
+
+Drop Call Seconds - The number of seconds from the time the customer line is picked up until the call is considered a DROP, only applies to outbound calls. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Drop Message - If set to Y will play a message to customer after the Drop Call Seconds timeout is reached without being transferred to an agent. This setting will override sending to a voicemail box if this is set to Y. + +
+
+
+Drop Exten - This is the dialplan extension that the desired Dropped call audio file is located at on your server. + + + +



+ +VICIDIAL_REMOTE_AGENTS TABLE

+
+
+User ID Start - This is the starting User ID that is used when the remote agent entries are inserted into the system. If the Number of Lines is set higher than 1, this number is incremented by one until each line has an entry. Make sure you create a new VICIDIAL user account with a user level of 4 or great if you want them to be able to use the vdremote.php page for remote web access of this account. + +
+
+
+Number of Lines - This defines how many remote agent entries the system creates, and determines how many lines it thinks it can safely send to the number below. + +
+
+
+Server IP - A remote agent entry is only good for one specific server, here is where you select which server you want. + +
+
+
+External Extension - This is the number that you want the calls forwarded to. Make sure that it is a full dialplan number and that if you need a 9 at the beginning you put it in here. Test by dialing this number from a phone on the system. + +
+
+
+Status - Here is where you turn the remote agent on and off. As soon as the agent is Active the system assumes that it can send calls to it. It may take up to 30 seconds once you change the status to Inactive to stop receiving calls. + +
+
+
+Campaign - Here is where you select the campaign that these remote agents will be logged into. Inbound needs to use the CLOSER campaign and select the inbound campaigns below that you want to receive calls from. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + + +



+ +VICIDIAL_CAMPAIGN_LISTS

+
+
+The lists within this campaign are listed here, whether they are active is denoted by the Y or N and you can go to the list screen by clicking on the list ID in the first column. + + +



+ +VICIDIAL_CAMPAIGN_STATUSES TABLE

+
+
+Through the use of custom campaign statuses, you can have statuses that only exist for a specific campaign. The Status must be 1-8 characters in length, the description must be 2-30 characters in length and Selectable defines whether it shows up in VICIDIAL as a disposition. + + + +



+ +VICIDIAL_CAMPAIGN_HOTKEYS TABLE

+
+
+Through the use of custom campaign hotkeys, agents that use the vicidial web-client can hangup and disposition calls just by pressing a single key on their keyboard. + + + + +



+ +VICIDIAL_LEAD_RECYCLE TABLE

+
+
+Through the use of lead recycling, you can call specific statuses of leads again at a specified interval without resetting the entire list. Lead recycling is campaign-specific and does not have to be a selected dialable status in your campaign. The attempt delay field is the number of seconds until the lead can be placed back in the hopper, this number must be at least 120 seconds. The attempt maximum field is the maximum number of times that a lead of this status can be attempted before the list needs to be reset, this number can be from 1 to 10. You can activate and deactivate a lead recycle entry with the provided links. This feature only works in auto-dial mode, where dial level is greater than 0. + + + + + +



+ +VICIDIAL_USER_GROUPS TABLE

+
+
+User Group - This is the short name of a Vicidial User group, try not to use any spaces or punctuation for this field. max 20 characters, minimum of 2 characters. + +
+
+
+Group Name - This is the description of the vicidial user group max of 40 characters. + + + + + +



+ +VICIDIAL_SCRIPTS TABLE

+
+
+Script ID - This is the short name of a Vicidial Script. This needs to be a unique identifier. Try not to use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Script Name - This is the title of a Vicidial Script. This is a short summary of the script. max 50 characters, minimum of 2 characters. There should be no spaces or punctuation of any kind in theis field. + +
+
+Script Comments - This is where you can place comments for a Vicidial Script such as -changed to free upgrade on Sept 23-. max 255 characters, minimum of 2 characters. + +
+
+Script Text - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today? + +
+
+
+Active - This determines whether this script can be selected to be used by a campaign. + + + + + +



+ +VICIDIAL_LEAD_FILTERS TABLE

+
+
+Filter ID - This is the short name of a Vicidial Lead Filter. This needs to be a unique identifier. Do not use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Filter Name - This is a more descriptive name of the Filter. This is a short summary of the filter. max 30 characters, minimum of 2 characters. + +
+
+Filter Comments - This is where you can place comments for a Vicidial Filter such as -calls all California leads-. max 255 characters, minimum of 2 characters. + +
+
+Filter SQL - This is where you place the SQL query fragment that you want to filter by. do not begin or end with an AND, that will be added by the hopper cron script automatically. an example SQL query that would work here is- called_count > 4 and called_count < 8 -. + + + + + +



+ +VICIDIAL_CALL TIMES TABLE

+
+
+Call Time ID - This is the short name of a Vicidial Call Time Definition. This needs to be a unique identifier. Do not use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Call Time Name - This is a more descriptive name of the Call Time Definition. This is a short summary of the Call Time definition. max 30 characters, minimum of 2 characters. + +
+
+Call Time Comments - This is where you can place comments for a Vicidial Call Time Definition such as -10am to 4pm with extra call state restrictions-. max 255 characters. + +
+
+Default Start and Stop Times - This is the default time that calling will be allowed to be started or stopped within this call time definition if the day-of-the-week start time is not defined. 0 is midnight. To prevent calling completely set this field to 2400 and set the Default Stop time to 2400. To allow calling 24 hours a day set the start time to 0 and the stop time to 2400. + +
+
+Weekday Start and Stop Times - These are the custom times per day that can be set for the call time definition. same rules apply as with the Default start and stop times. + +
+
+State Call Time Definitions - This is the list of State specific call time definitions that are followed in this Call Time Definition. + +
+
+State Call Time State - This is the two letter code for the state that this calling time definition is for. For this to be in effect the local call time that is set in the campaign must have this state call time record in it as well as all of the leads having two letter state codes in them. + + + + +



+ +VICIDIAL LIST LOADER FUNCTIONALITY

+
+
+The VICIDIAL basic web-based lead loader is designed simply to take a lead file - up to 8MB in size - that is either tab or pipe delimited and load it into the vicidial_list table. There is also a new beta version super lead loader that allows for field choosing and TXT- Plain Text, CSV- Comma Separated Values and XLS- Excel file formats. The lead loader does not do data validation or check for duplicates in itself or other lists, so that is something you need to do before you load the leads. Also, make sure that you have created the list that these leads are to be under so that you can use them. There is also the matter of time-zone-coding these leads. You may want to increase the frequency that the ADMIN_adjust_GMTnow_on_leads.pl is being run in the cron on your Asterisk server so that any loaded leads can be coded faster. Here is a list of the fields in their proper order for the lead files: +
    +
  1. Vendor Lead Code - shows up in the Vendor ID field of the GUI +
  2. Source Code - internal use only for admins and DBAs +
  3. List ID - the list number that these leads will show up under +
  4. Phone Code - the prefix for the phone number - 1 for US, 01144 for UK, 01161 for AUS, etc +
  5. Phone Number - must be at least 8 digits long +
  6. Title - title of the customer - Mr. Ms. Mrs, etc... +
  7. First Name +
  8. Middle Initial +
  9. Last Name +
  10. Address Line 1 +
  11. Address Line 2 +
  12. Address Line 3 +
  13. City +
  14. State - limited to 2 characters +
  15. Province +
  16. Postal Code +
  17. Country +
  18. Gender +
  19. Date of Birth +
  20. Alternate Phone Number +
  21. Email Address +
  22. Security Phrase +
  23. Comments +
+ +
NOTES: The Excel Lead loader functionality is enabled by a series of perl scripts and needs to have a properly configured /home/cron/AST_SERVER_conf.pl file in place on the web server. Also, a couple perl modules must be loaded for it to work as well - OLE-Storage_Lite and Spreadsheet-ParseExcel. You can check for runtime errors in these by looking at your apache error_log file. + +







+







+THE END +
+\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$dial_status_a = $row[3]; +$dial_status_b = $row[4]; +$dial_status_c = $row[5]; +$dial_status_d = $row[6]; +$dial_status_e = $row[7]; +$local_call_time = $row[16]; +if ($lead_filter_id=='') + { + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + +$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$camp_lists=''; +$o=0; +while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; +if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} +} +$camp_lists = eregi_replace(".$","",$camp_lists); + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + +echo "

\n"; +echo "Show Dialable Leads Count -

\n"; +echo "CAMPAIGN: $campaign_id
\n"; +echo "LISTS: $camp_lists
\n"; +echo "STATUSES: $dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e
\n"; +echo "FILTER: $lead_filter_id
\n"; +echo "CALL TIME: $local_call_time

\n"; + +### call function to calculate and print dialable leads +dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + +echo "

\n"; +echo "\n"; + +exit; +} + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) +{ + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDORLEADCODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551212'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[1]; +$script_text = $row[3]; + +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); +$script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); +$script_text = eregi_replace("\n","
",$script_text); + + +echo ""; + +echo "Preview Script: $script_id
\n"; +echo "
\n"; +echo "
$script_name
\n"; +echo "$script_text\n"; +echo "
\n"; + +echo "\n"; + +exit; +} + + + + +######################### HTML HEADER BEGIN ####################################### +if ($hh=='users') {$users_hh='bgcolor ="#FFFF99"'; $users_fc='BLACK';} # yellow + else {$users_hh=''; $users_fc='WHITE';} +if ($hh=='campaigns') {$campaigns_hh='bgcolor ="#FFCC99"'; $campaigns_fc='BLACK';} # orange + else {$campaigns_hh=''; $campaigns_fc='WHITE';} +if ($hh=='lists') {$lists_hh='bgcolor ="#FFCCCC"'; $lists_fc='BLACK';} # red + else {$lists_hh=''; $lists_fc='WHITE';} +if ($hh=='ingroups') {$ingroups_hh='bgcolor ="#CC99FF"'; $ingroups_fc='BLACK';} # purple + else {$ingroups_hh=''; $ingroups_fc='WHITE';} +if ($hh=='remoteagent') {$remoteagent_hh='bgcolor ="#CCFFCC"'; $remoteagent_fc='BLACK';} # green + else {$remoteagent_hh=''; $remoteagent_fc='WHITE';} +if ($hh=='usergroups') {$usergroups_hh='bgcolor ="#CCFFFF"'; $usergroups_fc='BLACK';} # cyan + else {$usergroups_hh=''; $usergroups_fc='WHITE';} +if ($hh=='scripts') {$scripts_hh='bgcolor ="#99FFCC"'; $scripts_fc='BLACK';} # light teal + else {$scripts_hh=''; $scripts_fc='WHITE';} +if ($hh=='filters') {$filters_hh='bgcolor ="#CCCCCC"'; $filters_fc='BLACK';} # grey + else {$filters_hh=''; $filters_fc='WHITE';} +if ($hh=='times') {$times_hh='bgcolor ="#99FF33"'; $times_fc='BLACK';} # hard teal + else {$times_hh=''; $times_fc='WHITE';} + +?> + + + + +\n"; +echo "
English Español
+ + + + + + + + + + + + + + + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + + + + +
  VICIDIAL ADMIN - Logout  
> SIZE=1> USERS > SIZE=1> CAMPAIGNS > SIZE=1> LISTS > SIZE=1> SCRIPTS > SIZE=1> FILTERS > SIZE=1> IN-GROUPS > SIZE=1> CALL TIMES > SIZE=1> USER GROUPS > SIZE=1> REMOTE AGENTS > REPORTS
  LIST USERS     |     ADD A NEW USER     |     SEARCH FOR A USER
  ADD CAMPAIGN     |     LIST CAMPAIGNS
  SHOW LISTS     |     ADD NEW LIST     |     SEARCH FOR A LEAD |     ADD NUMBER TO DNC           |     LOAD NEW LEADS
  ADD SCRIPT     |     VIEW SCRIPTS
  ADD FILTER     |     VIEW FILTERS
  SHOW IN-GROUPS     |     ADD NEW IN-GROUP
  SHOW CALL TIMES     |     ADD NEW CALL TIME     |     SHOW STATE CALL TIMES     |     ADD NEW STATE CALL TIME  
  ADD USER GROUP     |     LIST USER GROUPS     |     GROUP HOURLY
  SHOW REMOTE AGENTS     |     ADD NEW REMOTE AGENTS
 
+
\n"; +echo ""; + +echo "
ADD A NEW USER
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "$NWB#vicidial_users-user_group$NWE\n"; +echo "\n"; +echo "
User Number: $NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group:
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW CAMPAIGN\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Campaign ID: $NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $NWB#vicidial_campaigns-park_ext$NWE
Park Filename: $NWB#vicidial_campaigns-park_file_name$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: (digits only)$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) +{ +echo "
\n"; +echo ""; + +if (strlen($phone_number) > 2) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DNC NOT ADDED - This phone number is already in the Do Not Call List: $phone_number

\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');"; + $rslt=mysql_query($stmt, $link); + + echo "
DNC ADDED: $phone_number

\n"; + + ### LOG INSERTION TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW DNC NUMBER|$PHP_AUTH_USER|$ip|'$phone_number'|\n"); + fclose($fp); + } + } + } + +echo "
ADD A NUMBER TO THE DNC LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
Phone Number: (digits only)$NWB#vicidial_list-dnc$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW INBOUND GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group ID: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW REMOTE AGENTS\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW USERS GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW SCRIPT\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Script ID: (no spaces or punctuation)$NWB#vicidial_scripts-script_id$NWE
Script Name: (title of the script)$NWB#vicidial_scripts-script_name$NWE
Script Comments: $NWB#vicidial_scripts-script_comments$NWE
Active: $NWB#vicidial_scripts-active$NWE
Script Text: $NWB#vicidial_scripts-script_text$NWE
\n"; + +} + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW FILTER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Filter ID: (no spaces or punctuation)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter Name: (short description of the filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter Comments: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; +} + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW CALL TIME\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Call Time ID: (no spaces or punctuation)$NWB#vicidial_call_times-call_time_id$NWE
Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Day and time options will appear once you have created the Call Time Definition
\n"; +} + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW STATE CALL TIME\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
State Call Time ID: (no spaces or punctuation)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (no spaces or punctuation)$NWB#vicidial_call_times-state_call_time_state$NWE
State Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
State Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Day and time options will appear once you have created the Call Time Definition
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER NOT ADDED - there is already a user in the system with this user number\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
USER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
user id must be between 2 and 8 characters long\n"; + echo "
full name and password must be at least 2 characters long\n"; + } + else + { + echo "
USER ADDED: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass'|\n"); + fclose($fp); + } + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
CAMPAIGN NOT ADDED - Please go back and look at the data you entered\n"; + echo "
campaign ID must be between 2 and 8 characters in length\n"; + echo "
campaign name must be between 6 and 40 characters in length\n"; + } + else + { + echo "
CAMPAIGN ADDED: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('$campaign_id','$campaign_name','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo ""; + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 8 characters in length\n"; + echo "
status name must be between 2 and 30 characters in length\n"; + } + else + { + echo "
CAMPAIGN STATUS ADDED: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } + } +$ADD=31; +} + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) +{ + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN HOTKEY NOT ADDED - there is already a campaign-hotkey in the system with this hotkey\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAIGN HOTKEY NOT ADDED - Please go back and look at the data you entered\n"; + echo "
hotkey must be a single character between 1 and 9 \n"; + echo "
status must be between 1 and 8 characters in length\n"; + } + else + { + echo "
CAMPAIGN HOTKEY ADDED: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN HOTKEY |$PHP_AUTH_USER|$ip|'$status','$hotkey','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) +{ + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - there is already a lead-recycle for this campaign with this status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD RECYCLE ADDED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LIST NOT ADDED - there is already a list in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
LIST NOT ADDED - Please go back and look at the data you entered\n"; + echo "
List ID must be between 2 and 8 characters in length\n"; + echo "
List name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST ADDED: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + } + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GROUP NOT ADDED - there is already a group in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group ID must be between 2 and 20 characters in length and contain no ' -+'.\n"; + echo "
Group name and group color must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + echo "
GROUP ADDED: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
REMOTE AGENTS NOT ADDED - there is already a remote agents entry starting with this userID\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
User ID start and external extension must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + } + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER GROUP NOT ADDED - there is already a user group entry with this name\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW USER GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + } + } + } +$ADD=100000; +} + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SCRIPT NOT ADDED - there is already a script entry with this name\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Script name, description and text must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT ADDED: $script_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000000; +} + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
FILTER NOT ADDED - there is already a filter entry with this ID\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Filter ID, name and SQL must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='$lead_filter_sql';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER ADDED: $lead_filter_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=10000000; +} + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Call Time ID and name must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + + echo "
CALL TIME ADDED: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + } +$ADD=311111111; +} + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATE CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
STATE CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered\n"; + echo "
State Call Time ID, name and state must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + + echo "
STATE CALL TIME ADDED: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=3111111111; +} + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN STATUS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN STATUS DELETED: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAIGN HOTKEY NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + echo "
the campaign hotkey needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN HOTKEY DELETED: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level',lead_filter_id='$lead_filter_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG HOPPER RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=34; # go to campaign modification form below +} + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LIST NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
list name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST MODIFIED: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
RESETTING LIST-CALLED-STATUS\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + } + if ($campaign_id != "$old_campaign_id") + { + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + } + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
group name and group color must be at least 2 characters in length\n"; + } + else + { + echo "
GROUP MODIFIED: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_message='$drop_message',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111; # go to in-group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
User ID Start and External Extension must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + } + } + +$ADD=311111; # go to user group modification form below +} + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Script name, description and text must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111; # go to script modification form below +} + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Filter ID, name and SQL must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='$lead_filter_sql' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31111111; # go to filter modification form below +} + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CALL TIME NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Call Time ID and name must be at least 2 characters in length\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
CALL TIME MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + +$ADD=311111111; # go to call time modification form below +} + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
STATE CALL TIME NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
State Call Time ID, name and state must be at least 2 characters in length\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
STATE CALL TIME MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111111; # go to state call time modification form below +} + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
USER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + echo "
USER DELETION CONFIRMATION: $user\n"; + echo "

Click here to delete user $user


\n"; + } + +$ADD='3'; # go to user modification below +} + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAIGN NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + echo "
CAMPAIGN DELETION CONFIRMATION: $campaign_id\n"; + echo "

Click here to delete campaign $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + echo "
AGENT LOGOUT CONFIRMATION: $campaign_id\n"; + echo "

Click here to log all agents out of $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) +{ + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
LIST NOT DELETED - Please go back and look at the data you entered\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
LIST DELETION CONFIRMATION: $list_id\n"; + echo "

Click here to delete list and all of its leads $list_id


\n"; + } + +$ADD='311'; # go to campaign modification below +} + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
IN-GROUP DELETION CONFIRMATION: $group_id\n"; + echo "

Click here to delete in-group $group_id


\n"; + } + +$ADD='3111'; # go to in-group modification below +} + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTE AGENT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
REMOTE AGENT DELETION CONFIRMATION: $remote_agent_id\n"; + echo "

Click here to delete remote agent $remote_agent_id


\n"; + } + +$ADD='31111'; # go to remote agent modification below +} + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
USER GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + echo "
USER GROUP DELETION CONFIRMATION: $user_group\n"; + echo "

Click here to delete user group $user_group


\n"; + } + +$ADD='311111'; # go to user group modification below +} + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
SCRIPT DELETION CONFIRMATION: $script_id\n"; + echo "

Click here to delete script $script_id


\n"; + } + +$ADD='3111111'; # go to script modification below +} + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Filter ID must be at least 2 characters in length\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Click here to delete filter $lead_filter_id


\n"; + } + +$ADD='31111111'; # go to filter modification below +} + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + echo "
CALL TIME DELETION CONFIRMATION: $call_time_id\n"; + echo "

Click here to delete call time $call_time_id


\n"; + } + +$ADD='311111111'; # go to call time modification below +} + +###################### +# ADD=5111111111 confirmation before deletion of call time record +###################### + +if ($ADD==5111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
STATE CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + echo "
STATE CALL TIME DELETION CONFIRMATION: $call_time_id\n"; + echo "

Click here to delete state call time $call_time_id


\n"; + } + +$ADD='3111111111'; # go to state call time modification below +} + + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
USER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING USER!!!!|$PHP_AUTH_USER|$ip|user='$user'|\n"); + fclose($fp); + } + echo "
USER DELETION COMPLETED: $user\n"; + echo "

\n"; + } + +$ADD='0'; # go to user list +} + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) +{ + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAIGN NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!DELETING CAMPAIGN!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
CAMPAIGN DELETION COMPLETED: $campaign_id\n"; + echo "

\n"; + } + +$ADD='10'; # go to campaigns list +} + +###################### +# ADD=62 Logout all agents fro a campaign +###################### + +if ($ADD==62) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!AGENT LOGOUT!!!!!!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
AGENT LOGOUT COMPLETED: $campaign_id\n"; + echo "

\n"; + } + +$ADD='31'; # go to campaign modification below +} + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD RECYCLE DELETED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) +{ + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
LIST NOT DELETED - Please go back and look at the data you entered\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST LEADS FROM VICIDIAL_LIST TABLE\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING LIST!!!!|$PHP_AUTH_USER|$ip|list_id='$list_id'|\n"); + fclose($fp); + } + echo "
LIST DELETION COMPLETED: $list_id\n"; + echo "

\n"; + } + +$ADD='100'; # go to lists list +} + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_groups where group_id='$group_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING IN-GROUP!!|$PHP_AUTH_USER|$ip|group_id='$group_id'|\n"); + fclose($fp); + } + echo "
IN-GROUP DELETION COMPLETED: $group_id\n"; + echo "

\n"; + } + +$ADD='1000'; # go to in-group list +} + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTE AGENT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING RMTAGENT!!|$PHP_AUTH_USER|$ip|remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + echo "
REMOTE AGENT DELETION COMPLETED: $remote_agent_id\n"; + echo "

\n"; + } + +$ADD='10000'; # go to remote agents list +} + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
USER GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING USRGROUP!!|$PHP_AUTH_USER|$ip|user_group='$user_group'|\n"); + fclose($fp); + } + echo "
USER GROUP DELETION COMPLETED: $user_group\n"; + echo "

\n"; + } + +$ADD='100000'; # go to user group list +} + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING SCRIPT!!!!|$PHP_AUTH_USER|$ip|script_id='$script_id'|\n"); + fclose($fp); + } + echo "
SCRIPT DELETION COMPLETED: $script_id\n"; + echo "

\n"; + } + +$ADD='1000000'; # go to script list +} + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Filter ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING FILTER!!!!|$PHP_AUTH_USER|$ip|lead_filter_id='$lead_filter_id'|\n"); + fclose($fp); + } + echo "
FILTER DELETION COMPLETED: $lead_filter_id\n"; + echo "

\n"; + } + +$ADD='10000000'; # go to filter list +} + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
CALL TIME DELETION COMPLETED: $call_time_id\n"; + echo "

\n"; + } + +$ADD='100000000'; # go to call times list +} + + +###################### +# ADD=6111111111 delete call times record +###################### + +if ($ADD==6111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
STATE CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + + while ($sct_to_print > $o) { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "State Rule Removed: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|state_call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
STATE CALL TIME DELETION COMPLETED: $call_time_id\n"; + echo "

\n"; + } + +$ADD='1000000000'; # go to call times list +} + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + +if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
You do not have permissions to modify this user: $row[1]\n"; + } +else + { + echo "
MODIFY A USERS RECORD: $row[1]\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($LOGuser_level > 8) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "
User Number: $row[1]$NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group: $NWB#vicidial_users-user_group$NWE
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
AGENT INTERFACE OPTIONS:
Agent Choose Ingroups: $NWB#vicidial_users-agent_choose_ingroups$NWE
HotKeys Active: $NWB#vicidial_users-hotkeys_active$NWE
Scheduled Callbacks: $NWB#vicidial_users-scheduled_callbacks$NWE
Agent-Only Callbacks: $NWB#vicidial_users-agentonly_callbacks$NWE
Agent Call Manual: $NWB#vicidial_users-agentcall_manual$NWE
Vicidial Recording: $NWB#vicidial_users-vicidial_recording$NWE
Vicidial Transfers: $NWB#vicidial_users-vicidial_transfers$NWE
Closer Default Blended: $NWB#vicidial_users-closer_default_blended$NWE
Inbound Groups: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_users-closer_campaigns$NWE
ADMIN INTERFACE OPTIONS:
Alter Agent Interface Options: $NWB#vicidial_users-alter_agent_interface_options$NWE
Delete Users: $NWB#vicidial_users-delete_users$NWE
Delete User Groups: $NWB#vicidial_users-delete_user_groups$NWE
Delete Lists: $NWB#vicidial_users-delete_lists$NWE
Delete Campaigns: $NWB#vicidial_users-delete_campaigns$NWE
Delete In-Groups: $NWB#vicidial_users-delete_ingroups$NWE
Delete Remote Agents: $NWB#vicidial_users-delete_remote_agents$NWE
Delete Scripts: $NWB#vicidial_users-delete_scripts$NWE
Load Leads: $NWB#vicidial_users-load_leads$NWE
Campaign Detail: $NWB#vicidial_users-campaign_detail$NWE
AGC Admin Access: $NWB#vicidial_users-ast_admin_access$NWE
AGC Delete Phones: $NWB#vicidial_users-ast_delete_phones$NWE
Modify Leads: $NWB#vicidial_users-modify_leads$NWE
Change Agent Campaign: $NWB#vicidial_users-change_agent_campaign$NWE
Delete Filters: $NWB#vicidial_users-delete_filters$NWE
Delete Call Times: $NWB#vicidial_users-delete_call_times$NWE
Modify Call Times: $NWB#vicidial_users-modify_call_times$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

DELETE THIS USER\n"; + } + echo "

Click here for user time sheet\n"; + echo "

Click here for user status\n"; + echo "

Click here for user stats\n"; + echo "

Click here for user CallBack Holds\n"; + } + +} + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed + +if ($ADD==31) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $safe_harbor_message = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; +# $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + +echo "
MODIFY A CAMPAIGNS RECORD: $row[0] - Basic View"; +echo " | Detail View | "; +echo "Realtime Screen\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +if (eregi("CLOSER", $campaign_id)) + { + echo "\n"; + } + + + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Dial Timeout: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Dial Prefix: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
Campaign CallerID: $NWB#vicidial_campaigns-campaign_cid$NWE
Campaign VDAD exten: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Campaign Rec exten: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Campaign Recording: $NWB#vicidial_campaigns-campaign_recording$NWE
Campaign Rec Filename: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
Answering Machine Message: $NWB#vicidial_campaigns-am_message_exten$NWE
AMD Send to VM exten: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf Number 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf Number 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Alt Number Dialing: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Scheduled Callbacks: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Drop Call Seconds: $NWB#vicidial_campaigns-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Use Safe Harbor Message: $NWB#vicidial_campaigns-safe_harbor_message$NWE
Safe Harbor Exten: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Wrapup Seconds: $NWB#vicidial_campaigns-wrapup_seconds$NWE
Wrapup Message: $NWB#vicidial_campaigns-wrapup_message$NWE
Use Internal DNC List: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Allowed Inbound Groups:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
\n"; + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - HIDE

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - SHOW

"; + } + + + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "Click here to see all CallBack Holds in this campaign

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
CUSTOM STATUSES WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
STATUSDESCRIPTIONSELECTABLEDELETE
$rowx[0]$rowx[1]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN STATUS
\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Description:   \n"; +echo "Selectable:   \n"; +echo "
\n"; + +echo "

\n"; + + + +echo "
CUSTOM HOTKEYS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
HOTKEYSTATUSDESCRIPTIONDELETE
$rowx[1]$rowx[0]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN HOTKEY
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Hotkey:   \n"; +echo "Status:   \n"; +echo "
\n"; +echo "

\n"; + + + +echo "

LEAD RECYCLING WITHIN THIS CAMPAIGN:   $NWB#vicidial_lead_recycle$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +echo "
STATUSATTEMPT DELAYATTEMPT MAXIMUMACTIVE DELETE
$rowx[2]
\n"; + echo "\n"; + echo "\n"; + echo "
DELETE
\n"; + +echo "
ADD NEW CAMPAIGN LEAD RECYCLE
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Attempt Delay: \n"; +echo "Attempt Maximum: \n"; +echo "
\n"; + +echo "

\n"; + +echo "LOG ALL AGENTS OUT OF THIS CAMPAIGN

\n"; + +if ($LOGdelete_campaigns > 0) + { + echo "

DELETE THIS CAMPAIGN\n"; + } + +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ($ADD==34) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Basic View | "; +echo "Detail View | "; +echo "Realtime Screen\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Web Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Script: $script_id
Get Call Launch: $get_call_launch
\n"; + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - HIDE

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - SHOW

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "Click here to see all CallBack Holds in this campaign

\n"; +echo "
\n"; + +echo "
\n"; + +echo "LOG ALL AGENTS OUT OF THIS CAMPAIGN

\n"; + + +if ($LOGdelete_campaigns > 0) + { + echo "

DELETE THIS CAMPAIGN\n"; + } + + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT * from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + +echo "
MODIFY A LISTS RECORD: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: $row[0]$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
Reset Lead-Called-Status for this list: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
STATUSES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + +echo "\n"; +echo "\n"; + +echo "
STATUSSTATUS NAMECALLEDNOT CALLED
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + +echo "
\n"; +echo "
TIME ZONES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + +echo "\n"; +echo "\n"; + +echo "
GMT OFFSET NOW (local time)CALLEDNOT CALLED
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
CALLED COUNTS WITHIN THIS LIST:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + +echo "
STATUSSTATUS NAME$firstSUBTOTAL
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
TOTAL$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +if ($LOGdelete_lists > 0) + { + echo "

DELETE THIS LIST\n"; + } + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_message = $row[15]; + $drop_exten = $row[16]; + +echo "
MODIFY A GROUPS RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +echo "\n"; +echo "
Group ID: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf Number 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf Number 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Drop Call Seconds: $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Use Drop Message: $NWB#vicidial_inbound_groups-drop_message$NWE
Drop Exten: $NWB#vicidial_inbound_groups-drop_exten$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +if ($LOGdelete_ingroups > 0) + { + echo "

DELETE THIS IN-GROUP\n"; + } + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + + +if ($LOGdelete_remote_agents > 0) + { + echo "

DELETE THIS REMOTE AGENT\n"; + } + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
MODIFY A USERS GROUP ENTRY\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +if ($LOGdelete_user_groups > 0) + { + echo "

DELETE THIS USER GROUP\n"; + } + +} + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = $row[3]; + $active = $row[4]; +echo ""; + +echo "
MODIFY A SCRIPT\n"; +echo "\n"; +echo "\n"; +echo "
Script ID: $script_id$NWB#vicidial_scripts-script_name$NWE
Script Name: (title of the script)$NWB#vicidial_scripts-script_name$NWE
Script Comments: $NWB#vicidial_scripts-script_comments$NWE
Active: $NWB#vicidial_scripts-active$NWE
Script Text:

Preview Script
$NWB#vicidial_scripts-script_text$NWE
\n"; + +if ($LOGdelete_scripts > 0) + { + echo "

DELETE THIS SCRIPT\n"; + } + +} + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = $row[3]; +echo ""; + +echo "
MODIFY A FILTER\n"; +echo "\n"; +echo "\n"; +echo "
Filter ID: $lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter Name: (short description of the filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter Comments: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + +echo "

"; +echo "
TEST ON CAMPAIGN:
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($LOGdelete_filters > 0) + { + echo "

DELETE THIS FILTER\n"; + } + +} + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) +{ +if ($LOGmodify_call_times==1) +{ + +if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "State Rule Added: $state_rule
\n"; + } +if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "State Rule Removed: $state_rule
\n"; + } + +$ADD=311111111; +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +$ct_srs=1; +$b=0; +$srs_SQL =''; +if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } +echo "\n"; +echo "\n"; +while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } +if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } +else + {$srs_SQL='';} +$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; +$rslt=mysql_query($stmt, $link); +$sct_to_print = mysql_num_rows($rslt); +$sct_list=''; + +$o=0; +while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; +} +echo "\n"; +echo "\n"; + +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + +echo ""; + +echo "
MODIFY A CALL TIME\n"; +echo "\n"; +echo "\n"; +echo "
Call Time ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Default Start: Default Stop: $NWB#vicidial_call_times-ct_default_start$NWE
Sunday Start: Sunday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Monday Start: Monday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Tuesday Start: Tuesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Wednesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Thursday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Friday Start: Friday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Saturday Start: Saturday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Active State Call Time Definitions for this Record:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Add state call time rule:


\n"; +echo "CAMPAIGNS USING THIS CALL TIME:
\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + $CT_camp_id = $row[1]; + $CT_camp_name = $row[2]; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

DELETE THIS CALL TIME DEFINITION\n"; + } +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + +echo ""; + +echo "
MODIFY A STATE CALL TIME
\n"; +echo "\n"; +echo "\n"; +echo "
Call Time ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
State Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
State Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Default Start: Default Stop: $NWB#vicidial_call_times-ct_default_start$NWE
Sunday Start: Sunday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Monday Start: Monday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Tuesday Start: Tuesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Wednesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Thursday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Friday Start: Friday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Saturday Start: Saturday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; +echo "CALL TIMES USING THIS STATE CALL TIME:
\n"; +echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

DELETE THIS STATE CALL TIME DEFINITION\n"; + } + +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo "
\n"; +echo ""; + +echo "
SEARCH FOR A USER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
User Number:
Full Name:
User Level:
User Group:
\n"; + +} + +###################### +# ADD=66 user search results +###################### + +if ($ADD==66) +{ +echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS | STATUS | TIME
\n"; + +} + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and user='$user' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
USER CALLBACK HOLD LISTINGS: $user\n"; +$ADD='82'; +} + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and campaign_id='$campaign_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN CALLBACK HOLD LISTINGS: $campaign_id\n"; +$ADD='82'; +} + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and list_id='$list_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; +$ADD='82'; +} + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) +{ +echo "
\n"; +echo "
\n"; +echo "\n"; + + $o=0; + while ($cb_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
LEADLISTCAMPAIGNENTRY DATECALLBACK DATEUSERRECIPIENTSTATUS
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS | STATUS | TIME
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
LIST LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  MODIFY
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
INBOUND GROUP LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  MODIFY
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
REMOTE AGENTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]MODIFY
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER GROUPS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SCRIPTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) +{ +echo "\n";echo "\n";?> +
+
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LEAD FILTER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
CALL TIME LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[4] MODIFY
\n"; +} + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
STATE CALL TIME LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3] $row[4] MODIFY
\n"; +} + + + + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BUILD: $build
\n"; + + +?> + + +
+ + + +1) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "This campaign has $active_leads leads to be dialed in those lists\n"; + } + else + { + echo "no active lists selected for this campaign\n"; + } + } +else + { + echo "no active lists selected for this campaign\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/admin_changes_log.txt b/agc_2-X/trunk/LANG_admin/vicidial_en/admin_changes_log.txt new file mode 100644 index 00000000..e4750d94 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/admin_changes_log.txt @@ -0,0 +1,37 @@ +Wed, 14 Dec 2005 10:17:51 -0500|ADD A NEW SCRIPT ENTRY |6666|10.10.6.19|'TESTCAMP01','first test script','script_comments','script_text','Y'| +Wed, 14 Dec 2005 17:02:06 -0500|ADD A NEW SCRIPT ENTRY |6666|10.10.6.19|'TESTCAMP02','first test script','for testing purposes only','asdf asdf as dfafd as dfas fda sf as fa sdf a sdf as fda sdf a sdf as fas df as fa sf as dfa sdf a fd + + +hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there ','Y'| +Wed, 14 Dec 2005 17:04:05 -0500|ADD A NEW SCRIPT ENTRY |6666|10.10.6.19|'TESTCAMP03','first test script','for testing purposes only','asdf asdf as dfafd as dfas fda sf as fa sdf a sdf as fda sdf a sdf as fas df as fa sf as dfa sdf a fd + + +hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there hello there ','Y'| +Tue, 03 Jan 2006 11:33:22 -0500|RESET LIST CALLED |123456|10.10.6.19|list_name='test domestic lists'| +Tue, 03 Jan 2006 11:33:22 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='test domestic lists',campaign_id='TESTCAMP',active='Y' where list_id='101'| +Mon, 23 Jan 2006 10:45:26 -0500|ADD A NEW CAMPAIGN |123456|10.10.6.19|INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('CCONFIRM','College Partnership Confirm','Y','NEW','DOWN','','','','Y','50','1','oldest_call_finish','9am-9pm','','','NONE')| +Mon, 23 Jan 2006 10:46:09 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='NEW',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='60', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|N| +Mon, 23 Jan 2006 10:47:08 -0500|ADD A NEW CAMPAIGN HOTKEY |123456|10.10.6.19|'A','1','Answering Machine','Y','CCONFIRM'| +Mon, 23 Jan 2006 10:47:14 -0500|ADD A NEW CAMPAIGN HOTKEY |123456|10.10.6.19|'N','2','No Answer','Y','CCONFIRM'| +Mon, 23 Jan 2006 10:48:06 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership',active='Y',dial_status_a='N',dial_status_b='NEW',dial_status_c='DROP',dial_status_d='A',dial_status_e='NA',lead_order='DOWN COUNT',allow_closers='Y',hopper_level='200', auto_dial_level='2.7', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='http://10.10.10.196/vicidial/vicidial_college_partnership.php', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CPARTNER'|N| +Mon, 23 Jan 2006 10:48:22 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='NEW',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|N| +Mon, 23 Jan 2006 10:49:01 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='NEW',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='http://10.10.10.196/vicidial/vicidial_college_partnership_confirm.php', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|N| +Mon, 23 Jan 2006 11:07:57 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='NEW',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='http://10.10.10.196/vicidial/vicidial_college_partnership_confirm.php?STAGE=CONFIRMLOOKUP', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|N| +Mon, 23 Jan 2006 12:10:13 -0500|ADD A NEW LIST |123456|10.10.6.19|'80204','CP Confirm Jan28-29','CCONFIRM','N'| +Mon, 23 Jan 2006 12:14:26 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E',campaign_id='CCONFIRM',active='N' where list_id='80204'| +Mon, 23 Jan 2006 12:14:31 -0500|RESET LIST CALLED |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E'| +Mon, 23 Jan 2006 12:14:31 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E',campaign_id='CCONFIRM',active='Y' where list_id='80204'| +Mon, 23 Jan 2006 12:14:48 -0500|ADD A NEW LIST |123456|10.10.6.19|'80304','CPConfirm Jan28-29 W','CCONFIRM','Y'| +Mon, 23 Jan 2006 12:15:57 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='SALE',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='http://10.10.10.196/vicidial/vicidial_college_partnership_confirm.php?STAGE=CONFIRMLOOKUP', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|N| +Mon, 23 Jan 2006 12:16:16 -0500|RESET LIST CALLED |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E'| +Mon, 23 Jan 2006 12:16:16 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E',campaign_id='CCONFIRM',active='Y' where list_id='80204'| +Mon, 23 Jan 2006 12:16:37 -0500|RESET LIST CALLED |123456|10.10.6.19|list_name='CPConfirm Jan28-29 W'| +Mon, 23 Jan 2006 12:16:37 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='CPConfirm Jan28-29 W',campaign_id='CCONFIRM',active='Y' where list_id='80304'| +Mon, 23 Jan 2006 12:18:31 -0500|RESET LIST CALLED |123456|10.10.6.19|list_name='CPConfirm Jan28-29 W'| +Mon, 23 Jan 2006 12:18:31 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='CPConfirm Jan28-29 W',campaign_id='CCONFIRM',active='Y' where list_id='80304'| +Mon, 23 Jan 2006 12:18:42 -0500|RESET LIST CALLED |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E'| +Mon, 23 Jan 2006 12:18:42 -0500|MODIFY LIST INFO |123456|10.10.6.19|list_name='CPConfirm Jan28-29 E',campaign_id='CCONFIRM',active='Y' where list_id='80204'| +Mon, 23 Jan 2006 12:21:01 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='NEW',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='http://10.10.10.196/vicidial/vicidial_college_partnership_confirm.php?STAGE=CONFIRMLOOKUP', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|N| +Mon, 23 Jan 2006 12:21:13 -0500|CAMPAIGN HOPPERRESET|123456|10.10.6.19|campaign_name='College Partnership Confirm'| +Mon, 23 Jan 2006 12:21:13 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='College Partnership Confirm',active='Y',dial_status_a='NEW',dial_status_b='',dial_status_c='',dial_status_d='',dial_status_e='',lead_order='DOWN',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='9am-9pm', voicemail_ext='', dial_timeout='30', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8367', web_form_address='http://10.10.10.196/vicidial/vicidial_college_partnership_confirm.php?STAGE=CONFIRMLOOKUP', park_ext='', park_file_name='', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='FULLDATE_AGENT', campaign_script='', get_call_launch='NONE', am_message_exten='' where campaign_id='CCONFIRM'|Y| +Tue, 24 Jan 2006 11:35:57 -0500|MODIFY CAMPAIGN INFO|123456|10.10.6.19|campaign_name='UMG Card on File',active='Y',dial_status_a='N',dial_status_b='B',dial_status_c='DROP',dial_status_d='A',dial_status_e='NA',lead_order='DOWN COUNT',hopper_level='500', auto_dial_level='4.0' where campaign_id='UMGCOF'|N| diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/admin_modify_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_en/admin_modify_lead.php new file mode 100644 index 00000000..9dad4f62 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/admin_modify_lead.php @@ -0,0 +1,476 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + +### AST GUI database administration modify lead in vicidial_list +### admin_modify_lead.php + +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead + +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Lead record modification + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "information modified

\n"; + echo "\n"; + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + +} +else +{ + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + + + + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + +echo "

\n"; + +echo "
\n"; + +echo "CALLS TO THIS LEAD:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD
$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]
\n"; + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/admin_search_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_en/admin_search_lead.php new file mode 100644 index 00000000..a727e3a1 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/admin_search_lead.php @@ -0,0 +1,224 @@ + LICENSE: GPLv2 +### +### AST GUI database administration search for lead info +### admin_modify_lead.php +# +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Lead Search + +Lead Lookup + + + +
\n"; + echo "
\n"; + echo "\n"; + echo "Please enter a:
Vendor ID(vendor lead code): or \n"; + echo "
a Home Phone Number: or\n"; + echo "
a lead ID:

\n"; + echo "
\n"; + echo "\n
\n"; + echo "\n"; + exit; + } + +else + { + + if ($vendor_id) + { + $stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000"; + } + else + { + if ($phone) + { + $stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000"; + } + else + { + if ($lead_id) + { + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query($stmt, $link); + $results_to_print = mysql_num_rows($rslt); + if ($results_to_print < 1) + { + echo date("l F j, Y G:i:s A"); + echo "\n

\n"; + echo "The search variables you entered are not active in the system

\n"; + echo "Please go back and double check the information you entered and submit again\n"; + echo "
\n"; + echo "\n"; + exit; + } + else + { + echo "RESULTS: $results_to_print

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD IDSTATUSVENDOR IDLAST AGENTLIST IDPHONENAMECITYSECURITYLAST CALL
$o$row[0]$row[3]$row[5]$row[4]$row[7]$row[11]$row[13] $row[15]$row[19]$row[28]$row[2]
\n"; + } + } + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\nNEW SEARCH"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; + + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/count.htm b/agc_2-X/trunk/LANG_admin/vicidial_en/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/count.htm @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/dbconnect.php b/agc_2-X/trunk/LANG_admin/vicidial_en/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/group_hourly_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_en/group_hourly_stats.php new file mode 100644 index 00000000..b7eb1b31 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/group_hourly_stats.php @@ -0,0 +1,252 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: Group Hourly Stats +\n"; +?> + + +
+ + + + + += '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "
  VICIDIAL ADMIN: Group Hourly Stats  
\n"; + +echo "
\n"; + +echo "TSR HOUR COUNTS: $group | $status | $date_with_hour | $date_no_hour\n"; + +echo "
\n"; +echo "\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "\n"; + + +} + +echo "
TSR ID   $status   TOTAL CALLS   $status DAY    
$VDuser[$o] $VDname[$o] $VDcount[$o] $VDtotal[$o] $VDday[$o]MODIFY | STATS
TOTAL $status $hour_calls $total_calls $day_calls
\n"; +echo "

\n"; + + + echo "
Please enter the group you want to get hourly stats for:
\n"; + echo "\n"; + echo "group:
\n"; + echo "status:   (example: XFER)
\n"; + echo "date with hour:   (example: 2004-06-25 14)
\n"; + echo "\n"; + echo "


\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/help.gif b/agc_2-X/trunk/LANG_admin/vicidial_en/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/vicidial_en/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/listloader.php b/agc_2-X/trunk/LANG_admin/vicidial_en/listloader.php new file mode 100644 index 00000000..71dd25e4 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/listloader.php @@ -0,0 +1,698 @@ + LICENSE: GPLv2 +# +# AST Web GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1006 - added listID override and gmt_offset lookup while loading +# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. +# + +$version = '1.1.12'; +$build = '60619-1652'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];} +$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB=1; +#$DBX=1; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('listloader.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +?> + + + + + + method=post enctype="multipart/form-data"> +
+ + + + + + + + + + + + + +
Load leads from this file:
List ID Override: (numbers only or leave blank for values in the file)
CLICK HERE TO GO TO THE SUPER LEAD LOADER (BETA VERSION)     BACK TO ADMIN
+ +document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + $pulldate=date("Y-m-d H:i:s"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("./vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city = $row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) + { + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $gmt_offset = '0'; + $called_since_last_reset='N'; + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + print ""; +} else if (filesize($leadfile)>8388608) { + print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/listloaderMAIN.php b/agc_2-X/trunk/LANG_admin/vicidial_en/listloaderMAIN.php new file mode 100644 index 00000000..67ee25bc --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/listloaderMAIN.php @@ -0,0 +1,79 @@ + LICENSE: GPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + +VICIDIAL: Lead Loader Module + + + + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/new_listloader_superL.php b/agc_2-X/trunk/LANG_admin/vicidial_en/new_listloader_superL.php new file mode 100644 index 00000000..d9471182 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/new_listloader_superL.php @@ -0,0 +1,1364 @@ + LICENSE: GPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '1.1.12-1'; +$build = '60619-1651'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +VICIDIAL ADMIN: Super Lead Loader + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + + + + + + + + + + + + + + + + + + + +
Load leads from this file:
List ID Override: (numbers only or leave blank for values in the file)
File layout to use:Standard VICIDIAL    Custom layout
        
CLICK HERE TO GO TO THE BASIC LEAD LOADER         BACK TO ADMIN
SUPER LIST LOADER-     VERSION:     BUILD:
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Processing $delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + print "
Processing Excel file... \n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + # print "$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field"; + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile && filesize($LF_path)<=8388608) { + $total=0; $good=0; $bad=0; + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Processing $delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + $total=0; $good=0; $bad=0; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL ColumnFile data
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
        
\r\n"; + # } + print ""; + } +} else if (filesize($leadfile)>8388608) { + print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + + + + + + + + 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### MEXICO ### +if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### AUSTRALIA ### +if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### ALL OTHER COUNTRY CODES ### +if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/project_auth_entries.txt b/agc_2-X/trunk/LANG_admin/vicidial_en/project_auth_entries.txt new file mode 100644 index 00000000..b152bf1c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/project_auth_entries.txt @@ -0,0 +1,129 @@ +VICIDIAL|GOOD|Thu, 22 Sep 2005 17:42:07 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:04 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:14 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:15 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:16 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:17 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:18 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:19 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:20 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:35 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:37 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:03:39 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 13:14:51 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 16:18:06 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:48 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:57 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:48:00 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:48:01 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:48:43 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:50:19 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Tue, 04 Oct 2005 10:57:45 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +LIST_LOAD|GOOD|Tue, 04 Oct 2005 10:57:52 -0400|lead|load|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +VICIDIAL|GOOD|Tue, 04 Oct 2005 10:57:54 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:02:12 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:09:17 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:02:48 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 13 Dec 2005 17:44:00 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 13 Dec 2005 17:44:50 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 13 Dec 2005 17:53:06 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 13 Dec 2005 17:53:08 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 13 Dec 2005 17:53:11 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 10:17:14 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 10:17:51 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:01:30 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:02:01 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:02:06 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:04:05 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:04:07 -0500|6666|sales|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:04:25 -0500|123456|bob5|10.10.6.19|Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)|1 - TESTCAMP remote agent| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:04:33 -0500|123456|bob5|10.10.6.19|Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)|1 - TESTCAMP remote agent| +VICIDIAL|GOOD|Wed, 14 Dec 2005 17:04:36 -0500|123456|bob5|10.10.6.19|Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)|1 - TESTCAMP remote agent| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:09:08 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Fri, 23 Dec 2005 14:39:26 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Fri, 23 Dec 2005 14:39:37 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Tue, 03 Jan 2006 11:33:11 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Tue, 03 Jan 2006 11:33:15 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Tue, 03 Jan 2006 11:33:18 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Tue, 03 Jan 2006 11:33:22 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Tue, 03 Jan 2006 11:33:25 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:37:53 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:04 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:06 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:55 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:47:46 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:47:48 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:44:44 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:45:26 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:46:09 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:47:08 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:47:14 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:47:47 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:47:54 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:06 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:10 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:14 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:22 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:23 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:25 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:27 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:39 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:42 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:49 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:48:52 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 10:49:01 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 11:07:57 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:06:18 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:06:20 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:06:23 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:06:43 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:09:37 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:10:13 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:14:26 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:14:31 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:14:36 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:14:48 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:14:51 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:14:56 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:15:45 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:15:57 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:16:04 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:16:16 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:16:31 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:16:34 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:16:37 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:18:31 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:18:36 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:18:39 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:18:42 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:18:43 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:18:49 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:21:01 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Mon, 23 Jan 2006 12:21:13 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 10:01:26 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 10:01:30 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 10:08:30 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 10:08:33 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 11:34:58 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 11:35:04 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 11:35:10 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 11:35:22 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 11:35:49 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Tue, 24 Jan 2006 11:35:57 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 03 Mar 2006 16:14:19 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:03:05 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:23 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:45 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:47 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:52 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:56 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:57 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:21:59 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:22:00 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:22:01 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:41:20 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 10:05:32 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 10:05:35 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 10:06:06 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:35:54 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/remote_dispo.php b/agc_2-X/trunk/LANG_admin/vicidial_en/remote_dispo.php new file mode 100644 index 00000000..da249fba --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/remote_dispo.php @@ -0,0 +1,327 @@ + LICENSE: GPLv2 +### +# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call + +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL REMOTE: Call Disposition +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Call has been dispositioned       $NOW_TIME\n

\n"; + + echo "
\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Campaign ID: $campaign_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/server_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_en/server_stats.php new file mode 100644 index 00000000..a427f5c0 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/server_stats.php @@ -0,0 +1,96 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1037 - Added Link back to Admin section +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select * from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $i++; + } +?> + + + + + +VICIDIAL: Server Stats and Reports +VICIDIAL: Server Stats and Reports                           +BACK TO ADMIN

+ + +

+
+ $o)
+	{
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	$o++;
+	}
+
+?>
+
SERVERDESCRIPTIONIP ADDRESSACTIVEVDAD timeVDcall timePARK timeCLOSER/INBOUND time
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]LINKLINKLINKLINK
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/user_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_en/user_stats.php new file mode 100644 index 00000000..bdada227 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/user_stats.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: User Stats +\n"; +?> + + +
+ + + + + +\n"; +echo "
  VICIDIAL ADMIN: User Stats for  
  \n"; + +echo "
\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + +echo "
\n"; + +echo "TALK TIME AND STATUS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + +echo "\n"; +echo "
STATUSCOUNTHOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
TOTAL CALLS $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LOGIN/LOGOUT TIME:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours = ($event_seconds / 3600); + $event_hours = round($event_hours, 2); + $event_hours_int = intval("$event_hours"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours = ($total_login_time / 3600); +$total_login_hours = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
EVENT DATE CAMPAIGNHOURS:MINUTES
$row[0] $row[2] $row[3]
$row[0] $row[2] $row[3] $event_hours_int:$event_minutes_int
$row[0] $row[2] $row[3]
TOTAL $total_login_hours_int:$total_login_minutes_int
\n"; + + +echo "

\n"; + +echo "
\n"; + +echo "LAST 50 CALLS:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS PHONE CAMPAIGN LIST LEAD
$row[4] $row[7] $row[8] $row[10] $row[3] $row[2] $row[1]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/user_status.php b/agc_2-X/trunk/LANG_admin/vicidial_en/user_status.php new file mode 100644 index 00000000..8efe670f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/user_status.php @@ -0,0 +1,238 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $change_agent_campaign=$row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $i++; + } + + } + +$stmt="select * from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> + + +VICIDIAL ADMIN: User Status +\n"; +?> + + +
+
+ + + + +\n"; +echo "
  VICIDIAL ADMIN: User Status for  
  \n"; + +if ($stage == "live_campaign_change") +{ + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign
\n"; + + exit; +} + +if ($stage == "log_agent_out") +{ + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser
\n"; + + exit; +} + +if ($agents_to_print > 0) +{ + echo "
";
+	echo "Agent Logged in at server:  $Aserver_ip\n";
+	echo "               in session:  $Asession_id\n";
+	echo "               from phone:  $Aextension\n";
+	echo "Agent is in campaign:       $Acampaign\n";
+	echo "              status:       $Astatus\n";
+	echo " hungup last call at:       $Alast_call\n";
+	echo "       Closer groups:       $Acl_campaigns\n\n";
+
+	echo "
"; + + + if ($change_agent_campaign > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Current Campaign: \n"; + echo "
\n"; + + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } +} + +else +{ + echo "Agent is not logged in\n
"; + +} + + +echo "           $user - $full_name - \n"; + +echo "VICIDIAL Time Sheet\n"; + +echo "
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + +echo "|$stage|$group|"; + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_en/vdremote.php b/agc_2-X/trunk/LANG_admin/vicidial_en/vdremote.php new file mode 100644 index 00000000..dfe11fa3 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_en/vdremote.php @@ -0,0 +1,602 @@ + LICENSE: GPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time + +$version = '1.1.12'; +$build = '60619-1603'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +VICIDIAL REMOTE AGENTS: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Modify Remote Agents";} +if ($ADD==41111) {echo "Modify Remote Agents";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+
+ + + +
  VICIDIAL REMOTE AGENTS:   Logout  
  MODIFY | ">STATUS | ">INBOUND STATS
+"; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: $user_start
Number of Lines: (numbers only)
Server IP: $row[3]
External Extension: (number dialed to reach agents [i.e. 913125551212])
Status:
Campaign: $campaign_id
Inbound Groups: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + + } + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: $user_start
Number of Lines: (numbers only)
Server IP: $row[3]
External Extension: (number dialed to reach agents [i.e. 913125551212])
Status:
Campaign: $campaign_id
Inbound Groups: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) +{ + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]=' - WAITING - '; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i agents logged in on server $server_ip\n\n"; + + echo " - 5 minutes or more on call\n"; + echo " - Over 10 minutes on call\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* NO AGENTS ON CALLS *********************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) +{ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "VICIDIAL: Remote Agent inbound stats $NOW_TIME\n\n"; + echo "\n"; + echo "Total calls taken $query_date: $in_calls\n"; + echo "Total talk time on $query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Call list for $query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + # echo " $i agents logged in on server $server_ip\n\n"; + + # echo " - 5 minutes or more on call\n"; + # echo " - Over 10 minutes on call\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* NO CALLS ON THIS DAY *******************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_CLOSERstats.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_CLOSERstats.php new file mode 100644 index 00000000..495856fb --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_CLOSERstats.php @@ -0,0 +1,396 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Estadísticas de VDAD Closer\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFICAR | INFORMES \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "SELECCIONE POR FAVOR Una CAMPAÚA Y La FECHA ARRIBA Y El TECLEO SOMETEN\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Estadísticas de Auto-dial en CLOSER                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Llamadas dentro de esta campaña $TOTALcalls\n";
+echo "Longitud media para las llamadas en segundos: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls: $DROPcalls  $DROPpercent%\n";
+echo "Longitud media para las llamadas DROP en segundos:    $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- ESTADÍSTICAS DEL USUARIO\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USUARIO                  | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- ESTADÍSTICAS DEL TIEMPO\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRÁFICO EN 15 INCREMENTOS MINUCIOSOS DE LAS LLAMADAS TOTALES PUESTAS DE ESTA CAMPAÚA\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_VDADstats.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_VDADstats.php new file mode 100644 index 00000000..478ccef7 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_VDADstats.php @@ -0,0 +1,417 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFICAR | INFORMES \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "SELECCIONE POR FAVOR Una CAMPAÚA Y La FECHA ARRIBA Y El TECLEO SOMETEN\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Llamadas dentro de esta campaña $TOTALcalls\n";
+echo "Longitud media para las llamadas en segundos: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls: $DROPcalls  $DROPpercent%\n";
+echo "Longitud media para las llamadas DROP en segundos:    $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- AUTO-DIAL SIN RESPUESTA\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$NAcalls =	sprintf("%10s", $row[0]);
+$NApercent = (($NAcalls / $TOTALcalls) * 100);
+$NApercent = round($NApercent, 0);
+
+$average_na_seconds = ($row[1] / $row[0]);
+$average_na_seconds = round($average_na_seconds, 0);
+$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+
+echo "Llamadas sin Respuesta - ocupado, desconexión,..:  $NAcalls  $NApercent%\n";
+echo "Longitud media para las Llamadas sin Respuesta en segundos:       $average_na_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- ESTADÍSTICAS DEL USUARIO\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USUARIO                  | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- ESTADÍSTICAS DEL TIEMPO\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRÁFICO EN 15 INCREMENTOS MINUCIOSOS DE LAS LLAMADAS TOTALES PUESTAS DE ESTA CAMPAÚA\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..1f2ca7cd --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,161 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Lista De Hopper\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFICAR \n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "SELECCIONE POR FAVOR Una CAMPAÚA ARRIBA Y El TECLEO SOMETE\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Live Current Lista De Hopper                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+
+echo "Total de Leads en el hopper ahora mismo:       $TOTALcalls\n";
+
+
+##############################
+#########  LEAD STATS
+
+echo "\n";
+echo "---------- LEADS IN HOPPER\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+echo "|      | LEAD_ID   | PHONE NUM  | STATE | STATUS | COUNT | GMT    |\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$FMT_i =		sprintf("%-4s", $i);
+	$lead_id =		sprintf("%-9s", $row[0]);
+	$phone_number =	sprintf("%-10s", $row[1]);
+	$state =		sprintf("%-5s", $row[2]);
+	$status =		sprintf("%-6s", $row[3]);
+	$count =		sprintf("%-5s", $row[4]);
+	$gmt =			sprintf("%-6s", $row[5]);
+
+	echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
+
+	$i++;
+	}
+
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_admin_log_display.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_admin_log_display.php new file mode 100644 index 00000000..6d89ee3e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_admin_log_display.php @@ -0,0 +1,118 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date); + +# AST GUI database administration +# AST_admin_log_display.php +# +# CHANGES +# 50325-0932 - First build +# 51123-1443 - removed globals=on requirement +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '0.0.4'; +$build = '60620-1044'; + +$STARTtime = date("U"); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN LOG DISPLAY"; +echo "\n"; + +# Fri, 25 Mar 2005 + +$DAY_DATE = date("j"); +if ($DAY_DATE < 10) +# {$GREP_DATE = date("D, j M Y");} + {$GREP_DATE = date("D, 0j M Y");} +else + {$GREP_DATE = date("D, j M Y");} + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!$query_date) {$query_date = $GREP_DATE;} + +$Gquery_date = eregi_replace(" ",'\ ',$query_date); +echo "\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n\n";
+
+
+echo "VICIDIAL ADMIN CHANGE LOG                             $NOW_TIME\n";
+
+#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
+passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_performance.php new file mode 100644 index 00000000..5c58d6f8 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_performance.php @@ -0,0 +1,232 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Agent Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFICAR | INFORMES \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVIDOR AND DATE-TIME ABOVE AND CLICK ENVIAR\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_performance_detail.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_performance_detail.php
new file mode 100644
index 00000000..45a7f5f8
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_performance_detail.php
@@ -0,0 +1,406 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["ENVIAR"]))				{$ENVIAR=$_GET["ENVIAR"];}
+	elseif (isset($_POST["ENVIAR"]))		{$ENVIAR=$_POST["ENVIAR"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFICAR | INFORMES \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK ENVIAR\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 03:45:00";   
+	$query_date_END = "$query_date 15:15:00";
+	$time_BEGIN = "03:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:15:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance Detail                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TIME   | PAUSE  | PAUSAVG| WAIT   | WAITAVG| TALK   | TALKAVG| DISPO  | DISPAVG| A    | B    | DC   | DNC  | N    | NI   | CB   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$TOTtotWAIT=($TOTtotWAIT + $row[7]);
+	$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
+	$TOTtotDISPO=($TOTtotDISPO + $row[9]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtime =	($row[1] + $row[5] + $row[7] + $row[9]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+	$USERtotPAUSE =	$row[5];
+	$USERavgPAUSE =	$row[6];
+	$USERtotWAIT =	$row[7];
+	$USERavgWAIT =	$row[8];
+	$USERtotDISPO =	$row[9];
+	$USERavgDISPO =	$row[10];
+
+	$USERtime_M = ($USERtime / 60);
+	$USERtime_M = round($USERtime_M, 2);
+	$USERtime_M_int = intval("$USERtime_M");
+	$USERtime_S = ($USERtime_M - $USERtime_M_int);
+	$USERtime_S = ($USERtime_S * 60);
+	$USERtime_S = round($USERtime_S, 0);
+	if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
+	$USERtime_MS = "$USERtime_M_int:$USERtime_S";
+	$pfUSERtime_MS[$i] =		sprintf("%7s", $USERtime_MS);
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+
+	$USERtotPAUSE_M = ($USERtotPAUSE / 60);
+	$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
+	$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
+	$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
+	$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
+	$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
+	if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
+	$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
+	$pfUSERtotPAUSE_MS[$i] =		sprintf("%6s", $USERtotPAUSE_MS);
+
+	$USERavgPAUSE_M = ($USERavgPAUSE / 60);
+	$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
+	$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
+	$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
+	$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
+	$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
+	if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
+	$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
+	$pfUSERavgPAUSE_MS[$i] =		sprintf("%6s", $USERavgPAUSE_MS);
+
+	$USERtotWAIT_M = ($USERtotWAIT / 60);
+	$USERtotWAIT_M = round($USERtotWAIT_M, 2);
+	$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
+	$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
+	$USERtotWAIT_S = ($USERtotWAIT_S * 60);
+	$USERtotWAIT_S = round($USERtotWAIT_S, 0);
+	if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
+	$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
+	$pfUSERtotWAIT_MS[$i] =		sprintf("%6s", $USERtotWAIT_MS);
+
+	$USERavgWAIT_M = ($USERavgWAIT / 60);
+	$USERavgWAIT_M = round($USERavgWAIT_M, 2);
+	$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
+	$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
+	$USERavgWAIT_S = ($USERavgWAIT_S * 60);
+	$USERavgWAIT_S = round($USERavgWAIT_S, 0);
+	if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
+	$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
+	$pfUSERavgWAIT_MS[$i] =		sprintf("%6s", $USERavgWAIT_MS);
+	
+	$USERtotDISPO_M = ($USERtotDISPO / 60);
+	$USERtotDISPO_M = round($USERtotDISPO_M, 2);
+	$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
+	$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
+	$USERtotDISPO_S = ($USERtotDISPO_S * 60);
+	$USERtotDISPO_S = round($USERtotDISPO_S, 0);
+	if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
+	$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
+	$pfUSERtotDISPO_MS[$i] =		sprintf("%6s", $USERtotDISPO_MS);
+
+	$USERavgDISPO_M = ($USERavgDISPO / 60);
+	$USERavgDISPO_M = round($USERavgDISPO_M, 2);
+	$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
+	$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
+	$USERavgDISPO_S = ($USERavgDISPO_S * 60);
+	$USERavgDISPO_S = round($USERavgDISPO_S, 0);
+	if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
+	$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
+	$pfUSERavgDISPO_MS[$i] =		sprintf("%6s", $USERavgDISPO_MS);
+
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; $ctCB[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]);	$TOT_CB = ($TOT_CB + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtime_M = ($TOTtime / 60);
+	$TOTtime_M = round($TOTtime_M, 2);
+	$TOTtime_M_int = intval("$TOTtime_M");
+	$TOTtime_S = ($TOTtime_M - $TOTtime_M_int);
+	$TOTtime_S = ($TOTtime_S * 60);
+	$TOTtime_S = round($TOTtime_S, 0);
+	if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
+	$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
+	$TOTtime_MS =		sprintf("%7s", $TOTtime_MS);
+		while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOTtotDISPO_M = ($TOTtotDISPO / 60);
+	$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
+	$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
+	$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
+	$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
+	$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
+	if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
+	$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
+	$TOTtotDISPO_MS =		sprintf("%7s", $TOTtotDISPO_MS);
+		while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+
+	$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
+	$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
+	$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
+	$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
+	if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
+	$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
+	$TOTtotPAUSE_MS =		sprintf("%7s", $TOTtotPAUSE_MS);
+		while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+
+	$TOTtotWAIT_M = ($TOTtotWAIT / 60);
+	$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
+	$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
+	$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
+	$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
+	$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
+	if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
+	$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
+	$TOTtotWAIT_MS =		sprintf("%7s", $TOTtotWAIT_MS);
+		while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+
+
+	$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
+	$TOTavgTALK_M = round($TOTavgTALK_M, 2);
+	$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
+	$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
+	$TOTavgTALK_S = ($TOTavgTALK_S * 60);
+	$TOTavgTALK_S = round($TOTavgTALK_S, 0);
+	if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
+	$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
+	$TOTavgTALK_MS =		sprintf("%6s", $TOTavgTALK_MS);
+		while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+
+	$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
+	$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
+	$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
+	$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
+	$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
+	$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
+	if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
+	$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
+	$TOTavgDISPO_MS =		sprintf("%6s", $TOTavgDISPO_MS);
+		while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+
+	$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
+	$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
+	$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
+	$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
+	if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
+	$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
+	$TOTavgPAUSE_MS =		sprintf("%6s", $TOTavgPAUSE_MS);
+		while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+
+	$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
+	$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
+	$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
+	$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
+	$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
+	$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
+	if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
+	$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
+	$TOTavgWAIT_MS =		sprintf("%6s", $TOTavgWAIT_MS);
+		while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+
+	
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_CB = sprintf("%-5s", $TOT_CB);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
+echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_time_sheet.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_time_sheet.php
new file mode 100644
index 00000000..a01653c9
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_agent_time_sheet.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["ENVIAR"]))				{$ENVIAR=$_GET["ENVIAR"];}
+	elseif (isset($_POST["ENVIAR"]))		{$ENVIAR=$_POST["ENVIAR"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENTE ID AND DATE-TIME ABOVE AND CLICK ENVIAR\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTE TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "LLAMADAS TOTALES TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENTE TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_server_performance.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_server_performance.php
new file mode 100644
index 00000000..e7b7a022
--- /dev/null
+++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_server_performance.php
@@ -0,0 +1,310 @@
+    LICENSE: GPLv2
+#
+# CHANGES
+#
+# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))	{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))	{$submit=$_POST["submit"];}
+if (isset($_GET["ENVIAR"]))				{$ENVIAR=$_GET["ENVIAR"];}
+	elseif (isset($_POST["ENVIAR"]))	{$ENVIAR=$_POST["ENVIAR"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+# path from root to where ploticus files will be stored
+$DOCroot = "$WeBServeRRooT/vicidial/ploticus/";
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+if (!isset($group)) {$group = '';}
+
+$stmt="select server_ip from servers;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$servers_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $servers_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Server Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "             INFORMES \n"; +echo "\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVIDOR AND DATE-TIME ABOVE AND CLICK ENVIAR\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:32:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:32:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Server Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$HIGHload =	sprintf("%10s", $row[0]);
+$HIGHmulti = intval($HIGHload / 100);
+#$HIGHmulti = ($HIGHload / 100);
+
+$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$USEDram =	sprintf("%10s", $row[0]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average channels in use for server:       $AVGchannels\n";
+echo "Average load for server:                  $AVGload\n";
+echo "Peak load for server:                     $HIGHload\n";
+#echo "Peak used memory for server (in MB):      $USEDram\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 14 7\n";
+$HTMcontent .= "xscaletype: time hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHload\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc 30 minutes\n";
+$HTMcontent .= "minorticinc: 5 minutes\n";
+$HTMcontent .= "stubformat: hh:mm:ssa\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-2 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDAD.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDAD.php new file mode 100644 index 00000000..2fb623d0 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDAD.php @@ -0,0 +1,255 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Tiempo de los  Agentes En Llamadas        $NOW_TIME    INFORMES\n\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL    | STATUS | START TIME          | MINUTES |\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	$agentcount=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- ESPERANDO -';
+			$row[6]=$row[7];
+			}
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$sessionid =		sprintf("%-9s", $row[2]);
+		$channel =			sprintf("%-10s", $row[3]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[4]);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 5) {$G=''; $EG='';}
+		if ($call_time_M_int >= 10) {$G=''; $EG='';}
+		if (eregi("PAUSED",$row[4])) 
+			{
+			if ($call_time_M_int >= 1) 
+				{$i++; continue;} 
+			else
+				{$G=''; $EG='';}
+			}
+
+		$agentcount++;
+		echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+		echo "  $agentcount agentes identificados en el servidor $server_ip\n\n";
+
+		echo "             - Agentes detenidos brevemente\n";
+		echo "             - Llamadas de 5 minutos o más\n";
+		echo "             - Sobre 10 minutos en llamada\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************AGENTES SIN LLAMADAS*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+echo "| CHANNEL    | STATUS | CAMPAIGN | PHONE NUMBER       | START TIME          | MINUTES |\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-8s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+		echo "  $i llamadas en el servidor $server_ip\n\n";
+
+		echo "             - LLAMADAS ACTUALES EN ESPERA\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************LLAMADAS EN ESPERA*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDAD_closer.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDAD_closer.php new file mode 100644 index 00000000..9850f4ed --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDAD_closer.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Tiempo de los  Agentes En Llamadas        $NOW_TIME    INFORMES\n\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPAIGN     | FRONT  |\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED|CLOSER",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WAIT -';
+			$row[6]=$row[7];
+			}
+		$extension[$i] =		sprintf("%-10s", $row[0]);
+		$user[$i] =				sprintf("%-6s", $row[1]);
+		$sessionid[$i] =		sprintf("%-9s", $row[2]);
+		$channel[$i] =			sprintf("%-19s", $row[3]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $row[4]);
+		$start_time[$i] =		sprintf("%-8s", $row[5]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$row[8];
+		$lead_id[$i] =			$row[9];
+		$closer[$i] =			$row[1];
+		$call_time_S[$i] = ($STARTtime - $row[6]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+		$i++;
+		}
+		$ext_count = $i;
+		$i=0;
+	while ($i < $ext_count)
+		{
+
+		$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$camp_to_print = mysql_num_rows($rslt);
+		if ($camp_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$campaign = sprintf("%-12s", $row[0]);
+			$camp_color = $row[0];
+			}
+		else
+			{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+		if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+			{$campaign = '            ';   	$camp_color = '';}
+
+		$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$xfer_to_print = mysql_num_rows($rslt);
+		if ($xfer_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$fronter = sprintf("%-6s", $row[0]);
+			}
+		else
+			{$fronter = '      ';}
+
+		$G = '';		$EG = '';
+		$G=""; $EG='';
+	#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+	#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+		echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i agentes identificados en el servidor $server_ip\n\n";
+
+	#	echo "             - Llamadas de 5 minutos o más\n";
+	#	echo "             - Sobre 10 minutos en llamada\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************AGENTES SIN LLAMADAS*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPAIGN     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i llamadas en el servidor $server_ip\n\n";
+
+		echo "             - LLAMADAS ACTUALES EN ESPERA\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "*******************************LLAMADAS EN ESPERA*********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDADall.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDADall.php new file mode 100644 index 00000000..428c8d56 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDADall.php @@ -0,0 +1,349 @@ + LICENSE: GPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +if (!isset($group)) {$group='';} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Campaña: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Campaña: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFICAR | INFORMES \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo "LLAMADAS EN ESPERA\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Campaña: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVIDOR IP | CALL SERVIDOR IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n\n"; + + $Aecho .= " - Agentes detenidos brevemente\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo "AGENTES SIN LLAMADAS\n";
+	}
+
+?>
+
+ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDADall_SIPmonitor.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDADall_SIPmonitor.php new file mode 100644 index 00000000..27281fb1 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonVDADall_SIPmonitor.php @@ -0,0 +1,301 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala +# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$server_ip=$_GET["server_ip"]; if (!$server_ip) {$server_ip=$_POST["server_ip"];} +$reset_counter=$_GET["reset_counter"]; if (!$reset_counter) {$reset_counter=$_POST["reset_counter"];} +$RR=$_GET["RR"]; if (!$RR) {$RR=$_POST["RR"];} +$group=$_GET["group"]; if (!$group) {$group=$_POST["group"];} +$DB=$_GET["DB"]; if (!$DB) {$DB=$_POST["DB"];} +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$ENVIAR=$_GET["ENVIAR"]; if (!$ENVIAR) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!$RR) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VF DIALER: Time On VDAD Campaña: $group\n"; +echo "
\n"; +echo "VF DIALER: Realtime Campaña: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFICAR | INFORMES \n"; +echo "\n\n"; + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); + +echo "
"; +echo "DIAL LEVEL: $row[0]         "; +echo "STATUSES: $row[1], $row[2], $row[3], $row[4], $row[5]         "; +echo "ORDER: $row[6]"; +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and (campaign_id='" . mysql_real_escape_string($group) . "' or campaign_id LIKE \"CL_%\");";} +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo "LLAMADAS EN ESPERA\n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VF DIALER: Agents Time On Calls Campaña: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVIDOR IP | CALL SERVIDOR IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + $sessionid = trim($sessionid); + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " NOTE: Click LISTERN to monitor agent call, you must have installed softphone on you machine.\n\n"; + + + $Aecho .= " - Agentes detenidos brevemente\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo "AGENTES SIN LLAMADAS\n";
+	}
+
+?>
+
+ + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeoncall.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeoncall.php new file mode 100644 index 00000000..c417350c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeoncall.php @@ -0,0 +1,180 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Call\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Call                                          $NOW_TIME\n\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+echo "| STATION    | SESSIONID | CHANNEL   | NUMBER DIALED    | START TIME          | MINUTES |\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+
+$stmt="SELECT count(*) from live_sip_channels where server_ip='$server_ip';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="select extension from live_channels where server_ip='$server_ip';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$ext_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_zap_counter=0;
+	$sessions = '';
+	while ($i < $ext_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if (preg_match("/^8600/i",$row[0]))
+			{
+			$sessions .= "$row[0]|";
+			}
+		$i++;
+		}
+	$sessions = preg_replace("/\|$/",'',$sessions);
+
+	if ($DB) {echo "SESSIONS: -$sessions-\n";}
+
+	$stmt="select * from live_sip_channels where server_ip='$server_ip' order by channel;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_calls_counter=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
+			{
+			if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
+			$session_id = '';
+			}
+		else 
+			{
+			if (preg_match("/$row[3]/i",$sessions))
+				{
+				if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
+				$session_id = $row[3];
+				$station = preg_replace("/SIP\//",'',$row[0]);
+				$station = preg_replace("/-.*/",'',$station);
+			
+				$LIVE_sessions[$live_calls_counter] =			"$session_id";
+				$LIVE_sessions_FORMAT[$live_calls_counter] =	sprintf("%-9s", $session_id);
+				$LIVE_stations[$live_calls_counter] =			"$station";
+				$LIVE_stations_FORMAT[$live_calls_counter] =	sprintf("%-10s", $station);
+
+		#		echo "| $station | $session_id | \n";
+
+				$live_calls_counter++;
+				}
+			else
+				{
+				if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
+				$session_id = '';
+				}
+			}
+
+		$i++;
+		}
+
+		if ($live_calls_counter > 0)
+		{
+		$i=0;
+		$LC_counter = $live_calls_counter;
+
+		while ($i < $live_calls_counter)
+			{
+			$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='$server_ip' order by uniqueid desc LIMIT 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$parked_to_print = mysql_num_rows($rslt);
+			$row=mysql_fetch_row($rslt);
+
+			$channel =			sprintf("%-9s", $row[0]);
+			$number_dialed =	sprintf("%-16s", $row[2]);
+			$start_time =		sprintf("%-19s", $row[3]);
+			$call_time_S = ($STARTtime - $row[4]);
+
+			$call_time_M = ($call_time_S / 60);
+			$call_time_M = round($call_time_M, 2);
+			$call_time_M_int = intval("$call_time_M");
+			$call_time_SEC = ($call_time_M - $call_time_M_int);
+			$call_time_SEC = ($call_time_SEC * 60);
+			$call_time_SEC = round($call_time_SEC, 0);
+			if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+			$call_time_MS = "$call_time_M_int:$call_time_SEC";
+			$call_time_MS =		sprintf("%7s", $call_time_MS);
+			$G = '';		$EG = '';
+			if ($call_time_M_int >= 12) {$G=''; $EG='';}
+			if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+			echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+			$i++;
+			}
+
+		echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+		echo "  $i stations on live calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on live call\n";
+		echo "             - Over 30 minutes on live call\n";
+
+		}
+		else
+		{
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*************************************** NO LIVE STATIONS ********************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		}
+
+	}
+	else
+	{
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*************************************** NO LIVE STATIONS ********************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	}
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonpark.php b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonpark.php new file mode 100644 index 00000000..d098a8a4 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/AST_timeonpark.php @@ -0,0 +1,197 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park                       $NOW_TIME\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "********************LLAMADAS EN ESPERA*********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "*********************************AGENTES SIN LLAMADAS*********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/admin.php b/agc_2-X/trunk/LANG_admin/vicidial_es/admin.php new file mode 100644 index 00000000..558e011c --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/admin.php @@ -0,0 +1,6514 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["safe_harbor_message"])) {$safe_harbor_message=$_GET["safe_harbor_message"];} + elseif (isset($_POST["safe_harbor_message"])) {$safe_harbor_message=$_POST["safe_harbor_message"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_message"])) {$drop_message=$_GET["drop_message"];} + elseif (isset($_POST["drop_message"])) {$drop_message=$_POST["drop_message"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS ONLY ### +$user_level = ereg_replace("[^0-9]","",$user_level); +$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); +$xferconf_a_number = ereg_replace("[^0-9]","",$xferconf_a_number); +$xferconf_b_number = ereg_replace("[^0-9]","",$xferconf_b_number); +$drop_call_seconds = ereg_replace("[^0-9]","",$drop_call_seconds); +$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); +$safe_harbor_exten = ereg_replace("[^0-9]","",$safe_harbor_exten); +$am_message_exten = ereg_replace("[^0-9]","",$am_message_exten); +$campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); +$campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); +$drop_exten = ereg_replace("[^0-9]","",$drop_exten); +$dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); +$park_ext = ereg_replace("[^0-9]","",$park_ext); +$hopper_level = ereg_replace("[^0-9]","",$hopper_level); +$agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); +$hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); +$agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); +$agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); +$vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); +$vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); +$closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); +$alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); +$delete_users = ereg_replace("[^0-9]","",$delete_users); +$delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); +$delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); +$delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); +$delete_lists = ereg_replace("[^0-9]","",$delete_lists); +$delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); +$delete_filters = ereg_replace("[^0-9]","",$delete_filters); +$delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); +$delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); +$load_leads = ereg_replace("[^0-9]","",$delete_call_times); +$campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); +$ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); +$ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); +$modify_leads = ereg_replace("[^0-9]","",$modify_leads); +$change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); +$modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); +$ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); +$ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); +$ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); +$ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); +$ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); +$ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); +$ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); +$ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); +$ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); +$ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); +$ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); +$ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); +$ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); +$ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); +$ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); +$ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); +$number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); +$user_start = ereg_replace("[^0-9]","",$user_start); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +$remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); +$attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); +$hotkey = ereg_replace("[^0-9]","",$hotkey); +$list_id = ereg_replace("[^0-9]","",$list_id); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); +$allow_closers = ereg_replace("[^NY]","",$allow_closers); +$reset_hopper = ereg_replace("[^NY]","",$reset_hopper); +$amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); +$alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); +$safe_harbor_message = ereg_replace("[^NY]","",$safe_harbor_message); +$selectable = ereg_replace("[^NY]","",$selectable); +$reset_list = ereg_replace("[^NY]","",$reset_list); +$fronter_display = ereg_replace("[^NY]","",$fronter_display); +$drop_message = ereg_replace("[^NY]","",$drop_message); +$use_internal_dnc = ereg_replace("[^NY]","",$use_internal_dnc); + +### ALPHA-NUMERIC ONLY ### +$user = ereg_replace("[^0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^0-9a-zA-Z]","",$pass); +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); +$submit = ereg_replace("[^0-9a-zA-Z]","",$submit); +$CoNfIrM = ereg_replace("[^0-9a-zA-Z]","",$CoNfIrM); +$campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); +$get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); +$campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); +$ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); +$dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); +$state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); +$scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + +### DIGITS and Dots +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + +### DIGITS and spaces and hash and star and comma +$xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_a_dtmf); +$xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_b_dtmf); + +### ALPHA-NUMERIC and underscore and dash +$dial_status_e = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_e); +$dial_status_d = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_d); +$dial_status_c = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_c); +$dial_status_b = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_b); +$dial_status_a = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_a); +$stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); +$lead_filter_id = ereg_replace("[^-\_0-9a-zA-Z]","",$lead_filter_id); +$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); +$old_campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_campaign_id); +$park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); +$next_agent_call = ereg_replace("[^-\_0-9a-zA-Z]","",$next_agent_call); +$local_call_time = ereg_replace("[^-\_0-9a-zA-Z]","",$local_call_time); +$call_time_id = ereg_replace("[^-\_0-9a-zA-Z]","",$call_time_id); +$phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); +$phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); +$group_id = ereg_replace("[^-\_0-9a-zA-Z]","",$group_id); +$user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$user_group); +$OLDuser_group = ereg_replace("[^-\_0-9a-zA-Z]","",$OLDuser_group); +$state_rule = ereg_replace("[^-\_0-9a-zA-Z]","",$state_rule); + +### ALPHA-NUMERIC and spaces +$lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); +### ALPHA-NUMERIC and hash +$group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); +$campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); +$HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); +$status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); +$script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); +$script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); +$list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); +$lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); +$lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); +$campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); +$call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); +$call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + +### remove semi-colons ### +$lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + +### VARIABLES TO BE mysql_real_escape_string ### +# $web_form_address +# $script_text + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# AST GUI database administration +# admin.php +# +# CHANGES +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug +# + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$version = '1.1.12-3'; +$build = '60623-1159'; + +$STARTtime = date("U"); + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Usted ahora ha salido. Gracias\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGuser_level =$row[4]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD==1) {$hh='users'; echo "Añadir un Usuario";} +if ($ADD==11) {$hh='campaigns'; echo "Añadir una Campaña";} +if ($ADD==111) {$hh='lists'; echo "Añadir una Lista";} +if ($ADD==121) {$hh='lists'; echo "Agregue DNC Nuevo";} +if ($ADD==1111) {$hh='ingroups'; echo "Añadir un Grupo-Entrantes";} +if ($ADD==11111) {$hh='remoteagent'; echo "Añadir Agentes Remotos";} +if ($ADD==111111) {$hh='usergroups'; echo "Añadir un Grupo De Usuarios";} +if ($ADD==1111111) {$hh='scripts'; echo "Agregue La Nueva Escritura";} +if ($ADD==11111111) {$hh='filters'; echo "Agregue El Filtro Nuevo";} +if ($ADD==111111111) {$hh='times'; echo "Agregue El Nuevo Tiempo De la Llamada";} +if ($ADD==1111111111) {$hh='times'; echo "Agregue El Nuevo Tiempo De la Llamada Del Estado";} +if ($ADD==2) {$hh='users'; echo "Nueva Adición De Usuario";} +if ($ADD==21) {$hh='campaigns'; echo "Nueva Adición De la Campaña";} +if ($ADD==22) {$hh='campaigns'; echo "Nueva Adición Del Estado De la Campaña";} +if ($ADD==23) {$hh='campaigns'; echo "Nueva Adición De Tecla De Acceso Directo De la Campaña";} +if ($ADD==25) {$hh='campaigns'; echo "El Nuevo Plomo De la Campaña Recicla La Adición";} +if ($ADD==211) {$hh='lists'; echo "Nueva Adición De la Lista";} +if ($ADD==2111) {$hh='ingroups'; echo "Nueva Adición Del Grupo de Entrantes";} +if ($ADD==21111) {$hh='remoteagent'; echo "Nueva Adición de Agentes Remotos";} +if ($ADD==211111) {$hh='usergroups'; echo "Nueva Adición Del Grupo De Usuarios";} +if ($ADD==2111111) {$hh='scripts'; echo "Nueva Adición De la Escritura";} +if ($ADD==21111111) {$hh='filters'; echo "Nueva Adición Del Filtro";} +if ($ADD==211111111) {$hh='times'; echo "Nueva Adición Del Tiempo De la Llamada";} +if ($ADD==2111111111) {$hh='times'; echo "Nueva Adición Del Tiempo De la Llamada Del Estado";} +if ($ADD==3) {$hh='users'; echo "Modificar Usuario";} +if ($ADD==31) {$hh='campaigns'; echo "Modifcar Campaña";} +if ($ADD==34) {$hh='campaigns'; echo "Modificar Campaña - Vista Básica";} +if ($ADD==311) {$hh='lists'; echo "Modificar Lista";} +if ($ADD==3111) {$hh='ingroups'; echo "Modificar In-Group";} +if ($ADD==31111) {$hh='remoteagent'; echo "Modificar Agentes Remotos";} +if ($ADD==311111) {$hh='usergroups'; echo "Modificar Grupos De Usuarios";} +if ($ADD==3111111) {$hh='scripts'; echo "Modifique La Escritura";} +if ($ADD==31111111) {$hh='filters'; echo "Modifique El Filtro";} +if ($ADD==311111111) {$hh='times'; echo "Modifique El Tiempo De la Llamada";} +if ($ADD==321111111) {$hh='times'; echo "Modifique La Lista De las Definiciones Del Estado Del Tiempo De laLlamada";} +if ($ADD==3111111111) {$hh='times'; echo "Modifique El Tiempo De la Llamada Del Estado";} +if ($ADD=="4A") {$hh='users'; echo "Modificar Usuario - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Modificar Usuario - Admin";} +if ($ADD==4) {$hh='users'; echo "Modificar Usuario";} +if ($ADD==41) {$hh='campaigns'; echo "Modifcar Campaña";} +if ($ADD==42) {$hh='campaigns'; echo "Modifcar Campaña Status";} +if ($ADD==43) {$hh='campaigns'; echo "Modifcar Campaña HotKey";} +if ($ADD==44) {$hh='campaigns'; echo "Modificar Campaña - Vista Básica";} +if ($ADD==45) {$hh='campaigns'; echo "Modifique El Plomo De la Campaña Reciclan";} +if ($ADD==411) {$hh='lists'; echo "Modificar Lista";} +if ($ADD==4111) {$hh='ingroups'; echo "Modificar In-Group";} +if ($ADD==41111) {$hh='remoteagent'; echo "Modificar Agentes Remotos";} +if ($ADD==411111) {$hh='usergroups'; echo "Modificar Grupos De Usuarios";} +if ($ADD==4111111) {$hh='scripts'; echo "Modifique La Escritura";} +if ($ADD==41111111) {$hh='filters'; echo "Modifique El Filtro";} +if ($ADD==411111111) {$hh='times'; echo "Modifique El Tiempo De la Llamada";} +if ($ADD==4111111111) {$hh='times'; echo "Modifique El Tiempo De la Llamada Del Estado";} +if ($ADD==5) {$hh='users'; echo "Delete User";} +if ($ADD==51) {$hh='campaigns'; echo "Delete Campaña";} +if ($ADD==52) {$hh='campaigns'; echo "Agentes Del Registro de estado de la máquina";} +if ($ADD==511) {$hh='lists'; echo "Delete List";} +if ($ADD==5111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==51111) {$hh='remoteagent'; echo "Suprima los agentes alejados";} +if ($ADD==511111) {$hh='usergroups'; echo "Usuarios de la cancelación Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Escritura De la Cancelación";} +if ($ADD==51111111) {$hh='filters'; echo "Filtro De la Cancelación";} +if ($ADD==511111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==5111111111) {$hh='times'; echo "Tiempo De la Llamada Del Estado De la Cancelación";} +if ($ADD==6) {$hh='users'; echo "Delete User";} +if ($ADD==61) {$hh='campaigns'; echo "Delete Campaña";} +if ($ADD==62) {$hh='campaigns'; echo "Agentes Del Registro de estado de la máquina";} +if ($ADD==65) {$hh='campaigns'; echo "El Plomo De la Cancelación Recicla";} +if ($ADD==611) {$hh='lists'; echo "Delete List";} +if ($ADD==6111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==61111) {$hh='remoteagent'; echo "Suprima los agentes alejados";} +if ($ADD==611111) {$hh='usergroups'; echo "Usuarios de la cancelación Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Escritura De la Cancelación";} +if ($ADD==61111111) {$hh='filters'; echo "Filtro De la Cancelación";} +if ($ADD==611111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==6111111111) {$hh='times'; echo "Tiempo De la Llamada Del Estado De la Cancelación";} +if ($ADD==73) {$hh='campaigns'; echo "Cuenta Del Plomo De Dialable";} +if ($ADD==7111111) {$hh='scripts'; echo "Escritura De la Inspección previo";} +if ($ADD==0) {$hh='users'; echo "Lista De Usuarios";} +if ($ADD==8) {$hh='users'; echo "Servicios repetidos Dentro Del Agente";} +if ($ADD==81) {$hh='campaigns'; echo "Servicios repetidos Dentro De la Campaña";} +if ($ADD==811) {$hh='campaigns'; echo "Servicios repetidos Dentro De la Lista";} +if ($ADD==10) {$hh='campaigns'; echo "Campañas";} +if ($ADD==100) {$hh='lists'; echo "Listas";} +if ($ADD==1000) {$hh='ingroups'; echo "In-Groups";} +if ($ADD==10000) {$hh='remoteagent'; echo "Agentes Remotos";} +if ($ADD==100000) {$hh='usergroups'; echo "Grupos De Usuario";} +if ($ADD==1000000) {$hh='scripts'; echo "Escrituras";} +if ($ADD==10000000) {$hh='filters'; echo "Filtros";} +if ($ADD==100000000) {$hh='times'; echo "Tiempos De la Llamada";} +if ($ADD==1000000000) {$hh='times'; echo "Tiempos De la Llamada Del Estado";} +if ($ADD==55) {$hh='users'; echo "Formulario De Búsqueda";} +if ($ADD==66) {$hh='users'; echo "RESULTADOS DE LA BÚSQUEDA";} +if ($ADD==99999) {$hh='users'; echo "AYUDA";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or ($ADD==21) or ($ADD==31) or ($ADD==41) or ($ADD=="4A") or ($ADD=="4B") ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ($ADD==31) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<100) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 Border=0 ALT=\"AYUDA\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
VICIDIAL ADMIN: AYUDA


\n"; + +?> +VICIDIAL_USUARIOS TABLA

+ +
+Identificación del usuario - este campo es donde usted pone el número de la identificación del usuario de VICIDIAL, puede ser hasta 8 dígitos en longitud, debe ser por lo menos 2 caracteres en longitud. + +
+
+
+Contraseña - este campo es donde usted pone la contraseña de los usuarios de VICIDIAL. Deben ser por lo menos 2 caracteres en longitud. + +
+
+
+Nombre completo - este campo es donde usted pone el nombre completo de los usuarios de VICIDIAL. Deben ser por lo menos 2 caracteres en longitud. + +
+
+
+Nivel de usuario - este menú es donde usted selecciona el nivel de usuario de los usuarios de VICIDIAL. Debe ser un nivel de 1 a registrar en VICIDIAL, debe ser llano mayor de 2 a abrirse una sesión como más cercano, deben ser el nivel de usuario 8 o mayor conseguir en la sección de la tela del admin. + +
+
+
+Grupo de usuario - este menú es donde usted selecciona a grupo de usuarios de VICIDIAL que este usuario pertenecerá a. Esto no tiene ninguna restricciones en este tiempo, éste es justo subdividir a usuarios y permitir las características futuras basadas sobre él. + +
+
+
+Conexión del teléfono - aquí es para donde usted puede fijar un valor de la conexión del teléfono del defecto cuando los registros del usuario en vicidial.php. Este valor poblará el phone_login automáticamente cuando el usuario entra con su usuario-pasar-campaña en la pantalla de la conexión de vicidial.php. + +
+
+
+Paso del teléfono - aquí es para donde usted puede fijar un valor del paso del teléfono del defecto cuando los registros del usuario en vicidial.php. Este valor poblará los phone_pass automáticamente cuando el usuario entra con su usuario-pasar-campaña en la pantalla de la conexión de vicidial.php. + +
+
+
+HotKeys activo - esta opción si el sistema a 1 permite que el usuario utilice la función ra'pida-dispositioning de HotKeys adentro vicidial.php. + +
+
+
+El agente elige Ingroups - esta opción si el sistema a 1 permite que el usuario elija los ingroups de los cuales recibirán llamadas cuando ellos conexión a una campaña MÁS CERCANA o DE ENTRADA. Si no el encargado necesitará fijar esto en su pantalla del detalle del usuario de la página del admin. + +
+
+
+Grupos de entrada - aquí es donde usted selecciona a grupos de entrada que usted desea recibir llamadas de si usted ha seleccionado la campaña MÁS CERCANA. + +
+
+
+Servicios repetidos programar - esta opción no prohibe a agente a la disposición una llamada como CALLBK y elige los datos y el tiempo en los cuales el plomo será reactivado. + +
+
+
+Servicios repetidos del Agente-Solamente - esta opción permite que un agente fije un servicio repetido de modo que sean el único agente que puede llamar la parte posteriora del cliente. Esto también permite que el agente vea sus listados del servicio repetido y los llame detrás cualquier momento desean a. + +
+
+
+Manual de la llamada del agente - esta opción permite que un agente incorpore manualmente un nuevo plomo en el sistema y los llame. Esto también permite llamar de cualquier número de teléfono de su pantalla vicidial y pone esa llamada en su sesión. Utilice esta opción con la precaución. + +
+
+
+Grabación de Vicidial - esta opción puede evitar que un agente haga cualquier grabación después de que se abran una sesión a vicidial. Esta opción debe estar encendido para que vicidial siga la sesión de la grabación de la campaña. + +
+
+
+Vicidial transfiere - esta opción puede evitar que un agente abra la transferencia - la sesión de la conferencia de vicidial. Si esto es lisiado, el agente no puede llamada de los terceros o la transferencia oculta cualquiera llama. + +
+
+
+Un defecto más cercano mezclado - esta opción omite simplemente el checkbox mezclado en una pantalla MÁS CERCANA de la conexión. + +
+
+
+Altere las opciones de interfaz del agente - esta opción si el sistema a 1 permite que el usuario administrativo modifique las opciones de interfaz de los agentes en admin.php. + +
+
+
+Usuarios de la cancelación - esta opción si el sistema a 1 permite que el usuario suprima a otros usuarios del igual o de poco nivel de usuario del sistema. + +
+
+
+Suprima a grupos de usuario - esta opción si el sistema a 1 permite que el usuario suprima a grupos de usuario del sistema. + +
+
+
+La cancelación enumera - esta opción si el sistema a 1 permite que el usuario suprima listas vicidial del sistema. + +
+
+
+La cancelación hace campaña - esta opción si el sistema a 1 permite que el usuario suprima campañas vicidial del sistema. + +
+
+
+En-Grupos de la cancelación - esta opción si el sistema a 1 permite que el usuario suprima a En-Grupos vicidial del sistema. + +
+
+
+Suprima los agentes alejados - esta opción si el sistema a 1 permite que el usuario suprima agentes alejados vicidial del sistema. + +
+
+
+La carga conduce - esta opción si el sistema a 1 permite que el usuario cargue los plomos vicidial en la tabla del vicidial_list por el cargador basado tela del plomo. + +
+
+
+Detalle de la campaña - esta opción si el sistema a 1 permite que el usuario visión y modifique los elementos de la pantalla del detalle de la campaña. + +
+
+
+Acceso de AGC Admin - esta opción si el sistema a 1 permite a usuario a la conexión a las páginas astGUIclient del admin. + +
+
+
+La cancelación de AGC telefona - esta opción si el sistema a 1 permite que el usuario suprima entradas del teléfono en las páginas astGUIclient del admin. + +
+
+
+Escrituras de la cancelación - esta opción si el sistema a 1 permite que el usuario suprima las escrituras de la campaña en la pantalla de la modificación de la escritura. + +
+
+
+Modifique los plomos - esta opción si el sistema a 1 permite que el usuario modifique los plomos en la página de los resultados de la búsqueda del plomo de la sección del admin. + +
+
+
+Cambie la campaña del agente - esta opción si el sistema a 1 permite que el usuario altere la campaña que un agente está registrado en mientras que se registran en él. + +
+
+
+La cancelación se filtra - esta opción permite que el usuario pueda suprimir los filtros vicidial del plomo del sistema. + +
+
+
+Tiempos de la llamada de la cancelación - esta opción permite que elusuario pueda suprimir expedientes vicidial de los tiempos de lallamada y expedientes vicidial de los tiempos de la llamada del estadodel sistema. + +
+
+
+Modifique los tiempos de la llamada - esta opción permite que elusuario visión y modifique los expedientes de los tiempos de lallamada y de los tiempos de la llamada del estado. Un usuario nonecesita esta opción permitida si necesitan solamente cambiar laopción de los tiempos de la llamada en la pantalla de las campañas. + + + + +



+ +VICIDIAL_CAMPAÑAS TABLA

+
+
+Identificación de la campaña - Úste es el nombre corto de la campaña, él no es editable después de la sumisión inicial, no puede contener espacios y debe estar entre 2 y 8 caracteres en longitudh. + +
+
+
+Nombre de la campaña - Ésta es la descripción de la campaña, debe estar entre 6 y 40 caracteres en longitud. + +
+
+
+Activo - aquí es adonde usted fija la campaña a activo o a inactivo. Si es inactivo, noone puede registrar en él. + +
+
+
+Extensión del parque - aquí es donde usted puede modificar para requisitos particulares en-sostiene la música para VICIDIAL. Cerciórese de que la extensión esté en lugar en el extensions.conf y eso que señala al nombre de fichero abajo. + +
+
+
+Nombre del archivo del parque - aquí es donde usted puede modificar para requisitos particulares en-sostiene la música para VICIDIAL. Cerciórese de que el nombre de fichero sea 10 caracteres en longitud o menos y que el archivo está en lugar en el directorio de /var/lib/asterisk/sounds. + +
+
+
+Forma del Web - aquí es donde usted puede fijar el Web page de encargo que será abierto cuando el usuario chasca encendido el botón de la FORMA del WEB. + +
+
+
+Permita Closers - aquí es donde usted puede fijar si los usuarios de esta campaña tendrán la opción para enviar la llamada a un más cercano. + +
+
+
+Estado del dial - aquí es adonde usted fija los estados que usted está deseando marcar encendido dentro de las listas que son activas para la campaña abajo + +
+
+
+Orden de la lista - Este menú es donde usted selecciona cómo los plomos que emparejan los estados seleccionados arriba serán puestos en la tolva del plomo: +
  - DOWN: seleccione los primeros plomos cargados en la tabla del vicidial_list +
  - UP: seleccione los plomos pasados cargados en la tabla del vicidial_list +
  - UP PHONE: seleccione el número y los trabajos más altos de teléfono su manera abajo +
  - DOWN PHONE: seleccione el número y los trabajos más bajos de teléfono su manera para arriba +
  - UP LAST NAME: comienzo con los nombres pasados comenzando con Z y trabajos su manera abajo +
  - DOWN LAST NAME: comienzo con los nombres pasados comenzando con A y trabajos su manera para arriba +
  - UP COUNT: comienzo con los plomos y los trabajos llamados su manera abajo +
  - DOWN COUNT: comienzo con menos plomos y trabajos llamados su manera para arriba +
  - DOWN COUNT 2nd NEW: comienzo con menos plomos y trabajos llamados su manera para arriba que inserta un NEW plomo en cada otro lead(Must para no tener NEW seleccionado en los estados del dial) +
  - DOWN COUNT 3nd NEW: comienzo con menos plomos y trabajos llamados su manera para arriba que inserta un NEW plomo en cada tercer lead(Must para no tener NEW seleccionado en los estados del dial) +
  - DOWN COUNT 4th NEW: comienzo con menos plomos y trabajos llamados que su manera para arriba que inserta un NEW plomo en cada adelante conduzca (no debe tener NEW seleccionado en los estados del dial) + +
+
+
+Tolva llana - éste es cuántos conducen los intentos de la escritura de VDhopper para mantener la tabla del vicidial_hopper para esta campaña. Si funciona la escritura de VDhopper cada minuto, haga esto levemente mayor que el número de plomos que usted entra a través en un minuto. + +
+
+
+Filtro del plomo - éste es un método de filtrar sus plomos usando un fragmento de una pregunta del SQL. Utilice esta característica con la precaución, él es fácil de parar el marcar accidentalmente con la alteración más leve a la declaración del SQL. El defecto no es NINGUNO. + +
+
+
+Reajuste de la fuerza de la tolva - esto permite que usted limpie fuera del contenido de la tolva sobre la sumisión de la forma. Debe ser llenada otra vez cuando la escritura de VDhopper funciona. + +
+
+
+Nivel auto del dial - aquí es adonde usted fija cuántos alinea VICIDIAL debe utilizar por medios del agente activo cero 0 que el marcar del automóvil está apagado y los agentes chascarán para marcar cada número. Si no VICIDIAL mantendrá líneas que marcan iguales a los agentes activos multiplicados por el nivel del dial para llegar cuántas líneas debe permitir esta campaña en cada servidor. + +
+
+
+Llamada siguiente del agente - esto se determina qué agente recibe la llamada siguiente que está disponible: +
  - random: órdenes por el valor al azar de la actualización en la tabla de los vicidial_live_agents +
  - oldest_call_start: las órdenes por la vez última un agente fueron enviadas una llamada. Resultados en los agentes que reciben el número casi igual de llamadas cabalmente. +
  - oldest_call_finish: las órdenes por la vez última un agente acabaron una llamada. El agente de AKA que espera lo más de largo posible recibe la primera llamada. +
  - overall_user_level: las órdenes por el user_level del agente según lo definido en los vicidial_users tabulan un user_level más alto recibirán más llamadas. + +
+
+
+Tiempo de la llamada local - aquí es adonde usted fijó durante qué horas usted quisiera marcar, según lo determinado por el tiempo local en está en cuál usted está llamando. Esto es controlada por código de área y ajustada por tiempo de los ahorros de la luz del día si es aplicable. Las pautas generales en los E.E.U.U. para el negocio al negocio son los 9am a los 5pm y el negocio a las llamadas del consumidor es los 9am a los 9pm. + +
+
+
+Descanso del dial - si está definido, llamadas que normalmente retraso después de que el descanso definido en extensions.conf en lugar de otro descanso en esta cantidad de segundos si es menos que el descanso de extensions.conf. Esto permite descansos del dial rápidamente que cambian del servidor al servidor y a limitar los efectos a una sola campaña. Si usted está teniendo muchos de llamadas del contestador automático o de Buzón de Voz usted puede desear intentar cambiar este valor entre a 21-26 y ver si los resultados mejoran. + +
+
+
+Prefijo del dial - este campo permite más fácilmente cambiar una trayectoria de marcar a salir con un diverso método sin hacer una recarga en asterisco. El defecto es 9 basados sobre un 91NXXNXXXXXX en el dialplan - extensions.conf. + +
+
+
+CallerID de la Campaña - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. If you are using T1 or E1s to dial out this option is only available if you are using PRIs - ISDN T1s or E1s - that have the custom callerid feature turned on, this will not work with Robbed-bit service(RBS) circuits. This will also work through most VOIP(SIP or IAX trunks) providers that allow dynamic outbound callerID. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Extensión de la campaña VDAD - este campo permite una extensión de la transferencia del costumbre VDAD. Esto permite que usted utilice diversas escrituras del agi de VDADtransfer... dependiendo de su campaña. La transferencia AGI(exten 8365 agi-VDADtransfer.agi del defecto) apenas envía inmediatamente invita a los agentes tan pronto como él se tome. Una encuesta sobre política AGI la muestra adicional es también (8366 agi-VDADtransferSURVEY.agi ) ese ahora incluido los juegos un mensaje a la persona llamada y permite que él haga una opción presionando buttons(effectively la pre-investigacio'n el plomo). Observe por favor eso a excepción de los exámenes, llamadas políticas y las caridades esta forma de llamar son ilegales en los Estados Unidos. + +
+
+
+Extensión de Rec de la Campaña - este campo permite para que una extensión de encargo de la grabación sea utilizada con VICIDIAL. Esto permite que usted utilice diversas extensiones dependiendo sobre cuánto tiempo usted desea permitir una grabación máxima y qué tipo de codec usted desea registrar adentro. El defecto exten es 8309 que si usted sigue los ejemplos de SCRATCH_INSTALL registrarán en el formato de WAV para hasta que una hora. Otra opción incluida en los ejemplos es 8310 que registrarán en el formato del GSM para hasta que una hora. + +
+
+
+Grabación de la campaña - este menú permite que usted elija qué nivel de la grabación se permite en esta campaña. NEVER inhabilitará la grabación en el cliente. ONDEMAND es el defecto y permite que el agente comience y pare a registrar según lo necesitado. ALLCALLS comenzará la grabación en el cliente siempre que una llamada se envíe a un agente. + +
+
+
+Nombre de fichero de Rec de la campaña - este campo permite que usted modifique el nombre para requisitos particulares de la grabación cuando la grabación de la campaña es ONDEMAND o ALLCALLS. Las variables permitidas son CAMPAIGN CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. El defecto es FULLDATE_AGENTE y parecería este 20051020-103108_6666. Otro ejemplo es CAMPAIGN_TINYDATE_CUSTPHONE que parecería este TESTCAMP_51020103108_3125551212. 50 char max. + +
+
+
+Escritura de la campaña - este menú permite que usted elija la escritura que aparecerá en la pantalla de los agentes para esta campaña. No seleccione NONE no demostrar ninguna escritura para esta campaña. + +
+
+
+Consiga el lanzamiento de la llamada - este menú permite que usted elija si usted desee automo'vil-lance la página en una ventana separada, auto-switch de la tela-forma a la lengüeta de la ESCRITURA o no haga nada cuando una llamada se envía al agente para esta campaña. + +
+
+
+Mensaje del contestador automático - este campo está para entrar en una extensión para cegar llamadas de la transferencia a cuando el agente consigue un contestador automático y chasca encendido el botón del mensaje del contestador automático en el marco de la conferencia de la transferencia. Usted debe fijar esto exten para arriba en el dialplan - extensions.conf - y se cerciora de que juega un archivo audio después que cuelga para arriba. + +
+
+
+AMD envían a la VM exten - este menú permite que usted defina si un mensaje esté dejado en un contestador automático cuando se detecta la llamada será remitido inmediatamente a la extensión del Contestar-Ma'quina-Mensaje si AMD es activo y se determina que la llamada es un contestador automático. + +
+
+
+Xfer-Conf DTMF - Estos cuatro campos permiten para que usted tenga dos sistemas de conferencia de la transferencia y de precolocaciones de DTMF. Cuando se carga la llamada o la campaña, la escritura de vicidial.php demostrará dos botones en el marco de la transferir-conferencia y automo'vil-poblara' el nu'mero-a-dial y los campos del enviar-dtmf cuando está presionada. + +
+
+
+El marcar numérico del Alt del agente - esta opción permite que un agente marque manualmente el número de teléfono o el campo alterno address3 después de que se haya llamado el número principal. + +
+
+
+Servicios repetidos programar - esta opción no prohibe a agente a la disposición una llamada como CALLBK y elige los datos y el tiempo en los cuales el plomo será reactivado. + +
+
+
+Segundos de la llamada de la gota - el número de segundos a partirdel tiempo que la línea de cliente se escoge encima de hasta que lallamada se considera una GOTA, sólo se aplica a las llamadas desalida. + +
+
+
+Buzón de Voz - si estuvieron definidas, las llamadas que CAERÍAN normalmente en lugar de otro serían ordenadas a esta caja del voicemail para oír y para dejar un mensaje. + +
+
+
+seguro puerto mensaje - si fijar y juego uno mensaje clientedespués gota llamar segundo descanso ser alcanzar sin ser transferiruno agente. _ este fijar eliminar sending uno voicemail caja si esteser fijar y. + +
+
+
+seguro puerto Exten - este ser dialplan extensión que desear seguropuerto audio archivo ser localizar en en su servidor. + +
+
+
+Segundos de Wrapup - el número de los segundos para forzar un agenteesperar antes de permitir que reciban o que marquen otra llamada. Elcontador de tiempo comienza tan pronto como un agente cuelgue paraarriba en su cliente - o en el caso del número alterno que marcacuando el agente acaba el plomo - defecto sea los segundos 0. Si elcontador de tiempo funciona hacia fuera antes de que el agente tengadispositioned la llamada, el agente todavía no se mueve encendido ala llamada siguiente hasta que seleccionan una disposición. + +
+
+
+Mensaje de Wrapup - esto es un mensaje campaña-especi'fico que seexhibirá en la pantalla del wrapup si se fijan los segundos delwrapup. + +
+
+
+Mensaje de Wrapup - esto es un mensaje campaña-especi'fico que seexhibirá en la pantalla del wrapup si se fijan los segundos delwrapup. + +
+
+
+Lista interna del uso DNC - esto define si esta campaña es filtrarlos plomos contra la lista interna de DNC. Si se fija a Y, la tolvabuscará cada número de teléfono en la lista de DNC antes de ponerlaen la tolva. Si está en la lista de DNC entonces que cambiará eseconduce estado a DNCL así que no puede ser marcada. El defecto es N. + +
+
+
+Grupos De entrada Permitidos - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound/outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + + + +



+ +VICIDIAL_LISTAS TABLA

+
+
+Identificación de la lista - Úste es el nombre numérico de la lista, él no es editable después de la sumisión inicial, debe contener solamente números y debe estar entre 2 y 8 caracteres en longitud. + +
+
+
+Nombre de la lista - Ésta es la descripción de la lista, debe estar entre 2 y 20 caracteres en longitud. + +
+
+
+Campaña - Ésta es la campaña que esta lista pertenece a. Una lista se puede marcar solamente en una sola campaña contemporáneamente. + +
+
+
+Activo - esto define si la lista debe ser marcada encendido o no. + +
+
+
+Reajuste el Conducir-Llamar-Estado para esta lista - esto reajusta todos los plomos en esta lista a N para "no llamado puesto que reajuste pasado" y significa que cualquier plomo puede ahora ser llamado si es el estado derecho según lo definido en la pantalla de la campaña. + +
+
+
+Lista de VICIDIAL DNC - esto no llama la lista contiene cada plomo quese ha fijado a un estado de DNC en el sistema. A través de las LISTAS- AGREGUE EL NÚMERO a la página de DNC que usted puede agregarmanualmente un número a esta lista de modo que no sea llamada por lascampañas que utilizan la lista interna de DNC. + + + +



+ +VICIDIAL_INBOUND_GROUPS TABLA

+
+
+Identificación de grupo - Úste es el nombre corto del grupo de entrada, él no es editable después de la sumisión inicial, no debe contener cualquier espacio y debe estar entre 2 y 20 caracteres en longitud. + +
+
+
+Nombre de grupo - Ésta es la descripción del grupo, debe estar entre 2 y 30 caracteres en longitud. No puede incluir rociadas -, plusses + o espacios . + +
+
+
+Color del grupo - éste es el color que exhibe en el cliente app de VICIDIAL cuando una llamada viene adentro en este grupo. Debe estar entre 2 y 7 caracteres de largo. Si esto es una definición del color de la tuerca hexagonal usted debe recordar poner a # al principio de la secuencia o VICIDIAL no trabajará correctamente. + +
+
+
+Activo - esto se determina si este grupo demuestra para arriba en la caja de la selección cuando un agente de VICIDIAL entra. + +
+
+
+Forma del Web - Ésta es la dirección de encargo que el chascar en el botón de la FORMA del WEB en VICIDIAL le llevará para las llamadas que vienen adentro en este grupo. + +
+
+
+Llamada siguiente del agente - esto se determina qué agente recibe la llamada siguiente que está disponible: +
  - random: órdenes por el valor al azar de la actualización en la tabla de los vicidial_live_agents +
  - oldest_call_start: las órdenes por la vez última un agente fueron enviadas una llamada. Resultados en los agentes que reciben el número casi igual de llamadas cabalmente. +
  - oldest_call_finish: las órdenes por la vez última un agente acabaron una llamada. El agente de AKA que espera lo más de largo posible recibe la primera llamada. +
  - overall_user_level: las órdenes por el user_level del agente según lo definido en los vicidial_users tabulan un user_level más alto recibirán más llamadas. + +
+
+
+Exhibición de Fronter - este campo se determina si el agente de entrada de VICIDIAL tendría el name(if del fronter allí es uno) exhibido en el campo del estado cuando la llamada viene al agente. + +
+
+
+Escritura de la campaña - este menú permite que usted elija la escritura que aparecerá en la pantalla de los agentes para esta campaña. No seleccione NONE no demostrar ninguna escritura para esta campaña. + +
+
+
+Consiga el lanzamiento de la llamada - este menú permite que usted elija si usted desee automo'vil-lance la página en una ventana separada, auto-switch de la tela-forma a la lengüeta de la ESCRITURA o no haga nada cuando una llamada se envía al agente para esta campaña. + +
+
+
+Xfer-Conf DTMF - Estos cuatro campos permiten para que usted tenga dos sistemas de conferencia de la transferencia y de precolocaciones de DTMF. Cuando se carga la llamada o la campaña, la escritura de vicidial.php demostrará dos botones en el marco de la transferir-conferencia y automo'vil-poblara' el nu'mero-a-dial y los campos del enviar-dtmf cuando está presionada. + +
+
+
+Segundos de la llamada de la gota - el número de segundos a partirdel tiempo que la línea de cliente se escoge encima de hasta que lallamada se considera una GOTA, sólo se aplica a las llamadas desalida. + +
+
+
+Buzón de Voz - si estuvieron definidas, las llamadas que CAERÍAN normalmente en lugar de otro serían ordenadas a esta caja del voicemail para oír y para dejar un mensaje. + +
+
+
+Mensaje de la gota - si el sistema a Y juega un mensaje al clientedespués de que el descanso de los segundos de la llamada de la gotase alcance sin la transferencia a un agente. Este ajuste eliminaráenviar a una caja del voicemail si esto se fija a Y. + +
+
+
+Gota Exten - ésta es la extensión dialplan que el archivo audiocaído deseado de la llamada está situado en en su servidor. + + + +



+ +VICIDIAL_REMOTE_AGENTS TABLA

+
+
+Comienzo de la identificación del usuario - Ésta es la identificación del usuario que comienza se utiliza que cuando las entradas alejadas del agente se insertan en el sistema. Si el número de líneas se fija más altamente de 1, este número es incrementado por uno hasta que cada línea tiene una entrada. Se cerciora de usted crear una nueva cuenta del usuario de VICIDIAL con un nivel de usuario de 4 o grande si usted quisiera que pudieran utilizar la página de vdremote.php para el acceso alejado de la tela de esta cuenta. + +
+
+
+Número de líneas - el define cuánto crea el agente alejado las entradas el sistema, y se determina cuántas líneas piensa que puede enviar con seguridad al número debajo. + +
+
+
+IP del servidor - Una entrada alejada del agente es solamente buena para un servidor específico, aquí es donde usted selecciona a que el servidor usted desea. + +
+
+
+Extensión externa - éste es el número que usted desea las llamadas remitidas a. Cerciórese de que sea un número dialplan completo y que si usted necesita 9 al principio usted lo pone adentro aquí. Pruebe marcando este número de un teléfono en el sistema. + +
+
+
+Estado - aquí es donde usted da vuelta al agente alejado por intervalos. Tan pronto como el agente sea activo el sistema asume que puede enviarle llamadas. Puede tomar hasta 30 segundos una vez que usted cambie el estado a inactivo para parar el recibir de llamadas. + +
+
+
+Campaña - aquí es donde usted selecciona la campaña que estos agentes alejados serán registrados en. Necesidades de entrada de utilizar la campaña MÁS CERCANA y de seleccionar las campañas de entrada debajo de ésa que usted desea recibir llamadas de. + +
+
+
+Grupos de entrada - aquí es donde usted selecciona a grupos de entrada que usted desea recibir llamadas de si usted ha seleccionado la campaña MÁS CERCANA. + + +



+ +VICIDIAL_CAMPAIGN_LISTAS

+
+
+Las listas dentro de esta campaña se enumeran aquí, si son activas son denotadas por la Y o N y usted pueden ir a la pantalla de la lista chascando en la identificación de la lista en la primera columna. + + +



+ +VICIDIAL_CAMPAIGN_STATUSES TABLA

+
+
+Con el uso de los estados de encargo de la campaña, usted puede tener estados que existan solamente para una campaña específica. El estado debe ser 1-8 caracteres en longitud, la descripción debe ser 2-30 caracteres en longitud y seleccionable define si demuestra para arriba en VICIDIAL como disposición. + + + +



+ +VICIDIAL_CAMPAIGN_HOTKEYS TABLA

+
+
+Con el uso de los hotkeys de encargo de la campaña, los agentes que utilizan el retraso vicidial de la lata del tela-cliente y la disposición llama apenas presionando una sola llave en su teclado. + + + + +



+ +VICIDIAL_LEAD_RECYCLE TABLA

+
+
+Con el uso del plomo que recicla, usted puede llamar estadosespecíficos de plomos otra vez en un intervalo especificado sin elreajuste de la lista entera. El reciclaje del plomo escampaña-especi'fico y no tiene que ser un estado dialableseleccionado en su campaña. La tentativa retrasa el campo es elnúmero de segundos hasta que el plomo se puede poner detrás en latolva, este número debe ser por lo menos 120 segundos. El campomáximo de la tentativa es el número máximo de las épocas que unplomo de este estado se puede procurar antes de que la lista necesiteser reajustada, este número puede ser a partir la 1 a 10. Usted puedeactivar y desactivar un plomo recicle la entrada con los acoplamientosproporcionados. Esta característica trabaja solamente en modo delautomo'vil-dial, donde está mayor el nivel del dial de 0. + + + + + +



+ +VICIDIAL_USER_GROUPS TABLA

+
+
+Grupo de usuario - éste es el nombre corto de un grupo de usuario de Vicidial, intento para no utilizar ningunos espacios o puntuación para los caracteres de este máximo 20 del campo, mínimo de 2 caracteres. + +
+
+
+Nombre de grupo - Ésta es la descripción del máximo vicidial del grupo de usuario de 40 caracteres. + + + + + +



+ +VICIDIAL_ESCRITURAS TABLA

+
+
+Identificación de la escritura - Éste es el nombre corto de una escritura de Vicidial. Éste necesita ser un identificador único. Intente no utilizar ningunos espacios o puntuación para los caracteres de este máximo 10 del campo, mínimo de 2 caracteres. + +
+
+Nombre de la escritura - éste es el título de una escritura de Vicidial. Éste es un resumen corto de los caracteres del máximo 50 de la escritura, mínimo de 2 caracteres. No debe haber espacios o puntuación de la clase en campo de los theis. + +
+
+Comentarios de la escritura - éste es tal como donde usted puede poner los comentarios para una escritura de Vicidial - cambiantes para liberar mejora de sept. el 23 -. caracteres del máximo 255, mínimo de 2 caracteres. + +
+
+Texto de la escritura - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today? + +
+
+
+Activo - esto se determina si esta escritura se puede seleccionar para ser utilizado por una campaña. + + + + + +



+ +VICIDIAL_LEAD_FILTROS TABLA

+
+
+Identificación del filtro - Éste es el nombre corto de un filtro del plomo de Vicidial. Éste necesita ser un identificador único. No utilice ningunos espacios o puntuación para los caracteres de este máximo 10 del campo, mínimo de 2 caracteres. + +
+
+Nombre del filtro - éste es un nombre más descriptivo del filtro. Éste es un resumen corto de los caracteres del máximo 30 del filtro, mínimo de 2 caracteres. + +
+
+El filtro comenta - aquí es tal como donde usted puede poner los comentarios para un filtro de Vicidial - las llamadas todos los plomos de California -. los caracteres del máximo 255, mínimo de 2 caracteres. + +
+
+Filtro SQL - Aquí es adonde usted pone el fragmento de la pregunta del SQL que usted desea filtrar cerca no comienza o el extremo con Y, eso será agregado por la escritura del cron de la tolva automáticamente. una pregunta del SQL del ejemplo que trabajaría aquí es el called_count 4 y called_count. + + + + + +



+ +VICIDIAL_TIEMPOS DE LA LLAMADA TABLA

+
+
+Identificación del tiempo de la llamada - éste es el nombre corto deuna definición del tiempo de la llamada de Vicidial. Éste necesitaser un identificador único. No utilice ningunos espacios opuntuación para los caracteres de este máximo 10 del campo, mínimode 2 caracteres. + +
+
+Nombre del tiempo de la llamada - éste es un nombre más descriptivode la definición del tiempo de la llamada. Éste es un resumen cortode los caracteres del máximo 30 de la definición del tiempo de lallamada, mínimo de 2 caracteres. + +
+
+El tiempo de la llamada comenta - aquí es donde usted puede poner loscomentarios para una definición del tiempo de la llamada de Vicidialtal como -10am hasta los 4pm con restricciones adicionales del estadode la llamada -. los caracteres del máximo 255. + +
+
+Tiempos del comienzo y de parada del defecto - éste es el tiempo dedefecto paran que el llamar será permitido que sea comenzado o dentrode esta definición del tiempo de la llamada si la hora de salida dela di'a-de-$$$-SEMANA no se define. 0 es medianoche. Evitar el llamarfijó totalmente este campo a 2400 y fijó el tiempo de parada deldefecto a 2400. Permitir el llamar 24 horas al día fijó la hora desalida a 0 y el tiempo de parada a 2400. + +
+
+Tiempos del comienzo y de parada del día laborable - éstos son lostiempos de encargo por el día que se puede fijar para la definicióndel tiempo de la llamada que las mismas reglas se aplican como con lostiempos del comienzo y de parada del defecto. + +
+
+Definiciones del tiempo de la llamada del estado - ésta es la listade las definiciones específicas del tiempo de la llamada del estadoque se siguen en esta definición del tiempo de la llamada. + +
+
+Estado del tiempo de la llamada del estado - éste es el código dedos letras para el estado que esta definición del tiempo que llamaestá para. Para que esto sea en efecto la llamada local mida eltiempo que se fija en la campaña debe tener este expediente deltiempo de la llamada del estado en él así como todos los plomos quetienen dos códigos del estado de la letra en ellos. + + + + +



+ +FUNCIONALIDAD DEL CARGADOR DE LA LISTA DE VICIDIAL

+
+
+El VICIDIAL tela-baso' cargador del plomo se diseña simplemente llevar un file(up del plomo 8MB de tamaño) que es lengüeta o pipa delimitada y cargarlo en la tabla del vicidial_list. Hay también un cargador estupendo nuevo del plomo de la versión beta que permite para el campo que elige y de TXT- el texto claramente, los valores separados coma de CSV- y XLS- sobresalen formatos del archivo. El cargador del plomo no hace la validación de datos o la comprobación para duplicados en sí mismo u otras listas, de modo que esté algo usted necesita hacer antes de usted la carga los plomos. También, cerciórese de que usted haya creado la lista que estos plomos son estar debajo de modo que usted pueda utilizarlos. Hay también la materia de la tiempo-zona-codificacio'n estos plomos. Usted puede desear aumentar la frecuencia que el ADMIN_adjust_GMTnow_on_leads.pl se está funcionando en el cron en su servidor del asterisco para poder cifrar cualquier plomo cargado más rápidamente. Aquí está una lista de los campos en su orden apropiada para los archivos del plomo: +
    +
  1. Código del plomo del vendedor - demuestra para arriba en el campo de la identificación del vendedor del GUI +
  2. Código de fuente - uso interno solamente para los admins y DBAs +
  3. Identificación de la lista - el número de la lista que estos plomos demostrarán para arriba debajo +
  4. Código del teléfono - el prefijo para el teléfono number(1 para los E.E.U.U., 01144 para Reino Unido, 01161 para AUS, el etc) +
  5. Número de teléfono - debe ser por lo menos 8 dígitos de largo +
  6. Título - título del customer(Mr. Ms señ., etc...) +
  7. Nombre +
  8. Inicial Media +
  9. Apellidos +
  10. Dirección, línea 1 +
  11. Dirección, línea 2 +
  12. Dirección, línea 3 +
  13. Ciudad +
  14. Estado - limitado a 2 caracteres +
  15. Provincia +
  16. Código Postal +
  17. País +
  18. Sexo +
  19. Fecha de nacimiento +
  20. Número De Teléfono Alternativo +
  21. Dirección Email +
  22. Frase De Seguridad +
  23. Comentarios +
+ +
NOTAS: La funcionalidad del cargador del plomo del sobresalir es permitida por una serie de escrituras del Perl y necesita tener un archivo correctamente configurado de /home/cron/AST_SERVER_conf.pl en lugar en el web server. También, los módulos de un Perl de los pares se deben cargar para ella para trabajar también - oLE-Storage_Lite-Storage_Lite y la Hoja de balance-ParseExcel. Usted puede comprobar para saber si hay errores runtime en éstos mirando su archivo del error_log de apache. + +







+







+EL EXTREMO +
+\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$dial_status_a = $row[3]; +$dial_status_b = $row[4]; +$dial_status_c = $row[5]; +$dial_status_d = $row[6]; +$dial_status_e = $row[7]; +$local_call_time = $row[16]; +if ($lead_filter_id=='') + { + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + +$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$camp_lists=''; +$o=0; +while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; +if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} +} +$camp_lists = eregi_replace(".$","",$camp_lists); + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + +echo "

\n"; +echo "Demuestre La Cuenta De los Plomos De Dialable -

\n"; +echo "CAMPAIGN: $campaign_id
\n"; +echo "LISTAS: $camp_lists
\n"; +echo "STATUSES: $dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e
\n"; +echo "FILTER: $lead_filter_id
\n"; +echo "CALL TIME: $local_call_time

\n"; + +### call function to calculate and print dialable leads +dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + +echo "

\n"; +echo "\n"; + +exit; +} + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) +{ + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDORLEADCODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551212'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[1]; +$script_text = $row[3]; + +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); +$script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); +$script_text = eregi_replace("\n","
",$script_text); + + +echo ""; + +echo "Escritura De la Inspección previo: $script_id
\n"; +echo "
\n"; +echo "
$script_name
\n"; +echo "$script_text\n"; +echo "
\n"; + +echo "\n"; + +exit; +} + + + + +######################### HTML HEADER BEGIN ####################################### +if ($hh=='users') {$users_hh='bgcolor ="#FFFF99"'; $users_fc='BLACK';} # yellow + else {$users_hh=''; $users_fc='WHITE';} +if ($hh=='campaigns') {$campaigns_hh='bgcolor ="#FFCC99"'; $campaigns_fc='BLACK';} # orange + else {$campaigns_hh=''; $campaigns_fc='WHITE';} +if ($hh=='lists') {$lists_hh='bgcolor ="#FFCCCC"'; $lists_fc='BLACK';} # red + else {$lists_hh=''; $lists_fc='WHITE';} +if ($hh=='ingroups') {$ingroups_hh='bgcolor ="#CC99FF"'; $ingroups_fc='BLACK';} # purple + else {$ingroups_hh=''; $ingroups_fc='WHITE';} +if ($hh=='remoteagent') {$remoteagent_hh='bgcolor ="#CCFFCC"'; $remoteagent_fc='BLACK';} # green + else {$remoteagent_hh=''; $remoteagent_fc='WHITE';} +if ($hh=='usergroups') {$usergroups_hh='bgcolor ="#CCFFFF"'; $usergroups_fc='BLACK';} # cyan + else {$usergroups_hh=''; $usergroups_fc='WHITE';} +if ($hh=='scripts') {$scripts_hh='bgcolor ="#99FFCC"'; $scripts_fc='BLACK';} # light teal + else {$scripts_hh=''; $scripts_fc='WHITE';} +if ($hh=='filters') {$filters_hh='bgcolor ="#CCCCCC"'; $filters_fc='BLACK';} # grey + else {$filters_hh=''; $filters_fc='WHITE';} +if ($hh=='times') {$times_hh='bgcolor ="#99FF33"'; $times_fc='BLACK';} # hard teal + else {$times_hh=''; $times_fc='WHITE';} + +?> + + + + +\n"; +echo "
English Español
+ + + + + + + + + + + + + + + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + + + + +
  VICIDIAL ADMIN - Salir  
> SIZE=1> USUARIOS > SIZE=1> CAMPAÑAS > SIZE=1> LISTAS > SIZE=1> ESCRITURAS > SIZE=1> FILTROS > SIZE=1> EN-GROUPOS > SIZE=1> TIEMPOS DE LA LLAMADA > SIZE=1> GRUPOS DE USUARIO > SIZE=1> AGENTES REMOTOS > INFORMES
  MOSTRAR USUARIOS     |     NUEVO USUARIO     |     BUSCAR UN USUARIO
  NUEVA CAMPAÑA     |     MOSTRAR CAMPAÑAS
  MOSTRAR LISTAS     |     NUEVA LISTA     |     BÚSCAR UN LEAD |     AGREGUE EL NÚMERO A DNC           |     CARGAR LEADS
  AGREGUE LA ESCRITURA     |     ESCRITURAS DE LA VISIÓN
  AGREGUE EL FILTRO     |     FILTROS DE LA VISIÓN
  MOSTRAR EN-GROUPOS     |     NUEVO IN-GROUP
  DEMUESTRE LOS TIEMPOS DE LA LLAMADA     |     AGREGUE EL NUEVO TIEMPO DE LA LLAMADA     |     DEMUESTRE LOS TIEMPOS DE LA LLAMADA DEL ESTADO     |     AGREGUE EL NUEVO TIEMPO DE LA LLAMADA DEL ESTADO  
  NUEVO GRUPO DE USUARIO     |     MOSTRAR GRUPOS DE USUARIO     |     GRUPO POR HORA
  MOSTRAR LOS AGENTES REMOTOS     |     NUEVO AGENTE REMOTO
 
+
\n"; +echo ""; + +echo "
NUEVO USUARIO
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "$NWB#vicidial_users-user_group$NWE\n"; +echo "\n"; +echo "
NÚmero De Usuario: $NWB#vicidial_users-user$NWE
Contraseña: $NWB#vicidial_users-pass$NWE
Nombre Completo: $NWB#vicidial_users-full_name$NWE
Nivel Del Usuario: $NWB#vicidial_users-user_level$NWE
Grupo Del Usuario:
Conexión Del Teléfono: $NWB#vicidial_users-phone_login$NWE
Contraseña Del Teléfono: $NWB#vicidial_users-phone_pass$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo "
\n"; +echo ""; + +echo "
NUEVA CAMPAÑA\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID De la Campaña: $NWB#vicidial_campaigns-campaign_id$NWE
Nombre de la Campaña: $NWB#vicidial_campaigns-campaign_name$NWE
Activo: $NWB#vicidial_campaigns-active$NWE
Extensión del parking: $NWB#vicidial_campaigns-park_ext$NWE
Nombre de fichero Del Parking: $NWB#vicidial_campaigns-park_file_name$NWE
Formulario Web: $NWB#vicidial_campaigns-web_form_address$NWE
Permitir Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Nivel Del Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Nivel del Auto-Dial: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Llamar al Siguiente Agente: $NWB#vicidial_campaigns-next_agent_call$NWE
Franja horaria de llamada: $NWB#vicidial_campaigns-local_call_time$NWE
Buzón de Voz: $NWB#vicidial_campaigns-voicemail_ext$NWE
Escritura: $NWB#vicidial_campaigns-campaign_script$NWE
Consiga El Lanzamiento De la Llamada: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID De la Lista: (Solamente dígitos)$NWB#vicidial_lists-list_id$NWE
Nombre De la Lista: $NWB#vicidial_lists-list_name$NWE
Campaña: $NWB#vicidial_lists-campaign_id$NWE
Activo: $NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) +{ +echo "
\n"; +echo ""; + +if (strlen($phone_number) > 2) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DNC NO AGREGADO - este número de teléfono está en no llama ya lalista: $phone_number

\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');"; + $rslt=mysql_query($stmt, $link); + + echo "
DNC AGREGADO: $phone_number

\n"; + + ### LOG INSERTION TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW DNC NUMBER|$PHP_AUTH_USER|$ip|'$phone_number'|\n"); + fclose($fp); + } + } + } + +echo "
AGREGUE Un NÚMERO A la LISTA De DNC\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
Número De Teléfono: (Solamente dígitos)$NWB#vicidial_list-dnc$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo "
\n"; +echo ""; + +echo "
NUEVO GRUPO DE ENTRADA\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID De Grupo: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Nombre De Grupo: $NWB#vicidial_inbound_groups-group_name$NWE
Color Del Grupo: $NWB#vicidial_inbound_groups-group_color$NWE
Activo: $NWB#vicidial_inbound_groups-active$NWE
Formulario Web: $NWB#vicidial_inbound_groups-web_form_address$NWE
Buzón de Voz: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Llamar al Siguiente Agente: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Mostrar Fronter: $NWB#vicidial_inbound_groups-fronter_display$NWE
Escritura: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Consiga El Lanzamiento De la Llamada: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo "
\n"; +echo ""; + +echo "
NUEVO AGENTE REMOTO\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Comienzo Del ID del usuario: (Solamente números, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Número de líneas: (Solamente números)$NWB#vicidial_remote_agents-number_of_lines$NWE
IP Del Servidor: $NWB#vicidial_remote_agents-server_ip$NWE
Extensión Externa: (número del dialplan para alcanzar agentes)$NWB#vicidial_remote_agents-conf_exten$NWE
Estado: $NWB#vicidial_remote_agents-status$NWE
Campaña: $NWB#vicidial_remote_agents-campaign_id$NWE
Grupos De entrada: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTA: Puede tomar hasta 30 segundos para los cambios sometidos en esta pantalla para ir viva\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo "
\n"; +echo ""; + +echo "
NUEVO GRUPO DE USUARIOS\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Grupo: (sin espacios o signos de puntuación)$NWB#vicidial_user_groups-user_group$NWE
Descripción: (Descripción del grupo)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW SCRIPT\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Identificación De la Escritura:: (sin espacios o signos de puntuación)$NWB#vicidial_scripts-script_id$NWE
Nombre de la escritura: (título de la escritura)$NWB#vicidial_scripts-script_name$NWE
Comentarios de la escritura: $NWB#vicidial_scripts-script_comments$NWE
Activo: $NWB#vicidial_scripts-active$NWE
Texto de la escritura: $NWB#vicidial_scripts-script_text$NWE
\n"; + +} + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) +{ +echo "
\n"; +echo ""; + +echo "
AGREGUE EL FILTRO NUEVO\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Identificación Del Filtro: (sin espacios o signos de puntuación)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Nombre Del Filtro: (descripción corta del filtro)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Comentarios Del Filtro: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filtro Sql: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; +} + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) +{ +echo "
\n"; +echo ""; + +echo "
AGREGUE EL NUEVO TIEMPO DE LA LLAMADA\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Identificación Del Tiempo De la Llamada: (sin espacios o signos de puntuación)$NWB#vicidial_call_times-call_time_id$NWE
Nombre Del Tiempo De la Llamada: (descripción corta del tiempo de la llamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentarios Del Tiempo De la Llamada: $NWB#vicidial_call_times-call_time_comments$NWE
Las opciones del día y del tiempo aparecerán una vez que usted hayacreado la definición del tiempo de la llamada
\n"; +} + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) +{ +echo "
\n"; +echo ""; + +echo "
AGREGUE EL NUEVO TIEMPO DE LA LLAMADA DEL ESTADO\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Identificación Del Tiempo De la Llamada Del Estado: (sin espacios o signos de puntuación)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (sin espacios o signos de puntuación)$NWB#vicidial_call_times-state_call_time_state$NWE
_ Estado Llamar Tiempo Nombre: (descripción corta del tiempo de la llamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentarios Del Tiempo De la Llamada Del Estado: $NWB#vicidial_call_times-call_time_comments$NWE
Las opciones del día y del tiempo aparecerán una vez que usted hayacreado la definición del tiempo de la llamada
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USUARIO NO AGREGADO - hay ya un usuario en el sistema con este número del usuario\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
USUARIO NO AGREGADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
la ID del usuario debe estar entre 2 y 8 caracteres de largo\n"; + echo "
el nombre completo y la contraseña deben ser por lo menos 2 caracteres de largo\n"; + } + else + { + echo "
EL USUARIOAÑADIDO: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass'|\n"); + fclose($fp); + } + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAÚA NO AGREGADA - hay ya una campaña en el sistema con esta identificación\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
CAMPAÚA NO AGREGADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
la ID de la campaña debe estar entre 2 y 8 caracteres en longitud\n"; + echo "
el nombre de la campaña debe estar entre 6 y 40 caracteres en longitud\n"; + } + else + { + echo "
CAMPAÑA AÑADIDA: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('$campaign_id','$campaign_name','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo ""; + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|NUEVA CAMPAÑA |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ESTADO de la CAMPAÚA - hay ya una campaña - estado NO AGREGADO en el sistema con este nombre\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ESTADO de la CAMPAÚA NO AGREGADO - hay ya un global-estado en el sistema con este nombre\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
ESTADO de la CAMPAÚA NO AGREGADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el estado debe estar entre 1 y 8 caracteres en longitud\n"; + echo "
el nombre del estado debe estar entre 2 y 30 caracteres en longitud\n"; + } + else + { + echo "
ESTADO DE LA CAMPAÑA AÑADIDA: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|NUEVA CAMPAÑA STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } + } +$ADD=31; +} + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) +{ + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAÚA HOTKEY NO AGREGADA - hay ya una campaña-hotkey en el sistema con este hotkey\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAÚA HOTKEY NO AGREGADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el hotkey debe ser un solo carácter entre 1 y 9 \n"; + echo "
el estado debe estar entre 1 y 8 caracteres en longitud\n"; + } + else + { + echo "
ACCESO DIRECTO A LA CAMPAÑA AÑADIDO: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|NUEVA CAMPAÑA HOTKEY |$PHP_AUTH_USER|$ip|'$status','$hotkey','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) +{ + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
El PLOMO de la CAMPAÑA RECICLA NO AGREGADO - hay ya unconducir-reciclaje para esta campaña con este estado\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el estado debe estar entre 1 y 6 caracteres en longitud\n"; + echo "
la tentativa retrasa debe ser por lo menos 120 segundos\n"; + echo "
las tentativas máximas deben ser a partir la 1 a 10\n"; + } + else + { + echo "
EL PLOMO DE LA CAMPAÑA RECICLA AGREGADO: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LISTA NO AGREGADA - hay ya una lista en el sistema con esta ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
LISTA NO AGREGADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La ID de la lista debe estar entre 2 y 8 caracteres en longitud\n"; + echo "
El nombre de la lista debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
LISTA AÑADIDA: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + } + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GRUPO NO AGREGADO - hay ya un grupo en el sistema con esta ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GRUPO NO AGREGADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La ID de grupo debe estar entre 2 y 20 caracteres en longitud y contener no ' -+'.\n"; + echo "
El color del nombre de grupo y del grupo debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPO AÑADIDO: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
AGENTES ALEJADOS NO AGREGADOS - hay ya una entrada alejada de los agentes comenzando con esta ID del usuario\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
AGENTES ALEJADOS NO AGREGADOS - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
El comienzo de la ID del usuario y la extensión externa deben ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
AGENTES REMOTO AÑADIDO: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW AGENTES REMOTOS ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + } + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GRUPO de USUARIO NO AGREGADO - hay ya una entrada del grupo de usuario con este nombre\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
GRUPO de USUARIO NO AGREGADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
El nombre y la descripción de grupo deben ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPO DE USUARIO AÑADIDO: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|NUEVO USUARIO GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + } + } + } +$ADD=100000; +} + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
ESCRITURA NO AGREGADA - hay ya una entrada de la escritura con este nombre\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
ESCRITURA NO AGREGADA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
El nombre, la descripción y el texto de la escritura deben ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + + echo "
ESCRITURA AGREGADA: $script_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000000; +} + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
FILTRO NO AGREGADO - hay ya una entrada del filtro con esta identificación\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTRO NO AGREGADO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Filtre la identificación, nombre y el SQL debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='$lead_filter_sql';"; + $rslt=mysql_query($stmt, $link); + + echo "
EL FILTRO AGREGÓ: $lead_filter_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=10000000; +} + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DEFINICIÓN DEL TIEMPO DE LA LLAMADA NO AGREGADA - hay ya una entrada de tiempo de la llamada con esta identificación\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
DEFINICIÓN DEL TIEMPO DE LA LLAMADA NO AGREGADA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La identificación del tiempo de la llamada y el nombre deben ser porlo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + + echo "
TIEMPO DE LA LLAMADA AGREGADO: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + } +$ADD=311111111; +} + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DEFINICIÓN DEL TIEMPO DE LA LLAMADA DEL ESTADO NO AGREGADA - hay ya una entrada de tiempo de la llamada con esta identificación\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
DEFINICIÓN DEL TIEMPO DE LA LLAMADA DEL ESTADO NO AGREGADA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Indique que identificación del tiempo de la llamada, nombre y estadodebe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + + echo "
TIEMPO DE LA LLAMADA DEL ESTADO AGREGADO: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=3111111111; +} + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USUARIO NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La contraseña y el nombre completo cada ot de la necesidad sean por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
USUARIO MODIFICADO - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USUARIO NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La contraseña y el nombre completo cada ot de la necesidad sean por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
USUARIO MODIFICADO - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USUARIO NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La contraseña y el nombre completo cada ot de la necesidad sean por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
USUARIO MODIFICADO: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAÚA NO MODIFICADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el nombre de la campaña necesita ser por lo menos 6 caracteres en longitud\n"; + } + else + { + echo "
CAMPAÑA MODIFICADA: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
REAJUSTE DE LA TOLVA DEL PLOMO DE LA CAMPAÚA\n"; + echo "
- Espera 1 minuto antes de marcar el número siguiente\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
ESTADO de la CAMPAÚA NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
la ID de la campaña necesita ser por lo menos 2 caracteres en longitud\n"; + echo "
el estado de la campaña necesita ser por lo menos los caracteres 1 en longitud\n"; + } + else + { + echo "
ESTADO DE ENCARGO DE LA CAMPAÚA SUPRIMIDO: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAÚA HOTKEY NO MODIFICADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
la ID de la campaña necesita ser por lo menos 2 caracteres en longitud\n"; + echo "
el estado de la campaña necesita ser por lo menos los caracteres 1 en longitud\n"; + echo "
el hotkey de la campaña necesita ser por lo menos los caracteres 1 en longitud\n"; + } + else + { + echo "
LA CAMPAÚA DE ENCARGO HOTKEY SUPRIMIÚ: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAÚA NO MODIFICADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el nombre de la campaña necesita ser por lo menos 6 caracteres en longitud\n"; + } + else + { + echo "
CAMPAÑA MODIFICADA: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level',lead_filter_id='$lead_filter_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
REAJUSTE DE LA TOLVA DEL PLOMO DE LA CAMPAÚA\n"; + echo "
- Espera 1 minuto antes de marcar el número siguiente\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG HOPPER RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=34; # go to campaign modification form below +} + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el estado debe estar entre 1 y 6 caracteres en longitud\n"; + echo "
la tentativa retrasa debe ser por lo menos 120 segundos\n"; + echo "
las tentativas máximas deben ser a partir la 1 a 10\n"; + } + else + { + echo "
CAMPAIGN LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LISTA NO MODIFICADA - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el nombre de la lista debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
LISTA MODIFICADA: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
REAJUSTANDO LA LISTA - LLAMADA - ESTADO\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + } + if ($campaign_id != "$old_campaign_id") + { + echo "
QUITAR LOS PLOMOS DE LA TOLVA DE LA LISTA DE VIEJA TOLVA DE LA CAMPAÚA ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + } + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GRUPO NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el color del nombre de grupo y del grupo debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
GRUPO MODIFICADO: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_message='$drop_message',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111; # go to in-group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
AGENTES ALEJADOS NO MODIFICADOS - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
El comienzo de la ID del usuario y la extensión externa deben ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
LOS AGENTES ALEJADOS SE MODIFICARON\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY AGENTES REMOTOS ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
GRUPO de USUARIO NO MODIFICADO - vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
El nombre y la descripción de grupo deben ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
GRUPO DE USUARIO MODIFICADO\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + } + } + +$ADD=311111; # go to user group modification form below +} + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
ESCRITURA NO MODIFICADA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
El nombre, la descripción y el texto de la escritura deben ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
LA ESCRITURA SE MODIFICÓ\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111; # go to script modification form below +} + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTRO NO MODIFICADO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Filtre la identificación, nombre y el SQL debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='$lead_filter_sql' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTRO MODIFICADO\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31111111; # go to filter modification form below +} + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
TIEMPO DE LA LLAMADA NO MODIFICADO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La identificación del tiempo de la llamada y el nombre deben ser porlo menos 2 caracteres en longitud\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
TIEMPO DE LA LLAMADA MODIFICADO\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + +$ADD=311111111; # go to call time modification form below +} + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
TIEMPO DE LA LLAMADA DEL ESTADO NO MODIFICADO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Indique que identificación del tiempo de la llamada, nombre y estadodebe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
TIEMPO DE LA LLAMADA DEL ESTADO MODIFICADO\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111111; # go to state call time modification form below +} + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
USUARIO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DEL USUARIO: $user\n"; + echo "

Chasque aquí para suprimir a usuario $user


\n"; + } + +$ADD='3'; # go to user modification below +} + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAÑA NO SUPRIMIDA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Campaña_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DE LA CAMPAÑA: $campaign_id\n"; + echo "

Chasque aquí para suprimir campaña $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTES NO REGISTRADOS FUERA DE CAMPAÑA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Campaña_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DEL REGISTRO DE ESTADO DE LA MÁQUINA DEL AGENTE: $campaign_id\n"; + echo "

Chasque aquí para registrar todos los agentes fuera de $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) +{ + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
LISTA NO SUPRIMIDA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DE LA LISTA: $list_id\n"; + echo "

Chasque aquí para suprimir la lista y todos sus plomos $list_id


\n"; + } + +$ADD='311'; # go to campaign modification below +} + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
EN-GRUPO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DE EN-GRUPO: $group_id\n"; + echo "

Chasque aquí para suprimir a en-grupo $group_id


\n"; + } + +$ADD='3111'; # go to in-group modification below +} + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
AGENTE ALEJADO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN ALEJADA DE LA CANCELADURA DEL AGENTE: $remote_agent_id\n"; + echo "

Chasque aquí para suprimir el agente alejado $remote_agent_id


\n"; + } + +$ADD='31111'; # go to remote agent modification below +} + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
GRUPO DE USUARIO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DEL GRUPO DE USUARIO: $user_group\n"; + echo "

Chasque aquí para suprimir a grupo de usuario $user_group


\n"; + } + +$ADD='311111'; # go to user group modification below +} + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
ESCRITURA NO SUPRIMIDA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DE LA ESCRITURA: $script_id\n"; + echo "

Chasque aquí para suprimir la escritura $script_id


\n"; + } + +$ADD='3111111'; # go to script modification below +} + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
FILTRO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La identificación del filtro debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Chasque aquí para suprimir el filtro$lead_filter_id


\n"; + } + +$ADD='31111111'; # go to filter modification below +} + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
TIEMPO DE LA LLAMADA NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
_ llamar tiempo identificación deber ser por lo menos 2 carácter enlongitud\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DEL TIEMPO DE LA LLAMADA: $call_time_id\n"; + echo "

Click here to delete call time $call_time_id


\n"; + } + +$ADD='311111111'; # go to call time modification below +} + +###################### +# ADD=5111111111 confirmation before deletion of call time record +###################### + +if ($ADD==5111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
TIEMPO DE LA LLAMADA DEL ESTADO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
_ llamar tiempo identificación deber ser por lo menos 2 carácter enlongitud\n"; + } + else + { + echo "
CONFIRMACIÓN DE LA CANCELADURA DEL TIEMPO DE LA LLAMADA DEL ESTADO: $call_time_id\n"; + echo "

Click here to delete state call time $call_time_id


\n"; + } + +$ADD='3111111111'; # go to state call time modification below +} + + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
USUARIO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING USER!!!!|$PHP_AUTH_USER|$ip|user='$user'|\n"); + fclose($fp); + } + echo "
CANCELADURA DEL USUARIO TERMINADA: $user\n"; + echo "

\n"; + } + +$ADD='0'; # go to user list +} + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) +{ + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAÑA NO SUPRIMIDA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Campaña_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
QUITAR LOS PLOMOS DE LA TOLVA DE LA LISTA DE VIEJA TOLVA DE LA CAMPAÚA ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!DELETING CAMPAIGN!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
LA CANCELADURA DE LA CAMPAÑA TERMINÓ: $campaign_id\n"; + echo "

\n"; + } + +$ADD='10'; # go to campaigns list +} + +###################### +# ADD=62 Logout all agents fro a campaign +###################### + +if ($ADD==62) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTES NO REGISTRADOS FUERA DE CAMPAÑA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Campaña_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!AGENTE LOGOUT!!!!!!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
EL REGISTRO DE ESTADO DE LA MÁQUINA DEL AGENTE TERMINÓ: $campaign_id\n"; + echo "

\n"; + } + +$ADD='31'; # go to campaign modification below +} + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
EL PLOMO DE LA CAMPAÑA RECICLA NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
el estado debe estar entre 1 y 6 caracteres en longitud\n"; + echo "
la tentativa retrasa debe ser por lo menos 120 segundos\n"; + echo "
las tentativas máximas deben ser a partir la 1 a 10\n"; + } + else + { + echo "
EL PLOMO DE LA CAMPAÑA RECICLA SUPRIMIDO: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) +{ + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
LISTA NO SUPRIMIDA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
QUITAR LOS PLOMOS DE LA TOLVA DE LA LISTA DE VIEJA TOLVA DE LA CAMPAÚA ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
QUITAR LOS PLOMOS DE LA LISTA DE LA TABLA DE VICIDIAL_LIST\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING LIST!!!!|$PHP_AUTH_USER|$ip|list_id='$list_id'|\n"); + fclose($fp); + } + echo "
LA CANCELADURA DE LA LISTA TERMINÓ: $list_id\n"; + echo "

\n"; + } + +$ADD='100'; # go to lists list +} + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
EN-GRUPO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_groups where group_id='$group_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING IN-GROUP!!|$PHP_AUTH_USER|$ip|group_id='$group_id'|\n"); + fclose($fp); + } + echo "
CANCELADURA DE EN-GRUPO TERMINADA: $group_id\n"; + echo "

\n"; + } + +$ADD='1000'; # go to in-group list +} + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
AGENTE ALEJADO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING RMTAGENT!!|$PHP_AUTH_USER|$ip|remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + echo "
CANCELADURA ALEJADA DEL AGENTE TERMINADA: $remote_agent_id\n"; + echo "

\n"; + } + +$ADD='10000'; # go to remote agents list +} + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
GRUPO DE USUARIO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING USRGROUP!!|$PHP_AUTH_USER|$ip|user_group='$user_group'|\n"); + fclose($fp); + } + echo "
CANCELADURA DEL GRUPO DE USUARIO TERMINADA: $user_group\n"; + echo "

\n"; + } + +$ADD='100000'; # go to user group list +} + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
ESCRITURA NO SUPRIMIDA - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING SCRIPT!!!!|$PHP_AUTH_USER|$ip|script_id='$script_id'|\n"); + fclose($fp); + } + echo "
CANCELADURA DE LA ESCRITURA TERMINADA: $script_id\n"; + echo "

\n"; + } + +$ADD='1000000'; # go to script list +} + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
FILTRO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
La identificación del filtro debe ser por lo menos 2 caracteres en longitud\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING FILTER!!!!|$PHP_AUTH_USER|$ip|lead_filter_id='$lead_filter_id'|\n"); + fclose($fp); + } + echo "
CANCELADURA DEL FILTRO TERMINADA: $lead_filter_id\n"; + echo "

\n"; + } + +$ADD='10000000'; # go to filter list +} + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
TIEMPO DE LA LLAMADA NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
_ llamar tiempo identificación deber ser por lo menos 2 carácter enlongitud\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
_ LLAMAR TIEMPO CANCELADURA TERMINAR: $call_time_id\n"; + echo "

\n"; + } + +$ADD='100000000'; # go to call times list +} + + +###################### +# ADD=6111111111 delete call times record +###################### + +if ($ADD==6111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
TIEMPO DE LA LLAMADA DEL ESTADO NO SUPRIMIDO - Vaya por favor detrás y mire los datos que usted incorporó\n"; + echo "
_ llamar tiempo identificación deber ser por lo menos 2 carácter enlongitud\n"; + } + else + { + $stmt="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + + while ($sct_to_print > $o) { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "Regla Del Estado Quitada: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|state_call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
CANCELADURA DEL TIEMPO DE LA LLAMADA DEL ESTADO TERMINADA: $call_time_id\n"; + echo "

\n"; + } + +$ADD='1000000000'; # go to call times list +} + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + +if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
Usted no tiene permisos de modificar a este usuario: $row[1]\n"; + } +else + { + echo "
MODIFIQUE Un EXPEDIENTE De los USUARIOS: $row[1]\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($LOGuser_level > 8) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "
NÚmero De Usuario: $row[1]$NWB#vicidial_users-user$NWE
Contraseña: $NWB#vicidial_users-pass$NWE
Nombre Completo: $NWB#vicidial_users-full_name$NWE
Nivel Del Usuario: $NWB#vicidial_users-user_level$NWE
Grupo Del Usuario: $NWB#vicidial_users-user_group$NWE
Conexión Del Teléfono: $NWB#vicidial_users-phone_login$NWE
Contraseña Del Teléfono: $NWB#vicidial_users-phone_pass$NWE
OPCIONES DE INTERFAZ DEL AGENTE:
El Agente Elige Ingroups: $NWB#vicidial_users-agent_choose_ingroups$NWE
HotKeys Activo: $NWB#vicidial_users-hotkeys_active$NWE
Servicios repetidos Programar: $NWB#vicidial_users-scheduled_callbacks$NWE
Servicios repetidos Del Agente-Solamente: $NWB#vicidial_users-agentonly_callbacks$NWE
Manual de la llamada del agente: $NWB#vicidial_users-agentcall_manual$NWE
Grabación de Vicidial: $NWB#vicidial_users-vicidial_recording$NWE
Vicidial transfiere: $NWB#vicidial_users-vicidial_transfers$NWE
Un Defecto Más cercano Mezclado: $NWB#vicidial_users-closer_default_blended$NWE
Grupos De entrada: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_users-closer_campaigns$NWE
OPCIONES DE INTERFAZ DEL ADMIN:
Altere Las Opciones De Interfaz Del Agente: $NWB#vicidial_users-alter_agent_interface_options$NWE
Usuarios de la cancelación: $NWB#vicidial_users-delete_users$NWE
Suprima a grupos de usuario: $NWB#vicidial_users-delete_user_groups$NWE
La cancelación enumera: $NWB#vicidial_users-delete_lists$NWE
La cancelación hace campaña: $NWB#vicidial_users-delete_campaigns$NWE
En-Grupos de la cancelación: $NWB#vicidial_users-delete_ingroups$NWE
Suprima los agentes alejados: $NWB#vicidial_users-delete_remote_agents$NWE
Escritura De la Cancelacións: $NWB#vicidial_users-delete_scripts$NWE
La carga conduce: $NWB#vicidial_users-load_leads$NWE
Detalle de la campaña: $NWB#vicidial_users-campaign_detail$NWE
Acceso de AGC Admin: $NWB#vicidial_users-ast_admin_access$NWE
La cancelación de AGC telefona: $NWB#vicidial_users-ast_delete_phones$NWE
Modifique Los Plomos: $NWB#vicidial_users-modify_leads$NWE
Cambie La Campaña Del Agente: $NWB#vicidial_users-change_agent_campaign$NWE
Filtro De la Cancelacións: $NWB#vicidial_users-delete_filters$NWE
Delete Tiempos De la Llamada: $NWB#vicidial_users-delete_call_times$NWE
Modifique El Tiempo De la Llamadas: $NWB#vicidial_users-modify_call_times$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

SUPRIMA A ESTE USUARIO\n"; + } + echo "

Chasque aquí para la hoja de tiempo del usuario\n"; + echo "

Chasque aquí para el estado del usuario\n"; + echo "

Clique aquí para ver las estadísticas del usuario\n"; + echo "

Chasque aquí para los asimientos del servicio repetido del usuario\n"; + } + +} + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed + +if ($ADD==31) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $safe_harbor_message = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; +# $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + +echo "
MODIFIQUE Un EXPEDIENTE De las CAMPAÚAS: $row[0] - Vista Básica"; +echo " | Vista Detallada | "; +echo "Pantalla En tiempo real\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +if (eregi("CLOSER", $campaign_id)) + { + echo "\n"; + } + + + +echo "\n"; +echo "
ID De la Campaña: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Nombre de la Campaña: $NWB#vicidial_campaigns-campaign_name$NWE
Activo: $NWB#vicidial_campaigns-active$NWE
Extensión del parking: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Formulario Web: $NWB#vicidial_campaigns-web_form_address$NWE
Permitir Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Estado del dial 1: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 2: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 3: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 4: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 5: $NWB#vicidial_campaigns-dial_status$NWE
Orden De la Lista: $NWB#vicidial_campaigns-lead_order$NWE
Filtro del plomo: $NWB#vicidial_campaigns-lead_filter_id$NWE
Nivel Del Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Forzar el Reinicio del Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Nivel del Auto-Dial: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Llamar al Siguiente Agente: $NWB#vicidial_campaigns-next_agent_call$NWE
Franja horaria de llamada: $NWB#vicidial_campaigns-local_call_time$NWE
Tiempo de espera Del Dial: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Prefijo al marcar: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
CallerID de la Campaña: $NWB#vicidial_campaigns-campaign_cid$NWE
Exten VDAD de La campaña: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Extensión de Rec de la campaña: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Grabación De la Campaña: $NWB#vicidial_campaigns-campaign_recording$NWE
Nombre de fichero De Rec De la Campaña: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Consiga El Lanzamiento De la Llamada: $NWB#vicidial_campaigns-get_call_launch$NWE
Mensaje del contestador automático: $NWB#vicidial_campaigns-am_message_exten$NWE
AMD envían a la VM exten: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
Transfiera -Conf DTMF 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfiera -Conf El Número 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfiera -Conf DTMF 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfiera -Conf El Número 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
El Marcar Del Número Del Alt: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Servicios repetidos Programar: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Segundos De la Llamada De la Gota: $NWB#vicidial_campaigns-drop_call_seconds$NWE
Buzón de Voz: $NWB#vicidial_campaigns-voicemail_ext$NWE
Utilice El Mensaje Seguro Del Puerto: $NWB#vicidial_campaigns-safe_harbor_message$NWE
Puerto Seguro Exten: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Segundos De Wrapup: $NWB#vicidial_campaigns-wrapup_seconds$NWE
Mensaje De Wrapup: $NWB#vicidial_campaigns-wrapup_message$NWE
Utilice La Lista Interna de DNC: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Grupos De entrada Permitidos:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
\n"; + +echo "
\n"; +echo "
LISTAS DENTRO DE ESTA CAMPAÑA:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ID DE LA LISTANOMBRE DE LA LISTAACTIVO
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Esta campaña tiene $active_lists listas activas y $inactive_lists listas inactivas

\n"; + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - PIEL

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - DEMOSTRACIÓN

"; + } + + + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "Esta campaña tiene $hopper_leads Leads en el Hopper

\n"; +echo "Chasque aquí para ver qué plomos están en la tolva ahora

\n"; +echo "Chasque aquí para ver todos los asimientos del servicio repetido en esta campaña

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
ESTADOS DE ENCARGO DENTRO DE ESTA CAMPAÚA:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ESTADODESCRIPCIÓNSELECCIONABLEELIMINAR
$rowx[0]$rowx[1]$rowx[2]ELIMINAR
\n"; + +echo "
AGREGAR ESTADO PERSONALIZADO A LA CAMPAÑA
\n"; +echo "\n"; +echo "\n"; +echo "Estado:   \n"; +echo "Descripción:   \n"; +echo "Seleccionable:   \n"; +echo "
\n"; + +echo "

\n"; + + + +echo "
PERSONALIZAR ACCEDOS DIRECTOS PARA ESTA CAMPAÑA:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ACCESO DIRECTOESTADODESCRIPCIÓNELIMINAR
$rowx[1]$rowx[0]$rowx[2]ELIMINAR
\n"; + +echo "
AÑADIR ACCESO DIRECTO A LA CAMPAÑA
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Acceso Directo:   \n"; +echo "Estado:   \n"; +echo "
\n"; +echo "

\n"; + + + +echo "

PLOMO QUE RECICLA DENTRO DE ESTA CAMPAÑA:   $NWB#vicidial_lead_recycle$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +echo "
ESTADOLA TENTATIVA RETRASAMÁXIMO DE LA TENTATIVAACTIVO ELIMINAR
$rowx[2]
\n"; + echo "\n"; + echo "\n"; + echo "
ELIMINAR
\n"; + +echo "
AGREGUE EL NUEVO PLOMO DE LA CAMPAÑA RECICLAN
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Estado:   \n"; +echo "La Tentativa Retrasa: \n"; +echo "Máximo De la Tentativa: \n"; +echo "
\n"; + +echo "

\n"; + +echo "REGISTRE TODOS LOS AGENTES FUERA DE ESTA CAMPAÑA

\n"; + +if ($LOGdelete_campaigns > 0) + { + echo "

SUPRIMA ESTA CAMPAÑA\n"; + } + +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ($ADD==34) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Vista Básica | "; +echo "Vista Detallada | "; +echo "Pantalla En tiempo real\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
ID De la Campaña: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Nombre de la Campaña: $NWB#vicidial_campaigns-campaign_name$NWE
Activo: $NWB#vicidial_campaigns-active$NWE
Extensión del parking: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Formulario Web: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Permitir Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Estado del dial 1: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 2: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 3: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 4: $NWB#vicidial_campaigns-dial_status$NWE
Estado del dial 5: $NWB#vicidial_campaigns-dial_status$NWE
Orden De la Lista: $NWB#vicidial_campaigns-lead_order$NWE
Filtro del plomo: $NWB#vicidial_campaigns-lead_filter_id$NWE
Nivel Del Hopper: $NWB#vicidial_campaigns-hopper_level$NWE
Forzar el Reinicio del Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Nivel del Auto-Dial: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Script: $script_id
Consiga El Lanzamiento De la Llamada: $get_call_launch
\n"; + +echo "
\n"; +echo "
LISTAS DENTRO DE ESTA CAMPAÑA:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
ID DE LA LISTANOMBRE DE LA LISTAACTIVO
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "Esta campaña tiene $active_lists listas activas y $inactive_lists listas inactivas

\n"; + + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - PIEL

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - DEMOSTRACIÓN

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "Esta campaña tiene $hopper_leads Leads en el Hopper

\n"; +echo "Chasque aquí para ver qué plomos están en la tolva ahora

\n"; +echo "Chasque aquí para ver todos los asimientos del servicio repetido en esta campaña

\n"; +echo "
\n"; + +echo "
\n"; + +echo "REGISTRE TODOS LOS AGENTES FUERA DE ESTA CAMPAÑA

\n"; + + +if ($LOGdelete_campaigns > 0) + { + echo "

SUPRIMA ESTA CAMPAÑA\n"; + } + + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT * from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + +echo "
MODIFICAR UN REGISTRO DE LAS LISTAS: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
ID De la Lista: $row[0]$NWB#vicidial_lists-list_id$NWE
Nombre De la Lista: $NWB#vicidial_lists-list_name$NWE
Campaña: $NWB#vicidial_lists-campaign_id$NWE
Activo: $NWB#vicidial_lists-active$NWE
Reiniciar el Lead-Called-Status para esta lista: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
ESTADOS DENTRO DE ESTA LISTA:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + +echo "\n"; +echo "\n"; + +echo "
ESTADONOMBRE DEL ESTADOLLAMADONO LLAMADO
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
SUBTOTALES$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + +echo "
\n"; +echo "
ZONAS DE TIEMPO DENTRO DE ESTA LISTA:
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + +echo "\n"; +echo "\n"; + +echo "
DESPLAZAMIENTO GMT AHORA (tiempo local)LLAMADONO LLAMADO
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
SUBTOTALES$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
LLAMADAS REALIZADAS DENTRO DE ESTA LISTA:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + +echo "
ESTADONOMBRE DEL ESTADO$firstSUBTOTAL
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
TOTAL$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +if ($LOGdelete_lists > 0) + { + echo "

SUPRIMA ESTA LISTA\n"; + } + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_message = $row[15]; + $drop_exten = $row[16]; + +echo "
MODIFICAR UN REGISTRO DE LOS GRUPOS: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +echo "\n"; +echo "
ID De Grupo: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Nombre De Grupo: $NWB#vicidial_inbound_groups-group_name$NWE
Color Del Grupo: $NWB#vicidial_inbound_groups-group_color$NWE
Activo: $NWB#vicidial_inbound_groups-active$NWE
Formulario Web: $NWB#vicidial_inbound_groups-web_form_address$NWE
Llamar al Siguiente Agente: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Mostrar Fronter: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Consiga El Lanzamiento De la Llamada: $NWB#vicidial_inbound_groups-get_call_launch$NWE
Transfiera -Conf DTMF 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfiera -Conf El Número 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfiera -Conf DTMF 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfiera -Conf El Número 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Segundos De la Llamada De la Gota: $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
Buzón de Voz: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Utilice El Mensaje De la Gota: $NWB#vicidial_inbound_groups-drop_message$NWE
Gota Exten: $NWB#vicidial_inbound_groups-drop_exten$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +if ($LOGdelete_ingroups > 0) + { + echo "

SUPRIMA A ESTE EN-GRUPO\n"; + } + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFICAR UNA ENTRADA DE LOS AGENTES REMOTOS: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Comienzo Del ID del usuario: (Solamente números, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Número de líneas: (Solamente números)$NWB#vicidial_remote_agents-number_of_lines$NWE
IP Del Servidor: $NWB#vicidial_remote_agents-server_ip$NWE
Extensión Externa: (número del dialplan para alcanzar agentes)$NWB#vicidial_remote_agents-conf_exten$NWE
Estado: $NWB#vicidial_remote_agents-status$NWE
Campaña: $NWB#vicidial_remote_agents-campaign_id$NWE
Grupos De entrada: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTA: Puede tomar hasta 30 segundos para los cambios sometidos en esta pantalla para ir viva\n"; + + +if ($LOGdelete_remote_agents > 0) + { + echo "

SUPRIMA ESTE AGENTE ALEJADO\n"; + } + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
MODIFICAR UNA ENTRADA EN LOS GRUPOS DE USUARIOS\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Grupo: (sin espacios o signos de puntuación)$NWB#vicidial_user_groups-user_group$NWE
Descripción: (Descripción del grupo)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +if ($LOGdelete_user_groups > 0) + { + echo "

SUPRIMA A ESTE GRUPO DE USUARIO\n"; + } + +} + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = $row[3]; + $active = $row[4]; +echo ""; + +echo "
MODIFIQUE Una ESCRITURA\n"; +echo "\n"; +echo "\n"; +echo "
Identificación De la Escritura:: $script_id$NWB#vicidial_scripts-script_name$NWE
Nombre de la escritura: (título de la escritura)$NWB#vicidial_scripts-script_name$NWE
Comentarios de la escritura: $NWB#vicidial_scripts-script_comments$NWE
Activo: $NWB#vicidial_scripts-active$NWE
Texto de la escritura:

Escritura De la Inspección previo
$NWB#vicidial_scripts-script_text$NWE
\n"; + +if ($LOGdelete_scripts > 0) + { + echo "

SUPRIMA ESTA ESCRITURA\n"; + } + +} + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = $row[3]; +echo ""; + +echo "
MODIFIQUE Un FILTRO\n"; +echo "\n"; +echo "\n"; +echo "
Identificación Del Filtro:$lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Nombre Del Filtro: (descripción corta del filtro)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Comentarios Del Filtro: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filtro Sql: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + +echo "

"; +echo "
PRUEBE EN CAMPAÑA:
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($LOGdelete_filters > 0) + { + echo "

SUPRIMA ESTE FILTRO\n"; + } + +} + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) +{ +if ($LOGmodify_call_times==1) +{ + +if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Regla Del Estado Agregada: $state_rule
\n"; + } +if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "Regla Del Estado Quitada: $state_rule
\n"; + } + +$ADD=311111111; +} +else +{ +echo "Le no autorizan a visión esta página. Vaya por favor detrás."; +} + +} + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +$ct_srs=1; +$b=0; +$srs_SQL =''; +if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } +echo "\n"; +echo "\n"; +while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } +if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } +else + {$srs_SQL='';} +$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; +$rslt=mysql_query($stmt, $link); +$sct_to_print = mysql_num_rows($rslt); +$sct_list=''; + +$o=0; +while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; +} +echo "\n"; +echo "\n"; + +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + +echo ""; + +echo "
MODIFIQUE Un RATO De la LLAMADA\n"; +echo "\n"; +echo "\n"; +echo "
Identificación Del Tiempo De la Llamada: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Nombre Del Tiempo De la Llamada: (descripción corta del tiempo de la llamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentarios Del Tiempo De la Llamada: $NWB#vicidial_call_times-call_time_comments$NWE
Comienzo Del Defecto: Parada Del Defecto: $NWB#vicidial_call_times-ct_default_start$NWE
Comienzo De Domingo: Parada De Domingo: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Lunes: Parada De Lunes: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Martes: Parada De Martes: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Miércoles: Parada De Miércoles: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Parada De Jueves: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Viernes: Parada De Viernes: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Sábado: Parada De Sábado: $NWB#vicidial_call_times-ct_sunday_start$NWE
Definiciones activas del tiempo de la llamada del estado para estoexpediente:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Add state call time rule:


\n"; +echo "CAMPAÑAS USANDO ESTE TIEMPO DE LA LLAMADA:
\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + $CT_camp_id = $row[1]; + $CT_camp_name = $row[2]; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

SUPRIMA ESTA DEFINICIÓN DEL TIEMPO DE LA LLAMADA\n"; + } +} +else +{ +echo "Le no autorizan a visión esta página. Vaya por favor detrás."; +} + +} + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + +echo ""; + +echo "
_ MODIFICAR Uno ESTADO LLAMAR TIEMPO
\n"; +echo "\n"; +echo "\n"; +echo "
Identificación Del Tiempo De la Llamada: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
_ Estado Llamar Tiempo Nombre: (descripción corta del tiempo de la llamada)$NWB#vicidial_call_times-call_time_name$NWE
Comentarios Del Tiempo De la Llamada Del Estado: $NWB#vicidial_call_times-call_time_comments$NWE
Comienzo Del Defecto: Parada Del Defecto: $NWB#vicidial_call_times-ct_default_start$NWE
Comienzo De Domingo: Parada De Domingo: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Lunes: Parada De Lunes: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Martes: Parada De Martes: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Miércoles: Parada De Miércoles: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Parada De Jueves: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Viernes: Parada De Viernes: $NWB#vicidial_call_times-ct_sunday_start$NWE
Comienzo De Sábado: Parada De Sábado: $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; +echo "TIEMPOS DE LA LLAMADA USANDO ESTE TIEMPO DE LA LLAMADA DEL ESTADO:
\n"; +echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

SUPRIMA ESTA DEFINICIÓN DEL TIEMPO DE LA LLAMADA DEL ESTADO\n"; + } + +} +else +{ +echo "Le no autorizan a visión esta página. Vaya por favor detrás."; +} + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo "
\n"; +echo ""; + +echo "
BUSCAR UN USUARIO\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
NÚmero De Usuario:
Nombre Completo:
Nivel Del Usuario:
Grupo Del Usuario:
\n"; + +} + +###################### +# ADD=66 user search results +###################### + +if ($ADD==66) +{ +echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
RESULTADOS DE LA BÚSQUEDA:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFICAR | ESTADÍSTICAS | ESTADO | TIME
\n"; + +} + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and user='$user' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
USER CALLBACK HOLD LISTINGS: $user\n"; +$ADD='82'; +} + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and campaign_id='$campaign_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN CALLBACK HOLD LISTINGS: $campaign_id\n"; +$ADD='82'; +} + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and list_id='$list_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; +$ADD='82'; +} + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) +{ +echo "
\n"; +echo "
\n"; +echo "\n"; + + $o=0; + while ($cb_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
LEADLISTCAMPAIGNENTRY FECHACALLBACK FECHAUSERRECIPIENTESTADO
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USUARIOS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFICAR | ESTADÍSTICAS | ESTADO | TIME
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
CAMPAÑAS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  MODIFICAR
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
LISTAS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  MODIFICAR
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
GRUPOS DE ENTRADA :\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  MODIFICAR
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
AGENTES REMOTOS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]MODIFICAR
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ +echo "\n"; +- } +- else +- { +- $leads_in_list_Y = ($leads_in_list_Y + $rowx[2]); +- echo "\n"; +- +- } +- +- $o++; ++ echo "\n"; ++ $o++; + } + +-echo "\n"; +-echo "\n"; ++echo "\n"; ++echo "\n"; + + echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
GRUPOS DE USUARIO :\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFICAR
\n"; +} + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) +{ +echo "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
ESCRITURAS DE LA VISIÓN:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFICAR
\n"; +} + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LISTADOS DEL FILTRO DEL PLOMO:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFICAR
\n"; +} + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LISTADOS DEL TIEMPO DE LA LLAMADA:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[4] MODIFICAR
\n"; +} + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LISTADOS DEL TIEMPO DE LA LLAMADA DEL ESTADO:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3] $row[4] MODIFICAR
\n"; +} + + + + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds"; +echo "             VERSIÓN: $version"; +echo "             CONSTRUCCION: $build
\n"; + + +?> + + +
+ + + +1) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday tiempo local + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday tiempo local + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday tiempo local + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday tiempo local + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday tiempo local + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday tiempo local + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday tiempo local + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday tiempo local + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday tiempo local + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday tiempo local + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday tiempo local + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday tiempo local + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday tiempo local + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday tiempo local + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "Esta campaña tiene $active_leads Leads para ser llamados en estas listas\n"; + } + else + { + echo "ningunas listas activas seleccionadas para esta campaña\n"; + } + } +else + { + echo "ningunas listas activas seleccionadas para esta campaña\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/admin_changes_log.txt b/agc_2-X/trunk/LANG_admin/vicidial_es/admin_changes_log.txt new file mode 100644 index 00000000..9664215b --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/admin_changes_log.txt @@ -0,0 +1,5 @@ +Mon, 26 Sep 2005 12:20:13 -0400|MODIFY CAMPAIGN INFO|444|10.10.10.19|campaign_name='Test campaign for VICIDIAL 2',active='Y',dial_status_a='NEW',dial_status_b='N',dial_status_c='DROP',dial_status_d='A',dial_status_e='B',lead_order='DOWN',allow_closers='Y',hopper_level='100', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='24hours', voicemail_ext='138', dial_timeout='28', dial_prefix='9', campaign_cid='0000000000', campaign_vdad_exten='8365' where campaign_id='TESTCAMP'|N| +Mon, 26 Sep 2005 17:31:20 -0400|MODIFY USER INFO |444|10.10.10.19|pass='sales',full_name='1 - TESTCAMP remote agent',user_level='4',user_group='ADMIN' where user='123456'| +Fri, 28 Apr 2006 11:34:07 -0400|MODIFY CAMPAIGN INFO|123456|10.10.8.19|campaign_name='Test campaign for VICIDIAL 2',active='Y',dial_status_a='NA',dial_status_b='NP',dial_status_c='DROP',dial_status_d='N',dial_status_e='A',lead_order='DOWN COUNT',allow_closers='Y',hopper_level='50', auto_dial_level='1', next_agent_call='oldest_call_finish', local_call_time='24hours', voicemail_ext='138', dial_timeout='50', dial_prefix='9', campaign_cid='8775154102', campaign_vdad_exten='8365', web_form_address='http://10.10.10.196/vicidial/closer-fronter_popupX2-1.php', park_ext='8305', park_file_name='classical', campaign_rec_exten='8309', campaign_recording='ONDEMAND', campaign_rec_filename='TINYDATE_AGENT_CUSTPHONE', campaign_script='TESTCAMP04', get_call_launch='NONE', am_message_exten='8320', amd_send_to_vmx='N', xferconf_a_dtmf='1234',xferconf_a_number='7274514920', xferconf_b_dtmf='4321',xferconf_b_number='7274514032',lead_filter_id='NEWHIGH',alt_number_dialing='N',scheduled_callbacks='Y' where campaign_id='TESTCAMP'|N| +Fri, 28 Apr 2006 11:34:38 -0400|RESET LIST CALLED |123456|10.10.8.19|list_name='test domestic lists'| +Fri, 28 Apr 2006 11:34:38 -0400|MODIFY LIST INFO |123456|10.10.8.19|list_name='test domestic lists',campaign_id='TESTCAMP',active='Y' where list_id='101'| diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/admin_modify_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_es/admin_modify_lead.php new file mode 100644 index 00000000..7cb31f31 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/admin_modify_lead.php @@ -0,0 +1,476 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + +### AST GUI database administration modify lead in vicidial_list +### admin_modify_lead.php + +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead + +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Registro del Lead modificado + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Información modificada

\n"; + echo "\n"; + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + +} +else +{ + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Información de la llamada: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     ID De la Lista: $list_id
Nombre:   \n"; + echo " Apellidos:
Dirección 1 :
Dirección 2 :
Dirección 3 :
Ciudad :
Estado:   \n"; + echo " Código Postal:
Provincia:
País :
Alt Phone :
Email :
Seguridad:
Comentarios :
Disposición:
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + + + + + } + else + { + echo "las operaciones de búsqueda del plomo FALLARON para el lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + +echo "

\n"; + +echo "
\n"; + +echo "LLAMADAS A ESTE LEAD:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS TSR CAMPAÑA LIST LEAD
$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]
\n"; + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/admin_search_lead.php b/agc_2-X/trunk/LANG_admin/vicidial_es/admin_search_lead.php new file mode 100644 index 00000000..9867543d --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/admin_search_lead.php @@ -0,0 +1,224 @@ + LICENSE: GPLv2 +### +### AST GUI database administration search for lead info +### admin_modify_lead.php +# +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Buscar Lead + +Operaciones de búsqueda del Lead + + + +
\n"; + echo "
\n"; + echo "\n"; + echo "Por favor, Introduzca un:
Vendor ID(código del vendedor del Lead): or \n"; + echo "
un número de teléfono de casa: or\n"; + echo "
ID del Lead:

\n"; + echo "
\n"; + echo "\n
\n"; + echo "\n"; + exit; + } + +else + { + + if ($vendor_id) + { + $stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000"; + } + else + { + if ($phone) + { + $stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000"; + } + else + { + if ($lead_id) + { + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query($stmt, $link); + $results_to_print = mysql_num_rows($rslt); + if ($results_to_print < 1) + { + echo date("l F j, Y G:i:s A"); + echo "\n

\n"; + echo "Las variables de la búsqueda que usted incorporó no son activas en el sistema

\n"; + echo "Va por favor detrás y dobla el cheque la información que usted incorporó y somete otra vez\n"; + echo "
\n"; + echo "\n"; + exit; + } + else + { + echo "RESULTS: $results_to_print

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD IDESTADOVENDOR IDLAST AGENTID DE LA LISTAPHONENOMBRECITYSECURITYLAST CALL
$o$row[0]$row[3]$row[5]$row[4]$row[7]$row[11]$row[13] $row[15]$row[19]$row[28]$row[2]
\n"; + } + } + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\nNUEVA BÚSQUEDA"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds"; + + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/count.htm b/agc_2-X/trunk/LANG_admin/vicidial_es/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/count.htm @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/dbconnect.php b/agc_2-X/trunk/LANG_admin/vicidial_es/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/group_hourly_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_es/group_hourly_stats.php new file mode 100644 index 00000000..9323fcef --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/group_hourly_stats.php @@ -0,0 +1,252 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: Stats Cada hora Del Grupo +\n"; +?> + + +
+ + + + + += '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "
  VICIDIAL ADMIN: Stats Cada hora Del Grupo  
\n"; + +echo "
\n"; + +echo "CUENTAS DE HORAS DE TSR: $group | $status | $date_with_hour | $date_no_hour\n"; + +echo "
\n"; +echo "\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "\n"; + + +} + +echo "
TSR ID   $status   LLAMADAS TOTALES   $status DAY    
$VDuser[$o] $VDname[$o] $VDcount[$o] $VDtotal[$o] $VDday[$o]MODIFICAR | ESTADÍSTICAS
TOTAL $status $hour_calls $total_calls $day_calls
\n"; +echo "

\n"; + + + echo "
Inscriba por favor a grupo que usted desea conseguir el stats cada hora para:
\n"; + echo "\n"; + echo "group:
\n"; + echo "status:   (example: XFER)
\n"; + echo "date with hour:   (example: 2004-06-25 14)
\n"; + echo "\n"; + echo "


\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/help.gif b/agc_2-X/trunk/LANG_admin/vicidial_es/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/LANG_admin/vicidial_es/help.gif differ diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/listloader.php b/agc_2-X/trunk/LANG_admin/vicidial_es/listloader.php new file mode 100644 index 00000000..b4a89d27 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/listloader.php @@ -0,0 +1,698 @@ + LICENSE: GPLv2 +# +# AST Web GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1006 - added listID override and gmt_offset lookup while loading +# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. +# + +$version = '1.1.12'; +$build = '60619-1652'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];} +$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$ENVIAR=$_GET["ENVIAR"]; if (!$ENVIAR) {$ENVIAR=$_POST["ENVIAR"];} + + +#$DB=1; +#$DBX=1; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('listloader.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"AYUDA\""; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +?> + + + + + + method=post enctype="multipart/form-data"> +
+ + + + + + + + + + + + + +
Cargar Leads de este archivo:
ID De la Lista Override: (Solamente números or leave blank for values in the file)
CHASQUE AQUÍ PARA IR AL CARGADOR ESTUPENDO DEL PLOMO (BETA VERSIÓN)     DE NUEVO AL ADMIN
+ +document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + $pulldate=date("Y-m-d H:i:s"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("./vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Procesando$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city = $row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) + { + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $gmt_offset = '0'; + $called_since_last_reset='N'; + + if (strlen($list_id_override)>0) + { + # print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # tiempo local calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: El archivo no tiene el número requerido de los campos para procesarlo.
"; + } + print ""; +} else if (filesize($leadfile)>8388608) { + print "
ERROR: El archivo excede el límite 8MB.
"; +} +?> + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/listloaderMAIN.php b/agc_2-X/trunk/LANG_admin/vicidial_es/listloaderMAIN.php new file mode 100644 index 00000000..fa31b764 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/listloaderMAIN.php @@ -0,0 +1,79 @@ + LICENSE: GPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + +VICIDIAL: Módulo Cargador de Leads + + + + + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/new_listloader_superL.php b/agc_2-X/trunk/LANG_admin/vicidial_es/new_listloader_superL.php new file mode 100644 index 00000000..dcc2935a --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/new_listloader_superL.php @@ -0,0 +1,1364 @@ + LICENSE: GPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '1.1.12-1'; +$build = '60619-1651'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"AYUDA\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +VICIDIAL ADMIN: Super Lead Loader + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + + + + + + + + + + + + + + + + + + + +
Cargar Leads de este archivo:
ID De la Lista Override: (Solamente números or leave blank for values in the file)
Disposición de archivo a utilizar:VICIDIAL Estándar    Disposición de encargo
        
CHASQUE AQUÍ PARA IR AL CARGADOR DEL PLOMO DEL BASIC         DE NUEVO AL ADMIN
CARGADOR ESTUPENDO DE LA LISTA-     VERSIÓN:     CONSTRUCCION:
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Procesando$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + + if (strlen($list_id_override)>0) + { + # print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: El archivo no tiene el número requerido de los campos para procesarlo.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + print "
ProcesandoExcel file... \n"; + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + # print "$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field"; + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
ProcesandoCSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile && filesize($LF_path)<=8388608) { + $total=0; $good=0; $bad=0; + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Procesando$delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: El archivo no tiene el número requerido de los campos para procesarlo.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
ProcesandoCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Procesando$delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
ProcesandoCSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

ID DE LA LISTA OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + $total=0; $good=0; $bad=0; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL ColumnaDatos del archivo
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
        
\r\n"; + # } + print ""; + } +} else if (filesize($leadfile)>8388608) { + print "
ERROR: El archivo excede el límite 8MB.
"; +} +?> + + + + + + + + + 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### MEXICO ### +if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### AUSTRALIA ### +if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### ALL OTHER COUNTRY CODES ### +if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # tiempo local calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # tiempo local calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/project_auth_entries.txt b/agc_2-X/trunk/LANG_admin/vicidial_es/project_auth_entries.txt new file mode 100644 index 00000000..6269ce8e --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/project_auth_entries.txt @@ -0,0 +1,170 @@ +VICIDIAL|GOOD|Thu, 22 Sep 2005 17:42:04 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Thu, 22 Sep 2005 17:42:10 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Thu, 22 Sep 2005 18:35:53 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 11:28:16 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 11:32:26 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 11:32:28 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 12:39:09 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 12:52:43 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 12:52:45 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 14:33:18 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 14:33:20 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 16:31:02 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 16:31:09 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 16:31:11 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 16:31:13 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 16:31:15 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Fri, 23 Sep 2005 16:31:16 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:05:06 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:05:10 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:05:12 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:05:16 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:06 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:10 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:15 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:19 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:22 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:32 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:34 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:38 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:41 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:47 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:06:55 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:07:22 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:07:23 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:07:26 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:07:36 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:20:02 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:20:13 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:20:21 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:20:24 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 12:20:26 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 13:04:03 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +LIST_LOAD|GOOD|Mon, 26 Sep 2005 13:04:19 -0400|lead|load|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|| +VICIDIAL|GOOD|Mon, 26 Sep 2005 13:14:49 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 13:14:53 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +LIST_LOAD|GOOD|Mon, 26 Sep 2005 13:15:08 -0400|lead|load|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|| +VICIDIAL|GOOD|Mon, 26 Sep 2005 13:56:12 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 13:56:15 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VD_CLOSER|GOOD|Mon, 26 Sep 2005 13:56:28 -0400|over|ride|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|| +VICIDIAL|GOOD|Mon, 26 Sep 2005 16:17:15 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:01 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:04 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:05 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:07 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:13 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:20 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:29 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:34 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:37 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:39 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:41 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:47 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Mon, 26 Sep 2005 17:31:53 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:44 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:46 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:48 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:50 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:53 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Wed, 28 Sep 2005 17:47:54 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:48:44 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:48:46 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:48:48 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:48:52 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 30 Sep 2005 15:59:10 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:09:19 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:09:36 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:09:36 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:09:53 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:11:06 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:13 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:40 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:41 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:41 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:42 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:42 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:44 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:46 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:47 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:47 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:50 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:52 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:54 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:54 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +LIST_LOAD|GOOD|Thu, 06 Oct 2005 10:12:55 -0400|lead|load|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:58 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:12:59 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:00 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:00 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:02 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:04 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:04 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:06 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:06 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:09 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:52 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:13:59 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:26:16 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:26:17 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 06 Oct 2005 10:26:19 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:09:58 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:10:01 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:10:05 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:10:07 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:10:12 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:10:39 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Fri, 07 Oct 2005 10:36:07 -0400|444|444|10.10.10.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 10 Nov 2005 15:02:07 -0500|444|444|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 10 Nov 2005 15:02:19 -0500|444|444|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 10 Nov 2005 15:02:23 -0500|444|444|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 10 Nov 2005 15:02:29 -0500|444|444|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 10 Nov 2005 15:02:34 -0500|444|444|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Thu, 10 Nov 2005 15:03:08 -0500|444|444|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|Manager| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:02:45 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Tue, 22 Nov 2005 15:29:13 -0500|6666|sales|10.10.6.1|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|test user| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:05:59 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:06:07 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:06:10 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:06:33 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:06:38 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 22 Dec 2005 17:09:05 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Fri, 23 Dec 2005 14:39:34 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051111 Firefox/1.5|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:10 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:13 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 19 Jan 2006 15:38:14 -0500|123456|bob5|10.10.6.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 03 Mar 2006 16:14:23 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 03 Mar 2006 16:14:38 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 03 Mar 2006 16:14:55 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 17 Mar 2006 14:22:24 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 17 Mar 2006 14:22:27 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 17 Mar 2006 14:22:29 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 17 Mar 2006 14:59:52 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 17 Mar 2006 14:59:53 -0500|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:03:08 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:34:00 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 17:34:03 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 18:00:32 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:09:43 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:12:38 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:13:31 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:13:43 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:13:50 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:13:53 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:13:55 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:13:57 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:14:01 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:08 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 22:18:12 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Thu, 27 Apr 2006 23:40:33 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:33:41 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:33:43 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:33:47 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:33:49 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:07 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:20 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:24 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:26 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:38 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:46 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:34:50 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| +VICIDIAL|GOOD|Fri, 28 Apr 2006 11:35:52 -0400|123456|bob5|10.10.8.19|Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7|1 - MATT admin| diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/remote_dispo.php b/agc_2-X/trunk/LANG_admin/vicidial_es/remote_dispo.php new file mode 100644 index 00000000..79c582c2 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/remote_dispo.php @@ -0,0 +1,327 @@ + LICENSE: GPLv2 +### +# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call + +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +REMOTE VICIDIAL: Disposición De la Llamada +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "La llamada ha sido dispositioned       $NOW_TIME\n

\n"; + + echo "
\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Información de la llamada: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     ID De la Campaña: $campaign_id
Fronter: $tsr     ID De la Lista: $list_id
Nombre:   \n"; + echo " Apellidos:
Dirección 1 :
Dirección 2 :
Dirección 3 :
Ciudad :
Estado:   \n"; + echo " Código Postal:
Provincia:
País :
Alt Phone :
Email :
Seguridad:
Comentarios :
Disposición:
\n"; + echo "


\n"; + + } + else + { + echo "las operaciones de búsqueda del plomo FALLARON para el lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/server_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_es/server_stats.php new file mode 100644 index 00000000..6192c6d5 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/server_stats.php @@ -0,0 +1,96 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1037 - Added Link back to Admin section +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select * from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $i++; + } +?> + + + + + +VICIDIAL: ESTADÍSTICAS DEL SERVIDOR and Reports +VICIDIAL: ESTADÍSTICAS DEL SERVIDOR and Reports                           +DE NUEVO AL ADMIN

+ + +

+
+ $o)
+	{
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	$o++;
+	}
+
+?>
+
SERVERDESCRIPCIÓNIP ADDRESSACTIVOVDAD timeVDcall timePARK timeCLOSER/INBOUND time
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]LINKLINKLINKLINK
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/user_stats.php b/agc_2-X/trunk/LANG_admin/vicidial_es/user_stats.php new file mode 100644 index 00000000..04d67509 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/user_stats.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: User Stats +\n"; +?> + + +
+ + + + + +\n"; +echo "
  VICIDIAL ADMIN: User Stats for  
  \n"; + +echo "
\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + +echo "
\n"; + +echo "TIEMPO Y ESTADO DE CONVERSACIÓN:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + +echo "\n"; +echo "
ESTADOCUENTAHORAS:MINUTOS
$row[1] $row[0] $call_hours_int:$call_minutes_int
LLAMADAS TOTALES $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "TIEMPO LOGIN/LOGOUT:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours = ($event_seconds / 3600); + $event_hours = round($event_hours, 2); + $event_hours_int = intval("$event_hours"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours = ($total_login_time / 3600); +$total_login_hours = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
EVENTO FECHA CAMPAÑAHORAS:MINUTOS
$row[0] $row[2] $row[3]
$row[0] $row[2] $row[3] $event_hours_int:$event_minutes_int
$row[0] $row[2] $row[3]
TOTAL $total_login_hours_int:$total_login_minutes_int
\n"; + + +echo "

\n"; + +echo "
\n"; + +echo "ÚLTIMAS 50 LLAMADAS:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS PHONE CAMPAÑA LIST LEAD
$row[4] $row[7] $row[8] $row[10] $row[3] $row[2] $row[1]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/user_status.php b/agc_2-X/trunk/LANG_admin/vicidial_es/user_status.php new file mode 100644 index 00000000..477db530 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/user_status.php @@ -0,0 +1,238 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $change_agent_campaign=$row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $i++; + } + + } + +$stmt="select * from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> + + +VICIDIAL ADMIN: User Status +\n"; +?> + + +
+
+ + + + +\n"; +echo "
  VICIDIAL ADMIN: User Status for  
  \n"; + +if ($stage == "live_campaign_change") +{ + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign
\n"; + + exit; +} + +if ($stage == "log_agent_out") +{ + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser
\n"; + + exit; +} + +if ($agents_to_print > 0) +{ + echo "
";
+	echo "Agent Logged in at server:  $Aserver_ip\n";
+	echo "               in session:  $Asession_id\n";
+	echo "               from phone:  $Aextension\n";
+	echo "Agent is in campaign:       $Acampaign\n";
+	echo "              status:       $Astatus\n";
+	echo " hungup last call at:       $Alast_call\n";
+	echo "       Closer groups:       $Acl_campaigns\n\n";
+
+	echo "
"; + + + if ($change_agent_campaign > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Current Campaña: \n"; + echo "
\n"; + + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } +} + +else +{ + echo "Agent is not logged in\n
"; + +} + + +echo "           $user - $full_name - \n"; + +echo "VICIDIAL Time Sheet\n"; + +echo "
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + +echo "|$stage|$group|"; + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_admin/vicidial_es/vdremote.php b/agc_2-X/trunk/LANG_admin/vicidial_es/vdremote.php new file mode 100644 index 00000000..b0eef2f5 --- /dev/null +++ b/agc_2-X/trunk/LANG_admin/vicidial_es/vdremote.php @@ -0,0 +1,602 @@ + LICENSE: GPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time + +$version = '1.1.12'; +$build = '60619-1603'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["ENVIAR"])) {$ENVIAR=$_GET["ENVIAR"];} + elseif (isset($_POST["ENVIAR"])) {$ENVIAR=$_POST["ENVIAR"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Usted ahora ha salido. Gracias\n"; + exit; +} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Nombre y contraseña inválidos del usuario: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +VICIDIAL, AGENTES REMOTOS: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Modificar Agentes Remotos";} +if ($ADD==41111) {echo "Modificar Agentes Remotos";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+
+ + + +
  VICIDIAL, AGENTES REMOTOS:   Salir  
  MODIFICAR | ">ESTADO | ">ESTADÍSTICAS DE ENTRADA
+"; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFICAR UNA ENTRADA DE LOS AGENTES REMOTOS: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Comienzo Del ID del usuario: $user_start
Número de líneas: (Solamente números)
IP Del Servidor: $row[3]
Extensión Externa: (number dialed to reach agents [i.e. 913125551212])
Estado:
Campaña: $campaign_id
Grupos De entrada: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTA: Puede tomar hasta 30 segundos para los cambios sometidos en esta pantalla para ir viva\n"; + +} + + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
AGENTES ALEJADOS NO MODIFICADOS - vaya por favor detrás y mire los datos que usted incorporó\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
LOS AGENTES ALEJADOS SE MODIFICARON\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY AGENTES REMOTOS ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + + } + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFICAR UNA ENTRADA DE LOS AGENTES REMOTOS: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Comienzo Del ID del usuario: $user_start
Número de líneas: (Solamente números)
IP Del Servidor: $row[3]
Extensión Externa: (number dialed to reach agents [i.e. 913125551212])
Estado:
Campaña: $campaign_id
Grupos De entrada: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTA: Puede tomar hasta 30 segundos para los cambios sometidos en esta pantalla para ir viva\n"; + +} + + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) +{ + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
ERROR AGENTES REMOTOS – Por favor, vuelva atrás y compruebe los datos que introdujo\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]='- ESPERANDO -'; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i agentes identificados en el servidor $server_ip\n\n"; + + echo " - Llamadas de 5 minutos o más\n"; + echo " - Sobre 10 minutos en llamada\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************AGENTES SIN LLAMADAS*********************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) +{ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
ERROR AGENTES REMOTOS – Por favor, vuelva atrás y compruebe los datos que introdujo\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "VICIDIAL: Stats de entrada del agente alejado $NOW_TIME\n\n"; + echo "\n"; + echo "Llamadas totales tomadas $query_date: $in_calls\n"; + echo "Tiempo total de conversación$query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Lista la llamada para $query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + # echo " $i agentes identificados en el servidor $server_ip\n\n"; + + # echo " - Llamadas de 5 minutos o más\n"; + # echo " - Sobre 10 minutos en llamada\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "*********************************NINGUNA LLAMADA PARA HOY*******************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nScript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc.zip b/agc_2-X/trunk/LANG_agc.zip new file mode 100644 index 00000000..1dd19581 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc.zip differ diff --git a/agc_2-X/trunk/LANG_agc/agc/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc/active_list_refresh.php new file mode 100644 index 00000000..dd977642 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "List Display: "; +if ($ADD==1) {echo "Live Extensions";} +if ($ADD==2) {echo "Busy Extensions";} +if ($ADD==3) {echo "Outside Lines";} +if ($ADD==4) {echo "Local Extensions";} +if ($ADD==5) {echo "Conferences";} +if ($ADD==99999) {echo "HELP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc/astguiclient.php new file mode 100644 index 00000000..6d39bae8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "astGUIclient web client: Login\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
User Login:
User Password:
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "astGUIclient web client: Phone Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone Login
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "astGUIclient web client: Phone Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Phone Login
 
Sorry, your phone login and password are not active in this system, please try again:
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "astGUIclient web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +LOGOUT
\n"; ?> +
Main PanelActive Lines PanelConferences PanelCheck VoicemailLive Call
+
+ + +

Logout
+
+ + +
TRUNK HANGUP

+ Active Trunks Menu
+ Hangup Trunk   |   + Hijack Trunk   |   + Listen Trunk   |   + Refresh   |   + Back to Main Window +
+
+ + +
LOCAL HANGUP

+ Active Local Menu
+ Hangup Local   |   + Hijack Local   |   + Listen Local   |   + Refresh   |   + Back to Main Window +
+
+ + + + + + + +
LIVE CALL TRANSFER
Channel to be transferred: Channel
Extensions:
Extensions Menu
+
+ Send to selected extension

+ Send to selected vmail box

+ Send to this number:


+ Refresh


+ Back to Main Window

+
Conferences:
(click on a number below to send to a conference)
Send my channel too
Conferences Menu
+
+ + + + + +
LOCAL Extensions Dial
Phone calling from: Channel
Extensions:
Extensions Menu
+
+ Call selected extension

+ Call selected vmail box

+ Refresh


+ Back to Main Window

+
+
+ + +
PARKED CALLS:
+ Back to Main Window

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NEW:     OLD:             MANUAL DIAL       DIAL
PARKED CALLS: 0                LOCAL DIAL EXTENSIONS
OUTBOUND CALLS:
INBOUND CALLS:
astGUIclient web-client VERSION: BUILD:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITES       edit
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITES

 
SUBMIT FAVORITES CHANGES - requires logout
BACK TO MAIN WINDOW - ignore changes made
+
+ +
+ + + + + + + + + + + + + +
+PAUSE | START     Refresh rate: 1000 ms Faster | Slower

+
Initializing..
+
Active Extensions
+REFRESH | +ORDER | +
Outside Lines
+REFRESH | +ORDER | +
Local Extensions
+REFRESH | +ORDER | +
+ Data Goes Here

+
+ Data Goes Here

Trunk Action +
+ Data Goes Here

Local Action +
+
+ + + + +
+ + +Conferences List + + + +
+Click on a conference room number on the left for info on that conference +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc/calendar.php b/agc_2-X/trunk/LANG_agc/agc/calendar.php new file mode 100644 index 00000000..e4068019 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/calendar.php @@ -0,0 +1,125 @@ +"; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; + +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +echo "$CCAL_OUT\n"; + diff --git a/agc_2-X/trunk/LANG_agc/agc/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc/call_log_display.php new file mode 100644 index 00000000..4abec74d --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Call Log Display"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc/conf_exten_check.php new file mode 100644 index 00000000..1f93e8ec --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Conf Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten is not valid\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Status: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$ChannelA[$counter] ~"; + # echo "$ChannelA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten is not valid or Exten $exten is not valid\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conference $conf_exten has been registered to $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc/fix-dispo-list.patch b/agc_2-X/trunk/LANG_agc/agc/fix-dispo-list.patch new file mode 100644 index 00000000..f3cca9ef --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/fix-dispo-list.patch @@ -0,0 +1,73 @@ +--- /usr/src/astguiclient_snapshot_2006-04-10/VICIDIAL_web/admin.php 2006-02-27 15:58:50.000000000 -0800 ++++ /var/www/html/vicidial/admin.php 2006-04-10 23:12:19.000000000 -0700 +@@ -3320,15 +3320,38 @@ + $o=0; + while ($statuses_to_print > $o) + { +- $rowx=mysql_fetch_row($rsltx); +- $leads_in_list = ($leads_in_list + $rowx[2]); ++ $rowx=mysql_fetch_row($rsltx); ++ ++ $lead_list['count'] = ($lead_list['count'] + $rowx[2]); ++ if ($rowx[1] == 'N') ++ { ++ $since_reset = 'N'; ++ $since_resetX = 'Y'; ++ } ++ else ++ { ++ $since_reset = 'Y'; ++ $since_resetX = 'N'; ++ } ++ $lead_list[$since_reset][$rowx[0]] = $rowx[2]; ++ $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); ++ #If opposite side is not set, it may not in the future so give it a value of zero ++ if (!isset($lead_list[$since_resetX][$rowx[0]])) ++ { ++ $lead_list[$since_resetX][$rowx[0]]=0; ++ } ++ $o++; ++ } + ++ $o=0; ++ while (list($dispo,) = each($lead_list[$since_reset])) ++ { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + +- if ($rowx[0] == 'CBHOLD') ++ if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; +@@ -3338,24 +3361,12 @@ + $CLB=''; + $CLE=''; + } +- +- if ($rowx[1] == 'N') +- { +- $leads_in_list_N = ($leads_in_list_N + $rowx[2]); +- echo "
$CLB$rowx[0]$CLE $rowx[2]
$CLB$rowx[0]$CLE$rowx[2]
$CLB$dispo$CLE".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
SUBTOTALS$leads_in_list_Y$leads_in_list_N
TOTAL$leads_in_list
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; + diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK.gif new file mode 100644 index 00000000..30703a78 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_e.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_e.gif new file mode 100644 index 00000000..600cef89 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_e.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_es.gif new file mode 100644 index 00000000..600cef89 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_ptbr.gif new file mode 100644 index 00000000..3670af28 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_BLINK_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF.gif new file mode 100644 index 00000000..5b7e4c75 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF_es.gif new file mode 100644 index 00000000..ec9c1d55 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF_ptbr.gif new file mode 100644 index 00000000..3b1c4644 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON.gif new file mode 100644 index 00000000..ad55916d Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON_es.gif new file mode 100644 index 00000000..442a8084 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON_ptbr.gif new file mode 100644 index 00000000..ae53a393 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_check_voicemail_ON_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF.gif new file mode 100644 index 00000000..3752fb5e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF_es.gif new file mode 100644 index 00000000..1ff376d8 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF_ptbr.gif new file mode 100644 index 00000000..86a71723 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON.gif new file mode 100644 index 00000000..ed8ba2dd Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON_es.gif new file mode 100644 index 00000000..041d398f Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON_ptbr.gif new file mode 100644 index 00000000..c0601666 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_live_call_ON_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines.gif new file mode 100644 index 00000000..9f8eaf67 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines_es.gif new file mode 100644 index 00000000..bdefd015 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines_ptbr.gif new file mode 100644 index 00000000..1465ea6e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_active_lines_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_astguiclient.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_astguiclient.gif new file mode 100644 index 00000000..30373576 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_astguiclient.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_astguiclient_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_astguiclient_ptbr.gif new file mode 100644 index 00000000..30373576 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_astguiclient_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences.gif new file mode 100644 index 00000000..e3c80662 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences_es.gif new file mode 100644 index 00000000..14ab7171 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences_ptbr.gif new file mode 100644 index 00000000..14ab7171 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_conferences_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main.gif new file mode 100644 index 00000000..6e687e44 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main_es.gif new file mode 100644 index 00000000..b5fc2a5e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main_ptbr.gif new file mode 100644 index 00000000..b5fc2a5e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/agc_tab_main_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/blank.gif b/agc_2-X/trunk/LANG_agc/agc/images/blank.gif new file mode 100644 index 00000000..3a469695 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/blank.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/br.gif b/agc_2-X/trunk/LANG_agc/agc/images/br.gif new file mode 100644 index 00000000..423b8a0c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/br.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/de.gif b/agc_2-X/trunk/LANG_agc/agc/images/de.gif new file mode 100644 index 00000000..4dd34f6a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/de.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/down.gif b/agc_2-X/trunk/LANG_agc/agc/images/down.gif new file mode 100644 index 00000000..32d0a007 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/down.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/el.gif b/agc_2-X/trunk/LANG_agc/agc/images/el.gif new file mode 100644 index 00000000..9e79d8bf Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/el.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/en.gif b/agc_2-X/trunk/LANG_agc/agc/images/en.gif new file mode 100644 index 00000000..cb45f5f4 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/en.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/es.gif b/agc_2-X/trunk/LANG_agc/agc/images/es.gif new file mode 100644 index 00000000..308ea3cb Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/fr.gif b/agc_2-X/trunk/LANG_agc/agc/images/fr.gif new file mode 100644 index 00000000..21fb3d19 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/fr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/it.gif b/agc_2-X/trunk/LANG_agc/agc/images/it.gif new file mode 100644 index 00000000..6c7b1792 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/it.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/pt.gif b/agc_2-X/trunk/LANG_agc/agc/images/pt.gif new file mode 100644 index 00000000..646b76ac Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/pt.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/remove.gif b/agc_2-X/trunk/LANG_agc/agc/images/remove.gif new file mode 100644 index 00000000..89b0521c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/remove.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/up.gif b/agc_2-X/trunk/LANG_agc/agc/images/up.gif new file mode 100644 index 00000000..0d55544f Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/up.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber.gif new file mode 100644 index 00000000..a5a080d6 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF.gif new file mode 100644 index 00000000..75bc0e8f Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF_es.gif new file mode 100644 index 00000000..405ff336 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF_ptbr.gif new file mode 100644 index 00000000..0d297820 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_es.gif new file mode 100644 index 00000000..ca92716e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_ptbr.gif new file mode 100644 index 00000000..8625b1c9 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_dialnextnumber_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall.gif new file mode 100644 index 00000000..a6779255 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF.gif new file mode 100644 index 00000000..74b1f5a1 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF_es.gif new file mode 100644 index 00000000..21991dd5 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF_ptbr.gif new file mode 100644 index 00000000..19932ad2 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_es.gif new file mode 100644 index 00000000..9acc363a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_ptbr.gif new file mode 100644 index 00000000..e37d0fb4 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_grabparkedcall_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer.gif new file mode 100644 index 00000000..b4fdfae8 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF.gif new file mode 100644 index 00000000..e5736ae0 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF_es.gif new file mode 100644 index 00000000..570a6e5a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF_ptbr.gif new file mode 100644 index 00000000..57918268 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_es.gif new file mode 100644 index 00000000..94d3e225 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_ptbr.gif new file mode 100644 index 00000000..5841050c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_hangupcustomer_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall.gif new file mode 100644 index 00000000..88fee283 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF.gif new file mode 100644 index 00000000..8ad55010 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF_es.gif new file mode 100644 index 00000000..110ce6b0 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF_ptbr.gif new file mode 100644 index 00000000..25a6a2f2 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_es.gif new file mode 100644 index 00000000..2274a27c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_ptbr.gif new file mode 100644 index 00000000..b37d8358 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_parkcall_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause.gif new file mode 100644 index 00000000..3486a1c1 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF.gif new file mode 100644 index 00000000..fce03041 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF_es.gif new file mode 100644 index 00000000..494d68a5 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF_ptbr.gif new file mode 100644 index 00000000..3d8c8759 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_es.gif new file mode 100644 index 00000000..544a3797 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_ptbr.gif new file mode 100644 index 00000000..bea56d65 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_pause_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume.gif new file mode 100644 index 00000000..a7d75dd8 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF.gif new file mode 100644 index 00000000..0ae4cb9a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF_es.gif new file mode 100644 index 00000000..921d5d5e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF_ptbr.gif new file mode 100644 index 00000000..43bb9235 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_es.gif new file mode 100644 index 00000000..1b096144 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_ptbr.gif new file mode 100644 index 00000000..415b22d1 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_resume_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf.gif new file mode 100644 index 00000000..d19888ad Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF.gif new file mode 100644 index 00000000..08a4b392 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF_es.gif new file mode 100644 index 00000000..2d32c5e9 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF_ptbr.gif new file mode 100644 index 00000000..2d32c5e9 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_es.gif new file mode 100644 index 00000000..43964df4 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_ptbr.gif new file mode 100644 index 00000000..43964df4 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_senddtmf_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_spacer.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_spacer.gif new file mode 100644 index 00000000..d0a4f6ed Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_spacer.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording.gif new file mode 100644 index 00000000..022103d2 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF.gif new file mode 100644 index 00000000..3ee4ca62 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF_es.gif new file mode 100644 index 00000000..ff9a3447 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF_ptbr.gif new file mode 100644 index 00000000..22105778 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_es.gif new file mode 100644 index 00000000..26420f78 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_ptbr.gif new file mode 100644 index 00000000..15b25990 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_startrecording_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording.gif new file mode 100644 index 00000000..6f3bfede Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF.gif new file mode 100644 index 00000000..2e1efe4a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF_es.gif new file mode 100644 index 00000000..2806311f Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF_ptbr.gif new file mode 100644 index 00000000..c0259410 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_es.gif new file mode 100644 index 00000000..94f9de9d Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_ptbr.gif new file mode 100644 index 00000000..8a76e860 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_stoprecording_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf.gif new file mode 100644 index 00000000..c5738519 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF.gif new file mode 100644 index 00000000..dd0a579a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF_es.gif new file mode 100644 index 00000000..d0a54bf6 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF_ptbr.gif new file mode 100644 index 00000000..ebb69344 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_es.gif new file mode 100644 index 00000000..10cfa495 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_ptbr.gif new file mode 100644 index 00000000..f008e92c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_transferconf_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform.gif new file mode 100644 index 00000000..4d5228f3 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF.gif new file mode 100644 index 00000000..64316ced Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF_es.gif new file mode 100644 index 00000000..75a56196 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF_ptbr.gif new file mode 100644 index 00000000..75a56196 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_es.gif new file mode 100644 index 00000000..d7590d66 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_ptbr.gif new file mode 100644 index 00000000..d7590d66 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_LB_webform_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_ammessage.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_ammessage.gif new file mode 100644 index 00000000..484d01eb Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_ammessage.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_ammessage_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_ammessage_OFF.gif new file mode 100644 index 00000000..3aa94800 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_ammessage_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer.gif new file mode 100644 index 00000000..77c03e0b Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF.gif new file mode 100644 index 00000000..7fb481ee Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF_es.gif new file mode 100644 index 00000000..05adaac5 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF_ptbr.gif new file mode 100644 index 00000000..3a069c2b Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_es.gif new file mode 100644 index 00000000..fdad633a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_ptbr.gif new file mode 100644 index 00000000..c31c87fc Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_blindtransfer_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel.gif new file mode 100644 index 00000000..9a9ce7ba Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel_es.gif new file mode 100644 index 00000000..a4fbf1f5 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel_ptbr.gif new file mode 100644 index 00000000..a4fbf1f5 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_channel_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_code.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_code.gif new file mode 100644 index 00000000..8fb2b8c5 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_code.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer.gif new file mode 100644 index 00000000..68697edc Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF.gif new file mode 100644 index 00000000..8bf2e44b Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF_es.gif new file mode 100644 index 00000000..7ef98a94 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF_ptbr.gif new file mode 100644 index 00000000..1ac7dbbb Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_es.gif new file mode 100644 index 00000000..d71bca15 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_ptbr.gif new file mode 100644 index 00000000..90ec03f8 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_dialwithcustomer_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines.gif new file mode 100644 index 00000000..4e6db07e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF.gif new file mode 100644 index 00000000..f1ffdc12 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF_es.gif new file mode 100644 index 00000000..8f12accd Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF_ptbr.gif new file mode 100644 index 00000000..47b87225 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_es.gif new file mode 100644 index 00000000..646c8769 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_ptbr.gif new file mode 100644 index 00000000..fa0cf2fb Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupbothlines_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline.gif new file mode 100644 index 00000000..d25a105a Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF.gif new file mode 100644 index 00000000..a8fb4a3d Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF_es.gif new file mode 100644 index 00000000..3c717d09 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF_ptbr.gif new file mode 100644 index 00000000..f6d9080b Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_es.gif new file mode 100644 index 00000000..0d92a89c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_ptbr.gif new file mode 100644 index 00000000..c7d26417 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hangupxferline_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header.gif new file mode 100644 index 00000000..c813b9a3 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header_es.gif new file mode 100644 index 00000000..a92c2df0 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header_ptbr.gif new file mode 100644 index 00000000..a92c2df0 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_header_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive.gif new file mode 100644 index 00000000..8382205e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF.gif new file mode 100644 index 00000000..3357ed2b Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_es-orig.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_es-orig.gif new file mode 100644 index 00000000..638ef859 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_es-orig.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_es.gif new file mode 100644 index 00000000..5c9a3122 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_ptbr.gif new file mode 100644 index 00000000..335e6356 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_es.gif new file mode 100644 index 00000000..b064725c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_ptbr.gif new file mode 100644 index 00000000..a34409c2 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysactive_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysinactive_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysinactive_es.gif new file mode 100644 index 00000000..d0bf982c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_hotkeysinactive_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser.gif new file mode 100644 index 00000000..a1adca76 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF.gif new file mode 100644 index 00000000..9d3489fa Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF_es.gif new file mode 100644 index 00000000..45bc4290 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF_ptbr.gif new file mode 100644 index 00000000..45bc4290 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_es.gif new file mode 100644 index 00000000..d5c05657 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_ptbr.gif new file mode 100644 index 00000000..d5c05657 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_internalcloser_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall.gif new file mode 100644 index 00000000..7bca06f9 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF.gif new file mode 100644 index 00000000..63594d65 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF_es.gif new file mode 100644 index 00000000..9c41a291 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF_ptbr.gif new file mode 100644 index 00000000..63594d65 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_es.gif new file mode 100644 index 00000000..9aa29708 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_ptbr.gif new file mode 100644 index 00000000..7bca06f9 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_leave3waycall_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser.gif new file mode 100644 index 00000000..0e10a2ad Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF.gif new file mode 100644 index 00000000..ed11b7ac Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF_es.gif new file mode 100644 index 00000000..fbad052d Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF_ptbr.gif new file mode 100644 index 00000000..fbad052d Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_es.gif new file mode 100644 index 00000000..d36e1944 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_ptbr.gif new file mode 100644 index 00000000..d36e1944 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_localcloser_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number.gif new file mode 100644 index 00000000..33f30330 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number_es.gif new file mode 100644 index 00000000..6d672acc Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number_ptbr.gif new file mode 100644 index 00000000..22e82a58 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_number_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial.gif new file mode 100644 index 00000000..195b1a90 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF.gif new file mode 100644 index 00000000..7c275732 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF_es.gif new file mode 100644 index 00000000..ef710c9c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF_ptbr.gif new file mode 100644 index 00000000..72dee5c0 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_es.gif new file mode 100644 index 00000000..accda01c Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_ptbr.gif new file mode 100644 index 00000000..0101ea9e Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_parkcustomerdial_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds.gif new file mode 100644 index 00000000..92fc7f2b Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds_es.gif new file mode 100644 index 00000000..f4fe2b27 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds_ptbr.gif new file mode 100644 index 00000000..f4fe2b27 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_XB_seconds_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script.gif new file mode 100644 index 00000000..69e43b79 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script_es.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script_es.gif new file mode 100644 index 00000000..ba4320d4 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script_es.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script_ptbr.gif new file mode 100644 index 00000000..69e43b79 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_script_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_vicidial.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_vicidial.gif new file mode 100644 index 00000000..1e862589 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_vicidial.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_vicidial_ptbr.gif b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_vicidial_ptbr.gif new file mode 100644 index 00000000..1e862589 Binary files /dev/null and b/agc_2-X/trunk/LANG_agc/agc/images/vdc_tab_vicidial_ptbr.gif differ diff --git a/agc_2-X/trunk/LANG_agc/agc/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc/inbound_popup.php new file mode 100644 index 00000000..e26c4496 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +LIVE INBOUND CALL"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

LIVE INBOUND CALL

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid is not valid\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Channel: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "CUSTOM - \n"; + + echo "
Number Dialed: $row[8]
Notes: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "HANGUP - \n"; + echo "SEND TO MY VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc/live_exten_check.php new file mode 100644 index 00000000..e0ca96c8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Live Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ChannelA[$loop_count] = "$row[0]"; + $ChannelB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $ChannelA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc/manager_send.php b/agc_2-X/trunk/LANG_agc/agc/manager_send.php new file mode 100644 index 00000000..b934cbb8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Manager Send: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "HELP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten is not valid or queryCID $queryCID is not valid, Originate command not inserted\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nOriginateName Action not sent\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nOriginateNameVmail Action not sent\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten is not valid or queryCID $queryCID is not valid, Originate command not inserted\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten is not valid or ext_context $ext_context or queryCID $queryCID is not valid, Hangup command not inserted\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or queryCID $queryCID is not valid, Hangup command not inserted\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel is not live on $call_server_ip, Checking Live Channel...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup command sent for Channel $channel on $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "auto_dial_level $auto_dial_level must be set\n"; + echo "campaign $campaign must be set\n"; + echo "uniqueid $uniqueid must be set\n"; + echo "lead_id $lead_id must be set\n"; + echo "\nRedirectVD Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "parkedby $parkedby must be set\n"; + echo "\nRedirectToPark Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectFromPark Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectName Action not sent\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectNameVmail Action not sent\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "ExtraChannel $extrachannel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirect Action not sent\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Cannot find empty conference on $server_ip, Redirect command not inserted\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Channel $channel is not live on $call_server_ip, Redirect command not inserted\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra command sent for Channel $channel and \nExtraChannel $extrachannel\n to $exten on $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra command sent for Channel $channel on $call_server_ip and \nExtraChannel $extrachannel\n to $exten on $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirect Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for Channel $channel on $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or queryCID $queryCID is not valid or filename: $filename is not valid, $ACTION command not inserted\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $server_ip, $ACTION command not inserted\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION command sent for Channel $channel on $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or exten $exten is not valid or filename: $filename is not valid, $ACTION command not inserted\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going on in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION command sent for Channel $channel on $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n RECORDING WILL LAST UP TO 60 MINUTES\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc/park_calls_display.php new file mode 100644 index 00000000..246591b1 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Parked Calls Display"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc/vdc_db_query.php new file mode 100644 index 00000000..ef287987 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Invalid Username/Password: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Database Query Script"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Group Choice $closer_choice is not valid\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Group Choice $closer_choice has been registered to user $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "HOPPER EMPTY\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUMBER\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "HOPPER EMPTY\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "CALL NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID is not valid\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "LOG NOT ENTERED\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign is not valid\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inserted: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOG NOT ENTERED\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CALL_LOG Inserted: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "LOG NOT ENTERED\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "LOG NOT ENTERED\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id is not valid\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "LOG NOT ENTERED\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campaign $campaign is not valid\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INCALL + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INCALL + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send on to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If CALLBK, change vicidial_callback record to INACTIVE + if ($dispo == 'CALLBK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user on $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten is not valid\n"; + exit; + } +else + { + ##### Insert a LOGOUT record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation on the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id is not valid\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### CALLBACK ENTRY + if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' has been changed to ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id is not valid\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id information has been updated\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage is not valid\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' is now in status ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list is not valid\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc/vicidial.php b/agc_2-X/trunk/LANG_agc/agc/vicidial.php new file mode 100644 index 00000000..9d3763bb --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "You have now logged out. Thank you\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of seconds for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "VICIDIAL web client: Re-Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Login
 
Phone Login:
Phone Password:
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "VICIDIAL web client: Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

User Login

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Campaign Login
 
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "VICIDIAL web client: Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
Phone Login:
Phone Password:
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "VICIDIAL web client: Phone Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone Login
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_seconds=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Campaign not active, please try again
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Login incorrect, please try again
"; + } + } + if ($VDloginDISPLAY) + { + echo "VICIDIAL web client: Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Campaign Login
 
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "VICIDIAL web client: Phone Login Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login Error
 
Sorry, your phone login and password are not active in this system, please try again:
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "VICIDIAL web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed on this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login on phone: $SIP_user to campaign: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "VICIDIAL web client: VICIDIAL Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Sorry, there are no leads in the hopper for this campaign\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Password:
\n"; + echo "Campaign: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "VICIDIAL web client: VICIDIAL Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Password:
\n"; + echo "Campaign: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +LOGOUT\n"; ?> +
+
+ + + + + + + + +
VICIDIALSCRIPT   LIVE     session ID: Live Call
+
+ + + + +

VICIDIAL
+
+ + +MANUAL DIAL
+
+ + +X ACTIVE CALLBACKS
+
+ + +
CALLBACKS FOR AGENT :
Click on a callback below to call the customer back now. If you click on a record below to call it, it will be removed from the list. +
+
+
  + Refresh +                 + Go Back +
+
+ + +
NEW MANUAL DIAL LEAD FOR :

Enter information below for the new lead you wish to call. +
+ \n"; + } + ?> + Note: all new manual dial leads will go into list 999

+ + + + + + + + + + + + + + + +
Dial Code:   (This is usually a 1 in the USA-Canada)
Phone Number:   (10 digits max - digits only)
Search Existing Leads:   (This option if checked will attempt to find the phone number in the system before inserting it as a new lead)


If you want to dial a number and have it NOT be added as a new lead, enter in the exact dialstring that you want to call in the Dial Override field below. To hangup this call you will have to open the CALLS IN THIS SESSION link at the bottom of the screen and hang it up by clicking on its channel link there.
 
Dial Override:   (digits only please)
+
+ Dial Now +                 + Go Back +
+
+ + + + +Your Status:
Calls Dialing: +
+ + + + + +
+ + Transfer - Conference
+ INTERNAL CLOSER + LOCAL CLOSER + CODE + Hangup Xfer Line + Hangup Both Lines + +
+ + Number to call   + seconds   + channel + + OVERRIDE   + D1 + D2 +
+ + Dial With Customer + Park Customer Dial + LEAVE 3-WAY CALL + Dial Blind Transfer + Blind Transfer VMail Message +
+
+
+ + + + +
Lead Dispositioned As:

+ -
+
+
+ + + + + + + +
Disposition Hot Keys: + When active, simply press the keyboard key for the desired disposition for this call. The call will then be hungup and dispositioned automatically:
+ + + + + +
+
+ + +
Noone is in your session:
+ Go Back +

+ Call Agent Again +
+
+ + +
Customer has hung up:
+ Go Back +

+ Finish and Disposition Call + +
+
+ + +
Call Wrapup: seconds remaining in wrapup

+ +

+ Finish Wrapup and Move On + +
+
+ + +

LOGOUT
+
+ + +
+
+ + +
 
+
+ + +
Any changes made to the customer information below at this time will not be comitted, You must change customer information before you Hangup the call.
+
+ + +
DISPOSITION CALL :       Hangup Again       minimize
+ End-of-call Disposition Selection +
+ PAUSE AGENT DIALING
+ CLEAR FORM | + SUBMIT +

+ WEB FORM SUBMIT +

  +
+
+ + + +
Select a CallBack Date :
+ + + Select a Date Below   +     + Hour: +   + Minutes: +   + +  
+ MY CALLBACK ONLY
";} + ?> + CB Comments:

+ + SUBMIT

+ +

  +
+
+ + +
CLOSER INBOUND GROUP SELECTION
+ Closer Inbound Group Selection +
+ BLENDED CALLING(outbound activated)
+ RESET | + SUBMIT +



  +
+
+ + + + Channel + Channel + MY CALLBACK ONLY
";} + ?> +
+ + + + + + + +
LIVE CALL TRANSFER
Channel to be transferred: Channel
Extensions:
Extensions Menu
+
+ Send to selected extension

+ Send to selected vmail box

+ Send to this number:


+ REFRESH


+ Back to Main Window

+
Conferences:
(click on a number below to send to a conference)
Send my channel too
Conferences Menu
+
+ + + + +
VICIDIAL SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUS:
+
+Dial Next Number
+ LEAD PREVIEW
+ ALT PHONE DIAL
+ + +RECORDING FILE:
+
+
+RECORD ID:
+
+ +Start Recording
+
+Web Form
+
+Park Call
+Transfer - Conference
+
+Hangup Customer
+
+Send DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
seconds:   Channel:   Cust Time:
Customer Information:
Title:   First:   MI:   Last:
Address1:
Address2:   Address3:
City:   State:   PostCode:
Province:   Vendor ID:
Phone:   DialCode:   Alt. Phone:
Show:   Email:
Comments:
+ +
+


  + +
+ + + + +
VICIDIAL web-client version:     BUILD:               Server:              
+Show conference call channel information
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +HOT KEYS INACTIVE + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc/voicemail_check.php new file mode 100644 index 00000000..9cc655c6 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Voicemail Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "voicemail box $vmail_box is not valid\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_br/active_list_refresh.php new file mode 100644 index 00000000..1f1e784a --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Mostrar Lista: "; +if ($ADD==1) {echo "Extensões Ativas";} +if ($ADD==2) {echo "Extensões Ocupadas";} +if ($ADD==3) {echo "Linhas externas";} +if ($ADD==4) {echo "Extensões Locais";} +if ($ADD==5) {echo "Conferencias";} +if ($ADD==99999) {echo "AJUDA";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_br/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_br/astguiclient.php new file mode 100644 index 00000000..8c11bcba --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Você fez o logoff. Obrigado\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "astGUIclient web client: Login\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
Login do Usuário:
Senha do Usuário:
Login do Telefone:
Senha do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDISCAR|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDISCAR|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "astGUIclient web client: Login do Telefone\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Brazil
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Login do Telefone
 
Login do Telefone:
Senha do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "astGUIclient web client: Login do Telefone\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login do Telefone
 
Desculpe seu login de telefone e senha não estão ativos nesta campanha, por favor tente novamente:
 
Login do Telefone:
Senha do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "astGUIclient web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +SAIR
\n"; ?> +
Painel PrincipalLinhas Ativas no PainelPainel de ConferênciasVerificar Caixa PostalChamadas Ativas
+
+ + +

Logout
+
+ + +
TRUNK DESLIGAR

+ Active Trunks Menu
+ Desligar o Canal   |   + Capturar o Canal   |   + Ouvir o Canal   |   + Atualizar   |   + Voltar a página principal +
+
+ + +
DESLIGAR LOCAL

+ Menu Local Ativo
+ Desligar Local   |   + Capturar Local   |   + Ouvir Local   |   + Atualizar   |   + Voltar a página principal +
+
+ + + + + + + +
TRANSFERIR CHAMADAS ATIVAS
Canal a ser transferido: Canal
Extensões:
Extensões do Menu
+
+ Enviar para a extensão selecionada

+ Enviar para a caixa postal selecionada

+ Envie para este número:


+ Atualizar


+ Voltar a página principal

+
Conferencias:
(Clique no número abaixo para enviar a conferência)
Enviar meu canal para
Menu das conferências
+
+ + + + + +
Discar a extensão local
Telefone ligando de: Canal
Extensões:
Extensões do Menu
+
+ Ligar para a extensão selecionada

+ Ligar para a caixa postal selecionada

+ Atualizar


+ Voltar a página principal

+
+
+ + +
CHAMADAS EM ESPERA:
+ Voltar a página principal

+
+
+ + + + + + + + + + + + + + + +
  +
CAIXA POSTAL     NOVO:     VELHO:             DISCAGEM MANUAL       DISCAR
CHAMADAS EM ESPERA: 0                DISCAR A EXTENSÃO LOCAL
CHAMADAS SAINTES:
CHAMADAS ENTRANTES:
Versão do cliente web do astGUIClient: CONFIGURAÇÃO:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITOS       editar
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITOS

 
PARA ENVIAR MODIFICACOES FAVORITAS E NECESSARIO FAZER O SAIR
VOLTAR A TELA PRINCIPAL - as alterações serão ignoradas
+
+ +
+ + + + + + + + + + + + + +
+PAUSAR | INICIAR     Atualizar a taxa: 1000 ms Mais rápido | Mais devagar

+
Inicializando..
+
Extensões Ativas
+ATUALIZAR | +ORDEM | +
Linhas externas
+ATUALIZAR | +ORDEM | +
Extensões Locais
+ATUALIZAR | +ORDEM | +
+ Data vai aqui

+
+ Data vai aqui

Atividade do Tronco +
+ Data vai aqui

Atividade Local +
+
+ + + + +
+ + +Lista das conferências + + + +
+Clique no número da conferência, a esquerda, para entrar na conferência +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_br/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_br/call_log_display.php new file mode 100644 index 00000000..11771e35 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Registro de Ligações"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten não é válido ou protocolo $protocol não é válido\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_br/conf_exten_check.php new file mode 100644 index 00000000..ac0d543b --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Verificação da Extensão de Conferência"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten não é válido\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Status: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $CanalA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $CanalA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$CanalA[$counter] ~"; + # echo "$CanalA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten não é válido or Exten $exten não é válido\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conferencia $conf_exten já foi registrado para $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_br/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_br/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_br/inbound_popup.php new file mode 100644 index 00000000..089e809f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +CHAMADA ENTRANDO"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

CHAMADA ENTRANDO

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid não é válido\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Canal: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Canal=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "CUSTOMIZADO - \n"; + + echo "
Número Discado: $row[8]
Notas: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "DESLIGAR - \n"; + echo "ENVIAR PARA MINHA CAIXA POSTAL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_br/live_exten_check.php new file mode 100644 index 00000000..845ae60c --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Verificação de extensões ativas"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten não é válido ou protocolo $protocol não é válido\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $CanalA[$loop_count] = "$row[0]"; + $CanalB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $CanalA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_br/manager_send.php new file mode 100644 index 00000000..7a23c861 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Gerente Envia: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "AJUDA";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten não é válido or queryCID $queryCID não é válido, Originate comando não inserido\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate comando enviado para Exten $exten Canal $channelligado$server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "extenName $extenName Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nOriginateName Action não enviado\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "extenName $extenName Deve ser definido\n"; + echo "exten $exten Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nOriginateNameVmail Action não enviado\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten não é válido or queryCID $queryCID não é válido, Originate comando não inserido\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate comando enviado para Exten $exten Canal $channelligado$server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten não é válido or ext_context $ext_context or queryCID $queryCID não é válido, Hangup comando não inserido\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Canal $channel não é válido or queryCID $queryCID não é válido, Hangup comando não inserido\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel não está ativoligado$call_server_ip, Checking Live Canal...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Canal $channel não está ativoligado$call_server_ip, Hangup comando não inserido $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup comando enviado para Canal $channelligado$call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "exten $exten Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "auto_dial_level $auto_dial_level Deve ser definido\n"; + echo "campaign $campaign Deve ser definido\n"; + echo "uniqueid $uniqueid Deve ser definido\n"; + echo "lead_id $lead_id Deve ser definido\n"; + echo "\nRedirectVD Action não enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='TRANFERENCIA' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='TRANFERENCIA' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "exten $exten Deve ser definido\n"; + echo "extenName $extenName Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "parkedby $parkedby Deve ser definido\n"; + echo "\nRedirectToPark Action não enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "exten $exten Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nRedirectFromPark Action não enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "extenName $extenName Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nRedirectName Action não enviado\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "extenName $extenName Deve ser definido\n"; + echo "exten $exten Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nRedirectNameVmail Action não enviado\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "ExtraCanal $extrachannel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "exten $exten Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nRedirect Action não enviado\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Não foi possível achar uma conferência vazialigado$server_ip, Redirect comando não inserido\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Canal $channel não está ativoligado$call_server_ip, Redirect comando não inserido\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Canal $channel não está ativoligado$server_ip, Redirect comando não inserido\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra comando enviado para Canal $channel and \nExtraCanal $extrachannel\n to $extenligado$server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra comando enviado para Canal $channelligado$call_server_ip and \nExtraCanal $extrachannel\n to $extenligado$server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma dessas variáveis não é válido:\n"; + echo "Canal $channel Deve ser maior que 2 caracteres\n"; + echo "queryCID $queryCID Deve ser maior que 14 caracateres\n"; + echo "exten $exten Deve ser definido\n"; + echo "ext_context $ext_context Deve ser definido\n"; + echo "ext_priority $ext_priority Deve ser definido\n"; + echo "\nRedirect Action não enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Canal $channel não está ativoligado$server_ip, Redirect comando não inserido\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect comando enviado para Canal $channelligado$server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Canal $channel não é válido or queryCID $queryCID não é válido or filename: $filename não é válido, $ACTION comando não inserido\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Canal $channel não está ativoligado$server_ip, $ACTION comando não inserido\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION comando enviado para Canal $channelligado$server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Canal $channel não é válido or exten $exten não é válido or filename: $filename não é válido, $ACTION comando não inserido\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings goingligadoin this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION comando enviado para Canal $channelligado$server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n AS GRAVAÇÕES VÃO DURAR 60 MINUTOS\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_br/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_br/park_calls_display.php new file mode 100644 index 00000000..8b4310da --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Mostra as ligações em espera"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten não é válido ou protocolo $protocol não é válido\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_br/vdc_db_query.php new file mode 100644 index 00000000..a312b0bf --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Inválido Usuário/Senha: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Script de consulta ao banco de dados"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Escolha do Grupo $closer_choice não é válido\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Escolha do Grupo $closer_choice foi registrado para o usuário $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "LISTA DE DISCAGEM VAZIA\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context não é válido\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUMERO\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INCHAMADA + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "LISTA DE DISCAGEM VAZIA\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context não é válido\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCHAMADA + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "CHAMADA NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context não é válido\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID não é válido\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "REGISTRO NÃO DEFINIDO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign não é válido\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inserido: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "REGISTRO NÃO DEFINIDO\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CHAMADA_LOG Inserido: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "REGISTRO NÃO DEFINIDO\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "REGISTRO NÃO DEFINIDO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id não é válido\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "REGISTRO NÃO DEFINIDO\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campanha $campaign não é válido\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INCHAMADA in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INCHAMADA + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INCHAMADA + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INCHAMADA + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then sendligadoto vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If CHAMADABK, change vicidial_callback record to INACTIVE + if ($dispo == 'CHAMADABK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $userligado$server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten não é válido\n"; + exit; + } +else + { + ##### Insert a SAIR record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','SAIR','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservationligadothe vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id não é válido\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### CHAMADABACK ENTRY + if ( ($dispo_choice == 'CBHVELHO') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' foi modificado para ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id não é válido\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id a informação foi atualizada\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage não é válido\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' está agora com o status ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list não é válido\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_br/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_br/vicidial.php new file mode 100644 index 00000000..227202f0 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Você fez o logoff. Obrigado\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of segundos for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "VICIDISCAR web client: Re-Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Brazil
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Login
 
Login do Telefone:
Senha do Telefone:
Login do Usuário:
Senha do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "VICIDISCAR web client: Login da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Login do Usuário

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login da Campanha
 
Login do Usuário:
Senha do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "VICIDISCAR web client: Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
Login do Telefone:
Senha do Telefone:
Login do Usuário:
Senha do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "VICIDISCAR web client: Login do Telefone\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Brazil
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Login do Telefone
 
Login do Telefone:
Senha do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_segundos=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "A campanha não está ativa, por favor tente novamente
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Usuário incorreto, por favor tente novamente
"; + } + } + if ($VDloginDISPLAY) + { + echo "VICIDISCAR web client: Login da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login da Campanha
 
Login do Usuário:
Senha do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "VICIDISCAR web client: Login do Telefone Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login Error
 
Desculpe seu login de telefone e senha não estão ativos nesta campanha, por favor tente novamente:
 
Login do Telefone:
Senha do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "VICIDISCAR web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowedligadothis campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_loginligadophone: $SIP_userpara a campanha: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NOVO record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "VICIDISCAR web client: VICIDISCAR Login da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "Desculpe, não existem registros na fila de discagem\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Senha:
\n"; + echo "Campanha: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "VICIDISCAR web client: VICIDISCAR Login da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Brazil
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Senha:
\n"; + echo "Campanha: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +SAIR\n"; ?> +
+
+ + + + + + + + +
VICIDISCARSCRIPT   LIVE    ID da sessão: Chamadas Ativas
+
+ + + + +

VICIDISCAR
+
+ + +DISCAGEM MANUAL
+
+ + +X AGENDAMENTOS ATIVOS
+
+ + +
AGENDAMENTOS POR AGENTE :
Clique em um dos contatos abaixo para ligar. Se você clicar em um contatos abaixo o mesmo será removido da lista de Agendamentos. +
+
+
  + Atualizar +                 + Voltar +
+
+ + +
NOVA DISCAGEM MANUAL PARA :

Digite abaixo a informação do novo contato que você deseja ligar. +
+ \n"; + } + ?> + Nota: todos os novos contatos da discagem manual serão inseridos na lista 999

+ + + + + + + + + + + + + + + +
Codigo de Área:   (Normalmente é 1 nos EUA-Canada)
Telefone Number:   (Maximo de 10 digitos - apenas número)
Ligações Existentes Da Busca:   (Esta opção se verificado tentará encontrar o número de telefone no sistema antes de introduzi-lo como uma ligação nova)


Se você deseja ligar para um número que não está na lista de contatos, digite o número que voc6e deseja discar no campo Discagem Sobreposta abaixo. Para desligar essa ligação você deve abrir o link Ligações em sua sessão link no rodapé da página e desligar clicando no link do canal.
 
Discagem Sobreposta:   (digitos apenas por favor)
+
+ Discar Agora +                 + Voltar +
+
+ + + + +Your Status:
Calls Dialing: +
+ + + + + +
+ + Transferir a conferência
+ CLOSER INTERNO + CLOSER LOCAL + CODE + Desligar linha Xfer + Desligar ambas as linhas + +
+ + Número a ser discado   + segundos   + channel + + OVERRIDE   + D1 + D2 +
+ + Discar com o cliente + Colocar chamada do cliente em espera + ABANDONAR CHAMADA A TRES + Transferência sem acompanhamento + Blind Transfer VMail Message +
+
+
+ + + + +
Status da ligação definida como:

+ -
+
+
+ + + + + + + +
Atalhos para os status: + Quanto ativo apenas pressione a tecla do teclado referente ao status desejado. A ligação será desligada e salva com o status definido automaticamemente:
+ + + + + +
+
+ + +
Não existe ninguem na sua sessão:
+ Voltar +

+ Ligar novamente para o agente +
+
+ + +
O cliente desligou:
+ Voltar +

+ Finalize e coloque o status da ligação + +
+
+ + +
Chamada Wrapup: segundos restantes no wrapup

+ +

+ Revestimento Wrapup e movimento sobre + +
+
+ + +

SAIR
+
+ + +
+
+ + +
 
+
+ + +
Qualquer alteração feita nesta página não será salva. Você deve mudar as informações do cliente antes de desligar a ligação.
+
+ + +
SELEÇÃO DE STATUS :       Desligue novamente       minimizar
+ Fim da seleção de status +
+ PAUSAR DISCAGEM DO AGENTE
+ LIMPAR FORMULARIO | + ENVIAR +

+ WEB FORM ENVIAR +

  +
+
+ + + +
Selecione uma data para o retorno :
+ + + Selecione uma data abaixo   +     + Hour: +   + Minutes: +   + +  
+ ESTE AGENDAMENTO SO APARECE PARA MIM
";} + ?> + Comentarios do CB:

+ + ENVIAR

+ +

  +
+
+ + +
SELECAO DO GRUPO DE ENTRADA DO CLOSER
+ Seleção do grupo de entrada do closer +
+ LIGACAO MISTURADA(ligações externas ativadas)
+ REINICIAR | + ENVIAR +



  +
+
+ + + + Canal + Canal + ESTE AGENDAMENTO SO APARECE PARA MIM
";} + ?> +
+ + + + + + + +
TRANSFERIR CHAMADAS ATIVAS
Canal a ser transferido: Canal
Extensões:
Extensões do Menu
+
+ Enviar para a extensão selecionada

+ Enviar para a caixa postal selecionada

+ Envie para este número:


+ ATUALIZAR


+ Voltar a página principal

+
Conferencias:
(Clique no número abaixo para enviar a conferência)
Enviar meu canal para
Menu das conferências
+
+ + + + +
VICIDISCAR SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUS:
+
+Discar proximo número
+ VISUALIZAR CONTATO
+ DISCAR TELEFONE ALTERNATIVO
+ + +GRAVANDO ARQUIVO:
+
+
+ID da gravação:
+
+ +Inicia Gravação
+
+Web Form
+
+Colocar em espera
+Transferir a conferência
+
+Desligar Cliente
+
+Enviar DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
segundos:   Canal:   Tempo de cliente:
Informações do cliente:
Título:   Primeiro:   MI:  Ultimo:
Endereço1:
Endereço2:   Endereço3:
Cidade:   Estado:   CEP:
Bairro:   ID do Vendedor:
Telefone:   Codigo de Area:   Telefone Alternativo:
Mostrar:   Email:
Comentários:
+ +
+


  + +
+ + + + +
VICIDISCAR web-client version:     CONFIGURAÇÃO:               Servidor:              
+Mostrar informações de discagem do canal
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +ATALHOS DE STATUS INATIVOS + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_br/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_br/voicemail_check.php new file mode 100644 index 00000000..40f2fc42 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_br/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuário/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Verificar caixa postal"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "Caixa Postal $vmail_box não é válido\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_de/active_list_refresh.php new file mode 100644 index 00000000..586890cb --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Liste Anzeige: "; +if ($ADD==1) {echo "Phasenverlängerungen";} +if ($ADD==2) {echo "Beschäftigte Verlängerungen";} +if ($ADD==3) {echo "Äußere Linien";} +if ($ADD==4) {echo "Lokale Verlängerungen";} +if ($ADD==5) {echo "Konferenzen";} +if ($ADD==99999) {echo "HILFE";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_de/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_de/astguiclient.php new file mode 100644 index 00000000..461b51ff --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Sie haben jetzt heraus geloggt. Danke\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "astGUIclient web client: LOGON\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
LOGON
 
Benutzer-LOGON:
Benutzer-Kennwort:
Telefon-LOGON:
Telefon-Kennwort:

VERSION: $version       BAU: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIVORWAHLKNOPF|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIVORWAHLKNOPF|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "astGUIclient web client: Telefon-LOGON\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Deutsch
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefon-LOGON
 
Telefon-LOGON:
Telefon-Kennwort:

VERSION: $version       BAU: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "astGUIclient web client: Telefon-LOGON\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Telefon-LOGON
 
Traurig, Ihr Telefon-LOGON und Kennwort seien Sie nicht in diesem:
 
Telefon-LOGON:
Telefon-Kennwort:

VERSION: $version       BAU: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "astGUIclient web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +LOGOUT
\n"; ?> +
HauptverkleidungAktive Linien VerkleidungKonferenz-VerkleidungÜberprüfen Sie VoicemailLeben Anruf
+
+ + +

Logout
+
+ + +
TRUNK HÄNGEZUSTAND

+ Active Trunks Menu
+ Hängezustand-Stamm   |   + Straßenräuber-Stamm   |   + Hören Stamm   |   + ErneuernSie   |   + Zurück zu Hauptfenster +
+
+ + +
LOKALER HÄNGEZUSTAND

+ Aktives Lokales Menü
+ Hängezustand-Einheimischer   |   + Straßenräuber-Einheimischer   |   + Hören Einheimischer   |   + ErneuernSie   |   + Zurück zu Hauptfenster +
+
+ + + + + + + +
PHASENANRUF-ÜBERTRAGUNG
Gebracht zu werden Führung: Führung
Verlängerungen:
Verlängerungen Menü
+
+ Senden Sie zu vorgewählter Verlängerung

+ Senden Sie zu vorgewähltem vmail Kasten

+ Senden Sie zu dieser Zahl:


+ ErneuernSie


+ Zurück zu Hauptfenster

+
Konferenzen:
(klicken Sie an eine Zahl unten, um zu einer Konferenz zu senden)
Senden Sie meine Führung auch
Konferenz-Menü
+
+ + + + + +
LOKALER Verlängerungen Vorwahlknopf
Telefon, das von benennt: Führung
Verlängerungen:
Verlängerungen Menü
+
+ Anruf vorgewählte Verlängerung

+ Anruf vorgewählter vmail Kasten

+ ErneuernSie


+ Zurück zu Hauptfenster

+
+
+ + +
GEPARKTE ANRUFE:
+ Zurück zu Hauptfenster

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NEU:     ALT:             MANUELLER VORWAHLKNOPF       VORWAHLKNOPF
GEPARKTE ANRUFE: 0                LOKALE VORWAHLKNOPF-VERLÄNGERUNGEN
OUTBOUND ANRUFE:
INBOUND ANRUFE:
astGUIclient Netz-Klient VERSION: BAU:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
LIEBLINGE       redigieren sie
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
LIEBLINGE

 
SUBMITSie Sie LIEBLINGE ÄNDERUNGEN - erfordert Logout
ZURÜCK ZU MAIN FENSTER - ignorieren Sie die vorgenommenen Änderungen
+
+ +
+ + + + + + + + + + + + + +
+PAUSE | ANFANG     Erneuern Sie Rate: 1000 ms Schneller | Langsamer

+
Initialisierung..
+
Aktive Verlängerungen
+ERNEUERNSie | +AUFTRAG | +
Äußere Linien
+ERNEUERNSie | +AUFTRAG | +
Lokale Verlängerungen
+ERNEUERNSie | +AUFTRAG | +
+ Daten Gehen Hier

+
+ Daten Gehen Hier

Stamm-Tätigkeit +
+ Daten Gehen Hier

Lokale Tätigkeit +
+
+ + + + +
+ + +Konferenz-Liste + + + +
+Klicken Sie an Konferenzzimmernummer auf dem links für Info auf +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_de/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_de/call_log_display.php new file mode 100644 index 00000000..ed6d8f68 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Anruf-Maschinenbordbuch-Anzeige"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten ist unzulässig oder Protokoll $protocol ist unzulässig\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_de/conf_exten_check.php new file mode 100644 index 00000000..de56646a --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Conf Verlängerung Überprüfung"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten ist unzulässig\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Status: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $FührungA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $FührungA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$FührungA[$counter] ~"; + # echo "$FührungA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten ist unzulässig or Exten $exten ist unzulässig\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Konferenz $conf_exten ist zu registriert worden $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_de/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_de/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_de/inbound_popup.php new file mode 100644 index 00000000..f4058509 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +INBOUND LEBHAFTANRUF"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

INBOUND LEBHAFTANRUF

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid ist unzulässig\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Führung: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Führung=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "GEWOHNHEIT - \n"; + + echo "
Nummer Gewählt: $row[8]
Anmerkungen: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "HÄNGEZUSTAND - \n"; + echo "SENDEN SIE ZU MEINEM VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_de/live_exten_check.php new file mode 100644 index 00000000..4c60b701 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Phasenverlängerung Überprüfung"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten ist unzulässig oder Protokoll $protocol ist unzulässig\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $FührungA[$loop_count] = "$row[0]"; + $FührungB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "FührungA: $FührungA[$counter] ~"; + echo "FührungB: $FührungB[$counter] ~"; + echo "FührungBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "FührungA: $FührungA[$counter] ~"; + echo "FührungB: $FührungB[$counter] ~"; + echo "FührungBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "FührungA: $FührungA[$counter] ~"; + echo "FührungB: $FührungB[$counter] ~"; + echo "FührungBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "FührungA: $FührungA[$counter] ~"; + echo "FührungB: $FührungB[$counter] ~"; + echo "FührungBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "FührungA: $FührungA[$counter] ~"; + echo "FührungB: $FührungB[$counter] ~"; + echo "FührungBtrunk: $FührungA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_de/manager_send.php new file mode 100644 index 00000000..4564dadd --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Manager Senden: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "HILFE";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten ist unzulässig or queryCID $queryCID ist unzulässig, Originate Befehl nicht eingesetzt\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate Befehl gesendet für Exten $exten Führung $channel auf $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "extenName $extenName muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nOriginateName Action nicht gesendet\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "extenName $extenName muß eingestellt werden\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nOriginateNameVmail Action nicht gesendet\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten ist unzulässig or queryCID $queryCID ist unzulässig, Originate Befehl nicht eingesetzt\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate Befehl gesendet für Exten $exten Führung $channel auf $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten ist unzulässig or ext_context $ext_context or queryCID $queryCID ist unzulässig, Hangup Befehl nicht eingesetzt\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Führung $channel ist unzulässig or queryCID $queryCID ist unzulässig, Hangup Befehl nicht eingesetzt\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel ist nicht Phasen auf $call_server_ip, Checking Live Führung...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Führung $channel ist nicht Phasen auf $call_server_ip, Hangup Befehl nicht eingesetzt $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup Befehl gesendet für Führung $channel auf $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "auto_dial_level $auto_dial_level muß eingestellt werden\n"; + echo "campaign $campaign muß eingestellt werden\n"; + echo "uniqueid $uniqueid muß eingestellt werden\n"; + echo "lead_id $lead_id muß eingestellt werden\n"; + echo "\nRedirectVD Action nicht gesendet\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "extenName $extenName muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "parkedby $parkedby muß eingestellt werden\n"; + echo "\nRedirectToPark Action nicht gesendet\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nRedirectFromPark Action nicht gesendet\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "extenName $extenName muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nRedirectName Action nicht gesendet\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "extenName $extenName muß eingestellt werden\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nRedirectNameVmail Action nicht gesendet\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "ExtraFührung $extrachannel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nRedirect Action nicht gesendet\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Kann nicht leere Konferenz finden auf $server_ip, Redirect Befehl nicht eingesetzt\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Führung $channel ist nicht Phasen auf $call_server_ip, Redirect Befehl nicht eingesetzt\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Führung $channel ist nicht Phasen auf $server_ip, Redirect Befehl nicht eingesetzt\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra Befehl gesendet für Führung $channel and \nExtraFührung $extrachannel\n to $exten auf $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra Befehl gesendet für Führung $channel auf $call_server_ip and \nExtraFührung $extrachannel\n to $exten auf $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Eine dieser Variablen ist unzulässig:\n"; + echo "Führung $channel muß als 2 Buchstaben grösser sein\n"; + echo "queryCID $queryCID muß als 14 Buchstaben grösser sein\n"; + echo "exten $exten muß eingestellt werden\n"; + echo "ext_context $ext_context muß eingestellt werden\n"; + echo "ext_priority $ext_priority muß eingestellt werden\n"; + echo "\nRedirect Action nicht gesendet\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Führung $channel ist nicht Phasen auf $server_ip, Redirect Befehl nicht eingesetzt\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect Befehl gesendet für Führung $channel auf $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Führung $channel ist unzulässig or queryCID $queryCID ist unzulässig or filename: $filename ist unzulässig, $ACTION Befehl nicht eingesetzt\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Führung $channel ist nicht Phasen auf $server_ip, $ACTION Befehl nicht eingesetzt\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION Befehl gesendet für Führung $channel auf $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Führung $channel ist unzulässig or exten $exten ist unzulässig or filename: $filename ist unzulässig, $ACTION Befehl nicht eingesetzt\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going auf in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION Befehl gesendet für Führung $channel auf $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n AUFNAHME DAUERT BIS 60 MINUTEN\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_de/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_de/park_calls_display.php new file mode 100644 index 00000000..07057230 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Geparkte Anruf-Anzeige"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten ist unzulässig oder Protokoll $protocol ist unzulässig\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_de/vdc_db_query.php new file mode 100644 index 00000000..9417bb0f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Datenbank-Frage Index"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Gruppe Wahl $closer_choice ist unzulässig\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Gruppe Wahl $closer_choice ist zum Benutzer registriert worden $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "ZUFUHRBEHÄLTER LEER\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context ist unzulässig\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC ZAHL\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INANRUF + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "ZUFUHRBEHÄLTER LEER\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context ist unzulässig\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INANRUF + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "ANRUF NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context ist unzulässig\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID ist unzulässig\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "MASCHINENBORDBUCH NICHT BETRETEN\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign ist unzulässig\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Eingesetzt: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "MASCHINENBORDBUCH NICHT BETRETEN\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "ANRUF_LOG Eingesetzt: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "MASCHINENBORDBUCH NICHT BETRETEN\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "MASCHINENBORDBUCH NICHT BETRETEN\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id ist unzulässig\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "MASCHINENBORDBUCH NICHT BETRETEN\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Kampagne $campaign ist unzulässig\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INANRUF in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INANRUF + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INANRUF + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INANRUF + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send auf to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If ANRUFBK, change vicidial_callback record to INACTIVE + if ($dispo == 'ANRUFBK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user auf $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten ist unzulässig\n"; + exit; + } +else + { + ##### Insert a LOGOUT record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation auf the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id ist unzulässig\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### ANRUFBACK ENTRY + if ( ($dispo_choice == 'CBHALT') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' ist zu geändert worden ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id ist unzulässig\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id Informationen sind aktualisiert worden\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage ist unzulässig\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' ist jetzt im Status ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list ist unzulässig\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_de/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_de/vicidial.php new file mode 100644 index 00000000..8c05a573 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Sie haben jetzt heraus geloggt. Danke\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of Sekunden for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "VICIVORWAHLKNOPF web client: Re-LOGON\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Deutsch
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-LOGON
 
Telefon-LOGON:
Telefon-Kennwort:
Benutzer-LOGON:
Benutzer-Kennwort:
Kampagne: $camp_form_code

VERSION: $version       BAU: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "VICIVORWAHLKNOPF web client: Kampagne LOGON\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Benutzer-LOGON

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Kampagne LOGON
 
Benutzer-LOGON:
Benutzer-Kennwort:
Kampagne: $camp_form_code

VERSION: $version       BAU: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "VICIVORWAHLKNOPF web client: LOGON\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
LOGON
 
Telefon-LOGON:
Telefon-Kennwort:
Benutzer-LOGON:
Benutzer-Kennwort:
Kampagne: $camp_form_code

VERSION: $version       BAU: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "VICIVORWAHLKNOPF web client: Telefon-LOGON\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Deutsch
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Telefon-LOGON
 
Telefon-LOGON:
Telefon-Kennwort:

VERSION: $version       BAU: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_Sekunden=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Die aktive Kampagne nicht, versuchen bitte noch einmal
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Der falsche LOGON, versuchen bitte noch einmal
"; + } + } + if ($VDloginDISPLAY) + { + echo "VICIVORWAHLKNOPF web client: Kampagne LOGON\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Kampagne LOGON
 
Benutzer-LOGON:
Benutzer-Kennwort:
Kampagne: $camp_form_code

VERSION: $version       BAU: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "VICIVORWAHLKNOPF web client: Telefon-LOGON Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
LOGON Error
 
Traurig, Ihr Telefon-LOGON und Kennwort seien Sie nicht in diesem:
 
Telefon-LOGON:
Telefon-Kennwort:

VERSION: $version       BAU: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "VICIVORWAHLKNOPF web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed auf this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login auf phone: $SIP_user zur Kampagne: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NEU record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "VICIVORWAHLKNOPF web client: VICIVORWAHLKNOPF Kampagne LOGON\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "Traurig, gibt es keine Leitungen im Zufuhrbehälter für diese\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "LOGON: \n
"; + echo "Kennwort:
\n"; + echo "Kampagne: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "VICIVORWAHLKNOPF web client: VICIVORWAHLKNOPF Kampagne LOGON\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Deutsch
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "LOGON: \n
"; + echo "Kennwort:
\n"; + echo "Kampagne: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +LOGOUT\n"; ?> +
+
+ + + + + + + + +
VICIVORWAHLKNOPFSCRIPT   LIVE     Lernabschnitt ID: Leben Anruf
+
+ + + + +

VICIVORWAHLKNOPF
+
+ + +MANUELLER VORWAHLKNOPF
+
+ + +X AKTIVE WIEDERHOLUNGSBESUCHE
+
+ + +
WIEDERHOLUNGSBESUCHE FÜR MITTEL :
Klicken Sie an einen Wiederholungsbesuch unten, um die Kunde Rückseite jetzt zu benennen. Wenn Sie an eine Aufzeichnung unten klicken, um sie zu benennen, wird sie von der Liste entfernt. +
+
+
  + ErneuernSie +                 + Gehen Sie Zurück +
+
+ + +
NEUE MANUELLE VORWAHLKNOPF-LEITUNG FÜR :

Tragen Sie Informationen unten für die neue Leitung ein, die Sie benennen möchten. +
+ \n"; + } + ?> + Anmerkung: alle neuen manuellen Vorwahlknopfleitungen steigen in Liste 999 ein

+ + + + + + + + + + + + + + + +
Vorwahlknopf-Code:   (Dieses ist normalerweise 1 in den USA und im Kanada)
Telefon Number:   (10 Stellen Maximum - nur Stellen)
Suche existierende Anschlüsse:   (Wenn diese Option gesetzt ist wird versucht, die Telefonnummer im System zu finden, bevor sie als neuer Anschluss eingefügt wird)


Wenn Sie eine Nummer wählen und sie NICHT als neue Leitung hinzufügen lassen möchten, kommen Sie im genauen Dialstring diesem Sie möchten in der Vorwahlknopf-Übersteuerung benennen auffangen unten herein. Zum Hängezustand dieser Anruf müssen Sie die ANRUFE IN DIESER LERNABSCHNITT-Verbindung am unteren Bildschirmrand öffnen und ihn oben hängen, indem Sie dort auf seiner Führung Verbindung klicken.
 
Vorwahlknopf-Übersteuerung:   (Stellen gefallen nur)
+
+ Vorwahlknopf Jetzt +                 + Gehen Sie Zurück +
+
+ + + + +Ihr Status:
Calls Dialing: +
+ + + + + +
+ + Übertragung - Konferenz
+ INTERNES GENAUERES + EINHEIMISCHER GENAUER + CODE + Hängezustand Xfer Linie + Hängezustand Beide Linien + +
+ + Zahl zum zu benennen   + Sekunden   + channel + + OVERRIDE   + D1 + D2 +
+ + Vorwahlknopf Mit Kunden + Park-Kunde Vorwahlknopf + ANRUF DES URLAUB-3-WAY + Vorwahlknopf-Vorhang-Übertragung + Blind Transfer VMail Message +
+
+
+ + + + +
Leitung Dispositioned Wie:

+ -
+
+
+ + + + + + + +
Einteilung Heiße Schlüssel: + Wenn aktiv, betätigen Sie einfach die Taste für die gewünschte:
+ + + + + +
+
+ + +
Noone ist in Ihrem Lernabschnitt:
+ Gehen Sie Zurück +

+ Anruf-Mittel Wieder +
+
+ + +
Kunde hat oben gehangen:
+ Gehen Sie Zurück +

+ Ende und Einteilung Anruf + +
+
+ + +
Anruf Nachbereitung Verbleibende Sekunden der Nachbereitung

+ +

+ Beende Nachbereitung und mache weiter + +
+
+ + +

LOGOUT
+
+ + +
+
+ + +
 
+
+ + +
Alle mögliche Änderungen, die am Kunden vorgenommen wurden, den, Informationen unten diesmal nicht sind, comitted, Sie müssen Kunde Informationen vor Ihnen ändern Hängezustand der Anruf.
+
+ + +
EINTEILUNG ANRUF :       Hängezustand Wieder       setzen Sie herab
+ Ende-von-benennen Sie Einteilung Vorwähler +
+ STOPPEN SIE ZU BENENNEN
+ ZURÜCKSTELLEN | + SUBMITSie +

+ WEB FORM SUBMITSie +

  +
+
+ + + +
Wählen Sie ein Wiederholungsbesuch Datum vor :
+ + + Wählen Sie ein Datum unten vor   +     + Hour: +   + Minutes: +   + +  
+ NUR MEIN WIEDERHOLUNGSBESUCH
";} + ?> + COLUMBIUM Anmerkungen:

+ + SUBMITSie

+ +

  +
+
+ + +
GENAUERE INBOUND GRUPPENWAHL
+ Genauere Inbound Gruppenwahl +
+ GEMISCHTES BENENNEN(outbound aktiviert)
+ ZURÜCKSTELLEN | + SUBMITSie +



  +
+
+ + + + Führung + Führung + NUR MEIN WIEDERHOLUNGSBESUCH
";} + ?> +
+ + + + + + + +
PHASENANRUF-ÜBERTRAGUNG
Gebracht zu werden Führung: Führung
Verlängerungen:
Verlängerungen Menü
+
+ Senden Sie zu vorgewählter Verlängerung

+ Senden Sie zu vorgewähltem vmail Kasten

+ Senden Sie zu dieser Zahl:


+ ERNEUERNSie


+ Zurück zu Hauptfenster

+
Konferenzen:
(klicken Sie an eine Zahl unten, um zu einer Konferenz zu senden)
Senden Sie meine Führung auch
Konferenz-Menü
+
+ + + + +
VICIVORWAHLKNOPF SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUS:
+
+Vorwahlknopf-Folgende Zahl
+ LEITUNG VORBETRACHTUNG
+ WECH TELEFON
+ + +REGISTERAKTE:
+
+
+SATZ IDENTIFIKATION:
+
+ +Fangen Sie an Zu notieren
+
+Netz-Form
+
+Park-Anruf
+Übertragung - Konferenz
+
+Hängezustand-Kunde
+
+Senden Sie DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
Sekunden:   Führung:   Cust Zeit:
Kunde Informationen:
Titel:   Zuerst:   MI:  Letztes:
Adresse1:
Adresse2:   Adresse3:
Stadt:   Zustand:   PostCode:
Provinz:   Verkäufer Identifikation:
Telefon:   DialCode:   Wech Telefon:
Erscheinen:   Email:
Anmerkungen:
+ +
+


  + +
+ + + + +
VICIVORWAHLKNOPF Netz-Klient Version:     BAU:               Bediener:              
+Zeigen Sie Konferenzanruf-Führung Informationen
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +HEISSE SCHLÜSSEL UNAKTIVIERT + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_de/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_de/voicemail_check.php new file mode 100644 index 00000000..b872f19a --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_de/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Unzulässig Benutzername/Kennwort: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Unzulässig server_ip: |$server_ip| or Unzulässig session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Unzulässig session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Voicemail Überprüfung"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "voicemail Kasten $vmail_box ist unzulässig\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_el/active_list_refresh.php new file mode 100644 index 00000000..befdb32b --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Κατάλογος Οθόνης: "; +if ($ADD==1) {echo "Ενεργές τηλ. συνδέσεις";} +if ($ADD==2) {echo "Απασχολημένες τηλ. συνδέσεις";} +if ($ADD==3) {echo "Εξωτερικές γραμμές";} +if ($ADD==4) {echo "Τοπικές τηλ. συνδέσεις";} +if ($ADD==5) {echo "Διασκέψεις";} +if ($ADD==99999) {echo "ΒΟΗΘΕΙΑ";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_el/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_el/astguiclient.php new file mode 100644 index 00000000..1a77376a --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Έχετε αποσυνδεθεί. Σας ευχαριστούμε\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "astGUIclient web client: Σύνδεση\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Σύνδεση
 
Σύνδεση χρήστη:
Κωδικός πρόσβασης χρήστη:
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIΚΛΗΣΗ|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIΚΛΗΣΗ|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "astGUIclient web client: Σύνδεση Τηλεφώνου\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Ελληνικά
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Σύνδεση Τηλεφώνου
 
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "astGUIclient web client: Σύνδεση Τηλεφώνου\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Σύνδεση Τηλεφώνου
 
Συγγνώμη, αλλά η τηλεφωνική σύνδεση και ο κωδικός πρόσβασής σας δεν είναι ενεργά σε αυτό το σύστημα, παρακαλώ προσπαθήστε πάλι:
 
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "astGUIclient web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +ΑΠΟΣΥΝΔΕΣΗ
\n"; ?> +
Κύριος ΠίνακαςΠίνακας Ενεργών ΓραμμώνΠίνακας διασκέψεωνΕλεγχος Φωνητικού ταχυδρομείουΕνεργή κλήση
+
+ + +

Logout
+
+ + +
TRUNK ΚΛΕΙΣΙΜΟ

+ Active Trunks Menu
+ Κλείσιμο Trunk   |   + Κλέψιμο Trunk   |   + Ακούστε Trunk   |   + Ανανέωση   |   + Επιστροφή +
+
+ + +
ΤΟΠΙΚΟ ΚΛΕΙΣΙΜΟ ΤΗΛΕΦΩΝΟΥ

+ Ενεργές Τοπικές Επιλογές
+ Κλείσιμο τοπικού   |   + Κλέψιμο τοπικού   |   + Ακούστε τοπικό   |   + Ανανέωση   |   + Επιστροφή +
+
+ + + + + + + +
ΜΕΤΑΦΟΡΑ ΕΝΕΡΓΗΣ ΚΛΗΣΗΣ
Κανάλι που μεταφέρεται: Κανάλι
Τηλ.συνδέσεις:
Επιλογές τηλ. συνδέσεων
+
+ Στείλε στην επιλεγμένη τηλ.σύνδεση

+ Στείλε στο επιλεγμένο vmail

+ Στείλε σε αυτόν τον αριθμό:


+ Ανανέωση


+ Επιστροφή

+
Διασκέψεις:
(επιλέξτε έναν αριθμό κατωτέρω που θα σταλεί σε μια διάσκεψη)
Στείλε το κανάλι μου επίσης
Επιλογές διασκέψεων
+
+ + + + + +
ΤΟΠΙΚΕΣ τηλ. συνδέσεις Κλήσεως
Τηλέφωνο που καλεί από: Κανάλι
Τηλ.συνδέσεις:
Επιλογές τηλ. συνδέσεων
+
+ Επιλεγμένη κλήση τηλ. σύνδεσης

+ Επιλεγμένη κλήση vmail

+ Ανανέωση


+ Επιστροφή

+
+
+ + +
ΣΤΑΘΜ.ΚΛΗΣΕΙΣ:
+ Επιστροφή

+
+
+ + + + + + + + + + + + + + + +
  +
ΦΩΝ.ΤΑΧ.     ΝΕΟ:     ΠΑΛΑΙΟ:             ΧΕΙΡ.ΚΛΗΣΗ       ΚΛΗΣΗ
ΣΤΑΘΜ.ΚΛΗΣΕΙΣ: 0                ΤΗΛ.ΣΥΝΔ. ΤΟΠΙΚΗΣ ΚΛΗΣΗΣ
ΕΞΕΡΧΟΜΕΝΕΣ ΚΛΗΣΕΙΣ:
ΕΙΣΕΡΧΟΜΕΝΕΣ ΚΛΗΣΕΙΣ:
ΈΚΔΟΣΗ astGUIclient: ΔΗΜΙΟΥΡΓΙΑ:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
ΑΓΑΠΗΜΕΝΑ       διορθώστε
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
ΑΓΑΠΗΜΕΝΑ

 
ΥΠΟΒΑΛΤΕ τις ΑΛΛΑΓΕΣ ΣΥΜΠΑΘΕΙΩΝ - απαιτεί την αποσύνδεση
ΠΙΣΩ στο ΚΥΡΙΟ ΠΑΡΑΘΥΡΟ - αγνοήστε τις αλλαγές που γίνονται
+
+ +
+ + + + + + + + + + + + + +
+ΠΑΥΣΗ | ΕΝΑΡΞΗ     Ρυθμός ανανέωσης: 1000 ms Γρηγορότερα | Πιό αργά

+
Αρχή..
+
Ενεργές τηλ. συνδέσεις
+ΑΝΑΝΕΩΣΗ | +ΤΑΞΙΝ | +
Εξωτερικές γραμμές
+ΑΝΑΝΕΩΣΗ | +ΤΑΞΙΝ | +
Τοπικές τηλ. συνδέσεις
+ΑΝΑΝΕΩΣΗ | +ΤΑΞΙΝ | +
+ Τα δεδομένα πηγαίνουν εδώ

+
+ Τα δεδομένα πηγαίνουν εδώ

Κίνηση Trunk +
+ Τα δεδομένα πηγαίνουν εδώ

Τοπική Κίνηση +
+
+ + + + +
+ + +Κατάλογος διασκέψεων + + + +
+Επιλέξτε έναν αριθμό δωματίου συνδιάσκεψης στα αριστερά για τις πληροφορίες σε εκείνη την συνδιάσκεψη +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_el/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_el/call_log_display.php new file mode 100644 index 00000000..2b8304b0 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Έμφάνιση Καταγραμμένων Κλήσεων"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten δεν ισχύει ή πρωτόκολλο $protocol δεν ισχύει\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_el/conf_exten_check.php new file mode 100644 index 00000000..28b806da --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Ελεγχος τηλ.σύνδεσης διάσκεψης"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten δεν ισχύει\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Κατάσταση: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ΚανάλιA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ΚανάλιA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$ΚανάλιA[$counter] ~"; + # echo "$ΚανάλιA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten δεν ισχύει or Exten $exten δεν ισχύει\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Διάσκεψη $conf_exten έχει καταχωρηθεί $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_el/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_el/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_el/inbound_popup.php new file mode 100644 index 00000000..564999e3 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +ΕΝΕΡΓΗ ΕΙΣΕΡΧΟΜΕΝΗ ΚΛΗΣΗ"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

ΕΝΕΡΓΗ ΕΙΣΕΡΧΟΜΕΝΗ ΚΛΗΣΗ

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid δεν ισχύει\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Κανάλι: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Κανάλι=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "ΣΥΝΗΘΕΙΑ - \n"; + + echo "
Αριθμός που καλέσατε: $row[8]
Σημειώσεις: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "ΚΛΕΙΣΙΜΟ - \n"; + echo "ΣΤΕΙΛΕ ΣΤΟ ΦΩΝΗΤΙΚΟ ΤΑΧΥΔΡΟΜΕΙΟ ΜΟΥ\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_el/live_exten_check.php new file mode 100644 index 00000000..e07c3cad --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Ελεγχος ενεργής τηλ.σύνδεσης"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten δεν ισχύει ή πρωτόκολλο $protocol δεν ισχύει\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ΚανάλιA[$loop_count] = "$row[0]"; + $ΚανάλιB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ΚανάλιA: $ΚανάλιA[$counter] ~"; + echo "ΚανάλιB: $ΚανάλιB[$counter] ~"; + echo "ΚανάλιBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ΚανάλιA: $ΚανάλιA[$counter] ~"; + echo "ΚανάλιB: $ΚανάλιB[$counter] ~"; + echo "ΚανάλιBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ΚανάλιA: $ΚανάλιA[$counter] ~"; + echo "ΚανάλιB: $ΚανάλιB[$counter] ~"; + echo "ΚανάλιBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ΚανάλιA: $ΚανάλιA[$counter] ~"; + echo "ΚανάλιB: $ΚανάλιB[$counter] ~"; + echo "ΚανάλιBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "ΚανάλιA: $ΚανάλιA[$counter] ~"; + echo "ΚανάλιB: $ΚανάλιB[$counter] ~"; + echo "ΚανάλιBtrunk: $ΚανάλιA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_el/manager_send.php new file mode 100644 index 00000000..5ccefdc6 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Ο διευθυντής στέλνει: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "ΒΟΗΘΕΙΑ";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten δεν ισχύει or queryCID $queryCID δεν ισχύει, Originate εντολή που δεν έγινε εισαγωγή\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate εντολή που στέλνεται για Exten $exten Κανάλι $channel στο $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "extenName $extenName πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nOriginateName Action μην σταλμένος\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "extenName $extenName πρέπει να τεθεί\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nOriginateNameVmail Action μην σταλμένος\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten δεν ισχύει or queryCID $queryCID δεν ισχύει, Originate εντολή που δεν έγινε εισαγωγή\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate εντολή που στέλνεται για Exten $exten Κανάλι $channel στο $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten δεν ισχύει or ext_context $ext_context or queryCID $queryCID δεν ισχύει, Hangup εντολή που δεν έγινε εισαγωγή\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Κανάλι $channel δεν ισχύει or queryCID $queryCID δεν ισχύει, Hangup εντολή που δεν έγινε εισαγωγή\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel δεν είναι ενεργό στο $call_server_ip, Checking Live Κανάλι...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Κανάλι $channel δεν είναι ενεργό στο $call_server_ip, Hangup εντολή που δεν έγινε εισαγωγή $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup εντολή που στέλνεται για Κανάλι $channel στο $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "auto_dial_level $auto_dial_level πρέπει να τεθεί\n"; + echo "campaign $campaign πρέπει να τεθεί\n"; + echo "uniqueid $uniqueid πρέπει να τεθεί\n"; + echo "lead_id $lead_id πρέπει να τεθεί\n"; + echo "\nRedirectVD Action μην σταλμένος\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "extenName $extenName πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "parkedby $parkedby πρέπει να τεθεί\n"; + echo "\nRedirectToPark Action μην σταλμένος\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nRedirectFromPark Action μην σταλμένος\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "extenName $extenName πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nRedirectName Action μην σταλμένος\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "extenName $extenName πρέπει να τεθεί\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nRedirectNameVmail Action μην σταλμένος\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "ExtraΚανάλι $extrachannel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nRedirect Action μην σταλμένος\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Δεν υπάρχει κενή διάσκεψη στο $server_ip, Redirect εντολή που δεν έγινε εισαγωγή\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Κανάλι $channel δεν είναι ενεργό στο $call_server_ip, Redirect εντολή που δεν έγινε εισαγωγή\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Κανάλι $channel δεν είναι ενεργό στο $server_ip, Redirect εντολή που δεν έγινε εισαγωγή\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra εντολή που στέλνεται για Κανάλι $channel and \nExtraΚανάλι $extrachannel\n to $exten στο $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra εντολή που στέλνεται για Κανάλι $channel στο $call_server_ip and \nExtraΚανάλι $extrachannel\n to $exten στο $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Μία από αυτές τις μεταβλητές δεν ισχύει:\n"; + echo "Κανάλι $channel πρέπει να είναι μεγαλύτερος από 2 χαρακτήρες\n"; + echo "queryCID $queryCID πρέπει να είναι μεγαλύτερος από 14 χαρακτήρες\n"; + echo "exten $exten πρέπει να τεθεί\n"; + echo "ext_context $ext_context πρέπει να τεθεί\n"; + echo "ext_priority $ext_priority πρέπει να τεθεί\n"; + echo "\nRedirect Action μην σταλμένος\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Κανάλι $channel δεν είναι ενεργό στο $server_ip, Redirect εντολή που δεν έγινε εισαγωγή\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect εντολή που στέλνεται για Κανάλι $channel στο $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Κανάλι $channel δεν ισχύει or queryCID $queryCID δεν ισχύει or filename: $filename δεν ισχύει, $ACTION εντολή που δεν έγινε εισαγωγή\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Κανάλι $channel δεν είναι ενεργό στο $server_ip, $ACTION εντολή που δεν έγινε εισαγωγή\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION εντολή που στέλνεται για Κανάλι $channel στο $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Κανάλι $channel δεν ισχύει or exten $exten δεν ισχύει or filename: $filename δεν ισχύει, $ACTION εντολή που δεν έγινε εισαγωγή\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going στο in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION εντολή που στέλνεται για Κανάλι $channel στο $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n Η ΚΑΤΑΓΡΑΦΗ ΘΑ ΔΙΑΡΚΕΣΕΙ ΜΕΧΡΙ 60 ΛΕΠΤΑ\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_el/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_el/park_calls_display.php new file mode 100644 index 00000000..cfaee591 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Εμφάνιση Σταθμευμένων Κλήσεων"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten δεν ισχύει ή πρωτόκολλο $protocol δεν ισχύει\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_el/vdc_db_query.php new file mode 100644 index 00000000..0274d9e2 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Κώδικας ερώτησης βάσεων δεδομένων"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Επιλογή ομάδας $closer_choice δεν ισχύει\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Επιλογή ομάδας $closer_choice έχει καταχωρηθεί στο χρήστη $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "ΚΕΝΟΣ HOPPER\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context δεν ισχύει\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC ΑΡΙΘΜΟΣ\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INΚΛΗΣΗ + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "ΚΕΝΟΣ HOPPER\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context δεν ισχύει\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INΚΛΗΣΗ + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "ΚΛΗΣΗ NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context δεν ισχύει\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID δεν ισχύει\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "ΔΕΝ ΕΓΙΝΕ ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΚΑΤΑΓΡΑΦΗ ΓΕΓΟΝΟΤΩΝ\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign δεν ισχύει\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Εισαγωγή : $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "ΔΕΝ ΕΓΙΝΕ ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΚΑΤΑΓΡΑΦΗ ΓΕΓΟΝΟΤΩΝ\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "ΚΛΗΣΗ_LOG Εισαγωγή : $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "ΔΕΝ ΕΓΙΝΕ ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΚΑΤΑΓΡΑΦΗ ΓΕΓΟΝΟΤΩΝ\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "ΔΕΝ ΕΓΙΝΕ ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΚΑΤΑΓΡΑΦΗ ΓΕΓΟΝΟΤΩΝ\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id δεν ισχύει\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "ΔΕΝ ΕΓΙΝΕ ΕΙΣΑΓΩΓΗ ΣΤΗΝ ΚΑΤΑΓΡΑΦΗ ΓΕΓΟΝΟΤΩΝ\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Εκστρατεία $campaign δεν ισχύει\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INΚΛΗΣΗ in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INΚΛΗΣΗ + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INΚΛΗΣΗ + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INΚΛΗΣΗ + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send στο to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If ΚΛΗΣΗBK, change vicidial_callback record to INACTIVE + if ($dispo == 'ΚΛΗΣΗBK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user στο $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten δεν ισχύει\n"; + exit; + } +else + { + ##### Insert a ΑΠΟΣΥΝΔΕΣΗ record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','ΑΠΟΣΥΝΔΕΣΗ','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation στο the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id δεν ισχύει\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### ΚΛΗΣΗBACK ENTRY + if ( ($dispo_choice == 'CBHΠΑΛΑΙΟ') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' έχει αλλαχτεί ' . $dispo_choice . " Κατάσταση\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id δεν ισχύει\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id οι πληροφορίες έχουν ενημερωθεί\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage δεν ισχύει\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' είναι τώρα στη κατάσταση ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list δεν ισχύει\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_el/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_el/vicidial.php new file mode 100644 index 00000000..126d3070 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Έχετε αποσυνδεθεί. Σας ευχαριστούμε\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of δευτερόλεπτα for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "VICIΚΛΗΣΗ web client: Επανασύνδεση\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Ελληνικά
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Επανασύνδεση
 
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:
Σύνδεση χρήστη:
Κωδικός πρόσβασης χρήστη:
Εκστρατεία: $camp_form_code

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "VICIΚΛΗΣΗ web client: Σύνδεση εκστρατείας\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Σύνδεση χρήστη

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Σύνδεση εκστρατείας
 
Σύνδεση χρήστη:
Κωδικός πρόσβασης χρήστη:
Εκστρατεία: $camp_form_code

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "VICIΚΛΗΣΗ web client: Σύνδεση\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Σύνδεση
 
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:
Σύνδεση χρήστη:
Κωδικός πρόσβασης χρήστη:
Εκστρατεία: $camp_form_code

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "VICIΚΛΗΣΗ web client: Σύνδεση Τηλεφώνου\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Ελληνικά
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Σύνδεση Τηλεφώνου
 
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_δευτερόλεπτα=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Η εκστρατεία είναι μη ενεργή, παρακαλώ προσπαθήστε πάλι
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Η σύνδεση δεν είναι σωστή, παρακαλώ προσπαθήστε πάλι
"; + } + } + if ($VDloginDISPLAY) + { + echo "VICIΚΛΗΣΗ web client: Σύνδεση εκστρατείας\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Σύνδεση εκστρατείας
 
Σύνδεση χρήστη:
Κωδικός πρόσβασης χρήστη:
Εκστρατεία: $camp_form_code

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "VICIΚΛΗΣΗ web client: Σύνδεση Τηλεφώνου Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Σύνδεση Error
 
Συγγνώμη, αλλά η τηλεφωνική σύνδεση και ο κωδικός πρόσβασής σας δεν είναι ενεργά σε αυτό το σύστημα, παρακαλώ προσπαθήστε πάλι:
 
Σύνδεση Τηλεφώνου:
Κωδικός πρόσβασης Τηλεφώνου:

ΕΚΔΟΣΗ: $version       ΔΗΜΙΟΥΡΓΙΑ: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "VICIΚΛΗΣΗ web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed στο this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login στο phone: $SIP_user στην εκστρατεία: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a ΝΕΟ record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "VICIΚΛΗΣΗ web client: VICIΚΛΗΣΗ Σύνδεση εκστρατείας\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "Συγγνώμη, δεν υπάρχουν οδηγοί στον hopper για αυτήν την εκστρατεία\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Σύνδεση: \n
"; + echo "Κωδικός πρόσβασης:
\n"; + echo "Εκστρατεία: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "VICIΚΛΗΣΗ web client: VICIΚΛΗΣΗ Σύνδεση εκστρατείας\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Ελληνικά
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Σύνδεση: \n
"; + echo "Κωδικός πρόσβασης:
\n"; + echo "Εκστρατεία: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +ΑΠΟΣΥΝΔΕΣΗ\n"; ?> +
+
+ + + + + + + + +
VICIΚΛΗΣΗSCRIPT   LIVE     ID εργασίας: Ενεργή κλήση
+
+ + + + +

VICIΚΛΗΣΗ
+
+ + +ΧΕΙΡ.ΚΛΗΣΗ
+
+ + +X ΕΝΕΡΓΕΣ ΕΠΑΝΑΚΛΗΣΕΙΣ
+
+ + +
ΕΠΑΝΑΚΛΗΣΕΙΣ ΓΙΑ ΤΟΝ ΧΕΙΡΙΣΤΗ :
Επιλέξτε μία επανάκληση παρακάτω για να καλέσετε τον πελάτη τώρα. Εάν επιλέξετε μία εγγραφή παρακάτω, θα διαγραφεί από την λίστα. +
+
+
  + Ανανέωση +                 + Επιστροφή +
+
+ + +
ΝΕΑ ΧΕΙΡΟΚΙΝΗΤΗ ΚΛΗΣΗ ΟΔΗΓΟΥ ΓΙΑ :

Καταχωρήστε τις πληροφορίες παρακάτω για τον νέο οδηγό που επιθυμήτε να καλέσετε. +
+ \n"; + } + ?> + Σημείωση: όλες οι νέες χειροκίνητες κλήσεις θα πάνε στην λίστα 999

+ + + + + + + + + + + + + + + +
Κωδικός Κλήσης:   (Αυτό είναι συνήθως ένα 1 στις ΗΠΑ)
Τηλ Number:   (10 ψηφία μόνο)
Αναζήτηση Οδηγών:   (Η επιλογή αυτή επιτρέπει να βρει τον αριθμό στο σύστημα προτού γίνει εισαγωγή ως νέος οδηγός)


Εάν θέλετε να καλέσετε έναν αριθμό και να μην προστεθεί ως νέος οδηγός, καταχωρήστε τον με την σωστή μορφή στο πεδίο Αγνόησε Κλήση παρακάτω. Για να κλείσετε αυτή την κλήση θα πρέπει να ανοίξετε το ΚΛΗΣΕΙΣ ΣΕ ΑΥΤΗ ΤΗΝ ΔΙΑΙΔΚΑΣΙΑ στο κάτω μέρος της οθόνης και να την κλείσετε επιλέγοντας το κανάλι.
 
Αγνόησε Κλήση:   (παρακαλώ μόνο ψηφία)
+
+ Κάλεσε Τώρα +                 + Επιστροφή +
+
+ + + + +Your Κατάσταση:
Calls Dialing: +
+ + + + + +
+ + Μεταφορά - διάσκεψη
+ ΕΣΩΤΕΡΙΚΟΣ CLOSER + ΤΟΠΙΚΟΣ CLOSER + CODE + Κλείσιμο Γραμμής Xfer + Κλείσιμο και τις δύο γραμμές + +
+ + Αριθμός για κλήση   + δευτερόλεπτα   + channel + + OVERRIDE   + D1 + D2 +
+ + Κλήση με τον πελάτη + Στάθμευση κλήσης πελάτη + ΑΠΟΧΩΡΗΣΗ 3WAY ΚΛΗΣΗΣ + Τυφλή μεταφορά κλήσης + Blind Transfer VMail Message +
+
+
+ + + + +
Τερματισμό Καθοδήγησης όπως:

+ -
+
+
+ + + + + + + +
Πλήκτρα κλειδιά Τερματισμού: + Όταν είναι ενεργό, πιέστε απλά το πλήκτρο κλειδί για τον επιθυμητό τερματισμό της κλήσης. Η κλήση θα τρεματίσει αυτόματα:
+ + + + + +
+
+ + +
Κανένας δεν είναι στη σύνοδό σας:
+ Επιστροφή +

+ Ξανακάλεσε τον Χειριστή +
+
+ + +
Ο πελάτης έχει κλείσει το τηλέφωνο:
+ Επιστροφή +

+ Τελείωσε και Τερμάτισε την Κλήση + +
+
+ + +
Τύλιγμα Κλήσης: απομύνοντα δευτερόλεπτα σε τύλιγμα

+ +

+ Τελείωμα Τυλίγματος και προχωράει + +
+
+ + +

ΑΠΟΣΥΝΔΕΣΗ
+
+ + +
+
+ + +
 
+
+ + +
Οποιεσδήποτε αλλαγές που γίνονται στις πληροφορίες πελατών κατωτέρω αυτή τη στιγμή δεν θα είναι, πρέπει να αλλάξετε τις πληροφορίες πελατών ενώπιον σας Hangup η κλήση.
+
+ + +
Τερματισμός Κλήσης :       Ξανακλήσε       ελαχιστοποιήστε
+ Επιλογή τερματισμού της κλήσης +
+ ΤΕΡΜΑΤΙΣΜΟΣ ΚΛΗΣΗΣ
+ ΕΠΑΝΑΦΟΡΑ | + ΥΠΟΒΑΛΕΤΕ +

+ WEB FORM ΥΠΟΒΑΛΕΤΕ +

  +
+
+ + + +
Επιλέξτε μια ημερομηνία CallBack :
+ + + Επιλέξτε μια ημερομηνία κατωτέρω   +     + Hour: +   + Minutes: +   + +  
+ ΜΟΝΟ ΤΗΝ ΕΠΑΝΑΚΛΗΣΗ ΜΟΥ
";} + ?> + Σχόλια CB:

+ + ΥΠΟΒΑΛΕΤΕ

+ +

  +
+
+ + +
CLOSER ΕΙΣΕΡΧΟΜΕΝΗ ΕΠΙΛΟΓΗ ΟΜΑΔΑΣ
+ Επιλογή Closer εισερχόμενης ομάδας +
+ ΣΥΝΔΥΑΣΜΕΝΗ ΚΛΗΣΗ(εξερχόμενες ενεργοποιημένες)
+ ΕΠΑΝΑΦΟΡΑ | + ΥΠΟΒΑΛΕΤΕ +



  +
+
+ + + + Κανάλι + Κανάλι + ΜΟΝΟ ΤΗΝ ΕΠΑΝΑΚΛΗΣΗ ΜΟΥ
";} + ?> +
+ + + + + + + +
ΜΕΤΑΦΟΡΑ ΕΝΕΡΓΗΣ ΚΛΗΣΗΣ
Κανάλι που μεταφέρεται: Κανάλι
Τηλ.συνδέσεις:
Επιλογές τηλ. συνδέσεων
+
+ Στείλε στην επιλεγμένη τηλ.σύνδεση

+ Στείλε στο επιλεγμένο vmail

+ Στείλε σε αυτόν τον αριθμό:


+ ΑΝΑΝΕΩΣΗ


+ Επιστροφή

+
Διασκέψεις:
(επιλέξτε έναν αριθμό κατωτέρω που θα σταλεί σε μια διάσκεψη)
Στείλε το κανάλι μου επίσης
Επιλογές διασκέψεων
+
+ + + + +
VICIΚΛΗΣΗ SCRIPT
+
+ + + + + + + + + + + + + + + + + +
ΚΑΤΑΣΤΑΣΗ:
+
+Κλήση επόμενου αριθμού
+ ΠΡΟΒΟΛΗ ΟΔΗΓΟΥ
+ ΚΛΗΣΗ ENAΛ/ΚΟΥ ΤΗΛΕΦΩΝΟΥ
+ + +ΑΡΧΕΙΟ ΗΧΟΓΡ:
+
+
+ΤΑΥΤΟΤΗΤΑ ΕΓΓΡΑΦΗΣ:
+
+ +Εναρξη ηχογράφισης
+
+Σελίδα Διαδικτύου
+
+Στάθμευση Κλήσης
+Μεταφορά - διάσκεψη
+
+΄Κλείσιμο Πελάτη
+
+Στείλε DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
δευτερόλεπτα:   Κανάλι:   Χρόνος Πελάτη:
Πληροφορίες Πελάτη:
Τίτλος:   Πρώτο:   Μσ:  Επίθετο:
Διεύθυνση1:
Διεύθυνση2:   Διεύθυνση3:
Πόλη:   Κράτος:   Ταχ.Κωδ.:
Επαρχία:   ID προμηθευτού:
Τηλ:   Κωδικός Κλήσης:   Εναλ/κό Τηλ:
Παρουσίαση:   Ηλεκτρονικό ταχυδρομείο:
Σχόλια:
+ +
+


  + +
+ + + + +
Έκδοση VICIΚΛΗΣΗ:     ΔΗΜΙΟΥΡΓΙΑ:               Κεντρικός υπολογιστής:              
+Παρουσίαση πληροφοριών κλήσης καναλιού διασκέψης
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +ΠΛΗΚΤΡΑ ΚΛΕΙΔΙΑ ΑΝΕΝΕΡΓΑ + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_el/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_el/voicemail_check.php new file mode 100644 index 00000000..fb48dfb4 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_el/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Ακυρο Όνομα χρήστη/Κωδικός πρόσβασης: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Ακυρο server_ip: |$server_ip| or Ακυρο session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Ακυρο session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Έλεγχος φωνητικού ταχυδρομείου"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "Κουτί φωνητικού ταχυδρομείου $vmail_box δεν ισχύει\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_en/active_list_refresh.php new file mode 100644 index 00000000..dd977642 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "List Display: "; +if ($ADD==1) {echo "Live Extensions";} +if ($ADD==2) {echo "Busy Extensions";} +if ($ADD==3) {echo "Outside Lines";} +if ($ADD==4) {echo "Local Extensions";} +if ($ADD==5) {echo "Conferences";} +if ($ADD==99999) {echo "HELP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_en/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_en/astguiclient.php new file mode 100644 index 00000000..7da5ee3e --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "astGUIclient web client: Login\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
User Login:
User Password:
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "astGUIclient web client: Phone Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Español
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone Login
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "astGUIclient web client: Phone Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Phone Login
 
Sorry, your phone login and password are not active in this system, please try again:
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "astGUIclient web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +LOGOUT
\n"; ?> +
Main PanelActive Lines PanelConferences PanelCheck VoicemailLive Call
+
+ + +

Logout
+
+ + +
TRUNK HANGUP

+ Active Trunks Menu
+ Hangup Trunk   |   + Hijack Trunk   |   + Listen Trunk   |   + Refresh   |   + Back to Main Window +
+
+ + +
LOCAL HANGUP

+ Active Local Menu
+ Hangup Local   |   + Hijack Local   |   + Listen Local   |   + Refresh   |   + Back to Main Window +
+
+ + + + + + + +
LIVE CALL TRANSFER
Channel to be transferred: Channel
Extensions:
Extensions Menu
+
+ Send to selected extension

+ Send to selected vmail box

+ Send to this number:


+ Refresh


+ Back to Main Window

+
Conferences:
(click on a number below to send to a conference)
Send my channel too
Conferences Menu
+
+ + + + + +
LOCAL Extensions Dial
Phone calling from: Channel
Extensions:
Extensions Menu
+
+ Call selected extension

+ Call selected vmail box

+ Refresh


+ Back to Main Window

+
+
+ + +
PARKED CALLS:
+ Back to Main Window

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NEW:     OLD:             MANUAL DIAL       DIAL
PARKED CALLS: 0                LOCAL DIAL EXTENSIONS
OUTBOUND CALLS:
INBOUND CALLS:
astGUIclient web-client VERSION: BUILD:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITES       edit
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITES

 
SUBMIT FAVORITES CHANGES - requires logout
BACK TO MAIN WINDOW - ignore changes made
+
+ +
+ + + + + + + + + + + + + +
+PAUSE | START     Refresh rate: 1000 ms Faster | Slower

+
Initializing..
+
Active Extensions
+REFRESH | +ORDER | +
Outside Lines
+REFRESH | +ORDER | +
Local Extensions
+REFRESH | +ORDER | +
+ Data Goes Here

+
+ Data Goes Here

Trunk Action +
+ Data Goes Here

Local Action +
+
+ + + + +
+ + +Conferences List + + + +
+Click on a conference room number on the left for info on that conference +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_en/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_en/call_log_display.php new file mode 100644 index 00000000..4abec74d --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Call Log Display"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_en/conf_exten_check.php new file mode 100644 index 00000000..1f93e8ec --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Conf Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten is not valid\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Status: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$ChannelA[$counter] ~"; + # echo "$ChannelA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten is not valid or Exten $exten is not valid\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conference $conf_exten has been registered to $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_en/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_en/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_en/inbound_popup.php new file mode 100644 index 00000000..e26c4496 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +LIVE INBOUND CALL"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

LIVE INBOUND CALL

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid is not valid\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Channel: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "CUSTOM - \n"; + + echo "
Number Dialed: $row[8]
Notes: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "HANGUP - \n"; + echo "SEND TO MY VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_en/live_exten_check.php new file mode 100644 index 00000000..e0ca96c8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Live Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ChannelA[$loop_count] = "$row[0]"; + $ChannelB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $ChannelA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_en/manager_send.php new file mode 100644 index 00000000..b934cbb8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Manager Send: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "HELP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten is not valid or queryCID $queryCID is not valid, Originate command not inserted\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nOriginateName Action not sent\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nOriginateNameVmail Action not sent\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten is not valid or queryCID $queryCID is not valid, Originate command not inserted\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten is not valid or ext_context $ext_context or queryCID $queryCID is not valid, Hangup command not inserted\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or queryCID $queryCID is not valid, Hangup command not inserted\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel is not live on $call_server_ip, Checking Live Channel...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup command sent for Channel $channel on $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "auto_dial_level $auto_dial_level must be set\n"; + echo "campaign $campaign must be set\n"; + echo "uniqueid $uniqueid must be set\n"; + echo "lead_id $lead_id must be set\n"; + echo "\nRedirectVD Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "parkedby $parkedby must be set\n"; + echo "\nRedirectToPark Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectFromPark Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectName Action not sent\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectNameVmail Action not sent\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "ExtraChannel $extrachannel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirect Action not sent\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Cannot find empty conference on $server_ip, Redirect command not inserted\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Channel $channel is not live on $call_server_ip, Redirect command not inserted\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra command sent for Channel $channel and \nExtraChannel $extrachannel\n to $exten on $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra command sent for Channel $channel on $call_server_ip and \nExtraChannel $extrachannel\n to $exten on $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirect Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for Channel $channel on $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or queryCID $queryCID is not valid or filename: $filename is not valid, $ACTION command not inserted\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $server_ip, $ACTION command not inserted\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION command sent for Channel $channel on $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or exten $exten is not valid or filename: $filename is not valid, $ACTION command not inserted\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going on in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION command sent for Channel $channel on $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n RECORDING WILL LAST UP TO 60 MINUTES\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_en/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_en/park_calls_display.php new file mode 100644 index 00000000..246591b1 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Parked Calls Display"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_en/vdc_db_query.php new file mode 100644 index 00000000..ef287987 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Invalid Username/Password: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Database Query Script"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Group Choice $closer_choice is not valid\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Group Choice $closer_choice has been registered to user $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "HOPPER EMPTY\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUMBER\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "HOPPER EMPTY\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "CALL NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID is not valid\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "LOG NOT ENTERED\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign is not valid\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inserted: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOG NOT ENTERED\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CALL_LOG Inserted: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "LOG NOT ENTERED\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "LOG NOT ENTERED\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id is not valid\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "LOG NOT ENTERED\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campaign $campaign is not valid\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INCALL + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INCALL + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send on to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If CALLBK, change vicidial_callback record to INACTIVE + if ($dispo == 'CALLBK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user on $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten is not valid\n"; + exit; + } +else + { + ##### Insert a LOGOUT record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation on the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id is not valid\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### CALLBACK ENTRY + if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' has been changed to ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id is not valid\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id information has been updated\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage is not valid\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' is now in status ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list is not valid\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_en/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_en/vicidial.php new file mode 100644 index 00000000..cfaf680d --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "You have now logged out. Thank you\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of seconds for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "VICIDIAL web client: Re-Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Español
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Login
 
Phone Login:
Phone Password:
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "VICIDIAL web client: Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

User Login

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Campaign Login
 
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "VICIDIAL web client: Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
Phone Login:
Phone Password:
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "VICIDIAL web client: Phone Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Español
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone Login
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_seconds=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Campaign not active, please try again
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Login incorrect, please try again
"; + } + } + if ($VDloginDISPLAY) + { + echo "VICIDIAL web client: Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Campaign Login
 
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "VICIDIAL web client: Phone Login Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login Error
 
Sorry, your phone login and password are not active in this system, please try again:
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "VICIDIAL web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed on this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login on phone: $SIP_user to campaign: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "VICIDIAL web client: VICIDIAL Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "Sorry, there are no leads in the hopper for this campaign\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Password:
\n"; + echo "Campaign: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "VICIDIAL web client: VICIDIAL Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Password:
\n"; + echo "Campaign: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +LOGOUT\n"; ?> +
+
+ + + + + + + + +
VICIDIALSCRIPT   LIVE     session ID: Live Call
+
+ + + + +

VICIDIAL
+
+ + +MANUAL DIAL
+
+ + +X ACTIVE CALLBACKS
+
+ + +
CALLBACKS FOR AGENT :
Click on a callback below to call the customer back now. If you click on a record below to call it, it will be removed from the list. +
+
+
  + Refresh +                 + Go Back +
+
+ + +
NEW MANUAL DIAL LEAD FOR :

Enter information below for the new lead you wish to call. +
+ \n"; + } + ?> + Note: all new manual dial leads will go into list 999

+ + + + + + + + + + + + + + + +
Dial Code:   (This is usually a 1 in the USA-Canada)
Phone Number:   (10 digits max - digits only)
Search Existing Leads:   (This option if checked will attempt to find the phone number in the system before inserting it as a new lead)


If you want to dial a number and have it NOT be added as a new lead, enter in the exact dialstring that you want to call in the Dial Override field below. To hangup this call you will have to open the CALLS IN THIS SESSION link at the bottom of the screen and hang it up by clicking on its channel link there.
 
Dial Override:   (digits only please)
+
+ Dial Now +                 + Go Back +
+
+ + + + +Your Status:
Calls Dialing: +
+ + + + + +
+ + Transfer - Conference
+ INTERNAL CLOSER + LOCAL CLOSER + CODE + Hangup Xfer Line + Hangup Both Lines + +
+ + Number to call   + seconds   + channel + + OVERRIDE   + D1 + D2 +
+ + Dial With Customer + Park Customer Dial + LEAVE 3-WAY CALL + Dial Blind Transfer + Blind Transfer VMail Message +
+
+
+ + + + +
Lead Dispositioned As:

+ -
+
+
+ + + + + + + +
Disposition Hot Keys: + When active, simply press the keyboard key for the desired disposition for this call. The call will then be hungup and dispositioned automatically:
+ + + + + +
+
+ + +
Noone is in your session:
+ Go Back +

+ Call Agent Again +
+
+ + +
Customer has hung up:
+ Go Back +

+ Finish and Disposition Call + +
+
+ + +
Call Wrapup: seconds remaining in wrapup

+ +

+ Finish Wrapup and Move On + +
+
+ + +

LOGOUT
+
+ + +
+
+ + +
 
+
+ + +
Any changes made to the customer information below at this time will not be comitted, You must change customer information before you Hangup the call.
+
+ + +
DISPOSITION CALL :       Hangup Again       minimize
+ End-of-call Disposition Selection +
+ PAUSE AGENT DIALING
+ CLEAR FORM | + SUBMIT +

+ WEB FORM SUBMIT +

  +
+
+ + + +
Select a CallBack Date :
+ + + Select a Date Below   +     + Hour: +   + Minutes: +   + +  
+ MY CALLBACK ONLY
";} + ?> + CB Comments:

+ + SUBMIT

+ +

  +
+
+ + +
CLOSER INBOUND GROUP SELECTION
+ Closer Inbound Group Selection +
+ BLENDED CALLING(outbound activated)
+ RESET | + SUBMIT +



  +
+
+ + + + Channel + Channel + MY CALLBACK ONLY
";} + ?> +
+ + + + + + + +
LIVE CALL TRANSFER
Channel to be transferred: Channel
Extensions:
Extensions Menu
+
+ Send to selected extension

+ Send to selected vmail box

+ Send to this number:


+ REFRESH


+ Back to Main Window

+
Conferences:
(click on a number below to send to a conference)
Send my channel too
Conferences Menu
+
+ + + + +
VICIDIAL SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUS:
+
+Dial Next Number
+ LEAD PREVIEW
+ ALT PHONE DIAL
+ + +RECORDING FILE:
+
+
+RECORD ID:
+
+ +Start Recording
+
+Web Form
+
+Park Call
+Transfer - Conference
+
+Hangup Customer
+
+Send DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
seconds:   Channel:   Cust Time:
Customer Information:
Title:   First:   MI:   Last:
Address1:
Address2:   Address3:
City:   State:   PostCode:
Province:   Vendor ID:
Phone:   DialCode:   Alt. Phone:
Show:   Email:
Comments:
+ +
+


  + +
+ + + + +
VICIDIAL web-client version:     BUILD:               Server:              
+Show conference call channel information
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +HOT KEYS INACTIVE + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_en/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_en/voicemail_check.php new file mode 100644 index 00000000..9cc655c6 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_en/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Voicemail Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "voicemail box $vmail_box is not valid\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_es/active_list_refresh.php new file mode 100644 index 00000000..6813fdd1 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Mostrar Listas: "; +if ($ADD==1) {echo "Extensiones Activas";} +if ($ADD==2) {echo "Extensiones Ocupadas";} +if ($ADD==3) {echo "Líneas de salida";} +if ($ADD==4) {echo "Extensiones Locales";} +if ($ADD==5) {echo "Conferencias";} +if ($ADD==99999) {echo "AYUDA";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_es/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_es/astguiclient.php new file mode 100644 index 00000000..a0e69cf9 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Usted ahora ha registrado hacia fuera. Gracias\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "web client astGUIclient: Conexión\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conexión
 
Conexión Del Usuario:
Contraseña Del Usuario:
Conexión Del Teléfono:
Contraseña Del Teléfono:

VERSIÓN: $version       CONSTRUCCION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web client astGUIclient: Conexión Del Teléfono\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Español
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conexión Del Teléfono
 
Conexión Del Teléfono:
Contraseña Del Teléfono:

VERSIÓN: $version       CONSTRUCCION: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web client astGUIclient: Conexión Del Teléfono\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conexión Del Teléfono
 
Disculpe, la conexión del teléfono y contraseña no están activos en este sistema, intentelo otra vez por favor:
 
Conexión Del Teléfono:
Contraseña Del Teléfono:

VERSIÓN: $version       CONSTRUCCION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "web client astGUIclient\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +SALIR
\n"; ?> +
Pantalla PrincipalPantalla Lineas ActivasPantalla de ConferenciasComprobar buzón de vozLlamada Activa
+
+ + +

Logout
+
+ + +
TRUNK COLGAR

+ Active Trunks Menu
+ Colgar Trunk   |   + Capturar Trunk   |   + Escuchar Trunk   |   + Recarga   |   + Volver a la pantalla principal +
+
+ + +
Colgar Local

+ Menú Local Activa
+ Colgar Local   |   + Capturar Local   |   + Escuchar Local   |   + Recarga   |   + Volver a la pantalla principal +
+
+ + + + + + + +
TRANSFERIR LLAMADA ACTIVA
Canal que va a ser transferido: Canal
Extensiones:
Menú Extensiones
+
+ Envíe a la extensión seleccionada

+ Enviar al buzón de voz seleccionada

+ Envíe a este número:


+ Recarga


+ Volver a la pantalla principal

+
Conferencias:
(Pinchar en un número de abajo para enviar a una conferencia)
Enviar mi canal también
Menú de Conferencias
+
+ + + + + +
Marcar a Extensiones LOCALES
Teléfono llamando desde: Canal
Extensiones:
Menú Extensiones
+
+ Llamar extensión seleccionada

+ Llamar buzón de voz seleccionado

+ Recarga


+ Volver a la pantalla principal

+
+
+ + +
LLAMADAS APARCADAS:
+ Volver a la pantalla principal

+
+
+ + + + + + + + + + + + + + + +
  +
BUZÓN DE VOZ     NUEVO:     VIEJO:             MARCADO MANUAL       DIAL
LLAMADAS APARCADAS: 0                MARCAR EXTENSIONES LOCALES
LLAMADAS SALIENTES:
LLAMADAS ENTRANTES:
versión astGUIclient del tela-cliente: CONSTRUCCION:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITOS       corrija
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITOS

 
SOMETA LOS CAMBIOS de los FAVORITOS - requiere registro de estado de la máquina
DE NUEVO A VENTANA PRINCIPAL - no haga caso de los cambios realizados
+
+ +
+ + + + + + + + + + + + + +
+PAUSA | COMIENZO     Actualizar la tarifa: 1000 ms Más rápido | Más lento

+
Inizializando..
+
Extensiones Activas
+ACTUALIZAR | +ORDEN | +
Líneas de salida
+ACTUALIZAR | +ORDEN | +
Extensiones Locales
+ACTUALIZAR | +ORDEN | +
+ Los Datos Van Aquí

+
+ Los Datos Van Aquí

Acciones en Trunk +
+ Los Datos Van Aquí

Acción Local +
+
+ + + + +
+ + +Lista De las Conferencias + + + +
+Pinchar a la izquierda del número de una sala de conferencias para obtener información +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_es/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_es/call_log_display.php new file mode 100644 index 00000000..f6c36dff --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Motrar el registro de llamadas"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten No es válido o protocolo $protocol No es válido\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_es/conf_exten_check.php new file mode 100644 index 00000000..08a640e3 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Comprobar la Extensión de Conf"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten No es válido\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Estado: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $CanalA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $CanalA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$CanalA[$counter] ~"; + # echo "$CanalA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten No es válido or Exten $exten No es válido\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conferencia $conf_exten Ha sido registrado para $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_es/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_es/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_es/inbound_popup.php new file mode 100644 index 00000000..fe5e79b5 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +LLAMADA DE ENTRADA ACTIVA"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

LLAMADA DE ENTRADA ACTIVA

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid No es válido\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Canal: $row[1]
LlamadorID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Canal=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "A MEDIDA - \n"; + + echo "
Número Marcado: $row[8]
Notas: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "COLGAR - \n"; + echo "ENVIAR A MI BUZÓN DE VOZ\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_es/live_exten_check.php new file mode 100644 index 00000000..912854ad --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Comprobar Extensión Activa"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten No es válido o protocolo $protocol No es válido\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $CanalA[$loop_count] = "$row[0]"; + $CanalB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "CanalA: $CanalA[$counter] ~"; + echo "CanalB: $CanalB[$counter] ~"; + echo "CanalBtrunk: $CanalA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_es/manager_send.php new file mode 100644 index 00000000..930f11d9 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Enviar al Manager: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "AYUDA";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten No es válido or queryCID $queryCID No es válido, Originate comando no insertado\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate comando enviado a Exten $exten Canal $channel en $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "extenName $extenName debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nOriginateName Action no enviado\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "extenName $extenName debe ser fijado\n"; + echo "exten $exten debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nOriginateNameVmail Action no enviado\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten No es válido or queryCID $queryCID No es válido, Originate comando no insertado\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate comando enviado a Exten $exten Canal $channel en $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten No es válido or ext_context $ext_context or queryCID $queryCID No es válido, Hangup comando no insertado\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Canal $channel No es válido or queryCID $queryCID No es válido, Hangup comando no insertado\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel no está activo en $call_server_ip, Checking Live Canal...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Canal $channel no está activo en $call_server_ip, Hangup comando no insertado $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup comando enviado a Canal $channel en $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "exten $exten debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "auto_dial_level $auto_dial_level debe ser fijado\n"; + echo "campaign $campaign debe ser fijado\n"; + echo "uniqueid $uniqueid debe ser fijado\n"; + echo "lead_id $lead_id debe ser fijado\n"; + echo "\nRedirectVD Action no enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='TRANSFERENCIA' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='TRANSFERENCIA' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "exten $exten debe ser fijado\n"; + echo "extenName $extenName debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "parkedby $parkedby debe ser fijado\n"; + echo "\nRedirectToPark Action no enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "exten $exten debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nRedirectFromPark Action no enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "extenName $extenName debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nRedirectName Action no enviado\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "extenName $extenName debe ser fijado\n"; + echo "exten $exten debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nRedirectNameVmail Action no enviado\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "ExtraCanal $extrachannel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "exten $exten debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nRedirect Action no enviado\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "No puede encontrar conferencia vacía en $server_ip, Redirect comando no insertado\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Canal $channel no está activo en $call_server_ip, Redirect comando no insertado\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Canal $channel no está activo en $server_ip, Redirect comando no insertado\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra comando enviado a Canal $channel and \nExtraCanal $extrachannel\n to $exten en $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra comando enviado a Canal $channel en $call_server_ip and \nExtraCanal $extrachannel\n to $exten en $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una de estas variables No es válido:\n"; + echo "Canal $channel debe ser mayor de 2 caracteres\n"; + echo "queryCID $queryCID debe ser mayor de 14 caracteres\n"; + echo "exten $exten debe ser fijado\n"; + echo "ext_context $ext_context debe ser fijado\n"; + echo "ext_priority $ext_priority debe ser fijado\n"; + echo "\nRedirect Action no enviado\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Canal $channel no está activo en $server_ip, Redirect comando no insertado\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect comando enviado a Canal $channel en $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Canal $channel No es válido or queryCID $queryCID No es válido or filename: $filename No es válido, $ACTION comando no insertado\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Canal $channel no está activo en $server_ip, $ACTION comando no insertado\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION comando enviado a Canal $channel en $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Canal $channel No es válido or exten $exten No es válido or filename: $filename No es válido, $ACTION comando no insertado\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going en in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION comando enviado a Canal $channel en $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n LA GRABACIÓN DURARÁ HASTA 60 MINUTOS\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_es/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_es/park_calls_display.php new file mode 100644 index 00000000..0f8c81ab --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Mostrar Llamadas Aparcadas"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten No es válido o protocolo $protocol No es válido\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_es/vdc_db_query.php new file mode 100644 index 00000000..feeb72be --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Database Query Script"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Opción Del Grupo $closer_choice No es válido\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Opción Del Grupo $closer_choice se ha registrado al usuario $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "TOLVA VACÍA\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context No es válido\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NÚMERO\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INLLAMADA + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "TOLVA VACÍA\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context No es válido\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INLLAMADA + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LLAMADA NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context No es válido\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID No es válido\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "REGISTRO NO ENTRADO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign No es válido\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Insertado: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "REGISTRO NO ENTRADO\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "LLAMADA_LOG Insertado: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "REGISTRO NO ENTRADO\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "REGISTRO NO ENTRADO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id No es válido\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "REGISTRO NO ENTRADO\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campaña $campaign No es válido\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INLLAMADA in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INLLAMADA + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INLLAMADA + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INLLAMADA + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send en to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If LLAMADABK, change vicidial_callback record to INACTIVE + if ($dispo == 'LLAMADABK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user en $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten No es válido\n"; + exit; + } +else + { + ##### Insert a SALIR record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','SALIR','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation en the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id No es válido\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### LLAMADABACK ENTRY + if ( ($dispo_choice == 'CBHVIEJO') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' se ha cambiado a ' . $dispo_choice . " Estado\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id No es válido\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id La información ha sido actualizada\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage No es válido\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' ahora está en estado ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list No es válido\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_es/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_es/vicidial.php new file mode 100644 index 00000000..d70ec0f4 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Usted ahora ha registrado hacia fuera. Gracias\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of segundos for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "web client VICIDIAL: Conexión Otra Vez\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Español
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conexión Otra Vez
 
Conexión Del Teléfono:
Contraseña Del Teléfono:
Conexión Del Usuario:
Contraseña Del Usuario:
Campaña: $camp_form_code

VERSIÓN: $version       CONSTRUCCION: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "web client VICIDIAL: Conexión en la Campaña\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Conexión Del Usuario

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conexión en la Campaña
 
Conexión Del Usuario:
Contraseña Del Usuario:
Campaña: $camp_form_code

VERSIÓN: $version       CONSTRUCCION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "web client VICIDIAL: Conexión\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conexión
 
Conexión Del Teléfono:
Contraseña Del Teléfono:
Conexión Del Usuario:
Contraseña Del Usuario:
Campaña: $camp_form_code

VERSIÓN: $version       CONSTRUCCION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web client VICIDIAL: Conexión Del Teléfono\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Español
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conexión Del Teléfono
 
Conexión Del Teléfono:
Contraseña Del Teléfono:

VERSIÓN: $version       CONSTRUCCION: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_segundos=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "La campaña no está activa, intentelo otra vez, por favor
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "La conexión incorrecta, intentelo otra vez, por favor
"; + } + } + if ($VDloginDISPLAY) + { + echo "web client VICIDIAL: Conexión en la Campaña\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conexión en la Campaña
 
Conexión Del Usuario:
Contraseña Del Usuario:
Campaña: $camp_form_code

VERSIÓN: $version       CONSTRUCCION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web client VICIDIAL: Conexión Del Teléfono Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Conexión Error
 
Disculpe, la conexión del teléfono y contraseña no están activos en este sistema, intentelo otra vez por favor:
 
Conexión Del Teléfono:
Contraseña Del Teléfono:

VERSIÓN: $version       CONSTRUCCION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "web client VICIDIAL\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $LlamadorID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed en this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login en phone: $SIP_user a la campaña: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NUEVO record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "web client VICIDIAL: VICIDIAL Conexión en la Campaña\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "Lo siento, no hay leads en el hopper de esta campaña\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Conexión: \n
"; + echo "Contraseña:
\n"; + echo "Campaña: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "web client VICIDIAL: VICIDIAL Conexión en la Campaña\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Español
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Conexión: \n
"; + echo "Contraseña:
\n"; + echo "Campaña: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +SALIR\n"; ?> +
+
+ + + + + + + + +
VICIDIALSCRIPT   LIVE     sesión ID: Llamada Activa
+
+ + + + +

VICIDIAL
+
+ + +MARCADO MANUAL
+
+ + +X SERVICIOS REPETIDOS ACTIVOS
+
+ + +
SERVICIOS REPETIDOS PARA EL AGENTE :
Chasque encendido un servicio repetido abajo ahora para llamar la parte posteriora del cliente. Si usted chasca encendido un expediente abajo para llamarlo, será quitado de la lista. +
+
+
  + Recarga +                 + Vaya Detrás +
+
+ + +
NUEVO PLOMO MANUAL DEL DIAL PARA :

Incorpore la información abajo para el nuevo plomo que usted desea llamar. +
+ \n"; + } + ?> + Nota: todos los nuevos plomos manuales del dial entrarán la lista 999

+ + + + + + + + + + + + + + + +
Dial Código:   (Éste es generalmente un 1 en los U.S.A. y el Canadá)
Teléfono Number:   (máximo de 10 dígitos - dígitos solamente)
Plomos Existentes De la Búsqueda:   (Esta opción si está comprobada procurará encontrar el número de teléfono en el sistema antes de insertarlo como nuevo plomo)


Si usted desea marcar un número y hacerlo no agregar como nuevo plomo, entre en dialstring exacto ese usted desean llamar en el campo de la invalidación del dial abajo. Al retraso esta llamada usted tendrá que abrir las LLAMADAS EN ESTE acoplamiento de la SESIÓN en el fondo de la pantalla y colgarlas para arriba chascando en su acoplamiento del canal allí.
 
Inválidoación Del Dial:   (los dígitos satisfacen solamente)
+
+ Dial Ahora +                 + Vaya Detrás +
+
+ + + + +Su Estado:
Calls Dialing: +
+ + + + + +
+ + Transferencia - Conferencia
+ CLOSER INTERNO + CLOSER LOCAL + CODE + Colgar Línea Xfer + Colgar Ambas Líneas + +
+ + Número a llamar   + segundos   + channel + + OVERRIDE   + D1 + D2 +
+ + Marcar Con El Cliente + Dial Del Cliente Del Parque + ABANDONAR LLAMADA 3-WAY + Marcar Blind Transfer + Blind Transfer VMail Message +
+
+
+ + + + +
Lead Dispositioned Como:

+ -
+
+
+ + + + + + + +
Teclas de acceso rápido a la Disposición: + Cuando esté activo, presione simplemente la tecla para la disposición deseada para esta llamada. La llamada después será colgada y dispositioned automáticamente:
+ + + + + +
+
+ + +
Nadie está en su sesión:
+ Vaya Detrás +

+ Agente De la Llamada Otra vez +
+
+ + +
El cliente ha colgado:
+ Vaya Detrás +

+ Final y llamada de la disposición + +
+
+ + +
Llamada Wrapup: segundos restantes en wrapup

+ +

+ Final Wrapup y movimiento encendido + +
+
+ + +

SALIR
+
+ + +
+
+ + +
 
+
+ + +
Cualquier cambio realizado al cliente que no será la información abajo en este tiempo comitted, usted debe cambiar la información del cliente antes de usted retraso la llamada.
+
+ + +
DISPOSITION LLAMADA :       Retraso Otra vez       reduzca al mínimo
+ selección de la disposición del End-of-call +
+ PARAR LA LLAMADA
+ REINICIAR | + ENVIAR +

+ WEB FORM ENVIAR +

  +
+
+ + + +
Seleccione una fecha del servicio repetido :
+ + + Seleccione una fecha abajo   +     + Hour: +   + Minutes: +   + +  
+ MI SERVICIO REPETIDO SOLAMENTE
";} + ?> + Comentarios de los CBES:

+ + ENVIAR

+ +

  +
+
+ + +
SELECCIÓN DEL GRUPO DE ENTRANTES CLOSER
+ SELECCIÓN DEL GRUPO DE ENTRANTES CLOSER +
+ BLENDED LLAMADAING(Salientes activdas)
+ REINICIAR | + ENVIAR +



  +
+
+ + + + Canal + Canal + MI SERVICIO REPETIDO SOLAMENTE
";} + ?> +
+ + + + + + + +
TRANSFERIR LLAMADA ACTIVA
Canal que va a ser transferido: Canal
Extensiones:
Menú Extensiones
+
+ Envíe a la extensión seleccionada

+ Enviar al buzón de voz seleccionada

+ Envíe a este número:


+ ACTUALIZAR


+ Volver a la pantalla principal

+
Conferencias:
(Pinchar en un número de abajo para enviar a una conferencia)
Enviar mi canal también
Menú de Conferencias
+
+ + + + +
VICIDIAL SCRIPT
+
+ + + + + + + + + + + + + + + + + +
ESTADO:
+
+Marcar el Siguiente Número
+ MOSTRAR LEAD
+ TELÉFONO DEL ALT
+ + +GRABANDO ARCHIVO:
+
+
+GRABACIÓN ID:
+
+ +Comenzar La Grabación
+
+Formulario Web
+
+Aparcar llamada
+Transferencia - Conferencia
+
+Colgar al Cliente
+
+Enviar DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
segundos:   Canal:   Tiempo:
Información Del Cliente:
Título:   Primero:   IM:   Último:
Dirección1:
Dirección2:   Dirección3:
Ciudad:   Estado:   Código Postal:
Provincia:   Vendedor ID:
Teléfono:   Código Del Dial:   Teléfono Alt:
Demostración:   Email:
Comentarios:
+ +
+


  + +
+ + + + +
versión web client VICIDIAL:     CONSTRUCCION:               Servidor:              
+Mostrar la información del canal Conferencia
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +TECLAS ACCESO RÁPIDO INACTIVAS + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_es/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_es/voicemail_check.php new file mode 100644 index 00000000..46db91bd --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_es/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Nombre del usuario/Contraseña: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Comprobar el buzón de voz"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "caja del buzón de voz $vmail_box No es válido\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_fr/active_list_refresh.php new file mode 100644 index 00000000..df742e06 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Affichage De Liste: "; +if ($ADD==1) {echo "Prolongements De phase";} +if ($ADD==2) {echo "Prolongements Occupés";} +if ($ADD==3) {echo "Lignes Extérieures";} +if ($ADD==4) {echo "Prolongements Locaux";} +if ($ADD==5) {echo "Conférences";} +if ($ADD==99999) {echo "AIDE";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_fr/astguiclient.php new file mode 100644 index 00000000..41513012 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Vous vous êtes maintenant déconnecté. Merci\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "web client astGUIclient: Ouverture\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Ouverture
 
Ouverture D'Utilisateur:
Mot de passe D'Utilisateur:
Ouverture De Téléphone:
Mot de passe De Téléphone:

VERSION: $version       CONSTRUCTION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICICADRAN|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICICADRAN|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web client astGUIclient: Ouverture De Téléphone\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Français
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Ouverture De Téléphone
 
Ouverture De Téléphone:
Mot de passe De Téléphone:

VERSION: $version       CONSTRUCTION: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web client astGUIclient: Ouverture De Téléphone\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Ouverture De Téléphone
 
Désolé, votre ouverture de téléphone et mot de passe ne soyez pas:
 
Ouverture De Téléphone:
Mot de passe De Téléphone:

VERSION: $version       CONSTRUCTION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "web client astGUIclient\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +DÉCONNEXION
\n"; ?> +
Panneau PrincipalLignes Actives PanneauPanneau De ConférencesVérifiez VoicemailVivent L'Appel
+
+ + +

Logout
+
+ + +
TRUNK DÉCROCHEMENT

+ Active Trunks Menu
+ Tronc De Décrochement   |   + Tronc De Détournement   |   + Écoutent Le Tronc   |   + Régénérez   |   + De nouveau à la fenêtre principale +
+
+ + +
DÉCROCHEMENT LOCAL

+ Menu Local Actif
+ Gens du pays De Décrochement   |   + Gens du pays De Détournement   |   + Écoutent Les Gens du pays   |   + Régénérez   |   + De nouveau à la fenêtre principale +
+
+ + + + + + + +
TRANSFERT DE PHASE D'APPEL
La Manche à transférer: LaManche
Prolongements:
Menu De Prolongements
+
+ Envoyez à la prolongation choisie

+ Envoyez dans la boîte choisie de vmail

+ Envoyez à ce nombre:


+ Régénérez


+ De nouveau à la fenêtre principale

+
Conférences:
(cliquez sur un nombre ci-dessous pour envoyer à une)
Envoyez mon canal aussi
Menu De Conférences
+
+ + + + + +
Cadran LOCAL De Prolongements
Téléphone appelant de: LaManche
Prolongements:
Menu De Prolongements
+
+ Prolongation choisie par appel

+ Boîte de vmail choisie par appel

+ Régénérez


+ De nouveau à la fenêtre principale

+
+
+ + +
APPELS GARÉS:
+ De nouveau à la fenêtre principale

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NOUVEAU:     VIEUX:             CADRAN MANUEL       CADRAN
APPELS GARÉS: 0                PROLONGEMENTS LOCAUX DE CADRAN
APPELS EN PARTANCE:
APPELS D'ARRIVÉE:
VERSION astGUIclient d'enchaînement-client: CONSTRUCTION:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORIS       éditez
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORIS

 
SOUMETTEZ LES CHANGEMENTS de FAVORIS - exige la déconnexion
DE NOUVEAU À LA FENÊTRE PRINCIPALE - ignorez les changements faits
+
+ +
+ + + + + + + + + + + + + +
+PAUSE | DÉBUT     La vitesse de régénération: 1000 ms Plus rapidement | Plus lent

+
Initialisation..
+
Prolongements Actifs
+RÉGÉNÉREZ | +ORDRE | +
Lignes Extérieures
+RÉGÉNÉREZ | +ORDRE | +
Prolongements Locaux
+RÉGÉNÉREZ | +ORDRE | +
+ Les Données Vont Ici

+
+ Les Données Vont Ici

Action De Tronc +
+ Les Données Vont Ici

Action Locale +
+
+ + + + +
+ + +Liste De Conférences + + + +
+Cliquez sur un nombre de salle de conférence du côté gauche +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_fr/call_log_display.php new file mode 100644 index 00000000..2d6379db --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Affichage De Notation D'Appel"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten est inadmissible ou protocole $protocol est inadmissible\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_fr/conf_exten_check.php new file mode 100644 index 00000000..ca269d5f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Contrôle De Prolongation De Conf"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten est inadmissible\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Statut: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $LaMancheA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $LaMancheA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$LaMancheA[$counter] ~"; + # echo "$LaMancheA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten est inadmissible or Exten $exten est inadmissible\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conférence $conf_exten a été enregistré à $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_fr/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_fr/inbound_popup.php new file mode 100644 index 00000000..558eb7f5 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +APPEL D'ARRIVÉE DE PHASE"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

APPEL D'ARRIVÉE DE PHASE

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid est inadmissible\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
LaManche: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_LaManche=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "COUTUME - \n"; + + echo "
Numéro Composé: $row[8]
Notes: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "DÉCROCHEMENT - \n"; + echo "ENVOYEZ À MON VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_fr/live_exten_check.php new file mode 100644 index 00000000..499b228d --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Contrôle De phase De Prolongation"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten est inadmissible ou protocole $protocol est inadmissible\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $LaMancheA[$loop_count] = "$row[0]"; + $LaMancheB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "LaMancheA: $LaMancheA[$counter] ~"; + echo "LaMancheB: $LaMancheB[$counter] ~"; + echo "LaMancheBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "LaMancheA: $LaMancheA[$counter] ~"; + echo "LaMancheB: $LaMancheB[$counter] ~"; + echo "LaMancheBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "LaMancheA: $LaMancheA[$counter] ~"; + echo "LaMancheB: $LaMancheB[$counter] ~"; + echo "LaMancheBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "LaMancheA: $LaMancheA[$counter] ~"; + echo "LaMancheB: $LaMancheB[$counter] ~"; + echo "LaMancheBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "LaMancheA: $LaMancheA[$counter] ~"; + echo "LaMancheB: $LaMancheB[$counter] ~"; + echo "LaMancheBtrunk: $LaMancheA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_fr/manager_send.php new file mode 100644 index 00000000..85887f16 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Le Directeur Envoient: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "AIDE";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten est inadmissible or queryCID $queryCID est inadmissible, Originate commande non insérée\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate commande envoyée pour Exten $exten LaManche $channel sur $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "extenName $extenName doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nOriginateName Action non envoyé\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "extenName $extenName doit être placé\n"; + echo "exten $exten doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nOriginateNameVmail Action non envoyé\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten est inadmissible or queryCID $queryCID est inadmissible, Originate commande non insérée\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate commande envoyée pour Exten $exten LaManche $channel sur $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten est inadmissible or ext_context $ext_context or queryCID $queryCID est inadmissible, Hangup commande non insérée\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "LaManche $channel est inadmissible or queryCID $queryCID est inadmissible, Hangup commande non insérée\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel n'est pas de phase sur $call_server_ip, Checking Live LaManche...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "LaManche $channel n'est pas de phase sur $call_server_ip, Hangup commande non insérée $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup commande envoyée pour LaManche $channel sur $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "exten $exten doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "auto_dial_level $auto_dial_level doit être placé\n"; + echo "campaign $campaign doit être placé\n"; + echo "uniqueid $uniqueid doit être placé\n"; + echo "lead_id $lead_id doit être placé\n"; + echo "\nRedirectVD Action non envoyé\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "exten $exten doit être placé\n"; + echo "extenName $extenName doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "parkedby $parkedby doit être placé\n"; + echo "\nRedirectToPark Action non envoyé\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "exten $exten doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nRedirectFromPark Action non envoyé\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "extenName $extenName doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nRedirectName Action non envoyé\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "extenName $extenName doit être placé\n"; + echo "exten $exten doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nRedirectNameVmail Action non envoyé\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "ExtraLaManche $extrachannel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "exten $exten doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nRedirect Action non envoyé\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Ne peut pas trouver la conférence vide sur $server_ip, Redirect commande non insérée\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "LaManche $channel n'est pas de phase sur $call_server_ip, Redirect commande non insérée\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "LaManche $channel n'est pas de phase sur $server_ip, Redirect commande non insérée\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra commande envoyée pour LaManche $channel and \nExtraLaManche $extrachannel\n to $exten sur $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra commande envoyée pour LaManche $channel sur $call_server_ip and \nExtraLaManche $extrachannel\n to $exten sur $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Une de ces variables est inadmissible:\n"; + echo "LaManche $channel doivent être les 2 caractères plus grands que\n"; + echo "queryCID $queryCID doivent être les 14 caractères plus grands que\n"; + echo "exten $exten doit être placé\n"; + echo "ext_context $ext_context doit être placé\n"; + echo "ext_priority $ext_priority doit être placé\n"; + echo "\nRedirect Action non envoyé\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "LaManche $channel n'est pas de phase sur $server_ip, Redirect commande non insérée\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect commande envoyée pour LaManche $channel sur $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "LaManche $channel est inadmissible or queryCID $queryCID est inadmissible or filename: $filename est inadmissible, $ACTION commande non insérée\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "LaManche $channel n'est pas de phase sur $server_ip, $ACTION commande non insérée\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION commande envoyée pour LaManche $channel sur $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "LaManche $channel est inadmissible or exten $exten est inadmissible or filename: $filename est inadmissible, $ACTION commande non insérée\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going sur in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION commande envoyée pour LaManche $channel sur $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n L'ENREGISTREMENT DURERA JUSQU'À 60 MINUTES\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_fr/park_calls_display.php new file mode 100644 index 00000000..23d5e3b5 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Affichage Garé D'Appels"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten est inadmissible ou protocole $protocol est inadmissible\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_fr/vdc_db_query.php new file mode 100644 index 00000000..e2584b87 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Manuscrit De Question De Base de données"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Choix De Groupe $closer_choice est inadmissible\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Choix De Groupe $closer_choice a été enregistré à l'utilisateur $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "DISTRIBUTEUR VIDE\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context est inadmissible\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NOMBRE\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INAPPEL + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "DISTRIBUTEUR VIDE\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context est inadmissible\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INAPPEL + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "APPEL NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context est inadmissible\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID est inadmissible\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "NOTATION NON ENTRÉE\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign est inadmissible\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inséré: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "NOTATION NON ENTRÉE\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "APPEL_LOG Inséré: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "NOTATION NON ENTRÉE\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "NOTATION NON ENTRÉE\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id est inadmissible\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "NOTATION NON ENTRÉE\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campagne $campaign est inadmissible\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INAPPEL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INAPPEL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INAPPEL + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INAPPEL + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send sur to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If APPELBK, change vicidial_callback record to INACTIVE + if ($dispo == 'APPELBK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user sur $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten est inadmissible\n"; + exit; + } +else + { + ##### Insert a DÉCONNEXION record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','DÉCONNEXION','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation sur the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id est inadmissible\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### APPELBACK ENTRY + if ( ($dispo_choice == 'CBHVIEUX') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' a été changé en ' . $dispo_choice . " Statut\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id est inadmissible\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id l'information a été mise à jour\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage est inadmissible\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' est maintenant dans le statut ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list est inadmissible\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_fr/vicidial.php new file mode 100644 index 00000000..1ea3b1e2 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Vous vous êtes maintenant déconnecté. Merci\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of secondes for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "Web client de VICICADRAN: Re-Ouverture\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Français
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Ouverture
 
Ouverture De Téléphone:
Mot de passe De Téléphone:
Ouverture D'Utilisateur:
Mot de passe D'Utilisateur:
Campagne: $camp_form_code

VERSION: $version       CONSTRUCTION: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "Web client de VICICADRAN: Ouverture De Campagne\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Ouverture D'Utilisateur

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Ouverture De Campagne
 
Ouverture D'Utilisateur:
Mot de passe D'Utilisateur:
Campagne: $camp_form_code

VERSION: $version       CONSTRUCTION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "Web client de VICICADRAN: Ouverture\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Ouverture
 
Ouverture De Téléphone:
Mot de passe De Téléphone:
Ouverture D'Utilisateur:
Mot de passe D'Utilisateur:
Campagne: $camp_form_code

VERSION: $version       CONSTRUCTION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "Web client de VICICADRAN: Ouverture De Téléphone\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Français
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Ouverture De Téléphone
 
Ouverture De Téléphone:
Mot de passe De Téléphone:

VERSION: $version       CONSTRUCTION: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_secondes=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "La campagne non active, essayent svp encore
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "L'ouverture incorrecte, essayent svp encore
"; + } + } + if ($VDloginDISPLAY) + { + echo "Web client de VICICADRAN: Ouverture De Campagne\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Ouverture De Campagne
 
Ouverture D'Utilisateur:
Mot de passe D'Utilisateur:
Campagne: $camp_form_code

VERSION: $version       CONSTRUCTION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "Web client de VICICADRAN: Ouverture De Téléphone Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Ouverture Error
 
Désolé, votre ouverture de téléphone et mot de passe ne soyez pas:
 
Ouverture De Téléphone:
Mot de passe De Téléphone:

VERSION: $version       CONSTRUCTION: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "Web client de VICICADRAN\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed sur this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login sur phone: $SIP_user à la campagne: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NOUVEAU record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "Web client de VICICADRAN: VICICADRAN Ouverture De Campagne\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "Désolé, il n'y a aucun fil dans le distributeur pour cette campagne\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Ouverture: \n
"; + echo "Mot de passe:
\n"; + echo "Campagne: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "Web client de VICICADRAN: VICICADRAN Ouverture De Campagne\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Français
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Ouverture: \n
"; + echo "Mot de passe:
\n"; + echo "Campagne: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +DÉCONNEXION\n"; ?> +
+
+ + + + + + + + +
VICICADRANSCRIPT   LIVE     ID de session: Vivent L'Appel
+
+ + + + +

VICICADRAN
+
+ + +CADRAN MANUEL
+
+ + +X RAPPELS DE SERVICE ACTIFS
+
+ + +
RAPPELS DE SERVICE POUR L'AGENT :
Cliquez sur un rappel de service ci-dessous pour appeler le dos de client maintenant. Si vous cliquez sur un disque ci-dessous pour l'appeler, il sera enlevé de la liste. +
+
+
  + Régénérez +                 + Retournez +
+
+ + +
NOUVEAU FIL MANUEL DE CADRAN POUR :

Écrivez l'information ci-dessous pour le nouveau fil que vous souhaitez appeler. +
+ \n"; + } + ?> + Note : tous les nouveaux fils manuels de cadran entreront dans la liste 999

+ + + + + + + + + + + + + + + +
Cadran Code:   (C'est habituellement un 1 aux Etats-Unis et au Canada)
Téléphone Number:   (maximum de 10 chiffres - chiffres seulement)
Fils Existants De Recherche:   (Cette option si vérifié essayera de trouver le numéro de téléphone dans le système avant de l'insérer comme nouvelle avance)


Si vous voulez composer un numéro et le faire ne pas ajouter comme nouvelle avance, entrez dans dialstring exact ce vous veulent appeler dans le domaine de priorité de cadran ci-dessous. Au décrochement cet appel vous devrez ouvrir les APPELS DANS CE lien de SESSION au fond de l'écran et les accrocher vers le haut en cliquant sur son lien de canal là.
 
Dépassement De Cadran:   (les chiffres satisfont seulement)
+
+ Cadran Maintenant +                 + Retournez +
+
+ + + + +Votre Statut:
Calls Dialing: +
+ + + + + +
+ + Transfert - Conférence
+ PLUS ÉTROIT INTERNE + GENS DU PAYS PLUS ÉTROITS + CODE + Ligne De Xfer De Décrochement + Décrochement Les deux Lignes + +
+ + Nombre à appeler   + secondes   + channel + + OVERRIDE   + D1 + D2 +
+ + Cadran Avec Le Client + Cadran De Client De Parc + APPEL DU CONGÉ 3-WAY + Transfert D'Aveugle De Cadran + Blind Transfer VMail Message +
+
+
+ + + + +
Fil Dispositioned As:

+ -
+
+
+ + + + + + + +
Touches Directes De Disposition: + Si actif, appuyez sur simplement la touche de clavier pour la:
+ + + + + +
+
+ + +
Aucun n'est en votre session:
+ Retournez +

+ Agent D'Appel Encore +
+
+ + +
Le client a raccroché:
+ Retournez +

+ Finition et appel de disposition + +
+
+ + +
Appel Wrapup : secondes restantes dans le wrapup

+ +

+ Finition Wrapup et passer + +
+
+ + +

DÉCONNEXION
+
+ + +
+
+ + +
 
+
+ + +
Tous les changements faits au client que l'information ci-dessous actuellement ne sera pas comitted, vous doivent changer l'information de client avant vous décrochement l'appel.
+
+ + +
APPEL DE DISPOSITION :       Décrochement Encore       réduisez au minimum
+ Extrémité-de-appelez Le Choix De Disposition +
+ CESSEZ D'APPELER
+ REMISE | + SOUMETTEZ +

+ WEB FORM SOUMETTEZ +

  +
+
+ + + +
Choisissez une date de rappel de service :
+ + + Choisissez une date ci-dessous   +     + Hour: +   + Minutes: +   + +  
+ MON RAPPEL DE SERVICE SEULEMENT
";} + ?> + Commentaires de CB:

+ + SOUMETTEZ

+ +

  +
+
+ + +
UN CHOIX DE GROUPE D'ARRIVÉE PLUS ÉTROIT
+ Un Choix De Groupe D'arrivée Plus étroit +
+ APPELER MÉLANGÉ(en partance activé)
+ REMISE | + SOUMETTEZ +



  +
+
+ + + + LaManche + LaManche + MON RAPPEL DE SERVICE SEULEMENT
";} + ?> +
+ + + + + + + +
TRANSFERT DE PHASE D'APPEL
La Manche à transférer: LaManche
Prolongements:
Menu De Prolongements
+
+ Envoyez à la prolongation choisie

+ Envoyez dans la boîte choisie de vmail

+ Envoyez à ce nombre:


+ RÉGÉNÉREZ


+ De nouveau à la fenêtre principale

+
Conférences:
(cliquez sur un nombre ci-dessous pour envoyer à une)
Envoyez mon canal aussi
Menu De Conférences
+
+ + + + +
VICICADRAN SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUT:
+
+Prochain Nombre De Cadran
+ PRÉVISION DE FIL
+ TÉLÉPHONE D'ALT
+ + +DOSSIER D'ENREGISTREMENT:
+
+
+IDENTIFICATION DISQUE:
+
+ +Commencez À enregistrer
+
+Forme de Web
+
+Appel De Parc
+Transfert - Conférence
+
+Client De Décrochement
+
+Envoyez DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
secondes:   LaManche:   Temps De Cust:
L'Information De Client:
Titre:   D'abord:   MI :  Bout:
Adresse1:
Adresse2:   Adresse3:
Ville:   État:   Code postal:
Province:   Identification De Fournisseur:
Téléphone:   DialCode:   Alt. Téléphone:
Exposition:   Email:
Commentaires:
+ +
+


  + +
+ + + + +
Version d'enchaînement-client de VICICADRAN:     CONSTRUCTION:               Serveur:              
+Montrez l'information de canal de conférence téléphonique
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +TOUCHES DIRECTES INACTIVES + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_fr/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_fr/voicemail_check.php new file mode 100644 index 00000000..0fbb86d2 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_fr/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inadmissible Utilisateurname/Mot de passe: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inadmissible server_ip: |$server_ip| or Inadmissible session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inadmissible session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Contrôle De Voicemail"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "boîte de voicemail $vmail_box est inadmissible\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_it/active_list_refresh.php new file mode 100644 index 00000000..ca2e42d8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Esposizione Della Lista: "; +if ($ADD==1) {echo "Estensioni In tensione";} +if ($ADD==2) {echo "Estensioni Occupate";} +if ($ADD==3) {echo "Linee Esterne";} +if ($ADD==4) {echo "Estensioni Locali";} +if ($ADD==5) {echo "Congressi";} +if ($ADD==99999) {echo "AIUTO";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_it/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_it/astguiclient.php new file mode 100644 index 00000000..76229631 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Ora avete annotato fuori. Grazie\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "web client astGUIclient: Inizio attività\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Inizio attività
 
Inizio attività Dell'Utente:
Parola d'accesso Dell'Utente:
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIMANOPOLA|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIMANOPOLA|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web client astGUIclient: Inizio attività Del Telefono\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Italiano
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Inizio attività Del Telefono
 
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web client astGUIclient: Inizio attività Del Telefono\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Inizio attività Del Telefono
 
Spiacente, il vostri inizio attività del telefono e parola d'accesso:
 
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "web client astGUIclient\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +TERMINE
\n"; ?> +
Pannello PrincipaleLinee Attive PannelloPannello Di CongressiControlli VoicemailVive La Chiamata
+
+ + +

Logout
+
+ + +
TRUNK HANGUP

+ Active Trunks Menu
+ Tronco Di Hangup   |   + Tronco Di Dirottamento   |   + Ascolta Il Tronco   |   + Rinfreschi   |   + Di nuovo alla finestra principale +
+
+ + +
HANGUP LOCALE

+ Menu Locale Attivo
+ Local Di Hangup   |   + Local Di Dirottamento   |   + Ascolta Il Local   |   + Rinfreschi   |   + Di nuovo alla finestra principale +
+
+ + + + + + + +
TRASFERIMENTO IN TENSIONE DI CHIAMATA
Manica da trasferire: Manica
Estensioni:
Menu Di Estensioni
+
+ Trasmetta all'estensione selezionata

+ Trasmetta alla scatola selezionata del vmail

+ _ trasmett questo numero:


+ Rinfreschi


+ Di nuovo alla finestra principale

+
Congressi:
(scatti sopra un numero qui sotto per trasmettere ad un congresso)
Trasmetta la mia scanalatura anche
Menu Di Congressi
+
+ + + + + +
Manopola LOCALE Di Estensioni
Telefono che denomina da: Manica
Estensioni:
Menu Di Estensioni
+
+ Estensione selezionata chiamata

+ Scatola del vmail selezionata chiamata

+ Rinfreschi


+ Di nuovo alla finestra principale

+
+
+ + +
CHIAMATE PARCHEGGIATE:
+ Di nuovo alla finestra principale

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NUOVO:     VECCHIO:             MANOPOLA MANUALE       MANOPOLA
CHIAMATE PARCHEGGIATE: 0                ESTENSIONI LOCALI DELLA MANOPOLA
CHIAMATE OUTBOUND:
CHIAMATE INBOUND:
VERSIONEE astGUIclient del fotoricettore-cliente: CONFIGURAZIONE:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITI       pubblichi
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITI

 
PRESENTI I CAMBIAMENTI dei FAVORITI - richiede il termine attività
DI NUOVO ALLA FINESTRA PRINCIPALE - ignori i cambiamenti fatti
+
+ +
+ + + + + + + + + + + + + +
+PAUSA | INIZIO     La velocità di rinfrescamento: 1000 ms Più velocemente | Più lento

+
Inizializzazione..
+
Estensioni Attive
+RINFRESCHI | +ORDINE | +
Linee Esterne
+RINFRESCHI | +ORDINE | +
Estensioni Locali
+RINFRESCHI | +ORDINE | +
+ I Dati Vanno Qui

+
+ I Dati Vanno Qui

Azione Del Tronco +
+ I Dati Vanno Qui

Azione Locale +
+
+ + + + +
+ + +Lista Di Congressi + + + +
+Scatti sopra un numero di stanza di congresso a sinistra per l'Info su +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_it/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_it/call_log_display.php new file mode 100644 index 00000000..cc1556c0 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Esposizione Del Ceppo Di Chiamata"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten è non valido o protocollo $protocol è non valido\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_it/conf_exten_check.php new file mode 100644 index 00000000..ceecdb82 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Controllo Di Estensione Di Conf"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten è non valido\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Condizione: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ManicaA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ManicaA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$ManicaA[$counter] ~"; + # echo "$ManicaA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten è non valido or Exten $exten è non valido\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Congresso $conf_exten è stato registrato a $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_it/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_it/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_it/inbound_popup.php new file mode 100644 index 00000000..dc270cdd --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +CHIAMATA INBOUND IN TENSIONE"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

CHIAMATA INBOUND IN TENSIONE

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid è non valido\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Manica: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Manica=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "ABITUDINE - \n"; + + echo "
Il Numero Ha composto: $row[8]
Note: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "HANGUP - \n"; + echo "TRASMETTA AL MIO VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_it/live_exten_check.php new file mode 100644 index 00000000..857a5afa --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Controllo In tensione Di Estensione"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten è non valido o protocollo $protocol è non valido\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ManicaA[$loop_count] = "$row[0]"; + $ManicaB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ManicaA: $ManicaA[$counter] ~"; + echo "ManicaB: $ManicaB[$counter] ~"; + echo "ManicaBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ManicaA: $ManicaA[$counter] ~"; + echo "ManicaB: $ManicaB[$counter] ~"; + echo "ManicaBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ManicaA: $ManicaA[$counter] ~"; + echo "ManicaB: $ManicaB[$counter] ~"; + echo "ManicaBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ManicaA: $ManicaA[$counter] ~"; + echo "ManicaB: $ManicaB[$counter] ~"; + echo "ManicaBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "ManicaA: $ManicaA[$counter] ~"; + echo "ManicaB: $ManicaB[$counter] ~"; + echo "ManicaBtrunk: $ManicaA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_it/manager_send.php new file mode 100644 index 00000000..4f552da2 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Il Responsabile Trasmette: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "AIUTO";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten è non valido or queryCID $queryCID è non valido, Originate ordine non inserito\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate ordine trasmesso per Exten $exten Manica $channel su $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "extenName $extenName deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nOriginateName Action non trasmesso\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "extenName $extenName deve essere regolato\n"; + echo "exten $exten deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nOriginateNameVmail Action non trasmesso\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten è non valido or queryCID $queryCID è non valido, Originate ordine non inserito\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate ordine trasmesso per Exten $exten Manica $channel su $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten è non valido or ext_context $ext_context or queryCID $queryCID è non valido, Hangup ordine non inserito\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Manica $channel è non valido or queryCID $queryCID è non valido, Hangup ordine non inserito\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel non è in tensione su $call_server_ip, Checking Live Manica...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Manica $channel non è in tensione su $call_server_ip, Hangup ordine non inserito $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup ordine trasmesso per Manica $channel su $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "exten $exten deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "auto_dial_level $auto_dial_level deve essere regolato\n"; + echo "campaign $campaign deve essere regolato\n"; + echo "uniqueid $uniqueid deve essere regolato\n"; + echo "lead_id $lead_id deve essere regolato\n"; + echo "\nRedirectVD Action non trasmesso\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "exten $exten deve essere regolato\n"; + echo "extenName $extenName deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "parkedby $parkedby deve essere regolato\n"; + echo "\nRedirectToPark Action non trasmesso\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "exten $exten deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nRedirectFromPark Action non trasmesso\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "extenName $extenName deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nRedirectName Action non trasmesso\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "extenName $extenName deve essere regolato\n"; + echo "exten $exten deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nRedirectNameVmail Action non trasmesso\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "ExtraManica $extrachannel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "exten $exten deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nRedirect Action non trasmesso\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Non può trovare il congresso vuoto su $server_ip, Redirect ordine non inserito\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Manica $channel non è in tensione su $call_server_ip, Redirect ordine non inserito\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Manica $channel non è in tensione su $server_ip, Redirect ordine non inserito\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra ordine trasmesso per Manica $channel and \nExtraManica $extrachannel\n to $exten su $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra ordine trasmesso per Manica $channel su $call_server_ip and \nExtraManica $extrachannel\n to $exten su $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Una di queste variabili è non valido:\n"; + echo "Manica $channel deve essere più grande di 2 caratteri\n"; + echo "queryCID $queryCID deve essere più grande di 14 caratteri\n"; + echo "exten $exten deve essere regolato\n"; + echo "ext_context $ext_context deve essere regolato\n"; + echo "ext_priority $ext_priority deve essere regolato\n"; + echo "\nRedirect Action non trasmesso\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Manica $channel non è in tensione su $server_ip, Redirect ordine non inserito\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect ordine trasmesso per Manica $channel su $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Manica $channel è non valido or queryCID $queryCID è non valido or filename: $filename è non valido, $ACTION ordine non inserito\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Manica $channel non è in tensione su $server_ip, $ACTION ordine non inserito\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION ordine trasmesso per Manica $channel su $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Manica $channel è non valido or exten $exten è non valido or filename: $filename è non valido, $ACTION ordine non inserito\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going su in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION ordine trasmesso per Manica $channel su $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n LA REGISTRAZIONE DURERÀ FINO A 60 MINUTI\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_it/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_it/park_calls_display.php new file mode 100644 index 00000000..75c0a25f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Esposizione Parcheggiata Di Chiamate"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten è non valido o protocollo $protocol è non valido\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_it/vdc_db_query.php new file mode 100644 index 00000000..ea28cf72 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Scritto Di Domanda Della Base di dati"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Scelta Del Gruppo $closer_choice è non valido\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Scelta Del Gruppo $closer_choice è stato registrato all'utente $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "TRAMOGGIA VUOTA\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context è non valido\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUMERO\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INCHIAMATA + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "TRAMOGGIA VUOTA\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context è non valido\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCHIAMATA + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "CHIAMATA NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context è non valido\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID è non valido\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "CEPPO NON INSERITO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign è non valido\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inserito: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "CEPPO NON INSERITO\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CHIAMATA_LOG Inserito: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "CEPPO NON INSERITO\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "CEPPO NON INSERITO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id è non valido\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "CEPPO NON INSERITO\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campagna $campaign è non valido\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INCHIAMATA in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INCHIAMATA + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INCHIAMATA + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INCHIAMATA + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send su to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If CHIAMATABK, change vicidial_callback record to INACTIVE + if ($dispo == 'CHIAMATABK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user su $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten è non valido\n"; + exit; + } +else + { + ##### Insert a TERMINE record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','TERMINE','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation su the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id è non valido\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### CHIAMATABACK ENTRY + if ( ($dispo_choice == 'CBHVECCHIO') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' è stato cambiato a ' . $dispo_choice . " Condizione\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id è non valido\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id le informazioni sono state aggiornate\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage è non valido\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' è ora nella condizione ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list è non valido\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_it/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_it/vicidial.php new file mode 100644 index 00000000..a6b51ad1 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Ora avete annotato fuori. Grazie\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of secondi for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "Web client di VICIMANOPOLA: Re-Inizio attività\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Italiano
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Inizio attività
 
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:
Inizio attività Dell'Utente:
Parola d'accesso Dell'Utente:
Campagna: $camp_form_code

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "Web client di VICIMANOPOLA: Inizio attività Di Campagna\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Inizio attività Dell'Utente

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Inizio attività Di Campagna
 
Inizio attività Dell'Utente:
Parola d'accesso Dell'Utente:
Campagna: $camp_form_code

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "Web client di VICIMANOPOLA: Inizio attività\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Inizio attività
 
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:
Inizio attività Dell'Utente:
Parola d'accesso Dell'Utente:
Campagna: $camp_form_code

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "Web client di VICIMANOPOLA: Inizio attività Del Telefono\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Italiano
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Inizio attività Del Telefono
 
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_secondi=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "La campagna non attiva, prova prego ancora
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "L'inizio attività errato, prova prego ancora
"; + } + } + if ($VDloginDISPLAY) + { + echo "Web client di VICIMANOPOLA: Inizio attività Di Campagna\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Inizio attività Di Campagna
 
Inizio attività Dell'Utente:
Parola d'accesso Dell'Utente:
Campagna: $camp_form_code

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "Web client di VICIMANOPOLA: Inizio attività Del Telefono Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Inizio attività Error
 
Spiacente, il vostri inizio attività del telefono e parola d'accesso:
 
Inizio attività Del Telefono:
Parola d'accesso Del Telefono:

VERSIONE: $version       CONFIGURAZIONE: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "Web client di VICIMANOPOLA\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed su this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login su phone: $SIP_user alla campagna: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NUOVO record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "Web client di VICIMANOPOLA: VICIMANOPOLA Inizio attività Di Campagna\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "Spiacenti, non ci sono cavi nella tramoggia per questa campagna\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Inizio attività: \n
"; + echo "Parola d'accesso:
\n"; + echo "Campagna: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "Web client di VICIMANOPOLA: VICIMANOPOLA Inizio attività Di Campagna\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Italiano
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Inizio attività: \n
"; + echo "Parola d'accesso:
\n"; + echo "Campagna: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +TERMINE\n"; ?> +
+
+ + + + + + + + +
VICIMANOPOLASCRIPT   LIVE     ID di sessione: Vive La Chiamata
+
+ + + + +

VICIMANOPOLA
+
+ + +MANOPOLA MANUALE
+
+ + +X CHIAMATE RIPETUTE ATTIVE
+
+ + +
CHIAMATE RIPETUTE PER L'AGENTE :
Scatti sopra una chiamata ripetuta qui sotto ora per denominare la parte posteriore del cliente. Se scattate sopra un'annotazione qui sotto per denominarli, sarà rimossa dalla lista. +
+
+
  + Rinfreschi +                 + Vada Indietro +
+
+ + +
NUOVO CAVO MANUALE DELLA MANOPOLA PER :

Fornisca le informazioni qui sotto per il nuovo cavo che desiderate denominare. +
+ \n"; + } + ?> + Nota: tutti i nuovi cavi manuali della manopola entreranno nella lista 999

+ + + + + + + + + + + + + + + +
Codice Della Manopola:   (Ciò è solitamente un 1 negli S.U.A. e nel Canada)
Telefono Number:   (un massimo delle 10 cifre - cifre soltanto)
Cavi Esistenti Di Ricerca:   (Questa opzione se controllato tenterà di trovare il numero di telefono nel sistema prima dell'inserimento esso come cavo nuovo)


Se desiderate comporre un numero e farli non aggiungere come nuovo cavo, entri nel dialstring esatto quel voi desiderano denominare nel giacimento della sovrapposizione di un comando manuale della manopola qui sotto. Al hangup questa chiamata dovrete aprire le CHIAMATE in QUESTO collegamento di SESSIONE alla parte inferiore dello schermo ed appenderli in su scattandosi sul relativo collegamento della scanalatura là.
 
Sovrapposizione di un comando manuale Della Manopola:   (le cifre soddisfano soltanto)
+
+ Manopola Ora +                 + Vada Indietro +
+
+ + + + +La Vostra Condizione:
Calls Dialing: +
+ + + + + +
+ + Trasferimento - Congresso
+ PIÙ VICINO INTERNO + LOCAL PIÙ VICINO + CODE + Linea Di Xfer Di Hangup + Hangup Entrambe le Linee + +
+ + Numero da denominare   + secondi   + channel + + OVERRIDE   + D1 + D2 +
+ + Manopola Con Il Cliente + Manopola Del Cliente Del Parco + CHIAMATA DI PERMESSO 3-WAY + Trasferimento Dei Ciechi Della Manopola + Blind Transfer VMail Message +
+
+
+ + + + +
Cavo Dispositioned As:

+ -
+
+
+ + + + + + + +
Chiavi Calde Di Disposizione: + Una volta attivo, premi semplicemente la chiave di tastiera per la:
+ + + + + +
+
+ + +
Nessuno è nella vostra sessione:
+ Vada Indietro +

+ Agente Di Chiamata Ancora +
+
+ + +
Il cliente ha appeso in su:
+ Vada Indietro +

+ Rivestimento e chiamata di disposizione + +
+
+ + +
Chiamata Wrapup: secondi restanti nel wrapup

+ +

+ Rivestimento Wrapup e pass + +
+
+ + +

TERMINE
+
+ + +
+
+ + +
 
+
+ + +
Tutti i cambiamenti fatti al cliente che le informazioni qui sotto attualmente non saranno comitted, voi devono cambiare le informazioni del cliente prima di voi hangup la chiamata.
+
+ + +
CHIAMATA DI DISPOSIZIONE :       Hangup Ancora       minimizzi
+ Estremità-de-denomini La Selezione Di Disposizione +
+ SMETTA DI DENOMINARE
+ RISISTEMAZIONE | + PRESENTI +

+ WEB FORM PRESENTI +

  +
+
+ + + +
Selezioni una data di chiamata ripetuta :
+ + + Selezioni una data qui sotto   +     + Hour: +   + Minutes: +   + +  
+ LA MIA CHIAMATA RIPETUTA SOLTANTO
";} + ?> + Osservazioni dei CB:

+ + PRESENTI

+ +

  +
+
+ + +
SELEZIONE DI GRUPPO INBOUND PIÙ VICINA
+ Selezione Di Gruppo Inbound Più vicina +
+ CHIAMATA MESCOLATA(outbound attivato)
+ RISISTEMAZIONE | + PRESENTI +



  +
+
+ + + + Manica + Manica + LA MIA CHIAMATA RIPETUTA SOLTANTO
";} + ?> +
+ + + + + + + +
TRASFERIMENTO IN TENSIONE DI CHIAMATA
Manica da trasferire: Manica
Estensioni:
Menu Di Estensioni
+
+ Trasmetta all'estensione selezionata

+ Trasmetta alla scatola selezionata del vmail

+ _ trasmett questo numero:


+ RINFRESCHI


+ Di nuovo alla finestra principale

+
Congressi:
(scatti sopra un numero qui sotto per trasmettere ad un congresso)
Trasmetta la mia scanalatura anche
Menu Di Congressi
+
+ + + + +
VICIMANOPOLA SCRIPT
+
+ + + + + + + + + + + + + + + + + +
CONDIZIONE:
+
+Numero Seguente Della Manopola
+ PREVISIONE DEL CAVO
+ ALT DEL TELEFONO
+ + +LIMA DI REGISTRAZIONE:
+
+
+IDENTIFICAZIONE ANNOTAZIONE:
+
+ +Inizi A registrare
+
+Forma Di Fotoricettore
+
+Chiamata Del Parco
+Trasferimento - Congresso
+
+Cliente Di Hangup
+
+Trasmetta DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
secondi:   Manica:   Tempo Di Cust:
Le Informazioni Del Cliente:
Titolo:   In primo luogo:   Mi:  Ultimo:
Indirizzo1:
Indirizzo2:   Indirizzo3:
Città:   Dichiari:   PostCode:
Provincia:   Identificazione Del Fornitore:
Telefono:   DialCode:   Alt. Telefono:
Esposizione:   Email:
Osservazioni:
+ +
+


  + +
+ + + + +
Versione del fotoricettore-cliente di VICIMANOPOLA:     CONFIGURAZIONE:               Assistente:              
+Mostri le informazioni della scanalatura di chiamata di congresso
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +CHIAVI CALDE INATTIVE + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_it/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_it/voicemail_check.php new file mode 100644 index 00000000..4910d435 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_it/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Non valido Utentename/Parola d'accesso: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Non valido server_ip: |$server_ip| or Non valido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Non valido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Controllo Di Voicemail"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "scatola del voicemail $vmail_box è non valido\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/active_list_refresh.php b/agc_2-X/trunk/LANG_agc/agc_pt/active_list_refresh.php new file mode 100644 index 00000000..11e2d444 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/active_list_refresh.php @@ -0,0 +1,463 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.7'; +$build = '60421-1155'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Exposição Da Lista: "; +if ($ADD==1) {echo "Extensões Vivas";} +if ($ADD==2) {echo "Extensões Ocupadas";} +if ($ADD==3) {echo "Linhas Exteriores";} +if ($ADD==4) {echo "Extensões Locais";} +if ($ADD==5) {echo "Conferências";} +if ($ADD==99999) {echo "AJUDA";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/astguiclient.php b/agc_2-X/trunk/LANG_agc/agc_pt/astguiclient.php new file mode 100644 index 00000000..d222bbd0 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/astguiclient.php @@ -0,0 +1,2890 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.11'; +$build = '60421-1043'; + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Você tem registrado agora para fora. Obrigado\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "web client astGUIclient: Início de uma sessão\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início de uma sessão
 
Início de uma sessão Do Usuário:
Senha Do Usuário:
Início de uma sessão Do Telefone:
Senha Do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICISELETOR|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICISELETOR|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web client astGUIclient: Início de uma sessão Do Telefone\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Português
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Início de uma sessão Do Telefone
 
Início de uma sessão Do Telefone:
Senha Do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web client astGUIclient: Início de uma sessão Do Telefone\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início de uma sessão Do Telefone
 
Pesaroso, seus início de uma sessão do telefone e senha não seja:
 
Início de uma sessão Do Telefone:
Senha Do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "web client astGUIclient\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +LOGOUT
\n"; ?> +
Painel PrincipalLinhas Ativas PainelPainel Das ConferênciasVerifique VoicemailVive A Chamada
+
+ + +

Logout
+
+ + +
TRUNK HANGUP

+ Active Trunks Menu
+ Tronco Do Hangup   |   + Tronco Do Hijack   |   + Escuta O Tronco   |   + Refresque   |   + Para trás à janela principal +
+
+ + +
HANGUP LOCAL

+ Menu Local Ativo
+ Local Do Hangup   |   + Local Do Hijack   |   + Escuta O Local   |   + Refresque   |   + Para trás à janela principal +
+
+ + + + + + + +
TRANSFERÊNCIA VIVA DA CHAMADA
Canaleta a ser transferida: Canaleta
Extensões:
Menu Das Extensões
+
+ Emita à extensão selecionada

+ Emita à caixa selecionada do vmail

+ Emita a este número:


+ Refresque


+ Para trás à janela principal

+
Conferências:
(estale sobre um número abaixo para emitir a uma conferência)
Emita minha canaleta demasiado
Menu Das Conferências
+
+ + + + + +
Seletor LOCAL Das Extensões
Telefone que chama-se de: Canaleta
Extensões:
Menu Das Extensões
+
+ Extensão selecionada chamada

+ Caixa selecionada chamada do vmail

+ Refresque


+ Para trás à janela principal

+
+
+ + +
CHAMADAS ESTACIONADAS:
+ Para trás à janela principal

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NOVO:     VELHO:             SELETOR MANUAL       SELETOR
CHAMADAS ESTACIONADAS: 0                EXTENSÕES LOCAIS DO SELETOR
CHAMADAS OUTBOUND :
CHAMADAS INBOUND:
VERSÃO astGUIclient do correia-cliente: CONFIGURAÇÃO:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITOS       edite
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITOS

 
SUBMETA MUDANÇAS dos FAVORITOS - requer o logout
PARA TRÁS À JANELA PRINCIPAL - ignore as mudanças feitas
+
+ +
+ + + + + + + + + + + + + +
+PAUSA | COMEÇO     Refresque a taxa: 1000 ms Mais rapidamente | Mais lento

+
Inicializar..
+
Extensões Ativas
+REFRESQUE | +ORDEM | +
Linhas Exteriores
+REFRESQUE | +ORDEM | +
Extensões Locais
+REFRESQUE | +ORDEM | +
+ Os Dados Vão Aqui

+
+ Os Dados Vão Aqui

Ação Do Tronco +
+ Os Dados Vão Aqui

Ação Local +
+
+ + + + +
+ + +Lista Das Conferências + + + +
+Estale sobre um número de quarto da conferência na esquerda para o +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/call_log_display.php b/agc_2-X/trunk/LANG_agc/agc_pt/call_log_display.php new file mode 100644 index 00000000..5da9fe51 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/call_log_display.php @@ -0,0 +1,192 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.7'; +$build = '60421-1401'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Exposição Do Registro Da Chamada"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten é inválido ou protocolo $protocol é inválido\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/conf_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_pt/conf_exten_check.php new file mode 100644 index 00000000..51b67358 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/conf_exten_check.php @@ -0,0 +1,258 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.8'; +$build = '60421-1405'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Verificação Da Extensão De Conf"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten é inválido\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Status: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $CanaletaA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $CanaletaA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$CanaletaA[$counter] ~"; + # echo "$CanaletaA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten é inválido or Exten $exten é inválido\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conferência $conf_exten foi registado a $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/dbconnect.php b/agc_2-X/trunk/LANG_agc/agc_pt/dbconnect.php new file mode 100644 index 00000000..1662f18f --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/dbconnect.php @@ -0,0 +1,15 @@ + diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/inbound_popup.php b/agc_2-X/trunk/LANG_agc/agc_pt/inbound_popup.php new file mode 100644 index 00000000..16abb2a8 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/inbound_popup.php @@ -0,0 +1,348 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60421-1043'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +CHAMADA INBOUND VIVA"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

CHAMADA INBOUND VIVA

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid é inválido\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Canaleta: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Canaleta=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "COSTUME - \n"; + + echo "
O Número Marcou: $row[8]
Notas: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "HANGUP - \n"; + echo "EMITA A MEU VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/live_exten_check.php b/agc_2-X/trunk/LANG_agc/agc_pt/live_exten_check.php new file mode 100644 index 00000000..ef528784 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/live_exten_check.php @@ -0,0 +1,273 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.11'; +$build = '60421-1359'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Verificação Viva Da Extensão"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten é inválido ou protocolo $protocol é inválido\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $CanaletaA[$loop_count] = "$row[0]"; + $CanaletaB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanaletaA: $CanaletaA[$counter] ~"; + echo "CanaletaB: $CanaletaB[$counter] ~"; + echo "CanaletaBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanaletaA: $CanaletaA[$counter] ~"; + echo "CanaletaB: $CanaletaB[$counter] ~"; + echo "CanaletaBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanaletaA: $CanaletaA[$counter] ~"; + echo "CanaletaB: $CanaletaB[$counter] ~"; + echo "CanaletaBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "CanaletaA: $CanaletaA[$counter] ~"; + echo "CanaletaB: $CanaletaB[$counter] ~"; + echo "CanaletaBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "CanaletaA: $CanaletaA[$counter] ~"; + echo "CanaletaB: $CanaletaB[$counter] ~"; + echo "CanaletaBtrunk: $CanaletaA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/manager_send.php b/agc_2-X/trunk/LANG_agc/agc_pt/manager_send.php new file mode 100644 index 00000000..a1309814 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/manager_send.php @@ -0,0 +1,903 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.23'; +$build = '60421-1413'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "O Gerente Emite: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "AJUDA";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten é inválido or queryCID $queryCID é inválido, Originate comando não introduzido\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate comando emitido para Exten $exten Canaleta $channel em $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "extenName $extenName deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nOriginateName Action não emitido\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "extenName $extenName deve ser ajustado\n"; + echo "exten $exten deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nOriginateNameVmail Action não emitido\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten é inválido or queryCID $queryCID é inválido, Originate comando não introduzido\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate comando emitido para Exten $exten Canaleta $channel em $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten é inválido or ext_context $ext_context or queryCID $queryCID é inválido, Hangup comando não introduzido\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Canaleta $channel é inválido or queryCID $queryCID é inválido, Hangup comando não introduzido\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel não está vivo em $call_server_ip, Checking Live Canaleta...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Canaleta $channel não está vivo em $call_server_ip, Hangup comando não introduzido $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup comando emitido para Canaleta $channel em $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "exten $exten deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "auto_dial_level $auto_dial_level deve ser ajustado\n"; + echo "campaign $campaign deve ser ajustado\n"; + echo "uniqueid $uniqueid deve ser ajustado\n"; + echo "lead_id $lead_id deve ser ajustado\n"; + echo "\nRedirectVD Action não emitido\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "exten $exten deve ser ajustado\n"; + echo "extenName $extenName deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "parkedby $parkedby deve ser ajustado\n"; + echo "\nRedirectToPark Action não emitido\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "exten $exten deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nRedirectFromPark Action não emitido\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "extenName $extenName deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nRedirectName Action não emitido\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "extenName $extenName deve ser ajustado\n"; + echo "exten $exten deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nRedirectNameVmail Action não emitido\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "ExtraCanaleta $extrachannel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "exten $exten deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nRedirect Action não emitido\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Não pode encontrar a conferência vazia em $server_ip, Redirect comando não introduzido\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Canaleta $channel não está vivo em $call_server_ip, Redirect comando não introduzido\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Canaleta $channel não está vivo em $server_ip, Redirect comando não introduzido\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra comando emitido para Canaleta $channel and \nExtraCanaleta $extrachannel\n to $exten em $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra comando emitido para Canaleta $channel em $call_server_ip and \nExtraCanaleta $extrachannel\n to $exten em $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Uma destas variáveis é inválido:\n"; + echo "Canaleta $channel deve ser mais grande de 2 caráteres\n"; + echo "queryCID $queryCID deve ser mais grande de 14 caráteres\n"; + echo "exten $exten deve ser ajustado\n"; + echo "ext_context $ext_context deve ser ajustado\n"; + echo "ext_priority $ext_priority deve ser ajustado\n"; + echo "\nRedirect Action não emitido\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Canaleta $channel não está vivo em $server_ip, Redirect comando não introduzido\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect comando emitido para Canaleta $channel em $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Canaleta $channel é inválido or queryCID $queryCID é inválido or filename: $filename é inválido, $ACTION comando não introduzido\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Canaleta $channel não está vivo em $server_ip, $ACTION comando não introduzido\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION comando emitido para Canaleta $channel em $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Canaleta $channel é inválido or exten $exten é inválido or filename: $filename é inválido, $ACTION comando não introduzido\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going em in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION comando emitido para Canaleta $channel em $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n A GRAVAÇÃO DURARÁ ATÉ 60 MINUTOS\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/park_calls_display.php b/agc_2-X/trunk/LANG_agc/agc_pt/park_calls_display.php new file mode 100644 index 00000000..620cff28 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/park_calls_display.php @@ -0,0 +1,142 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.3'; +$build = '60421-1111'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Exposição Estacionada Das Chamadas"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten é inválido ou protocolo $protocol é inválido\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/vdc_db_query.php b/agc_2-X/trunk/LANG_agc/agc_pt/vdc_db_query.php new file mode 100644 index 00000000..db511ca0 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Certificado Da Pergunta Da Base de dados"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Escolha Do Grupo $closer_choice é inválido\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Escolha Do Grupo $closer_choice foi registado ao usuário $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "FUNIL VAZIO\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context é inválido\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NÚMERO\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INCHAMADA + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "FUNIL VAZIO\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context é inválido\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCHAMADA + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "CHAMADA NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context é inválido\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID é inválido\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "REGISTRO NÃO ENTRADO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign é inválido\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Introduzido: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "REGISTRO NÃO ENTRADO\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CHAMADA_LOG Introduzido: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "REGISTRO NÃO ENTRADO\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "REGISTRO NÃO ENTRADO\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id é inválido\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "REGISTRO NÃO ENTRADO\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campanha $campaign é inválido\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INCHAMADA in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INCHAMADA + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INCHAMADA + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INCHAMADA + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send em to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If CHAMADABK, change vicidial_callback record to INACTIVE + if ($dispo == 'CHAMADABK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user em $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten é inválido\n"; + exit; + } +else + { + ##### Insert a LOGOUT record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation em the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id é inválido\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### CHAMADABACK ENTRY + if ( ($dispo_choice == 'CBHVELHO') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' foi mudado a ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id é inválido\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id a informação foi atualizada\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage é inválido\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' está agora no status ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list é inválido\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/vicidial.php b/agc_2-X/trunk/LANG_agc/agc_pt/vicidial.php new file mode 100644 index 00000000..5f6c2a90 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "Você tem registrado agora para fora. Obrigado\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +#$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of segundos for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "Web client de VICISELETOR: Re-Início de uma sessão\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Português
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Início de uma sessão
 
Início de uma sessão Do Telefone:
Senha Do Telefone:
Início de uma sessão Do Usuário:
Senha Do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "Web client de VICISELETOR: Início de uma sessão Da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Início de uma sessão Do Usuário

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início de uma sessão Da Campanha
 
Início de uma sessão Do Usuário:
Senha Do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "Web client de VICISELETOR: Início de uma sessão\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início de uma sessão
 
Início de uma sessão Do Telefone:
Senha Do Telefone:
Início de uma sessão Do Usuário:
Senha Do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "Web client de VICISELETOR: Início de uma sessão Do Telefone\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Português
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Início de uma sessão Do Telefone
 
Início de uma sessão Do Telefone:
Senha Do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_segundos=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "A campanha nao ativa, tenta por favor outra vez
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "O início de uma sessão incorreto, tenta por favor outra vez
"; + } + } + if ($VDloginDISPLAY) + { + echo "Web client de VICISELETOR: Início de uma sessão Da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início de uma sessão Da Campanha
 
Início de uma sessão Do Usuário:
Senha Do Usuário:
Campanha: $camp_form_code

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "Web client de VICISELETOR: Início de uma sessão Do Telefone Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Início de uma sessão Error
 
Pesaroso, seus início de uma sessão do telefone e senha não seja:
 
Início de uma sessão Do Telefone:
Senha Do Telefone:

VERSÃO: $version       CONFIGURAÇÃO: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "Web client de VICISELETOR\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed em this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login em phone: $SIP_user à campanha: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NOVO record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "Web client de VICISELETOR: VICISELETOR Início de uma sessão Da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "Pesaroso, não há nenhuma ligação no funil para esta campanha\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Início de uma sessão: \n
"; + echo "Senha:
\n"; + echo "Campanha: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "Web client de VICISELETOR: VICISELETOR Início de uma sessão Da Campanha\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Português
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Início de uma sessão: \n
"; + echo "Senha:
\n"; + echo "Campanha: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +LOGOUT\n"; ?> +
+
+ + + + + + + + +
VICISELETORSCRIPT   LIVE     sessão ID: Vive A Chamada
+
+ + + + +

VICISELETOR
+
+ + +SELETOR MANUAL
+
+ + +X RECHAMADAS ATIVAS
+
+ + +
RECHAMADAS PARA O AGENTE :
Estale sobre uma rechamada abaixo para chamar agora a parte traseira do cliente. Se você estalar sobre um registro abaixo para o chamar, estará removido da lista. +
+
+
  + Refresque +                 + Vá Para trás +
+
+ + +
LIGAÇÃO MANUAL NOVA DO SELETOR PARA :

Incorpore a informação abaixo para a ligação que nova você deseja se chamar. +
+ \n"; + } + ?> + Nota: todas as ligações manuais novas do seletor entrarão na lista 999

+ + + + + + + + + + + + + + + +
Código Do Seletor:   (Este é geralmente um 1 nos EUA e no Canadá)
Telefone Number:   (máximo de 10 dígitos - dígitos somente)
Ligações Existentes Da Busca:   (Esta opção se verificado tentará encontrar o número de telefone no sistema antes de introduzi-lo como uma ligação nova)


Se você quiser marcar um número e o ter não adicionado como uma ligação nova, entre no dialstring exato esse você querem chamar-se abaixo no campo da ultrapassagem do seletor. Ao hangup esta chamada você terá que abrir as CHAMADAS ncEsta ligação da SESSÃO no fundo da tela e pendurá-las acima estalando em sua ligação da canaleta lá.
 
Ultrapassagem Do Seletor:   (os dígitos satisfazem somente)
+
+ Seletor Agora +                 + Vá Para trás +
+
+ + + + +Seu Status:
Calls Dialing: +
+ + + + + +
+ + Transferência - Conferência
+ MAIS PRÓXIMO INTERNO + LOCAL MAIS PRÓXIMO + CODE + Linha De Xfer Do Hangup + Hangup Ambas as Linhas + +
+ + Número a chamar-se   + segundos   + channel + + OVERRIDE   + D1 + D2 +
+ + Seletor Com Cliente + Seletor Do Cliente Do Parque + CHAMADA DA LICENÇA 3-WAY + Transferência Da Cortina Do Seletor + Blind Transfer VMail Message +
+
+
+ + + + +
Ligação Dispositioned Como:

+ -
+
+
+ + + + + + + +
Chaves Quentes Da Disposição: + Quando ativo, pressione simplesmente a chave de teclado para a:
+ + + + + +
+
+ + +
Noone está em sua sessão:
+ Vá Para trás +

+ Agente Da Chamada Outra vez +
+
+ + +
O cliente pendurou acima:
+ Vá Para trás +

+ Revestimento e chamada da disposição + +
+
+ + +
Chamada Wrapup: segundos restantes no wrapup

+ +

+ Revestimento Wrapup e movimento sobre + +
+
+ + +

LOGOUT
+
+ + +
+
+ + +
 
+
+ + +
Todas as mudanças feitas ao cliente que a informação abaixo neste tempo não será comitted, você devem mudar a informação do cliente antes de você hangup a chamada.
+
+ + +
CHAMADA DA DISPOSIÇÃO :       Hangup Outra vez       minimize
+ Extremidade-$$$-CHAME A Seleção Da Disposição +
+ PARE DE CHAMAR-SE
+ RESTAURAÇÃO | + SUBMETA +

+ WEB FORM SUBMETA +

  +
+
+ + + +
Selecione uma data da rechamada :
+ + + Selecione uma data abaixo   +     + Hour: +   + Minutes: +   + +  
+ MINHA RECHAMADA SOMENTE
";} + ?> + Comentários dos CB:

+ + SUBMETA

+ +

  +
+
+ + +
SELEÇÃO DE GRUPO INBOUND MAIS PRÓXIMA
+ Seleção De Grupo Inbound Mais próxima +
+ CHAMADA MISTURADA(outbound ativado)
+ RESTAURAÇÃO | + SUBMETA +



  +
+
+ + + + Canaleta + Canaleta + MINHA RECHAMADA SOMENTE
";} + ?> +
+ + + + + + + +
TRANSFERÊNCIA VIVA DA CHAMADA
Canaleta a ser transferida: Canaleta
Extensões:
Menu Das Extensões
+
+ Emita à extensão selecionada

+ Emita à caixa selecionada do vmail

+ Emita a este número:


+ REFRESQUE


+ Para trás à janela principal

+
Conferências:
(estale sobre um número abaixo para emitir a uma conferência)
Emita minha canaleta demasiado
Menu Das Conferências
+
+ + + + +
VICISELETOR SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUS:
+
+Número Seguinte Do Seletor
+ INSPECÇÃO PRÉVIA DA LIGAÇÃO
+ ALT DO TELEFONE
+ + +LIMA DE GRAVAÇÃO:
+
+
+ID REGISTRO:
+
+ +Comece Gravar
+
+Formulário Da Correia fotorreceptora
+
+Chamada Do Parque
+Transferência - Conferência
+
+Cliente Do Hangup
+
+Emita DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
segundos:   Canaleta:   Tempo De Cust:
Informação Do Cliente:
Título:   Primeiramente:   Mi:  Último:
Endereço1:
Endereço2:   Endereço3:
Cidade:   Estado:   PostCode:
Província:   Vendedor Id:
Telefone:   DialCode:   Alt. Telefone:
Mostra:   Email:
Comentários:
+ +
+


  + +
+ + + + +
Versão do correia-cliente de VICISELETOR:     CONFIGURAÇÃO:               Usuário:              
+Mostre a informação da canaleta da chamada de conferência
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +CHAVES QUENTES INATIVAS + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/LANG_agc/agc_pt/voicemail_check.php b/agc_2-X/trunk/LANG_agc/agc_pt/voicemail_check.php new file mode 100644 index 00000000..b12b1a83 --- /dev/null +++ b/agc_2-X/trunk/LANG_agc/agc_pt/voicemail_check.php @@ -0,0 +1,136 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.4'; +$build = '60421-1147'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Inválido Usuárioname/Senha: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Inválido server_ip: |$server_ip| or Inválido session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Inválido session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Verificação De Voicemail"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "caixa do voicemail $vmail_box é inválido\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/MySQL_AST_CREATE_tables.sql new file mode 100644 index 00000000..6b37871d --- /dev/null +++ b/agc_2-X/trunk/MySQL_AST_CREATE_tables.sql @@ -0,0 +1,789 @@ + CREATE TABLE phones ( +extension VARCHAR(100), +dialplan_number VARCHAR(20), +voicemail_id VARCHAR(10), +phone_ip VARCHAR(15), +computer_ip VARCHAR(15), +server_ip VARCHAR(15), +login VARCHAR(15), +pass VARCHAR(10), +status VARCHAR(10), +active ENUM('Y','N'), +phone_type VARCHAR(50), +fullname VARCHAR(50), +company VARCHAR(10), +picture VARCHAR(19), +messages INT(4), +old_messages INT(4), +protocol ENUM('SIP','Zap','IAX2','EXTERNAL') default 'SIP', +local_gmt TINYINT(2) default '-5', +ASTmgrUSERNAME VARCHAR(20) default 'cron', +ASTmgrSECRET VARCHAR(20) default '1234', +login_user VARCHAR(20), +login_pass VARCHAR(20), +login_campaign VARCHAR(10), +park_on_extension VARCHAR(10) default '8301', +conf_on_extension VARCHAR(10) default '8302', +VICIDIAL_park_on_extension VARCHAR(10) default '8301', +VICIDIAL_park_on_filename VARCHAR(10) default 'park', +monitor_prefix VARCHAR(10) default '8612', +recording_exten VARCHAR(10) default '8309', +voicemail_exten VARCHAR(10) default '8501', +voicemail_dump_exten VARCHAR(20) default '85026666666666', +ext_context VARCHAR(20) default 'default', +dtmf_send_extension VARCHAR(100) default 'local/8500998@default', +call_out_number_group VARCHAR(100) default 'Zap/g2/', +client_browser VARCHAR(100) default '/usr/bin/mozilla', +install_directory VARCHAR(100) default '/usr/local/perl_TK', +local_web_callerID_URL VARCHAR(255) default 'http://astguiclient.sf.net/test_callerid_output.php', +VICIDIAL_web_URL VARCHAR(255) default 'http://astguiclient.sf.net/test_VICIDIAL_output.php', +AGI_call_logging_enabled ENUM('0','1') default '1', +user_switching_enabled ENUM('0','1') default '1', +conferencing_enabled ENUM('0','1') default '1', +admin_hangup_enabled ENUM('0','1') default '0', +admin_hijack_enabled ENUM('0','1') default '0', +admin_monitor_enabled ENUM('0','1') default '1', +call_parking_enabled ENUM('0','1') default '1', +updater_check_enabled ENUM('0','1') default '1', +AFLogging_enabled ENUM('0','1') default '1', +QUEUE_ACTION_enabled ENUM('0','1') default '1', +CallerID_popup_enabled ENUM('0','1') default '1', +voicemail_button_enabled ENUM('0','1') default '1', +enable_fast_refresh ENUM('0','1') default '0', +fast_refresh_rate INT(5) default '1000', +enable_persistant_mysql ENUM('0','1') default '0', +auto_dial_next_number ENUM('0','1') default '1', +VDstop_rec_after_each_call ENUM('0','1') default '1', +DBX_server VARCHAR(15), +DBX_database VARCHAR(15) default 'asterisk', +DBX_user VARCHAR(15) default 'cron', +DBX_pass VARCHAR(15) default '1234', +DBX_port INT(6) default '3306', +DBY_server VARCHAR(15), +DBY_database VARCHAR(15) default 'asterisk', +DBY_user VARCHAR(15) default 'cron', +DBY_pass VARCHAR(15) default '1234', +DBY_port INT(6) default '3306', +outbound_cid VARCHAR(20), +index (server_ip) +); + + CREATE TABLE servers ( +server_id VARCHAR(10) NOT NULL, +server_description VARCHAR(255), +server_ip VARCHAR(15) NOT NULL, +active ENUM('Y','N'), +asterisk_version VARCHAR(20) default '1.2.9', +max_vicidial_trunks SMALLINT(4) default '96', +telnet_host VARCHAR(20) NOT NULL default 'localhost', +telnet_port INT(5) NOT NULL default '5038', +ASTmgrUSERNAME VARCHAR(20) NOT NULL default 'cron', +ASTmgrSECRET VARCHAR(20) NOT NULL default '1234', +ASTmgrUSERNAMEupdate VARCHAR(20) NOT NULL default 'updatecron', +ASTmgrUSERNAMElisten VARCHAR(20) NOT NULL default 'listencron', +ASTmgrUSERNAMEsend VARCHAR(20) NOT NULL default 'sendcron', +local_gmt VARCHAR(5) default '-5', +voicemail_dump_exten VARCHAR(20) NOT NULL default '85026666666666', +answer_transfer_agent VARCHAR(20) NOT NULL default '8365', +ext_context VARCHAR(20) NOT NULL default 'default' +); + + + CREATE TABLE live_channels ( +channel VARCHAR(100) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +channel_group VARCHAR(30), +extension VARCHAR(100), +channel_data VARCHAR(100) +); + + CREATE TABLE live_sip_channels ( +channel VARCHAR(100) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +channel_group VARCHAR(30), +extension VARCHAR(100), +channel_data VARCHAR(100) +); + + CREATE TABLE parked_channels ( +channel VARCHAR(100) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +channel_group VARCHAR(30), +extension VARCHAR(100), +parked_by VARCHAR(100), +parked_time DATETIME +); + + CREATE TABLE conferences ( +conf_exten INT(7) UNSIGNED NOT NULL, +server_ip VARCHAR(15) NOT NULL, +extension VARCHAR(100) +); + + CREATE TABLE recording_log ( +recording_id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +channel VARCHAR(100), +server_ip VARCHAR(15), +extension VARCHAR(100), +start_time DATETIME, +start_epoch INT(10), +end_time DATETIME, +end_epoch INT(10), +length_in_sec INT(10), +length_in_min DOUBLE(8,2), +filename VARCHAR(50), +location VARCHAR(255), +index (filename) +); + + CREATE TABLE live_inbound ( +uniqueid DOUBLE(18,7) NOT NULL, +channel VARCHAR(100) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +caller_id VARCHAR(30), +extension VARCHAR(100), +phone_ext VARCHAR(40), +start_time DATETIME, +acknowledged ENUM('Y','N') default 'N', +inbound_number VARCHAR(20), +comment_a VARCHAR(50), +comment_b VARCHAR(50), +comment_c VARCHAR(50), +comment_d VARCHAR(50), +comment_e VARCHAR(50) +); + + CREATE TABLE inbound_numbers ( +extension VARCHAR(30) NOT NULL, +full_number VARCHAR(30) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +inbound_name VARCHAR(30) +); + + CREATE TABLE server_updater ( +server_ip VARCHAR(15) NOT NULL, +last_update DATETIME +); + + CREATE TABLE call_log ( +uniqueid DOUBLE(18,7) PRIMARY KEY UNIQUE NOT NULL, +channel VARCHAR(100), +channel_group VARCHAR(30), +type VARCHAR(10), +server_ip VARCHAR(15), +extension VARCHAR(100), +number_dialed VARCHAR(15), +caller_code VARCHAR(20), +start_time DATETIME, +start_epoch INT(10), +end_time DATETIME, +end_epoch INT(10), +length_in_sec INT(10), +length_in_min DOUBLE(8,2), +index (caller_code), +index (server_ip), +index (channel) +); + + CREATE TABLE park_log ( +uniqueid DOUBLE(18,7) PRIMARY KEY UNIQUE NOT NULL, +status VARCHAR(10), +channel VARCHAR(100), +channel_group VARCHAR(30), +server_ip VARCHAR(15), +parked_time DATETIME, +grab_time DATETIME, +hangup_time DATETIME, +parked_sec INT(10), +talked_sec INT(10), +extension VARCHAR(100), +user VARCHAR(20), +index (parked_time) +); + + CREATE TABLE vicidial_manager ( +man_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +uniqueid DOUBLE(18,7), +entry_date DATETIME, +status ENUM('NEW','QUEUE','SENT','UPDATED','DEAD'), +response ENUM('Y','N'), +server_ip VARCHAR(15) NOT NULL, +channel VARCHAR(100), +action VARCHAR(20), +callerid VARCHAR(20), +cmd_line_b VARCHAR(100), +cmd_line_c VARCHAR(100), +cmd_line_d VARCHAR(100), +cmd_line_e VARCHAR(100), +cmd_line_f VARCHAR(100), +cmd_line_g VARCHAR(100), +cmd_line_h VARCHAR(100), +cmd_line_i VARCHAR(100), +cmd_line_j VARCHAR(100), +cmd_line_k VARCHAR(100), +index (callerid), +index (uniqueid), +index serverstat(server_ip,status) +); + + CREATE TABLE vicidial_list ( +lead_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +entry_date DATETIME, +modify_date TIMESTAMP, +status VARCHAR(6), +user VARCHAR(20), +vendor_lead_code VARCHAR(20), +source_id VARCHAR(6), +list_id BIGINT(14) UNSIGNED, +gmt_offset_now DECIMAL(4,2) DEFAULT '0.00', +called_since_last_reset ENUM('Y','N','Y1','Y2','Y3','Y4','Y5','Y6','Y7','Y8','Y9','Y10') default 'N', +phone_code VARCHAR(10), +phone_number VARCHAR(10), +title VARCHAR(4), +first_name VARCHAR(30), +middle_initial VARCHAR(1), +last_name VARCHAR(30), +address1 VARCHAR(100), +address2 VARCHAR(100), +address3 VARCHAR(100), +city VARCHAR(50), +state VARCHAR(2), +province VARCHAR(50), +postal_code VARCHAR(10), +country_code VARCHAR(3), +gender ENUM('M','F'), +date_of_birth DATE, +alt_phone VARCHAR(10), +email VARCHAR(70), +security_phrase VARCHAR(100), +comments VARCHAR(255), +called_count INT(8) UNSIGNED NOT NULL default '0', +index (phone_number), +index (list_id), +index (called_since_last_reset), +index (status), +index (gmt_offset_now) +); + + CREATE TABLE vicidial_hopper ( +hopper_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +lead_id INT(9) UNSIGNED NOT NULL, +campaign_id VARCHAR(8), +status ENUM('READY','QUEUE','INCALL','DONE') default 'READY', +user VARCHAR(20), +list_id BIGINT(14) UNSIGNED NOT NULL, +gmt_offset_now DECIMAL(4,2) DEFAULT '0.00', +state VARCHAR(2) default '', +index (lead_id) +); + + CREATE TABLE vicidial_live_agents ( +live_agent_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +user VARCHAR(20), +server_ip VARCHAR(15) NOT NULL, +conf_exten VARCHAR(20), +extension VARCHAR(100), +status ENUM('READY','QUEUE','INCALL','PAUSED','CLOSER') default 'PAUSED', +lead_id INT(9) UNSIGNED NOT NULL, +campaign_id VARCHAR(8), +uniqueid DOUBLE(18,7), +callerid VARCHAR(20), +channel VARCHAR(100), +random_id INT(8) UNSIGNED, +last_call_time DATETIME, +last_update_time TIMESTAMP, +last_call_finish DATETIME, +closer_campaigns TEXT, +call_server_ip VARCHAR(15), +user_level INT(2) default '0', +index (random_id), +index (last_call_time), +index (last_update_time), +index (last_call_finish) +); + + CREATE TABLE vicidial_auto_calls ( +auto_call_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +server_ip VARCHAR(15) NOT NULL, +campaign_id VARCHAR(20), +status ENUM('SENT','RINGING','LIVE','XFER','PAUSED','CLOSER','BUSY','DISCONNECT') default 'PAUSED', +lead_id INT(9) UNSIGNED NOT NULL, +uniqueid DOUBLE(18,7), +callerid VARCHAR(20), +channel VARCHAR(100), +phone_code VARCHAR(10), +phone_number VARCHAR(10), +call_time DATETIME, +call_type ENUM('IN','OUT') default 'OUT', +index (uniqueid), +index (callerid), +index (call_time) +); + + CREATE TABLE vicidial_log ( +uniqueid DOUBLE(18,7) PRIMARY KEY UNIQUE NOT NULL, +lead_id INT(9) UNSIGNED NOT NULL, +list_id BIGINT(14) UNSIGNED, +campaign_id VARCHAR(8), +call_date DATETIME, +start_epoch INT(10) UNSIGNED, +end_epoch INT(10) UNSIGNED, +length_in_sec INT(10), +status VARCHAR(6), +phone_code VARCHAR(10), +phone_number VARCHAR(10), +user VARCHAR(20), +comments VARCHAR(255), +processed ENUM('Y','N'), +index (lead_id), +index (call_date) +); + + CREATE TABLE vicidial_closer_log ( +closecallid INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +lead_id INT(9) UNSIGNED NOT NULL, +list_id BIGINT(14) UNSIGNED, +campaign_id VARCHAR(20), +call_date DATETIME, +start_epoch INT(10) UNSIGNED, +end_epoch INT(10) UNSIGNED, +length_in_sec INT(10), +status VARCHAR(6), +phone_code VARCHAR(10), +phone_number VARCHAR(10), +user VARCHAR(20), +comments VARCHAR(255), +processed ENUM('Y','N'), +index (lead_id), +index (call_date) +); + + CREATE TABLE vicidial_xfer_log ( +xfercallid INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +lead_id INT(9) UNSIGNED NOT NULL, +list_id BIGINT(14) UNSIGNED, +campaign_id VARCHAR(20), +call_date DATETIME, +phone_code VARCHAR(10), +phone_number VARCHAR(10), +user VARCHAR(20), +closer VARCHAR(20), +index (lead_id), +index (call_date) +); + + CREATE TABLE vicidial_users ( +user_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +user VARCHAR(20), +pass VARCHAR(20), +full_name VARCHAR(50), +user_level INT(2), +user_group VARCHAR(20), +phone_login VARCHAR(20), +phone_pass VARCHAR(20), +delete_users ENUM('0','1') default '0', +delete_user_groups ENUM('0','1') default '0', +delete_lists ENUM('0','1') default '0', +delete_campaigns ENUM('0','1') default '0', +delete_ingroups ENUM('0','1') default '0', +delete_remote_agents ENUM('0','1') default '0', +load_leads ENUM('0','1') default '0', +campaign_detail ENUM('0','1') default '0', +ast_admin_access ENUM('0','1') default '0', +ast_delete_phones ENUM('0','1') default '0', +delete_scripts ENUM('0','1') default '0', +modify_leads ENUM('0','1') default '0', +hotkeys_active ENUM('0','1') default '0', +change_agent_campaign ENUM('0','1') default '0', +agent_choose_ingroups ENUM('0','1') default '1', +closer_campaigns TEXT, +scheduled_callbacks ENUM('0','1') default '1', +agentonly_callbacks ENUM('0','1') default '0', +agentcall_manual ENUM('0','1') default '0', +vicidial_recording ENUM('0','1') default '1', +vicidial_transfers ENUM('0','1') default '1', +delete_filters ENUM('0','1') default '0', +alter_agent_interface_options ENUM('0','1') default '0', +closer_default_blended ENUM('0','1') default '0', +delete_call_times ENUM('0','1') default '0', +modify_call_times ENUM('0','1') default '0', +index (user) +); + + CREATE TABLE vicidial_user_log ( +user_log_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +user VARCHAR(20), +event VARCHAR(50), +campaign_id VARCHAR(8), +event_date DATETIME, +event_epoch INT(10) UNSIGNED, +index (user) +); + + CREATE TABLE vicidial_user_groups ( +user_group VARCHAR(20) NOT NULL, +group_name VARCHAR(40) NOT NULL +); + + CREATE TABLE vicidial_campaigns ( +campaign_id VARCHAR(8) PRIMARY KEY UNIQUE NOT NULL, +campaign_name VARCHAR(40), +active ENUM('Y','N'), +dial_status_a VARCHAR(6), +dial_status_b VARCHAR(6), +dial_status_c VARCHAR(6), +dial_status_d VARCHAR(6), +dial_status_e VARCHAR(6), +lead_order VARCHAR(20), +park_ext VARCHAR(10), +park_file_name VARCHAR(10), +web_form_address VARCHAR(255), +allow_closers ENUM('Y','N'), +hopper_level INT(8) UNSIGNED default '1', +auto_dial_level ENUM('0','1','1.1','1.2','1.3','1.4','1.5','1.6','1.7','1.8','1.9','2.0','2.2','2.5','2.7','3.0','3.5','4.0') default '0', +next_agent_call ENUM('random','oldest_call_start','oldest_call_finish','overall_user_level') default 'oldest_call_finish', +local_call_time VARCHAR(10) DEFAULT '9am-9pm', +voicemail_ext VARCHAR(10), +dial_timeout TINYINT UNSIGNED default '60', +dial_prefix VARCHAR(20) default '9', +campaign_cid VARCHAR(10) default '0000000000', +campaign_vdad_exten VARCHAR(20) default '8365', +campaign_rec_exten VARCHAR(20) default '8309', +campaign_recording ENUM('NEVER','ONDEMAND','ALLCALLS') default 'ONDEMAND', +campaign_rec_filename VARCHAR(50) default 'FULLDATE_CUSTPHONE', +campaign_script VARCHAR(10), +get_call_launch ENUM('NONE','SCRIPT','WEBFORM') default 'NONE', +am_message_exten VARCHAR(20), +amd_send_to_vmx ENUM('Y','N') default 'N', +xferconf_a_dtmf VARCHAR(50), +xferconf_a_number VARCHAR(50), +xferconf_b_dtmf VARCHAR(50), +xferconf_b_number VARCHAR(50), +alt_number_dialing ENUM('Y','N') default 'N', +scheduled_callbacks ENUM('Y','N') default 'N', +lead_filter_id VARCHAR(10) default 'NONE', +drop_call_seconds TINYINT(3) unsigned default '5', +safe_harbor_message ENUM('Y','N') default 'N', +safe_harbor_exten VARCHAR(20) default '8307', +display_dialable_count ENUM('Y','N') default 'Y', +wrapup_seconds SMALLINT(3) UNSIGNED default '0', +wrapup_message VARCHAR(255) default 'Wrapup Call', +closer_campaigns TEXT default '', +use_internal_dnc ENUM('Y','N') default 'N' +); + + CREATE TABLE vicidial_lists ( +list_id BIGINT(14) UNSIGNED PRIMARY KEY UNIQUE NOT NULL, +list_name VARCHAR(30), +campaign_id VARCHAR(8), +active ENUM('Y','N') +); + + CREATE TABLE vicidial_statuses ( +status VARCHAR(6) PRIMARY KEY UNIQUE NOT NULL, +status_name VARCHAR(30), +selectable ENUM('Y','N') +); + + CREATE TABLE vicidial_campaign_statuses ( +status VARCHAR(6) NOT NULL, +status_name VARCHAR(30), +selectable ENUM('Y','N'), +campaign_id VARCHAR(8), +index (campaign_id) +); + + CREATE TABLE vicidial_campaign_hotkeys ( +status VARCHAR(6) NOT NULL, +hotkey VARCHAR(1) NOT NULL, +status_name VARCHAR(30), +selectable ENUM('Y','N'), +campaign_id VARCHAR(8), +index (campaign_id) +); + + CREATE TABLE vicidial_conferences ( +conf_exten INT(7) UNSIGNED NOT NULL, +server_ip VARCHAR(15) NOT NULL, +extension VARCHAR(100) +); + + CREATE TABLE vicidial_phone_codes ( +country_code SMALLINT(5) UNSIGNED, +country CHAR(3), +areacode CHAR(3), +state VARCHAR(4), +GMT_offset VARCHAR(5), +DST enum('Y','N'), +DST_range VARCHAR(8), +geographic_description VARCHAR(30) +); + + CREATE TABLE vicidial_inbound_groups ( +group_id VARCHAR(20) PRIMARY KEY UNIQUE NOT NULL, +group_name VARCHAR(30), +group_color VARCHAR(7), +active ENUM('Y','N'), +web_form_address VARCHAR(255), +voicemail_ext VARCHAR(10), +next_agent_call ENUM('random','oldest_call_start','oldest_call_finish','overall_user_level') default 'oldest_call_finish', +fronter_display ENUM('Y','N') default 'Y', +ingroup_script VARCHAR(10), +get_call_launch ENUM('NONE','SCRIPT','WEBFORM') default 'NONE', +xferconf_a_dtmf VARCHAR(50), +xferconf_a_number VARCHAR(50), +xferconf_b_dtmf VARCHAR(50), +xferconf_b_number VARCHAR(50), +drop_call_seconds SMALLINT(4) unsigned default '360', +drop_message ENUM('Y','N') default 'N', +drop_exten VARCHAR(20) default '8307' +); + +CREATE TABLE vicidial_stations ( +agent_station VARCHAR(10) PRIMARY KEY UNIQUE NOT NULL, +phone_channel VARCHAR(100), +computer_ip VARCHAR(15) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +DB_server_ip VARCHAR(15) NOT NULL, +DB_user VARCHAR(15), +DB_pass VARCHAR(15), +DB_port VARCHAR(6) +); + + CREATE TABLE vicidial_remote_agents ( +remote_agent_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +user_start VARCHAR(20), +number_of_lines TINYINT UNSIGNED default '1', +server_ip VARCHAR(15) NOT NULL, +conf_exten VARCHAR(20), +status ENUM('ACTIVE','INACTIVE') default 'INACTIVE', +campaign_id VARCHAR(8), +closer_campaigns TEXT +); + + CREATE TABLE live_inbound_log ( +uniqueid DOUBLE(18,7) NOT NULL, +channel VARCHAR(100) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +caller_id VARCHAR(30), +extension VARCHAR(100), +phone_ext VARCHAR(40), +start_time DATETIME, +acknowledged ENUM('Y','N') default 'N', +inbound_number VARCHAR(20), +comment_a VARCHAR(50), +comment_b VARCHAR(50), +comment_c VARCHAR(50), +comment_d VARCHAR(50), +comment_e VARCHAR(50), +index (uniqueid), +index (phone_ext), +index (start_time) +); + + CREATE TABLE web_client_sessions ( +extension VARCHAR(100) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +program ENUM('agc','vicidial','monitor','other') default 'agc', +start_time DATETIME NOT NULL, +session_name VARCHAR(40) UNIQUE NOT NULL +); + + CREATE TABLE server_performance ( +start_time DATETIME NOT NULL, +server_ip VARCHAR(15) NOT NULL, +sysload INT(6) NOT NULL, +freeram SMALLINT(5) UNSIGNED NOT NULL, +usedram SMALLINT(5) UNSIGNED NOT NULL, +processes SMALLINT(4) UNSIGNED NOT NULL, +channels_total SMALLINT(4) UNSIGNED NOT NULL, +trunks_total SMALLINT(4) UNSIGNED NOT NULL, +clients_total SMALLINT(4) UNSIGNED NOT NULL, +clients_zap SMALLINT(4) UNSIGNED NOT NULL, +clients_iax SMALLINT(4) UNSIGNED NOT NULL, +clients_local SMALLINT(4) UNSIGNED NOT NULL, +clients_sip SMALLINT(4) UNSIGNED NOT NULL, +live_recordings SMALLINT(4) UNSIGNED NOT NULL, +cpu_user_percent SMALLINT(3) UNSIGNED NOT NULL default '0', +cpu_system_percent SMALLINT(3) UNSIGNED NOT NULL default '0', +cpu_idle_percent SMALLINT(3) UNSIGNED NOT NULL default '0' +); + + CREATE TABLE vicidial_agent_log ( +agent_log_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +user VARCHAR(20), +server_ip VARCHAR(15) NOT NULL, +event_time DATETIME, +lead_id INT(9) UNSIGNED, +campaign_id VARCHAR(8), +pause_epoch INT(10) UNSIGNED, +pause_sec SMALLINT(5) UNSIGNED default '0', +wait_epoch INT(10) UNSIGNED, +wait_sec SMALLINT(5) UNSIGNED default '0', +talk_epoch INT(10) UNSIGNED, +talk_sec SMALLINT(5) UNSIGNED default '0', +dispo_epoch INT(10) UNSIGNED, +dispo_sec SMALLINT(5) UNSIGNED default '0', +status VARCHAR(6) +); + + CREATE TABLE vicidial_scripts ( +script_id VARCHAR(10) PRIMARY KEY UNIQUE NOT NULL, +script_name VARCHAR(50), +script_comments VARCHAR(255), +script_text TEXT, +active ENUM('Y','N') +); + + CREATE TABLE phone_favorites ( +extension VARCHAR(100), +server_ip VARCHAR(15), +extensions_list TEXT +); + + CREATE TABLE vicidial_callbacks ( +callback_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +lead_id INT(9) UNSIGNED, +list_id BIGINT(14) UNSIGNED, +campaign_id VARCHAR(8), +status VARCHAR(10), +entry_time DATETIME, +callback_time DATETIME, +modify_date TIMESTAMP, +user VARCHAR(20), +recipient ENUM('USERONLY','ANYONE'), +comments VARCHAR(255), +index (lead_id), +index (status), +index (callback_time) +); + + CREATE TABLE vicidial_list_pins ( +pins_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +entry_time DATETIME, +phone_number VARCHAR(10), +lead_id INT(9) UNSIGNED, +campaign_id VARCHAR(20), +product_code VARCHAR(20), +user VARCHAR(20), +digits VARCHAR(20), +index (lead_id), +index (phone_number), +index (entry_time) +); + + CREATE TABLE vicidial_lead_filters ( +lead_filter_id VARCHAR(10) PRIMARY KEY NOT NULL, +lead_filter_name VARCHAR(30) NOT NULL, +lead_filter_comments VARCHAR(255), +lead_filter_sql TEXT +); + + CREATE TABLE vicidial_call_times ( +call_time_id VARCHAR(10) PRIMARY KEY NOT NULL, +call_time_name VARCHAR(30) NOT NULL, +call_time_comments VARCHAR(255) default '', +ct_default_start SMALLINT(4) unsigned NOT NULL default '900', +ct_default_stop SMALLINT(4) unsigned NOT NULL default '2100', +ct_sunday_start SMALLINT(4) unsigned default '0', +ct_sunday_stop SMALLINT(4) unsigned default '0', +ct_monday_start SMALLINT(4) unsigned default '0', +ct_monday_stop SMALLINT(4) unsigned default '0', +ct_tuesday_start SMALLINT(4) unsigned default '0', +ct_tuesday_stop SMALLINT(4) unsigned default '0', +ct_wednesday_start SMALLINT(4) unsigned default '0', +ct_wednesday_stop SMALLINT(4) unsigned default '0', +ct_thursday_start SMALLINT(4) unsigned default '0', +ct_thursday_stop SMALLINT(4) unsigned default '0', +ct_friday_start SMALLINT(4) unsigned default '0', +ct_friday_stop SMALLINT(4) unsigned default '0', +ct_saturday_start SMALLINT(4) unsigned default '0', +ct_saturday_stop SMALLINT(4) unsigned default '0', +ct_state_call_times TEXT default '' +); + + CREATE TABLE vicidial_state_call_times ( +state_call_time_id VARCHAR(10) PRIMARY KEY NOT NULL, +state_call_time_state VARCHAR(2) NOT NULL, +state_call_time_name VARCHAR(30) NOT NULL, +state_call_time_comments VARCHAR(255) default '', +sct_default_start SMALLINT(4) unsigned NOT NULL default '900', +sct_default_stop SMALLINT(4) unsigned NOT NULL default '2100', +sct_sunday_start SMALLINT(4) unsigned default '0', +sct_sunday_stop SMALLINT(4) unsigned default '0', +sct_monday_start SMALLINT(4) unsigned default '0', +sct_monday_stop SMALLINT(4) unsigned default '0', +sct_tuesday_start SMALLINT(4) unsigned default '0', +sct_tuesday_stop SMALLINT(4) unsigned default '0', +sct_wednesday_start SMALLINT(4) unsigned default '0', +sct_wednesday_stop SMALLINT(4) unsigned default '0', +sct_thursday_start SMALLINT(4) unsigned default '0', +sct_thursday_stop SMALLINT(4) unsigned default '0', +sct_friday_start SMALLINT(4) unsigned default '0', +sct_friday_stop SMALLINT(4) unsigned default '0', +sct_saturday_start SMALLINT(4) unsigned default '0', +sct_saturday_stop SMALLINT(4) unsigned default '0' +); + + CREATE TABLE vicidial_campaign_stats ( +campaign_id VARCHAR(20) PRIMARY KEY NOT NULL, +update_time TIMESTAMP, +dialable_leads INT(9) UNSIGNED default '0', +calls_today INT(9) UNSIGNED default '0', +drops_today INT(9) UNSIGNED default '0', +drops_today_pct VARCHAR(6) default '0', +calls_hour INT(9) UNSIGNED default '0', +drops_hour INT(9) UNSIGNED default '0', +drops_hour_pct VARCHAR(6) default '0', +calls_halfhour INT(9) UNSIGNED default '0', +drops_halfhour INT(9) UNSIGNED default '0', +drops_halfhour_pct VARCHAR(6) default '0', +calls_fivemin INT(9) UNSIGNED default '0', +drops_fivemin INT(9) UNSIGNED default '0', +drops_fivemin_pct VARCHAR(6) default '0', +calls_onemin INT(9) UNSIGNED default '0', +drops_onemin INT(9) UNSIGNED default '0', +drops_onemin_pct VARCHAR(6) default '0' +); + + CREATE TABLE vicidial_dnc ( +phone_number VARCHAR(10) PRIMARY KEY NOT NULL +); + + CREATE TABLE vicidial_lead_recycle ( +recycle_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY UNIQUE NOT NULL, +campaign_id VARCHAR(8), +status VARCHAR(6) NOT NULL, +attempt_delay SMALLINT(5) UNSIGNED default '1800', +attempt_maximum TINYINT(3) UNSIGNED default '32', +active ENUM('Y','N') default 'N', +index (campaign_id) +); + + + +INSERT INTO vicidial_call_times SET call_time_id='24hours',call_time_name='default 24 hours calling',ct_default_start='0',ct_default_stop='2400'; +INSERT INTO vicidial_call_times SET call_time_id='9am-9pm',call_time_name='default 9am to 9pm calling',ct_default_start='900',ct_default_stop='2100'; +INSERT INTO vicidial_call_times SET call_time_id='9am-5pm',call_time_name='default 9am to 5pm calling',ct_default_start='900',ct_default_stop='1700'; +INSERT INTO vicidial_call_times SET call_time_id='12pm-5pm',call_time_name='default 12pm to 5pm calling',ct_default_start='1200',ct_default_stop='1700'; +INSERT INTO vicidial_call_times SET call_time_id='12pm-9pm',call_time_name='default 12pm to 9pm calling',ct_default_start='1200',ct_default_stop='1200'; +INSERT INTO vicidial_call_times SET call_time_id='5pm-9pm',call_time_name='default 5pm to 9pm calling',ct_default_start='1700',ct_default_stop='2100'; + +INSERT INTO vicidial_state_call_times SET state_call_time_id='alabama',state_call_time_state='AL',state_call_time_name='Alabama 8am-8pm and Sunday',sct_default_start='800',sct_default_stop='2000',sct_sunday_start='2400',sct_sunday_stop='2400'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='illinois',state_call_time_state='IL',state_call_time_name='Illinois 8am',sct_default_start='800',sct_default_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='indiana',state_call_time_state='IN',state_call_time_name='Indiana 8pm restriction',sct_default_start='900',sct_default_stop='2000'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='kentucky',state_call_time_state='KY',state_call_time_name='Kentucky 10am restriction',sct_default_start='1000',sct_default_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='louisiana',state_call_time_state='LA',state_call_time_name='Louisiana 8am-8pm and Sunday',sct_default_start='800',sct_default_stop='2000',sct_sunday_start='2400',sct_sunday_stop='2400'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='massachuse',state_call_time_state='MA',state_call_time_name='Massachusetts 8am-8pm',sct_default_start='800',sct_default_stop='2000'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='mississipp',state_call_time_state='MS',state_call_time_name='Mississippi 8am-8pm and Sunday',sct_default_start='800',sct_default_stop='2000',sct_sunday_start='2400',sct_sunday_stop='2400'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='nebraska',state_call_time_state='NE',state_call_time_name='Nebraska 8am',sct_default_start='800',sct_default_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='nevada',state_call_time_state='NV',state_call_time_name='Nevada 8pm restriction',sct_default_start='900',sct_default_stop='2000'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='pennsylvan',state_call_time_state='PN',state_call_time_name='Pennsylvania sunday restriction',sct_sunday_start='1330',sct_sunday_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='rhodeislan',state_call_time_state='RI',state_call_time_name='Rhode Island restrictions',sct_default_start='900',sct_default_stop='1800',sct_sunday_start='2400',sct_sunday_stop='2400',sct_saturday_start='1000',sct_saturday_stop='1700'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='sdakota',state_call_time_state='SD',state_call_time_name='South Dakota sunday restrict',sct_sunday_start='2400',sct_sunday_stop='2400'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='tennessee',state_call_time_state='TN',state_call_time_name='Tennessee 8am',sct_default_start='800',sct_default_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='texas',state_call_time_state='TX',state_call_time_name='Texas sunday restriction',sct_sunday_start='1200',sct_sunday_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='utah',state_call_time_state='UT',state_call_time_name='Utah 8pm restriction',sct_default_start='900',sct_default_stop='2000'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='washington',state_call_time_state='WA',state_call_time_name='Washington 8am',sct_default_start='800',sct_default_stop='2100'; +INSERT INTO vicidial_state_call_times SET state_call_time_id='wyoming',state_call_time_state='WY',state_call_time_name='Wyoming 8am-8pm',sct_default_start='800',sct_default_stop='2000'; + diff --git a/agc_2-X/trunk/VD_amd.agi b/agc_2-X/trunk/VD_amd.agi new file mode 100644 index 00000000..8adf0e89 --- /dev/null +++ b/agc_2-X/trunk/VD_amd.agi @@ -0,0 +1,368 @@ +#!/usr/bin/perl +# +# VD_amd.agi version 0.3 +# +# NOTE: This script is only needed with app_amd enabled systems +# +# runs after a call goes through AMD in extensions.conf to send the call on to +# it's proper destination +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; VICIDIAL_auto_dialer transfer script AMD with Load Balanced: +# exten => 8369,1,AGI(call_log.agi,${EXTEN}) +# exten => 8369,2,(AMD),AMD +# exten => 8369,3,AGI(VD_amd.agi,${EXTEN}) +# exten => 8369,4,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# exten => 8369,5,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# exten => 8369,6,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# exten => 8369,7,Hangup +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60206-1434 first build +# 60207-1205 added database records entries/modifications +# 60207-1507 added ability to send AMs to campaign-defined message to leave + + +$V = 0; # set to 1 for verbose mode +$M = 0; # set to 1 for 2 line messages mode +$A = 1; # set to 1 for AMD output messages mode +$AMD_LOG = 1; # set to 1 for logfile + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() +{ + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1; $calleridnum = $callerid;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; +# ### set the callerid to the ACQS value(calleridname) +# print "SET CALLERID $callerid\n"; +# checkresult($result); +# print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; +# ### set the callerid to the ACQS value(calleridname) +# print "SET CALLERID $callerid\n"; +# checkresult($result); +# print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); +$VD_lead_id = $CIDlead_id; + +if ($V) {print STDERR "\nVD_amd : $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VD amd START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|\n";} + + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + + +$AMDSTATUS = $AGI->get_variable(AMDSTATUS); +$AMDCAUSE = $AGI->get_variable(AMDCAUSE); + +if ($A) {print STDERR "AAAAA AMD results: |$AMDSTATUS|$AMDCAUSE|\n";} + +# AAAAA AMD results: |AMD_PERSON|AMD_HUMAN-300-300| +# AAAAA AMD results: |AMD_MACHINE|AMD_LONGGREETING-1500-1500| + + +if ($AMD_LOG) + { + open(Lout, ">>/home/cron/AMD_log.txt") + || die "Can't open /home/cron/AMD_log.txt: $!\n"; + print Lout "$now_date|$VD_lead_id| |$AMDSTATUS|$AMDCAUSE|$calleridnum|\n"; + close(Lout); + } + + +################################################################################## +########## AMD says it's a person so exit and go on to transfer scripts ########## +if ($AMDSTATUS =~ /PERSON|NOTSURE|HANGUP/) +{ + if ($A) {print STDERR " AMD exiting\n";} + exit; +} + +else +{ +################################################################################ +########## AMD says it's a machine so modify statuses and hangup call ########## +########## something will go here later for leaving a message on AMs ########## +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +########## FIND ext_context from the servers table ########## +$stmtA = "SELECT ext_context FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBext_context = "$record->[1]"; + if ($DBext_context) {$ext_context = $DBext_context;} + } + } + +########## FIND vicidial_auto_calls record ########## +$stmtA = "SELECT campaign_id,phone_code,phone_number FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VD_campaign_id = "$record->[0]"; + $VD_phone_code = "$record->[1]"; + $VD_phone_number = "$record->[2]"; + } + } + +########## UPDATE vicidial_list ########## +$stmtA = "UPDATE vicidial_list set status='A' where lead_id = '$VD_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id\n";} + +########## DELETE vicidial_auto_calls entry ########## +$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAC record deleted: |$affected_rows| |$VD_lead_id|$uniqueid|$VD_callerid|$server_ip\n";} + +########## FIND AND UPDATE vicidial_log ########## +$stmtA = "SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); + $epc_countCUSTDATA=0; +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VD_start_epoch = "$record->[0]"; + $epc_countCUSTDATA++; + } + } +if (!$epc_countCUSTDATA) + { + if($M){print STDERR "\nVD amd: no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";} + $end_epoch = ($now_date_epoch + 3); + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch) values('$uniqueid','$VD_lead_id','$VD_campaign_id','$now_date','$now_date_epoch','A','$VD_phone_code','$VD_phone_number','VDAD','N','3','$end_epoch')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + } +else + { + $VD_seconds = ($now_date_epoch - $VD_start_epoch); + $stmtA = "UPDATE vicidial_log set status='A',end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|\n";} + } + + +### Grab vmail forward message values from the database +$stmtA = "SELECT am_message_exten,amd_send_to_vmx FROM vicidial_campaigns where campaign_id = '$VD_campaign_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DB_am_message_exten = "$record->[0]"; + $DB_amd_send_to_vmx = "$record->[1]"; + } + } + +if ($M) {print STDERR "-- AMD campaign values: |$VD_campaign_id|$DB_am_message_exten|$DB_amd_send_to_vmx|\n";} + +if ( ($DB_amd_send_to_vmx =~ /Y/) && (length($DB_am_message_exten) > 0) ) + { + $stmtA = "UPDATE vicidial_log set status='AM' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log AM update: |$affected_rows|$uniqueid|\n";} + + $stmtA = "UPDATE vicidial_list set status='AM' where lead_id='$VD_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list AM update: |$affected_rows|$uniqueid|\n";} + + print STDERR "\nexiting the AMD app, transferring call to $DB_am_message_exten"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DB_am_message_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + exit; + } + +$dbhA->close; + +$AGI->hangup($channel); + +exit; +} + + + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/VD_amd_post.agi b/agc_2-X/trunk/VD_amd_post.agi new file mode 100644 index 00000000..f15bb59d --- /dev/null +++ b/agc_2-X/trunk/VD_amd_post.agi @@ -0,0 +1,239 @@ +#!/usr/bin/perl +# +# VD_amd_post.agi version 0.1 +# +# NOTE: This script is only needed with app_amd enabled systems +# +# runs after a call goes through AMD in extensions.conf to send the call on to +# it's proper destination +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; VICIDIAL_auto_dialer transfer script AMD with Load Balanced: +# exten => 8369,1,AGI(call_log.agi,${EXTEN}) +# exten => 8369,2,(AMD),AMD +# exten => 8369,3,AGI(VD.agi,${EXTEN}) +# exten => 8369,4,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# exten => 8369,5,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# exten => 8369,6,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# exten => 8369,7,Hangup +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60217-1119 first build +# + +$V = 0; # set to 1 for verbose mode +$M = 0; # set to 1 for 2 line messages mode +$A = 1; # set to 1 for AMD output messages mode +$AMD_LOG = 0; # set to 1 for logfile + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() +{ + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; +# ### set the callerid to the ACQS value(calleridname) +# print "SET CALLERID $callerid\n"; +# checkresult($result); +# print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; +# ### set the callerid to the ACQS value(calleridname) +# print "SET CALLERID $callerid\n"; +# checkresult($result); +# print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); +$VD_lead_id = $CIDlead_id; + +if ($V) {print STDERR "\nVD_amd_post : $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VD amd START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|\n";} + + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + + + + + + + + + + + +################################################################################ +########## AMD says it's a machine so modify statuses and hangup call ########## +########## something will go here later for leaving a message on AMs ########## +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +$stmtA = "UPDATE vicidial_log set status='AL' where lead_id='$VD_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_log AM update: |$affected_rows|$uniqueid|\n";} + +$stmtA = "UPDATE vicidial_list set status='AL' where lead_id='$VD_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_list AM update: |$affected_rows|$uniqueid|\n";} + + + +$dbhA->close; + + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/VD_app_conference_0.6.zip b/agc_2-X/trunk/VD_app_conference_0.6.zip new file mode 100644 index 00000000..46ea14ce Binary files /dev/null and b/agc_2-X/trunk/VD_app_conference_0.6.zip differ diff --git a/agc_2-X/trunk/VD_hangup.agi b/agc_2-X/trunk/VD_hangup.agi new file mode 100644 index 00000000..afbd0779 --- /dev/null +++ b/agc_2-X/trunk/VD_hangup.agi @@ -0,0 +1,385 @@ +#!/usr/bin/perl +# +# VD_hangup.agi version 0.2 +# +# NOTE: This script is only needed on Asterisk 1.2.X and higher systems +# +# runs when a call hangs up in the second priority behind call_log. This script +# will lookup the uniqueid of the call and/or the callerIDname and update tables +# if it is a VICIDIAL inbound or outbound call that hungup before sent to agent +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => h,1,DeadAGI(call_log.agi,${EXTEN}) +# exten => h,2,DeadAGI(VD_hangup.agi,PRI-----DEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) +# +# NOTES: +# - To disable Busy and Disconnect detection change the first field from PRI to NONPRI +# - To disable Debug output to file change the second field from DEBUG to NODEBUG +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60203-1218 - fixed calleridname issue with 1.2 tree for custom CID +# 60314-1250 - Altered to allow for ignoring of AGI-defined status +# 60612-1500 - Added option for text log of hangup codes +# - Added option for PRI hangup code dispositions: BUSY, DISCONNECT +# 60615-1101 - Fixed log updates for CLOSER transfer from fronter calls +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $PRI = $ARGV_vars[0]; + $DEBUG = $ARGV_vars[1]; + $hangup_cause = $ARGV_vars[2]; + $dialstatus = $ARGV_vars[3]; + $dial_time = $ARGV_vars[4]; + $ring_time = $ARGV_vars[5]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() +{ + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; +# ### set the callerid to the ACQS value(calleridname) +# print "SET CALLERID $callerid\n"; +# checkresult($result); +# print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; +# ### set the callerid to the ACQS value(calleridname) +# print "SET CALLERID $callerid\n"; +# checkresult($result); +# print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";} + +if ($DEBUG =~ /^DEBUG$/) +{ + ### open the error out file for writing ### + open(out, ">>/home/cron/HANGUP_test-output.txt") + || die "Can't open /home/cron/HANGUP_test-output.txt: $!\n"; + + print out "$now_date|$hangup_cause|$dialstatus|$dial_time|$ring_time|$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n"; + + close(out); +} +else {print STDERR "\nDEBUG: $DEBUG\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nVD_hangup : $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VD hangup START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|\n";} + + +if ($channel =~ /^Local/) +{ + if ( ($PRI =~ /^PRI$/) && ($callerid =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) && ( ($dialstatus =~ /BUSY/) || ( ($dialstatus =~ /CHANUNAVAIL/) && ($hangup_cause =~ /^1$|^28$/) ) ) ) + { + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + if ($dialstatus =~ /BUSY/) {$VDL_status = 'B'; $VDAC_status = 'BUSY';} + if ($dialstatus =~ /CHANUNAVAIL/) {$VDL_status = 'DC'; $VDAC_status = 'DISCONNECT';} + + $stmtA = "UPDATE vicidial_auto_calls set status='$VDAC_status' where callerid = '$callerid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAC update: |$affected_rows|$CIDlead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='$VDL_status' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id\n";} + + $stmtA = "UPDATE vicidial_log set status='$VDL_status' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|\n";} + + $dbhA->close; + } + else + { + if ($M) {print STDERR "-- VDhangup Local DEBUG: |$PRI|$callerid|$dialstatus|$hangup_cause|\n";} + } + + if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} + if ($priority > 2) {sleep(1);} + exit; +} + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +########## FIND AND DELETE vicidial_auto_calls ########## +$stmtA = "SELECT lead_id,callerid FROM vicidial_auto_calls where uniqueid = '$uniqueid' limit 1;"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); + $rec_countCUSTDATA=0; +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VD_lead_id = "$record->[0]"; + $VD_callerid = "$record->[1]"; + $rec_countCUSTDATA++; + } + } + +if (!$rec_countCUSTDATA) + { + if($M){print STDERR "\nVD hangup: no VDAC record found: $uniqueid $calleridname\n";} + exit; + } + +$stmtA = "DELETE FROM vicidial_auto_calls where uniqueid='$uniqueid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAC record deleted: |$affected_rows| |$VD_lead_id|$uniqueid|$VD_callerid|$server_ip\n";} + + +########## FIND AND UPDATE vicidial_log ########## +$stmtA = "SELECT start_epoch,status FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$VD_lead_id' limit 1;"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); + $epc_countCUSTDATA=0; + $VD_closecallid=''; +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VD_start_epoch = "$record->[0]"; + $VD_status = "$record->[1]"; + $epc_countCUSTDATA++; + } + } +if (!$epc_countCUSTDATA) + { + if($M){print STDERR "\nVD hangup: no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";} + + $secX = time(); + $Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours + ($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget); + $Ryear = ($Ryear + 1900); + $Rmon++; + if ($Rmon < 10) {$Rmon = "0$Rmon";} + if ($Rmday < 10) {$Rmday = "0$Rmday";} + if ($Rhour < 10) {$Rhour = "0$Rhour";} + if ($Rmin < 10) {$Rmin = "0$Rmin";} + if ($Rsec < 10) {$Rsec = "0$Rsec";} + $RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec"; + + $stmtA = "SELECT start_epoch,status,closecallid FROM vicidial_closer_log where lead_id = '$VD_lead_id' and call_date > \"$RSQLdate\" order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + $epc_countCUSTDATA=0; + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VD_start_epoch = "$record->[0]"; + $VD_status = "$record->[1]"; + $VD_closecallid = "$record->[2]"; + $epc_countCUSTDATA++; + } + } + } +if (!$epc_countCUSTDATA) + { + if($M){print STDERR "\nVD hangup: no VDL or VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";} + exit; + } +$VD_seconds = ($now_date_epoch - $VD_start_epoch); + +$SQL_status=''; +if ($VD_status =~ /^NA$|^NEW$|^QUEUE$|^XFER$/) + { + $SQL_status = "status='DROP',"; + + ########## FIND AND UPDATE vicidial_list ########## + $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$VD_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id\n";} + } + +$stmtA = "UPDATE vicidial_log set $SQL_status end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|\n";} + + + + +########## UPDATE vicidial_closer_log ########## +if (length($VD_closecallid) < 1) + { + if($M){print STDERR "\nVD hangup: no VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";} + exit; + } +$VD_seconds = ($now_date_epoch - $VD_start_epoch); +$stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where closecallid = '$VD_closecallid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDCL update: |$affected_rows|$uniqueid|$VD_closecallid|\n";} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/VICIDIAL_IN_new_leads_file.pl b/agc_2-X/trunk/VICIDIAL_IN_new_leads_file.pl new file mode 100644 index 00000000..2274bb2d --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_IN_new_leads_file.pl @@ -0,0 +1,867 @@ +#!/usr/bin/perl +# +# VICIDIAL_IN_new_leads_file.pl version 0.3 +# +# DESCRIPTION: +# script lets you insert leads into the vicidial_list table from a TAB-delimited +# lead file that is in the proper format. (for format see --help) +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# CHANGES +# 60615-1543 - Added gmt_offset_now lookup for each lead +# - Added option to force a gmt value(field after COMMENTS field) +# 60616-0958 - Added listID override feature to force all leads into same list +# + +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + +print "\n\n\n\n\n\n\n\n\n\n\n\n-- VICIDIAL_IN_new_leads_file.pl --\n\n"; +print "This program is designed to take a tab delimited file and import it into the VICIDIAL system. \n\n"; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-forcegmt] = forces gmt value of column after comments column\n [-debug] = debug output\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + print "This script takes in lead files in the following order when they are placed in the /home/cron/VICIDIAL/LEADS_IN directory to be imported into the vicidial_list table:\n\n"; + print "vendor_lead_code|source_code|list_id|phone_code|phone_number|title|first_name|middle|last_name|address1|address2|address3|city|state|province|postal_code|country|gender|date_of_birth|alt_phone|email|security_phrase|COMMENTS\n\n"; + print "3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS\n\n"; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; + print "\n-----DEBUGGING -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-q/i) + { + $q=1; + } + if ($args =~ /-t/i) + { + $T=1; + $TEST=1; + print "\n----- TESTING -----\n\n"; + } + if ($args =~ /-forcegmt/i) + { + $forcegmt=1; + print "\n----- FORCE GMT -----\n\n"; + } + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + } +} +else +{ +print "no command line options set\n"; +} +### end parsing run-time options ### + + +$suf = '.txt'; +$people_packages_id_update=''; +$dir1 = '/home/cron/VICIDIAL/LEADS_IN'; +$dir2 = '/home/cron/VICIDIAL/LEADS_IN/DONE'; + + + opendir(FILE, "$dir1/"); + @FILES = readdir(FILE); + +foreach(@FILES) + { + $size1 = 0; + $size2 = 0; + $person_id_delete = ''; + $transaction_id_delete = ''; + + if (length($FILES[$i]) > 4) + { + + $size1 = (-s "$dir1/$FILES[$i]"); + if (!$q) {print "$FILES[$i] $size1\n";} + sleep(2); + $size2 = (-s "$dir1/$FILES[$i]"); + if (!$q) {print "$FILES[$i] $size2\n\n";} + + + if ( ($FILES[$i] !~ /^TRANSFERRED/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) + { + $GOODfname = $FILES[$i]; + $FILES[$i] =~ s/ /_/gi; + $FILES[$i] =~ s/\(|\)|\||\\|\/|\'|\"|//gi; + rename("$dir1/$GOODfname","$dir1/$FILES[$i]"); + $FILEname = $FILES[$i]; + + $Routfile = "ERR_$source$FILES[$i]"; + $Soutfile = "STS_$source$FILES[$i]"; + $Toutfile = "SQL_$source$FILES[$i]"; + $Doutfile = "DEL_$source$FILES[$i]"; + + `cp -f $dir1/$FILES[$i] $dir2/$source$FILES[$i]`; + + ### open the in file for reading ### + open(infile, "$dir2/$source$FILES[$i]") + || die "Can't open $source$FILES[$i]: $!\n"; + + ### open the error out file for writing ### + open(Rout, ">>$dir2/$Routfile") + || die "Can't open $Routfile: $!\n"; + + ### open the error out file for writing ### + open(Tout, ">>$dir2/$Toutfile") + || die "Can't open $Toutfile: $!\n"; + + ### open the error out file for writing ### + open(Dout, ">>$dir2/$Doutfile") + || die "Can't open $Doutfile: $!\n"; + + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use Net::MySQL; + + my $dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + ### Grab Server values from the database + $stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + + + + + + + print "\n\n SQL inserts will be put in $Toutfile\n\n"; + + $a=0; ### each line of input file counter ### + $b=0; ### status of 'APPROVED' counter ### + $c=0; ### status of 'DECLINED' counter ### + $d=0; ### status of 'REFERRED' counter ### + $e=0; ### status of 'ERROR' counter ### + $f=0; ### number of modified packages ### + $g=0; ### number of credits ### + + $multi_insert_counter=0; + $multistmt=''; + + while () + { + +# print "$a| $number\n"; + $number = $_; + chomp($number); +# $number =~ s/,/\|/gi; + $number =~ s/\t/\|/gi; + $number =~ s/\'|\t|\r|\n|\l//gi; + $number =~ s/\'|\t|\r|\n|\l//gi; + $number =~ s/\",,,,,,,\"/\|\|\|\|\|\|\|/gi; + $number =~ s/\",,,,,,\"/\|\|\|\|\|\|/gi; + $number =~ s/\",,,,,\"/\|\|\|\|\|/gi; + $number =~ s/\",,,,\"/\|\|\|\|/gi; + $number =~ s/\",,,\"/\|\|\|/gi; + $number =~ s/\",,\"/\|\|/gi; + $number =~ s/\",\"/\|/gi; + $number =~ s/\"//gi; + @m = split(/\|/, $number); + +# This is the format for the lead files +#3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS + + + $vendor_lead_code = $m[0]; chomp($vendor_lead_code); + $source_code = $m[1]; chomp($source_code); $source_id = $source_code; + $list_id = $m[2]; chomp($list_id); + $phone_code = $m[3]; chomp($phone_code); $phone_code =~ s/\D//gi; + $phone_number = $m[4]; chomp($phone_number); $phone_number =~ s/\D//gi; + $USarea = substr($phone_number, 0, 3); + $title = $m[5]; chomp($title); + $first_name = $m[6]; chomp($first_name); + $middle_initial = $m[7]; chomp($middle_initial); + $last_name = $m[8]; chomp($last_name); + $address1 = $m[9]; chomp($address1); + $address2 = $m[10]; chomp($address2); + $address3 = $m[11]; chomp($address3); + $city = $m[12]; chomp($city); + $state = $m[13]; chomp($state); + $province = $m[14]; chomp($province); + $postal_code = $m[15]; chomp($postal_code); + $country = $m[16]; chomp($country); + $gender = $m[17]; + $date_of_birth = $m[18]; + $alt_phone = $m[19]; + $email = $m[20]; + $security_phrase = $m[21]; + $comments = $m[22]; + + + if (length($phone_number)>8) + { + # set default values + $entry_date = "$pulldate0"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $called_since_last_reset='N'; + $gmt_offset = '0'; + + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + if ($forcegmt > 0) + { + $gmt_offset = $m[23]; # set GMT offset value to 24th field value + } + else + { + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &USA_dstcalc; + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + } + if ($multi_insert_counter > 8) + { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','0');"; + if($DB){print STDERR "\n|$stmtZ|\n";} + if (!$T) {$dbhA->query($stmtZ); } # or die "Couldn't execute query: |$stmtA|\n"; + + $multistmt=''; + $multi_insert_counter=0; + $c++; + } + else + { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments','0'),"; + $multi_insert_counter++; + } + + $b++; + } + else + { + print "BAD Home_Phone: $phone|$vendor_id"; + $e++; + } + + $a++; + + if ($a =~ /100$/i) {print STDERR "0 $a\r";} + if ($a =~ /200$/i) {print STDERR "+ $a\r";} + if ($a =~ /300$/i) {print STDERR "| $a\r";} + if ($a =~ /400$/i) {print STDERR "\\ $a\r";} + if ($a =~ /500$/i) {print STDERR "- $a\r";} + if ($a =~ /600$/i) {print STDERR "/ $a\r";} + if ($a =~ /700$/i) {print STDERR "| $a\r";} + if ($a =~ /800$/i) {print STDERR "+ $a\r";} + if ($a =~ /900$/i) {print STDERR "0 $a\r";} + if ($a =~ /000$/i) {print "$a|$b|$c|$d|$e|$phone_number|\n";} + + } + + if (length($multistmt) > 10) + { + chop($multistmt); + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt;"; + if($DB){print STDERR "\n|$stmtZ|\n";} + if (!$T) {$dbhA->query($stmtZ); } # or die "Couldn't execute query: |$stmtA|\n"; + + $multistmt=''; + $multi_insert_counter=0; + $c++; + } + + ### open the stats out file for writing ### + open(Sout, ">>/$dir2/$Soutfile") + || die "Can't open $Soutfile: $!\n"; + + + ### close file handler and DB connections ### + print "\n\nTOTALS FOR $FILEname:\n"; + print "Transactions sent:$a\n"; + print "INSERTED: $b\n"; + print "INSERT STATEMENTS:$c\n"; + print "ERROR: $e\n"; +# print "Modified PAID NS: $f\n"; +# print "Credits: $g\n\n"; + + print Sout "\nTOTALS FOR $FILEname:\n"; + print Sout "Transactions sent:$a\n"; + print Sout "INSERTED: $b\n"; + print Sout "INSERT STATEMENTS:$c\n"; + print Sout "ERROR: $e\n"; +# print Sout "Modified PAID NS: $f\n"; +# print Sout "Credits: $g\n\n"; + + close(infile); + close(Rout); + chmod 0777, "$dir2/$Routfile"; + close(Sout); + chmod 0777, "$dir2/$Soutfile"; + close(Tout); + chmod 0777, "$dir2/$Toutfile"; + close(Dout); + chmod 0777, "$dir2/$Doutfile"; + + if (!$T) {`mv -f $dir1/$FILEname $dir2/$FILEname`;} + + } + } + $i++; +} + + +### calculate time to run script ### +$secY = time(); +$secZ = ($secY - $secX); +$secZm = ($secZ /60); + +print "script execution time in seconds: $secZ minutes: $secZm\n"; + +exit; + + + + + + + + +sub USA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +#********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $USA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } + } else { + $USA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $USA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } + } else { + $USA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_CLOSERstats.php b/agc_2-X/trunk/VICIDIAL_web/AST_CLOSERstats.php new file mode 100644 index 00000000..b7a7bb8c --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_CLOSERstats.php @@ -0,0 +1,396 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1714 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select group_id from vicidial_inbound_groups;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Closer Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Closer Stats                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls placed from this Campaign:        $TOTALcalls\n";
+echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 999 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls:                             $DROPcalls  $DROPpercent%\n";
+echo "Average Length for DROP Calls in seconds:     $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='$group';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_VDADstats.php b/agc_2-X/trunk/VICIDIAL_web/AST_VDADstats.php new file mode 100644 index 00000000..9ac17006 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_VDADstats.php @@ -0,0 +1,417 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1718 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: VDAD Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Auto-dial Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls placed from this Campaign:        $TOTALcalls\n";
+echo "Average Call Length for all Calls in seconds: $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total DROP Calls:                             $DROPcalls  $DROPpercent%\n";
+echo "Average Length for DROP Calls in seconds:     $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- AUTO-DIAL NO ANSWERS\n";
+
+$stmt="select count(*),sum(length_in_sec) from vicidial_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='NA' and (length_in_sec <= 60 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$NAcalls =	sprintf("%10s", $row[0]);
+$NApercent = (($NAcalls / $TOTALcalls) * 100);
+$NApercent = round($NApercent, 0);
+
+$average_na_seconds = ($row[1] / $row[0]);
+$average_na_seconds = round($average_na_seconds, 0);
+$average_na_seconds =	sprintf("%10s", $average_na_seconds);
+
+echo "Total NA calls -Busy,Disconnect,BTvoicemail:  $NAcalls  $NApercent%\n";
+echo "Average Call Length for NA Calls in seconds:  $average_na_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select vicidial_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_log,vicidial_users where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and  campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_log.user is not null and length_in_sec is not null and length_in_sec > 4 and vicidial_log.user=vicidial_users.user group by vicidial_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from vicidial_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id='" . mysql_real_escape_string($group) . "' and status='DROP';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS PLACED FROM THIS CAMPAIGN\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/VICIDIAL_web/AST_VICIDIAL_hopperlist.php new file mode 100644 index 00000000..1824a939 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_VICIDIAL_hopperlist.php @@ -0,0 +1,161 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1654 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $campaign_id[$i] =$row[0]; + $campaign_name[$i] =$row[1]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Hopper List\n"; +echo "
\n"; +#echo "\n"; +#echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A CAMPAIGN ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Live Current Hopper List                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+
+echo "Total leads in hopper right now:       $TOTALcalls\n";
+
+
+##############################
+#########  LEAD STATS
+
+echo "\n";
+echo "---------- LEADS IN HOPPER\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+echo "|      | LEAD_ID   | PHONE NUM  | STATE | STATUS | COUNT | GMT    |\n";
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+$stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.lead_id=vicidial_list.lead_id order by hopper_id limit 2000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$FMT_i =		sprintf("%-4s", $i);
+	$lead_id =		sprintf("%-9s", $row[0]);
+	$phone_number =	sprintf("%-10s", $row[1]);
+	$state =		sprintf("%-5s", $row[2]);
+	$status =		sprintf("%-6s", $row[3]);
+	$count =		sprintf("%-5s", $row[4]);
+	$gmt =			sprintf("%-6s", $row[5]);
+
+	echo "| $FMT_i | $lead_id | $phone_number | $state | $status | $count | $gmt |\n";
+
+	$i++;
+	}
+
+echo "+------+-----------+------------+-------+--------+-------+--------+\n";
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_admin_log_display.php b/agc_2-X/trunk/VICIDIAL_web/AST_admin_log_display.php new file mode 100644 index 00000000..b5286873 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_admin_log_display.php @@ -0,0 +1,118 @@ + LICENSE: GPLv2 +### + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$query_date = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$query_date); + +# AST GUI database administration +# AST_admin_log_display.php +# +# CHANGES +# 50325-0932 - First build +# 51123-1443 - removed globals=on requirement +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1044 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '0.0.4'; +$build = '60620-1044'; + +$STARTtime = date("U"); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 8;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN LOG DISPLAY"; +echo "\n"; + +# Fri, 25 Mar 2005 + +$DAY_DATE = date("j"); +if ($DAY_DATE < 10) +# {$GREP_DATE = date("D, j M Y");} + {$GREP_DATE = date("D, 0j M Y");} +else + {$GREP_DATE = date("D, j M Y");} + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!$query_date) {$query_date = $GREP_DATE;} + +$Gquery_date = eregi_replace(" ",'\ ',$query_date); +echo "\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+echo "VICIDIAL ADMIN CHANGE LOG                             $NOW_TIME\n";
+
+#passthru("grep $Gquery_date /home/www/htdocs/vicidial/admin_changes_log.txt");
+passthru("grep $Gquery_date $WeBServeRRooT/vicidial/admin_changes_log.txt");
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_agent_performance.php b/agc_2-X/trunk/VICIDIAL_web/AST_agent_performance.php new file mode 100644 index 00000000..a489bc7d --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_agent_performance.php @@ -0,0 +1,232 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1711 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($group)) {$group = '';} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select campaign_id from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$campaigns_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $campaigns_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Agent Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:33:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:33:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:33:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:33:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TALK   | TALKAVG| A    | B    | DC   | DNC  | N    | NI   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(length_in_sec) as talk,full_name,vicidial_users.user,avg(length_in_sec) from vicidial_users,vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and vicidial_users.user=vicidial_log.user and campaign_id='" . mysql_real_escape_string($group) . "' group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_log where call_date <= '$query_date_END' and call_date >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtotTALK_MS|        | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_SALE|\n";
+echo "+-----------------+--------+--------+--------+--------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_agent_performance_detail.php b/agc_2-X/trunk/VICIDIAL_web/AST_agent_performance_detail.php
new file mode 100644
index 00000000..2dd3dc5e
--- /dev/null
+++ b/agc_2-X/trunk/VICIDIAL_web/AST_agent_performance_detail.php
@@ -0,0 +1,406 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1712 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["shift"]))				{$shift=$_GET["shift"];}
+	elseif (isset($_POST["shift"]))		{$shift=$_POST["shift"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select campaign_id from vicidial_campaigns;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$campaigns_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $campaigns_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Performance\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A CAMPAIGN AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 03:45:00";   
+	$query_date_END = "$query_date 15:15:00";
+	$time_BEGIN = "03:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:15:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Agent Performance Detail                        $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENTS Details -------------\n\n";
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "| USER NAME       | ID     | CALLS  | TIME   | PAUSE  | PAUSAVG| WAIT   | WAITAVG| TALK   | TALKAVG| DISPO  | DISPAVG| A    | B    | DC   | DNC  | N    | NI   | CB   | SALE |\n";
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+$stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and campaign_id='" . mysql_real_escape_string($group) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 group by full_name order by calls desc limit 1000;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$TOTcalls=($TOTcalls + $row[0]);
+	$TOTtime=($TOTtime + $row[1] + $row[5] + $row[7] + $row[9]);
+	$TOTtotTALK=($TOTtotTALK + $row[1]);
+	$TOTtotWAIT=($TOTtotWAIT + $row[7]);
+	$TOTtotPAUSE=($TOTtotPAUSE + $row[5]);
+	$TOTtotDISPO=($TOTtotDISPO + $row[9]);
+	$calls[$i] =	sprintf("%-6s", $row[0]);
+	$full_name[$i]=	sprintf("%-15s", $row[2]); while(strlen($full_name[$i])>15) {$full_name[$i] = substr("$full_name[$i]", 0, -1);}
+	$user[$i] =		sprintf("%-6s", $row[3]);
+	$USERtime =	($row[1] + $row[5] + $row[7] + $row[9]);
+	$USERtotTALK =	$row[1];
+	$USERavgTALK =	$row[4];
+	$USERtotPAUSE =	$row[5];
+	$USERavgPAUSE =	$row[6];
+	$USERtotWAIT =	$row[7];
+	$USERavgWAIT =	$row[8];
+	$USERtotDISPO =	$row[9];
+	$USERavgDISPO =	$row[10];
+
+	$USERtime_M = ($USERtime / 60);
+	$USERtime_M = round($USERtime_M, 2);
+	$USERtime_M_int = intval("$USERtime_M");
+	$USERtime_S = ($USERtime_M - $USERtime_M_int);
+	$USERtime_S = ($USERtime_S * 60);
+	$USERtime_S = round($USERtime_S, 0);
+	if ($USERtime_S < 10) {$USERtime_S = "0$USERtime_S";}
+	$USERtime_MS = "$USERtime_M_int:$USERtime_S";
+	$pfUSERtime_MS[$i] =		sprintf("%7s", $USERtime_MS);
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$pfUSERtotTALK_MS[$i] =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$pfUSERavgTALK_MS[$i] =		sprintf("%6s", $USERavgTALK_MS);
+
+	$USERtotPAUSE_M = ($USERtotPAUSE / 60);
+	$USERtotPAUSE_M = round($USERtotPAUSE_M, 2);
+	$USERtotPAUSE_M_int = intval("$USERtotPAUSE_M");
+	$USERtotPAUSE_S = ($USERtotPAUSE_M - $USERtotPAUSE_M_int);
+	$USERtotPAUSE_S = ($USERtotPAUSE_S * 60);
+	$USERtotPAUSE_S = round($USERtotPAUSE_S, 0);
+	if ($USERtotPAUSE_S < 10) {$USERtotPAUSE_S = "0$USERtotPAUSE_S";}
+	$USERtotPAUSE_MS = "$USERtotPAUSE_M_int:$USERtotPAUSE_S";
+	$pfUSERtotPAUSE_MS[$i] =		sprintf("%6s", $USERtotPAUSE_MS);
+
+	$USERavgPAUSE_M = ($USERavgPAUSE / 60);
+	$USERavgPAUSE_M = round($USERavgPAUSE_M, 2);
+	$USERavgPAUSE_M_int = intval("$USERavgPAUSE_M");
+	$USERavgPAUSE_S = ($USERavgPAUSE_M - $USERavgPAUSE_M_int);
+	$USERavgPAUSE_S = ($USERavgPAUSE_S * 60);
+	$USERavgPAUSE_S = round($USERavgPAUSE_S, 0);
+	if ($USERavgPAUSE_S < 10) {$USERavgPAUSE_S = "0$USERavgPAUSE_S";}
+	$USERavgPAUSE_MS = "$USERavgPAUSE_M_int:$USERavgPAUSE_S";
+	$pfUSERavgPAUSE_MS[$i] =		sprintf("%6s", $USERavgPAUSE_MS);
+
+	$USERtotWAIT_M = ($USERtotWAIT / 60);
+	$USERtotWAIT_M = round($USERtotWAIT_M, 2);
+	$USERtotWAIT_M_int = intval("$USERtotWAIT_M");
+	$USERtotWAIT_S = ($USERtotWAIT_M - $USERtotWAIT_M_int);
+	$USERtotWAIT_S = ($USERtotWAIT_S * 60);
+	$USERtotWAIT_S = round($USERtotWAIT_S, 0);
+	if ($USERtotWAIT_S < 10) {$USERtotWAIT_S = "0$USERtotWAIT_S";}
+	$USERtotWAIT_MS = "$USERtotWAIT_M_int:$USERtotWAIT_S";
+	$pfUSERtotWAIT_MS[$i] =		sprintf("%6s", $USERtotWAIT_MS);
+
+	$USERavgWAIT_M = ($USERavgWAIT / 60);
+	$USERavgWAIT_M = round($USERavgWAIT_M, 2);
+	$USERavgWAIT_M_int = intval("$USERavgWAIT_M");
+	$USERavgWAIT_S = ($USERavgWAIT_M - $USERavgWAIT_M_int);
+	$USERavgWAIT_S = ($USERavgWAIT_S * 60);
+	$USERavgWAIT_S = round($USERavgWAIT_S, 0);
+	if ($USERavgWAIT_S < 10) {$USERavgWAIT_S = "0$USERavgWAIT_S";}
+	$USERavgWAIT_MS = "$USERavgWAIT_M_int:$USERavgWAIT_S";
+	$pfUSERavgWAIT_MS[$i] =		sprintf("%6s", $USERavgWAIT_MS);
+	
+	$USERtotDISPO_M = ($USERtotDISPO / 60);
+	$USERtotDISPO_M = round($USERtotDISPO_M, 2);
+	$USERtotDISPO_M_int = intval("$USERtotDISPO_M");
+	$USERtotDISPO_S = ($USERtotDISPO_M - $USERtotDISPO_M_int);
+	$USERtotDISPO_S = ($USERtotDISPO_S * 60);
+	$USERtotDISPO_S = round($USERtotDISPO_S, 0);
+	if ($USERtotDISPO_S < 10) {$USERtotDISPO_S = "0$USERtotDISPO_S";}
+	$USERtotDISPO_MS = "$USERtotDISPO_M_int:$USERtotDISPO_S";
+	$pfUSERtotDISPO_MS[$i] =		sprintf("%6s", $USERtotDISPO_MS);
+
+	$USERavgDISPO_M = ($USERavgDISPO / 60);
+	$USERavgDISPO_M = round($USERavgDISPO_M, 2);
+	$USERavgDISPO_M_int = intval("$USERavgDISPO_M");
+	$USERavgDISPO_S = ($USERavgDISPO_M - $USERavgDISPO_M_int);
+	$USERavgDISPO_S = ($USERavgDISPO_S * 60);
+	$USERavgDISPO_S = round($USERavgDISPO_S, 0);
+	if ($USERavgDISPO_S < 10) {$USERavgDISPO_S = "0$USERavgDISPO_S";}
+	$USERavgDISPO_MS = "$USERavgDISPO_M_int:$USERavgDISPO_S";
+	$pfUSERavgDISPO_MS[$i] =		sprintf("%6s", $USERavgDISPO_MS);
+
+	$i++;
+	}
+
+$k=0;
+while($k < $i)
+	{
+	$ctA[$k]="0   "; $ctB[$k]="0   "; $ctDC[$k]="0   "; $ctDNC[$k]="0   "; $ctN[$k]="0   "; $ctNI[$k]="0   "; $ctSALE[$k]="0   "; $ctCB[$k]="0   "; 
+	$stmt="select count(*),status from vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$user[$k]' and campaign_id='" . mysql_real_escape_string($group) . "' group by status;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$rows_to_print = mysql_num_rows($rslt);
+	$m=0;
+	while ($m < $rows_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ($row[1] == 'A') {$ctA[$k]=sprintf("%-4s", $row[0]);		$TOT_A = ($TOT_A + $row[0]);}
+		if ($row[1] == 'B') {$ctB[$k]=sprintf("%-4s", $row[0]);		$TOT_B = ($TOT_B + $row[0]);}
+		if ($row[1] == 'DC') {$ctDC[$k]=sprintf("%-4s", $row[0]);	$TOT_DC = ($TOT_DC + $row[0]);}
+		if ($row[1] == 'DNC') {$ctDNC[$k]=sprintf("%-4s", $row[0]);	$TOT_DNC = ($TOT_DNC + $row[0]);}
+		if ($row[1] == 'N') {$ctN[$k]=sprintf("%-4s", $row[0]);		$TOT_N = ($TOT_N + $row[0]);}
+		if ($row[1] == 'NI') {$ctNI[$k]=sprintf("%-4s", $row[0]);	$TOT_NI = ($TOT_NI + $row[0]);}
+		if (($row[1] == 'SALE') || ($row[1] == 'XFER') ) {$ctSALE[$k]=sprintf("%-4s", $row[0]);	$TOT_SALE = ($TOT_SALE + $row[0]);}
+		if (($row[1] == 'CALLBK') || ($row[1] == 'CBHOLD') ) {$ctCB[$k]=sprintf("%-4s", $row[0]);	$TOT_CB = ($TOT_CB + $row[0]);}
+		$m++;
+		}
+	echo "| $full_name[$k] | $user[$k] | $calls[$k] | $pfUSERtime_MS[$k]| $pfUSERtotPAUSE_MS[$k] | $pfUSERavgPAUSE_MS[$k] | $pfUSERtotWAIT_MS[$k] | $pfUSERavgWAIT_MS[$k] | $pfUSERtotTALK_MS[$k] | $pfUSERavgTALK_MS[$k] | $pfUSERtotDISPO_MS[$k] | $pfUSERavgDISPO_MS[$k] | $ctA[$k] | $ctB[$k] | $ctDC[$k] | $ctDNC[$k] | $ctN[$k] | $ctNI[$k] | $ctCB[$k] | $ctSALE[$k] |\n";
+
+
+
+	$k++;
+	}
+
+	$TOTcalls =	sprintf("%-7s", $TOTcalls);
+
+	$TOTtime_M = ($TOTtime / 60);
+	$TOTtime_M = round($TOTtime_M, 2);
+	$TOTtime_M_int = intval("$TOTtime_M");
+	$TOTtime_S = ($TOTtime_M - $TOTtime_M_int);
+	$TOTtime_S = ($TOTtime_S * 60);
+	$TOTtime_S = round($TOTtime_S, 0);
+	if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";}
+	$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S";
+	$TOTtime_MS =		sprintf("%7s", $TOTtime_MS);
+		while(strlen($TOTtime_MS)>7) {$TOTtime_MS = substr("$TOTtime_MS", 0, -1);}
+
+	$TOTtotTALK_M = ($TOTtotTALK / 60);
+	$TOTtotTALK_M = round($TOTtotTALK_M, 2);
+	$TOTtotTALK_M_int = intval("$TOTtotTALK_M");
+	$TOTtotTALK_S = ($TOTtotTALK_M - $TOTtotTALK_M_int);
+	$TOTtotTALK_S = ($TOTtotTALK_S * 60);
+	$TOTtotTALK_S = round($TOTtotTALK_S, 0);
+	if ($TOTtotTALK_S < 10) {$TOTtotTALK_S = "0$TOTtotTALK_S";}
+	$TOTtotTALK_MS = "$TOTtotTALK_M_int:$TOTtotTALK_S";
+	$TOTtotTALK_MS =		sprintf("%7s", $TOTtotTALK_MS);
+		while(strlen($TOTtotTALK_MS)>7) {$TOTtotTALK_MS = substr("$TOTtotTALK_MS", 0, -1);}
+
+	$TOTtotDISPO_M = ($TOTtotDISPO / 60);
+	$TOTtotDISPO_M = round($TOTtotDISPO_M, 2);
+	$TOTtotDISPO_M_int = intval("$TOTtotDISPO_M");
+	$TOTtotDISPO_S = ($TOTtotDISPO_M - $TOTtotDISPO_M_int);
+	$TOTtotDISPO_S = ($TOTtotDISPO_S * 60);
+	$TOTtotDISPO_S = round($TOTtotDISPO_S, 0);
+	if ($TOTtotDISPO_S < 10) {$TOTtotDISPO_S = "0$TOTtotDISPO_S";}
+	$TOTtotDISPO_MS = "$TOTtotDISPO_M_int:$TOTtotDISPO_S";
+	$TOTtotDISPO_MS =		sprintf("%7s", $TOTtotDISPO_MS);
+		while(strlen($TOTtotDISPO_MS)>7) {$TOTtotDISPO_MS = substr("$TOTtotDISPO_MS", 0, -1);}
+
+	$TOTtotPAUSE_M = ($TOTtotPAUSE / 60);
+	$TOTtotPAUSE_M = round($TOTtotPAUSE_M, 2);
+	$TOTtotPAUSE_M_int = intval("$TOTtotPAUSE_M");
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_M - $TOTtotPAUSE_M_int);
+	$TOTtotPAUSE_S = ($TOTtotPAUSE_S * 60);
+	$TOTtotPAUSE_S = round($TOTtotPAUSE_S, 0);
+	if ($TOTtotPAUSE_S < 10) {$TOTtotPAUSE_S = "0$TOTtotPAUSE_S";}
+	$TOTtotPAUSE_MS = "$TOTtotPAUSE_M_int:$TOTtotPAUSE_S";
+	$TOTtotPAUSE_MS =		sprintf("%7s", $TOTtotPAUSE_MS);
+		while(strlen($TOTtotPAUSE_MS)>7) {$TOTtotPAUSE_MS = substr("$TOTtotPAUSE_MS", 0, -1);}
+
+	$TOTtotWAIT_M = ($TOTtotWAIT / 60);
+	$TOTtotWAIT_M = round($TOTtotWAIT_M, 2);
+	$TOTtotWAIT_M_int = intval("$TOTtotWAIT_M");
+	$TOTtotWAIT_S = ($TOTtotWAIT_M - $TOTtotWAIT_M_int);
+	$TOTtotWAIT_S = ($TOTtotWAIT_S * 60);
+	$TOTtotWAIT_S = round($TOTtotWAIT_S, 0);
+	if ($TOTtotWAIT_S < 10) {$TOTtotWAIT_S = "0$TOTtotWAIT_S";}
+	$TOTtotWAIT_MS = "$TOTtotWAIT_M_int:$TOTtotWAIT_S";
+	$TOTtotWAIT_MS =		sprintf("%7s", $TOTtotWAIT_MS);
+		while(strlen($TOTtotWAIT_MS)>7) {$TOTtotWAIT_MS = substr("$TOTtotWAIT_MS", 0, -1);}
+
+
+	$TOTavgTALK_M = ( ($TOTtotTALK / $TOTcalls) / 60);
+	$TOTavgTALK_M = round($TOTavgTALK_M, 2);
+	$TOTavgTALK_M_int = intval("$TOTavgTALK_M");
+	$TOTavgTALK_S = ($TOTavgTALK_M - $TOTavgTALK_M_int);
+	$TOTavgTALK_S = ($TOTavgTALK_S * 60);
+	$TOTavgTALK_S = round($TOTavgTALK_S, 0);
+	if ($TOTavgTALK_S < 10) {$TOTavgTALK_S = "0$TOTavgTALK_S";}
+	$TOTavgTALK_MS = "$TOTavgTALK_M_int:$TOTavgTALK_S";
+	$TOTavgTALK_MS =		sprintf("%6s", $TOTavgTALK_MS);
+		while(strlen($TOTavgTALK_MS)>6) {$TOTavgTALK_MS = substr("$TOTavgTALK_MS", 0, -1);}
+
+	$TOTavgDISPO_M = ( ($TOTtotDISPO / $TOTcalls) / 60);
+	$TOTavgDISPO_M = round($TOTavgDISPO_M, 2);
+	$TOTavgDISPO_M_int = intval("$TOTavgDISPO_M");
+	$TOTavgDISPO_S = ($TOTavgDISPO_M - $TOTavgDISPO_M_int);
+	$TOTavgDISPO_S = ($TOTavgDISPO_S * 60);
+	$TOTavgDISPO_S = round($TOTavgDISPO_S, 0);
+	if ($TOTavgDISPO_S < 10) {$TOTavgDISPO_S = "0$TOTavgDISPO_S";}
+	$TOTavgDISPO_MS = "$TOTavgDISPO_M_int:$TOTavgDISPO_S";
+	$TOTavgDISPO_MS =		sprintf("%6s", $TOTavgDISPO_MS);
+		while(strlen($TOTavgDISPO_MS)>6) {$TOTavgDISPO_MS = substr("$TOTavgDISPO_MS", 0, -1);}
+
+	$TOTavgPAUSE_M = ( ($TOTtotPAUSE / $TOTcalls) / 60);
+	$TOTavgPAUSE_M = round($TOTavgPAUSE_M, 2);
+	$TOTavgPAUSE_M_int = intval("$TOTavgPAUSE_M");
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_M - $TOTavgPAUSE_M_int);
+	$TOTavgPAUSE_S = ($TOTavgPAUSE_S * 60);
+	$TOTavgPAUSE_S = round($TOTavgPAUSE_S, 0);
+	if ($TOTavgPAUSE_S < 10) {$TOTavgPAUSE_S = "0$TOTavgPAUSE_S";}
+	$TOTavgPAUSE_MS = "$TOTavgPAUSE_M_int:$TOTavgPAUSE_S";
+	$TOTavgPAUSE_MS =		sprintf("%6s", $TOTavgPAUSE_MS);
+		while(strlen($TOTavgPAUSE_MS)>6) {$TOTavgPAUSE_MS = substr("$TOTavgPAUSE_MS", 0, -1);}
+
+	$TOTavgWAIT_M = ( ($TOTtotWAIT / $TOTcalls) / 60);
+	$TOTavgWAIT_M = round($TOTavgWAIT_M, 2);
+	$TOTavgWAIT_M_int = intval("$TOTavgWAIT_M");
+	$TOTavgWAIT_S = ($TOTavgWAIT_M - $TOTavgWAIT_M_int);
+	$TOTavgWAIT_S = ($TOTavgWAIT_S * 60);
+	$TOTavgWAIT_S = round($TOTavgWAIT_S, 0);
+	if ($TOTavgWAIT_S < 10) {$TOTavgWAIT_S = "0$TOTavgWAIT_S";}
+	$TOTavgWAIT_MS = "$TOTavgWAIT_M_int:$TOTavgWAIT_S";
+	$TOTavgWAIT_MS =		sprintf("%6s", $TOTavgWAIT_MS);
+		while(strlen($TOTavgWAIT_MS)>6) {$TOTavgWAIT_MS = substr("$TOTavgWAIT_MS", 0, -1);}
+
+	
+	$TOT_A = sprintf("%-5s", $TOT_A);
+	$TOT_B = sprintf("%-5s", $TOT_B);
+	$TOT_DC = sprintf("%-5s", $TOT_DC);
+	$TOT_DNC = sprintf("%-5s", $TOT_DNC);
+	$TOT_N = sprintf("%-5s", $TOT_N);
+	$TOT_NI = sprintf("%-5s", $TOT_NI);
+	$TOT_CB = sprintf("%-5s", $TOT_CB);
+	$TOT_SALE = sprintf("%-5s", $TOT_SALE);
+
+echo "+-----------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+echo "|  TOTALS                  | $TOTcalls| $TOTtime_MS| $TOTtotPAUSE_MS| $TOTavgPAUSE_MS | $TOTtotWAIT_MS| $TOTavgWAIT_MS | $TOTtotTALK_MS| $TOTavgTALK_MS | $TOTtotDISPO_MS| $TOTavgDISPO_MS | $TOT_A| $TOT_B| $TOT_DC| $TOT_DNC| $TOT_N| $TOT_NI| $TOT_CB| $TOT_SALE|\n";
+echo "+--------------------------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------+------+------+------+------+------+------+------+\n";
+
+echo "\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_agent_time_sheet.php b/agc_2-X/trunk/VICIDIAL_web/AST_agent_time_sheet.php
new file mode 100644
index 00000000..46659eb6
--- /dev/null
+++ b/agc_2-X/trunk/VICIDIAL_web/AST_agent_time_sheet.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1729 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "TOTAL CALLS TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_agent_time_sheet_archive.php b/agc_2-X/trunk/VICIDIAL_web/AST_agent_time_sheet_archive.php
new file mode 100644
index 00000000..f14eca16
--- /dev/null
+++ b/agc_2-X/trunk/VICIDIAL_web/AST_agent_time_sheet_archive.php
@@ -0,0 +1,281 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1721 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["agent"]))				{$agent=$_GET["agent"];}
+	elseif (isset($_POST["agent"]))		{$agent=$_POST["agent"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["calls_summary"]))				{$calls_summary=$_GET["calls_summary"];}
+	elseif (isset($_POST["calls_summary"]))		{$calls_summary=$_POST["calls_summary"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Agent Time Sheet\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$agent)
+{
+echo "\n";
+echo "PLEASE SELECT AN AGENT ID AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from available agent log data\n";
+}
+
+else
+{
+$query_date_BEGIN = "$query_date 00:00:00";   
+$query_date_END = "$query_date 23:59:59";
+$time_BEGIN = "00:00:00";   
+$time_END = "23:59:59";
+
+$stmt="select full_name from vicidial_users where user='$agent';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$full_name = $row[0];
+
+echo "VICIDIAL: Agent Time Sheet                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- AGENT TIME SHEET: $agent - $full_name -------------\n\n";
+
+if ($calls_summary)
+	{
+	$stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+
+	$TOTAL_TIME = ($row[1] + $row[3] + $row[5] + $row[7]);
+
+		$TOTAL_TIME_H = ($TOTAL_TIME / 3600);
+		$TOTAL_TIME_H = round($TOTAL_TIME_H, 2);
+		$TOTAL_TIME_H_int = intval("$TOTAL_TIME_H");
+		$TOTAL_TIME_M = ($TOTAL_TIME_H - $TOTAL_TIME_H_int);
+		$TOTAL_TIME_M = ($TOTAL_TIME_M * 60);
+		$TOTAL_TIME_M = round($TOTAL_TIME_M, 2);
+		$TOTAL_TIME_M_int = intval("$TOTAL_TIME_M");
+		$TOTAL_TIME_S = ($TOTAL_TIME_M - $TOTAL_TIME_M_int);
+		$TOTAL_TIME_S = ($TOTAL_TIME_S * 60);
+		$TOTAL_TIME_S = round($TOTAL_TIME_S, 0);
+		if ($TOTAL_TIME_S < 10) {$TOTAL_TIME_S = "0$TOTAL_TIME_S";}
+		if ($TOTAL_TIME_M_int < 10) {$TOTAL_TIME_M_int = "0$TOTAL_TIME_M_int";}
+		$TOTAL_TIME_HMS = "$TOTAL_TIME_H_int:$TOTAL_TIME_M_int:$TOTAL_TIME_S";
+		$pfTOTAL_TIME_HMS =		sprintf("%8s", $TOTAL_TIME_HMS);
+
+		$TALK_TIME_H = ($row[1] / 3600);
+		$TALK_TIME_H = round($TALK_TIME_H, 2);
+		$TALK_TIME_H_int = intval("$TALK_TIME_H");
+		$TALK_TIME_M = ($TALK_TIME_H - $TALK_TIME_H_int);
+		$TALK_TIME_M = ($TALK_TIME_M * 60);
+		$TALK_TIME_M = round($TALK_TIME_M, 2);
+		$TALK_TIME_M_int = intval("$TALK_TIME_M");
+		$TALK_TIME_S = ($TALK_TIME_M - $TALK_TIME_M_int);
+		$TALK_TIME_S = ($TALK_TIME_S * 60);
+		$TALK_TIME_S = round($TALK_TIME_S, 0);
+		if ($TALK_TIME_S < 10) {$TALK_TIME_S = "0$TALK_TIME_S";}
+		if ($TALK_TIME_M_int < 10) {$TALK_TIME_M_int = "0$TALK_TIME_M_int";}
+		$TALK_TIME_HMS = "$TALK_TIME_H_int:$TALK_TIME_M_int:$TALK_TIME_S";
+		$pfTALK_TIME_HMS =		sprintf("%8s", $TALK_TIME_HMS);
+
+		$PAUSE_TIME_H = ($row[3] / 3600);
+		$PAUSE_TIME_H = round($PAUSE_TIME_H, 2);
+		$PAUSE_TIME_H_int = intval("$PAUSE_TIME_H");
+		$PAUSE_TIME_M = ($PAUSE_TIME_H - $PAUSE_TIME_H_int);
+		$PAUSE_TIME_M = ($PAUSE_TIME_M * 60);
+		$PAUSE_TIME_M = round($PAUSE_TIME_M, 2);
+		$PAUSE_TIME_M_int = intval("$PAUSE_TIME_M");
+		$PAUSE_TIME_S = ($PAUSE_TIME_M - $PAUSE_TIME_M_int);
+		$PAUSE_TIME_S = ($PAUSE_TIME_S * 60);
+		$PAUSE_TIME_S = round($PAUSE_TIME_S, 0);
+		if ($PAUSE_TIME_S < 10) {$PAUSE_TIME_S = "0$PAUSE_TIME_S";}
+		if ($PAUSE_TIME_M_int < 10) {$PAUSE_TIME_M_int = "0$PAUSE_TIME_M_int";}
+		$PAUSE_TIME_HMS = "$PAUSE_TIME_H_int:$PAUSE_TIME_M_int:$PAUSE_TIME_S";
+		$pfPAUSE_TIME_HMS =		sprintf("%8s", $PAUSE_TIME_HMS);
+
+		$WAIT_TIME_H = ($row[5] / 3600);
+		$WAIT_TIME_H = round($WAIT_TIME_H, 2);
+		$WAIT_TIME_H_int = intval("$WAIT_TIME_H");
+		$WAIT_TIME_M = ($WAIT_TIME_H - $WAIT_TIME_H_int);
+		$WAIT_TIME_M = ($WAIT_TIME_M * 60);
+		$WAIT_TIME_M = round($WAIT_TIME_M, 2);
+		$WAIT_TIME_M_int = intval("$WAIT_TIME_M");
+		$WAIT_TIME_S = ($WAIT_TIME_M - $WAIT_TIME_M_int);
+		$WAIT_TIME_S = ($WAIT_TIME_S * 60);
+		$WAIT_TIME_S = round($WAIT_TIME_S, 0);
+		if ($WAIT_TIME_S < 10) {$WAIT_TIME_S = "0$WAIT_TIME_S";}
+		if ($WAIT_TIME_M_int < 10) {$WAIT_TIME_M_int = "0$WAIT_TIME_M_int";}
+		$WAIT_TIME_HMS = "$WAIT_TIME_H_int:$WAIT_TIME_M_int:$WAIT_TIME_S";
+		$pfWAIT_TIME_HMS =		sprintf("%8s", $WAIT_TIME_HMS);
+
+		$WRAPUP_TIME_H = ($row[7] / 3600);
+		$WRAPUP_TIME_H = round($WRAPUP_TIME_H, 2);
+		$WRAPUP_TIME_H_int = intval("$WRAPUP_TIME_H");
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_H - $WRAPUP_TIME_H_int);
+		$WRAPUP_TIME_M = ($WRAPUP_TIME_M * 60);
+		$WRAPUP_TIME_M = round($WRAPUP_TIME_M, 2);
+		$WRAPUP_TIME_M_int = intval("$WRAPUP_TIME_M");
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_M - $WRAPUP_TIME_M_int);
+		$WRAPUP_TIME_S = ($WRAPUP_TIME_S * 60);
+		$WRAPUP_TIME_S = round($WRAPUP_TIME_S, 0);
+		if ($WRAPUP_TIME_S < 10) {$WRAPUP_TIME_S = "0$WRAPUP_TIME_S";}
+		if ($WRAPUP_TIME_M_int < 10) {$WRAPUP_TIME_M_int = "0$WRAPUP_TIME_M_int";}
+		$WRAPUP_TIME_HMS = "$WRAPUP_TIME_H_int:$WRAPUP_TIME_M_int:$WRAPUP_TIME_S";
+		$pfWRAPUP_TIME_HMS =		sprintf("%8s", $WRAPUP_TIME_HMS);
+
+		$TALK_AVG_M = ($row[2] / 60);
+		$TALK_AVG_M = round($TALK_AVG_M, 2);
+		$TALK_AVG_M_int = intval("$TALK_AVG_M");
+		$TALK_AVG_S = ($TALK_AVG_M - $TALK_AVG_M_int);
+		$TALK_AVG_S = ($TALK_AVG_S * 60);
+		$TALK_AVG_S = round($TALK_AVG_S, 0);
+		if ($TALK_AVG_S < 10) {$TALK_AVG_S = "0$TALK_AVG_S";}
+		$TALK_AVG_MS = "$TALK_AVG_M_int:$TALK_AVG_S";
+		$pfTALK_AVG_MS =		sprintf("%6s", $TALK_AVG_MS);
+
+		$PAUSE_AVG_M = ($row[4] / 60);
+		$PAUSE_AVG_M = round($PAUSE_AVG_M, 2);
+		$PAUSE_AVG_M_int = intval("$PAUSE_AVG_M");
+		$PAUSE_AVG_S = ($PAUSE_AVG_M - $PAUSE_AVG_M_int);
+		$PAUSE_AVG_S = ($PAUSE_AVG_S * 60);
+		$PAUSE_AVG_S = round($PAUSE_AVG_S, 0);
+		if ($PAUSE_AVG_S < 10) {$PAUSE_AVG_S = "0$PAUSE_AVG_S";}
+		$PAUSE_AVG_MS = "$PAUSE_AVG_M_int:$PAUSE_AVG_S";
+		$pfPAUSE_AVG_MS =		sprintf("%6s", $PAUSE_AVG_MS);
+
+		$WAIT_AVG_M = ($row[6] / 60);
+		$WAIT_AVG_M = round($WAIT_AVG_M, 2);
+		$WAIT_AVG_M_int = intval("$WAIT_AVG_M");
+		$WAIT_AVG_S = ($WAIT_AVG_M - $WAIT_AVG_M_int);
+		$WAIT_AVG_S = ($WAIT_AVG_S * 60);
+		$WAIT_AVG_S = round($WAIT_AVG_S, 0);
+		if ($WAIT_AVG_S < 10) {$WAIT_AVG_S = "0$WAIT_AVG_S";}
+		$WAIT_AVG_MS = "$WAIT_AVG_M_int:$WAIT_AVG_S";
+		$pfWAIT_AVG_MS =		sprintf("%6s", $WAIT_AVG_MS);
+
+		$WRAPUP_AVG_M = ($row[8] / 60);
+		$WRAPUP_AVG_M = round($WRAPUP_AVG_M, 2);
+		$WRAPUP_AVG_M_int = intval("$WRAPUP_AVG_M");
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_M - $WRAPUP_AVG_M_int);
+		$WRAPUP_AVG_S = ($WRAPUP_AVG_S * 60);
+		$WRAPUP_AVG_S = round($WRAPUP_AVG_S, 0);
+		if ($WRAPUP_AVG_S < 10) {$WRAPUP_AVG_S = "0$WRAPUP_AVG_S";}
+		$WRAPUP_AVG_MS = "$WRAPUP_AVG_M_int:$WRAPUP_AVG_S";
+		$pfWRAPUP_AVG_MS =		sprintf("%6s", $WRAPUP_AVG_MS);
+
+	echo "TOTAL CALLS TAKEN: $row[0]\n";
+	echo "TALK TIME:               $pfTALK_TIME_HMS     AVERAGE: $pfTALK_AVG_MS\n";
+	echo "PAUSE TIME:              $pfPAUSE_TIME_HMS     AVERAGE: $pfPAUSE_AVG_MS\n";
+	echo "WAIT TIME:               $pfWAIT_TIME_HMS     AVERAGE: $pfWAIT_AVG_MS\n";
+	echo "WRAPUP TIME:             $pfWRAPUP_TIME_HMS     AVERAGE: $pfWRAPUP_AVG_MS\n";
+	echo "----------------------------------------------------------------\n";
+	echo "TOTAL ACTIVE AGENT TIME: $pfTOTAL_TIME_HMS\n";
+
+	echo "\n";
+	}
+else
+	{
+	echo "Call Activity Summary\n\n";
+
+	}
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "FIRST LOGIN:          $row[0]\n";
+$start = $row[1];
+
+$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log_archive where event_time <= '" . mysql_real_escape_string($query_date_END) . "' and event_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and user='" . mysql_real_escape_string($agent) . "' order by event_time desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+echo "LAST LOG ACTIVITY:    $row[0]\n";
+$end = $row[1];
+
+$login_time = ($end - $start);
+	$LOGIN_TIME_H = ($login_time / 3600);
+	$LOGIN_TIME_H = round($LOGIN_TIME_H, 2);
+	$LOGIN_TIME_H_int = intval("$LOGIN_TIME_H");
+	$LOGIN_TIME_M = ($LOGIN_TIME_H - $LOGIN_TIME_H_int);
+	$LOGIN_TIME_M = ($LOGIN_TIME_M * 60);
+	$LOGIN_TIME_M = round($LOGIN_TIME_M, 2);
+	$LOGIN_TIME_M_int = intval("$LOGIN_TIME_M");
+	$LOGIN_TIME_S = ($LOGIN_TIME_M - $LOGIN_TIME_M_int);
+	$LOGIN_TIME_S = ($LOGIN_TIME_S * 60);
+	$LOGIN_TIME_S = round($LOGIN_TIME_S, 0);
+	if ($LOGIN_TIME_S < 10) {$LOGIN_TIME_S = "0$LOGIN_TIME_S";}
+	if ($LOGIN_TIME_M_int < 10) {$LOGIN_TIME_M_int = "0$LOGIN_TIME_M_int";}
+	$LOGIN_TIME_HMS = "$LOGIN_TIME_H_int:$LOGIN_TIME_M_int:$LOGIN_TIME_S";
+	$pfLOGIN_TIME_HMS =		sprintf("%8s", $LOGIN_TIME_HMS);
+
+echo "-----------------------------------------\n";
+echo "TOTAL LOGGED-IN TIME:    $pfLOGIN_TIME_HMS\n";
+
+}
+
+
+
+?>
+
+
\ No newline at end of file
diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_parkstats.php b/agc_2-X/trunk/VICIDIAL_web/AST_parkstats.php
new file mode 100644
index 00000000..eef768ca
--- /dev/null
+++ b/agc_2-X/trunk/VICIDIAL_web/AST_parkstats.php
@@ -0,0 +1,396 @@
+    LICENSE: GPLv2
+###
+# CHANGES
+#
+# 60619-1717 - Added variable filtering to eliminate SQL injection attack threat
+#            - Added required user/pass to gain access to this page
+#
+
+require("dbconnect.php");
+
+$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
+$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
+$PHP_SELF=$_SERVER['PHP_SELF'];
+if (isset($_GET["group"]))				{$group=$_GET["group"];}
+	elseif (isset($_POST["group"]))		{$group=$_POST["group"];}
+if (isset($_GET["query_date"]))				{$query_date=$_GET["query_date"];}
+	elseif (isset($_POST["query_date"]))		{$query_date=$_POST["query_date"];}
+if (isset($_GET["submit"]))				{$submit=$_GET["submit"];}
+	elseif (isset($_POST["submit"]))		{$submit=$_POST["submit"];}
+if (isset($_GET["SUBMIT"]))				{$SUBMIT=$_GET["SUBMIT"];}
+	elseif (isset($_POST["SUBMIT"]))		{$SUBMIT=$_POST["SUBMIT"];}
+
+$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
+$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
+
+	$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;";
+	if ($DB) {echo "|$stmt|\n";}
+	$rslt=mysql_query($stmt, $link);
+	$row=mysql_fetch_row($rslt);
+	$auth=$row[0];
+
+  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
+	{
+    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
+    Header("HTTP/1.0 401 Unauthorized");
+    echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
+    exit;
+	}
+
+$NOW_DATE = date("Y-m-d");
+$NOW_TIME = date("Y-m-d H:i:s");
+$STARTtime = date("U");
+if (!isset($group)) {$group = '';}
+if (!isset($query_date)) {$query_date = $NOW_DATE;}
+
+$stmt="select distinct channel_group from park_log;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$groups_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $groups_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$groups[$i] =$row[0];
+	$i++;
+	}
+?>
+
+
+
+
+
+\n";
+echo "VICIDIAL: Park Stats\n";
+echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "           MODIFY | REPORTS \n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A GROUP AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "VICIDIAL: Park Stats                             $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$stmt="select count(*),sum(parked_sec) from park_log where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls taken in this Group:              $TOTALcalls\n";
+echo "Average Hold Time(seconds) for all Calls:     $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(parked_sec) from park_log where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Dropped Calls:                          $DROPcalls  $DROPpercent%\n";
+echo "Average Hold Time(seconds) for Dropped Calls: $average_hold_seconds\n";
+
+
+##############################
+#########  USER STATS
+
+echo "\n";
+echo "---------- USER STATS\n";
+echo "+--------------------------+------------+--------+--------+\n";
+echo "| USER                     | CALLS      | TIME M | AVRG M |\n";
+echo "+--------------------------+------------+--------+--------+\n";
+
+$stmt="select park_log.user,full_name,count(*),sum(talked_sec),avg(talked_sec) from park_log,vicidial_users where parked_time >= '$query_date 00:00:01' and parked_time <= '$query_date 23:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and park_log.user is not null and talked_sec is not null and talked_sec > 4 and park_log.user=vicidial_users.user group by park_log.user;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$user =			sprintf("%-6s", $row[0]);
+	$full_name =	sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$USERcalls =	sprintf("%10s", $row[2]);
+	$USERtotTALK =	$row[3];
+	$USERavgTALK =	$row[4];
+
+	$USERtotTALK_M = ($USERtotTALK / 60);
+	$USERtotTALK_M = round($USERtotTALK_M, 2);
+	$USERtotTALK_M_int = intval("$USERtotTALK_M");
+	$USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int);
+	$USERtotTALK_S = ($USERtotTALK_S * 60);
+	$USERtotTALK_S = round($USERtotTALK_S, 0);
+	if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";}
+	$USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S";
+	$USERtotTALK_MS =		sprintf("%6s", $USERtotTALK_MS);
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n";
+
+	$i++;
+	}
+
+echo "+--------------------------+------------+--------+--------+\n";
+
+##############################
+#########  TIME STATS
+
+echo "\n";
+echo "---------- TIME STATS\n";
+
+echo "\n";
+
+$hi_hour_count=0;
+$last_full_record=0;
+$i=0;
+$h=0;
+while ($i <= 96)
+	{
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:00:00' and parked_time <= '$query_date $h:14:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:00:00' and parked_time <= '$query_date $h:14:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:15:00' and parked_time <= '$query_date $h:29:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:15:00' and parked_time <= '$query_date $h:29:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:30:00' and parked_time <= '$query_date $h:44:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:30:00' and parked_time <= '$query_date $h:44:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:45:00' and parked_time <= '$query_date $h:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$hour_count[$i] = $row[0];
+	if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+	if ($hour_count[$i] > 0) {$last_full_record = $i;}
+	$stmt="select count(*) from park_log where parked_time >= '$query_date $h:45:00' and parked_time <= '$query_date $h:59:59' and status ='HUNGUP' and channel_group='" . mysql_real_escape_string($group) . "' and (talked_sec < 5 or talked_sec is null);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$row=mysql_fetch_row($rslt);
+	$drop_count[$i] = $row[0];
+	$i++;
+	$h++;
+	}
+
+$hour_multiplier = (100 / $hi_hour_count);
+#$hour_multiplier = round($hour_multiplier, 0);
+
+echo "\n";
+echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP\n";
+
+$k=1;
+$Mk=0;
+$call_scale = '0';
+while ($k <= 102) 
+	{
+	if ($Mk >= 5) 
+		{
+		$Mk=0;
+		$scale_num=($k / $hour_multiplier);
+		$scale_num = round($scale_num, 0);
+		$LENscale_num = (strlen($scale_num));
+		$k = ($k + $LENscale_num);
+		$call_scale .= "$scale_num";
+		}
+	else
+		{
+		$call_scale .= " ";
+		$k++;   $Mk++;
+		}
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+$ZZ = '00';
+$i=0;
+$h=4;
+$hour= -1;
+$no_lines_yet=1;
+
+while ($i <= 96)
+	{
+	$char_counter=0;
+	$time = '      ';
+	if ($h >= 4) 
+		{
+		$hour++;
+		$h=0;
+		if ($hour < 10) {$hour = "0$hour";}
+		$time = "+$hour$ZZ+";
+		}
+	if ($h == 1) {$time = "   15 ";}
+	if ($h == 2) {$time = "   30 ";}
+	if ($h == 3) {$time = "   45 ";}
+	$Ghour_count = $hour_count[$i];
+	if ($Ghour_count < 1) 
+		{
+		if ( ($no_lines_yet) or ($i > $last_full_record) )
+			{
+			$do_nothing=1;
+			}
+		else
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			echo "|$time|";
+			$k=0;   while ($k <= 102) {echo " ";   $k++;}
+			echo "| $hour_count[$i] |\n";
+			}
+		}
+	else
+		{
+		$no_lines_yet=0;
+		$Xhour_count = ($Ghour_count * $hour_multiplier);
+		$Yhour_count = (99 - $Xhour_count);
+
+		$Gdrop_count = $drop_count[$i];
+		if ($Gdrop_count < 1) 
+			{
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "*X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 101) {echo " ";   $char_counter++;}
+			echo "| 0     | $hour_count[$i] |\n";
+
+			}
+		else
+			{
+			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+			$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+			$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+			echo "|$time|";
+			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+			echo "D";   $char_counter++;
+			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+			echo "X";   $char_counter++;
+			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 102) {echo " ";   $char_counter++;}
+			echo "| $drop_count[$i] | $hour_count[$i] |\n";
+			}
+		}
+	
+	
+	$i++;
+	$h++;
+	}
+
+
+echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_server_performance.php b/agc_2-X/trunk/VICIDIAL_web/AST_server_performance.php new file mode 100644 index 00000000..fdedb9d9 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_server_performance.php @@ -0,0 +1,310 @@ + LICENSE: GPLv2 +# +# CHANGES +# +# 60619-1732 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["shift"])) {$shift=$_GET["shift"];} + elseif (isset($_POST["shift"])) {$shift=$_POST["shift"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +# path from root to where ploticus files will be stored +$DOCroot = "$WeBServeRRooT/vicidial/ploticus/"; + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($group)) {$group = '';} + +$stmt="select server_ip from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } +?> + + + + + +\n"; +echo "VICIDIAL: Server Performance\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "             REPORTS \n"; +echo "
\n\n"; + +echo "
\n";
+
+
+if (!$group)
+{
+echo "\n";
+echo "PLEASE SELECT A SERVER AND DATE-TIME ABOVE AND CLICK SUBMIT\n";
+echo " NOTE: stats taken from 6 hour shift specified\n";
+}
+
+else
+{
+if ($shift == 'AM') 
+	{
+	$query_date_BEGIN = "$query_date 08:45:00";   
+	$query_date_END = "$query_date 15:32:00";
+	$time_BEGIN = "08:45:00";   
+	$time_END = "15:15:00";
+	}
+if ($shift == 'PM') 
+	{
+	$query_date_BEGIN = "$query_date 15:32:00";   
+	$query_date_END = "$query_date 23:15:00";
+	$time_BEGIN = "15:15:00";   
+	$time_END = "23:15:00";
+	}
+
+echo "VICIDIAL: Server Performance                             $NOW_TIME\n";
+
+echo "Time range: $query_date_BEGIN to $query_date_END\n\n";
+echo "---------- TOTALS, PEAKS and AVERAGES\n";
+
+$stmt="select sysload from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by sysload desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$HIGHload =	sprintf("%10s", $row[0]);
+$HIGHmulti = intval($HIGHload / 100);
+#$HIGHmulti = ($HIGHload / 100);
+
+$stmt="select AVG(sysload),AVG(channels_total) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGload =	sprintf("%10s", $row[0]);
+$AVGchannels =	sprintf("%10s", $row[1]);
+
+$stmt="select AVG(cpu_user_percent),AVG(cpu_system_percent),AVG(cpu_idle_percent) from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$AVGcpuUSER =	sprintf("%10s", $row[0]);
+$AVGcpuSYSTEM =	sprintf("%10s", $row[1]);
+$AVGcpuIDLE =	sprintf("%10s", $row[2]);
+
+$stmt="select usedram from server_performance where start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "' order by usedram desc limit 1;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$USEDram =	sprintf("%10s", $row[0]);
+
+$stmt="select count(*),SUM(length_in_min) from call_log where extension NOT IN('8365','8366','8367') and  start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' and server_ip='" . mysql_real_escape_string($group) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$OFFHOOKtime =	sprintf("%10s", $row[1]);
+
+
+echo "Total Calls in/out on this server:        $TOTALcalls\n";
+echo "Total Off-Hook time on this server (min): $OFFHOOKtime\n";
+echo "Average channels in use for server:       $AVGchannels\n";
+echo "Average load for server:                  $AVGload\n";
+echo "Peak load for server:                     $HIGHload\n";
+#echo "Peak used memory for server (in MB):      $USEDram\n";
+echo "Average USER process cpu percentage:      $AVGcpuUSER %\n";
+echo "Average SYSTEM process cpu percentage:    $AVGcpuSYSTEM %\n";
+echo "Average IDLE process cpu percentage:      $AVGcpuIDLE %\n";
+
+echo "\n";
+echo "---------- LINE GRAPH:\n";
+
+
+
+##############################
+#########  Graph stats
+
+$DAT = '.dat';
+$HTM = '.htm';
+$PNG = '.png';
+$filedate = date("Y-m-d_His");
+$DATfile = "$group$query_date$shift$filedate$DAT";
+$HTMfile = "$group$query_date$shift$filedate$HTM";
+$PNGfile = "$group$query_date$shift$filedate$PNG";
+
+$HTMfp = fopen ("$DOCroot/$HTMfile", "a");
+$DATfp = fopen ("$DOCroot/$DATfile", "a");
+
+$stmt="select DATE_FORMAT(start_time,'%H:%i:%s') as timex,sysload,processes,channels_total,live_recordings,cpu_user_percent,cpu_system_percent from server_performance where server_ip='" . mysql_real_escape_string($group) . "' and start_time <= '" . mysql_real_escape_string($query_date_END) . "' and start_time >= '" . mysql_real_escape_string($query_date_BEGIN) . "' order by timex;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$rows_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $rows_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+	$row[5] = intval(($row[5] + $row[6]) * $HIGHmulti);
+	$row[6] = intval($row[6] * $HIGHmulti);
+	fwrite ($DATfp, "$row[5]\t$row[6]\t$row[0]\t$row[1]\t$row[2]\t$row[3]\n");
+	$i++;
+	}
+fclose($DATfp);
+
+$rows_to_max = ($rows_to_print + 100);
+
+
+
+$HTMcontent  = '';
+$HTMcontent .= "#proc page\n";
+$HTMcontent .= "#if @DEVICE in png,gif\n";
+$HTMcontent .= "   scale: 0.6\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#endif\n";
+$HTMcontent .= "#proc getdata\n";
+$HTMcontent .= "file: $DOCroot/$DATfile\n";
+$HTMcontent .= "fieldnames: userproc sysproc time load processes channels\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc areadef\n";
+$HTMcontent .= "title: Server $group   $query_date_BEGIN to $query_date_END\n";
+$HTMcontent .= "titledetails: size=14  align=C\n";
+$HTMcontent .= "rectangle: 1 1 14 7\n";
+$HTMcontent .= "xscaletype: time hh:mm:ss\n";
+$HTMcontent .= "xrange: $time_BEGIN $time_END\n";
+$HTMcontent .= "yrange: 0 $HIGHload\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc xaxis\n";
+$HTMcontent .= "stubs: inc 30 minutes\n";
+$HTMcontent .= "minorticinc: 5 minutes\n";
+$HTMcontent .= "stubformat: hh:mm:ssa\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc yaxis\n";
+$HTMcontent .= "stubs: inc 50\n";
+$HTMcontent .= "grid: color=yellow\n";
+$HTMcontent .= "gridskip: min\n";
+$HTMcontent .= "ticincrement: 100 1000\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: userproc\n";
+$HTMcontent .= "linedetails: color=purple width=.5\n";
+$HTMcontent .= "fill: lavender\n";
+$HTMcontent .= "legendlabel: user proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc lineplot\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: sysproc\n";
+$HTMcontent .= "linedetails: color=yelloworange width=.5\n";
+$HTMcontent .= "fill: dullyellow\n";
+$HTMcontent .= "legendlabel: system proc%\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: load\n";
+$HTMcontent .= "linedetails: color=blue width=.5\n";
+$HTMcontent .= "legendlabel: load\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: processes\n";
+$HTMcontent .= "linedetails: color=red width=.5\n";
+$HTMcontent .= "legendlabel: processes\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc curvefit\n";
+$HTMcontent .= "xfield: time\n";
+$HTMcontent .= "yfield: channels\n";
+$HTMcontent .= "linedetails: color=green width=.5\n";
+$HTMcontent .= "legendlabel: channels\n";
+$HTMcontent .= "maxinpoints: $rows_to_max\n";
+$HTMcontent .= "\n";
+$HTMcontent .= "#proc legend\n";
+$HTMcontent .= "location: max-2 max\n";
+$HTMcontent .= "seglen: 0.2\n";
+$HTMcontent .= "\n";
+
+fwrite ($HTMfp, "$HTMcontent");
+fclose($HTMfp);
+
+
+passthru("/usr/local/bin/pl -png $DOCroot/$HTMfile -o $DOCroot/$PNGfile");
+
+sleep(1);
+
+echo "
\n"; +echo "\n"; +echo "\n"; + + +echo ""; + +} + + + +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDAD.php b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDAD.php new file mode 100644 index 00000000..52efd9cc --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDAD.php @@ -0,0 +1,255 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 60620-1040 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Agents Time On Calls                         $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL    | STATUS | START TIME          | MINUTES |\n";
+echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	$agentcount=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED",$row[4]))
+			{
+			$row[3]='';
+			$row[5]=' - WAITING - ';
+			$row[6]=$row[7];
+			}
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$sessionid =		sprintf("%-9s", $row[2]);
+		$channel =			sprintf("%-10s", $row[3]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[4]);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 5) {$G=''; $EG='';}
+		if ($call_time_M_int >= 10) {$G=''; $EG='';}
+		if (eregi("PAUSED",$row[4])) 
+			{
+			if ($call_time_M_int >= 1) 
+				{$i++; continue;} 
+			else
+				{$G=''; $EG='';}
+			}
+
+		$agentcount++;
+		echo "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+------------+--------+---------------------+---------+\n";
+		echo "  $agentcount agents logged in on server $server_ip\n\n";
+
+		echo "             - Paused agents\n";
+		echo "             - 5 minutes or more on call\n";
+		echo "             - Over 10 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+echo "| CHANNEL    | STATUS | CAMPAIGN | PHONE NUMBER       | START TIME          | MINUTES |\n";
+echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 10) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 10) {$cc=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-8s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$start_time =		sprintf("%-19s", $row[5]);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+--------+----------+--------------------+---------------------+---------+\n";
+		echo "  $i calls being placed on server $server_ip\n\n";
+
+		echo "             - LIVE CALL WAITING\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "******************************* NO LIVE CALLS WAITING *********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDAD_closer.php b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDAD_closer.php new file mode 100644 index 00000000..eb7d3c39 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDAD_closer.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer +# +# CHANGES +# +# 60620-1037 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; +# $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where grab_time < '$timeSIXhoursAGO' and (hangup_time is null or hangup_time='');"; +# $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + } + } + +?> + + + +\n"; +echo " + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD\n"; +echo "
";
+
+###################################################################################
+###### TIME ON SYSTEM
+###################################################################################
+
+echo "VICIDIAL: Agents Time On Calls                         $NOW_TIME    REPORTS\n\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+echo "| STATION    | USER   | SESSIONID | CHANNEL             | STATUS | CALLTIME | MINUTES | CAMPAIGN     | FRONT  |\n";
+echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+
+
+$stmt="select extension,user,conf_exten,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),uniqueid,lead_id from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by extension;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+			if (eregi("READY|PAUSED|CLOSER",$row[4]))
+			{
+			$row[3]='';
+			$row[5]='- WAIT -';
+			$row[6]=$row[7];
+			}
+		$extension[$i] =		sprintf("%-10s", $row[0]);
+		$user[$i] =				sprintf("%-6s", $row[1]);
+		$sessionid[$i] =		sprintf("%-9s", $row[2]);
+		$channel[$i] =			sprintf("%-19s", $row[3]);
+			$cc[$i]=0;
+		while ( (strlen($channel[$i]) > 19) and ($cc[$i] < 100) )
+			{
+			$channel[$i] = eregi_replace(".$","",$channel[$i]);   
+			$cc[$i]++;
+			if (strlen($channel[$i]) <= 19) {$cc[$i]=101;}
+			}
+		$status[$i] =			sprintf("%-6s", $row[4]);
+		$start_time[$i] =		sprintf("%-8s", $row[5]);
+			$cd[$i]=0;
+		while ( (strlen($start_time[$i]) > 8) and ($cd[$i] < 100) )
+			{
+			$start_time[$i] = eregi_replace("^.","",$start_time[$i]);   
+			$cd[$i]++;
+			if (strlen($start_time[$i]) <= 8) {$cd[$i]=101;}
+			}
+		$uniqueid[$i] =			$row[8];
+		$lead_id[$i] =			$row[9];
+		$closer[$i] =			$row[1];
+		$call_time_S[$i] = ($STARTtime - $row[6]);
+
+		$call_time_M[$i] = ($call_time_S[$i] / 60);
+		$call_time_M[$i] = round($call_time_M[$i], 2);
+		$call_time_M_int[$i] = intval("$call_time_M[$i]");
+		$call_time_SEC[$i] = ($call_time_M[$i] - $call_time_M_int[$i]);
+		$call_time_SEC[$i] = ($call_time_SEC[$i] * 60);
+		$call_time_SEC[$i] = round($call_time_SEC[$i], 0);
+		if ($call_time_SEC[$i] < 10) {$call_time_SEC[$i] = "0$call_time_SEC[$i]";}
+		$call_time_MS[$i] = "$call_time_M_int[$i]:$call_time_SEC[$i]";
+		$call_time_MS[$i] =		sprintf("%7s", $call_time_MS[$i]);
+		$i++;
+		}
+		$ext_count = $i;
+		$i=0;
+	while ($i < $ext_count)
+		{
+
+		$stmt="select campaign_id from vicidial_auto_calls where uniqueid='$uniqueid[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "';";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$camp_to_print = mysql_num_rows($rslt);
+		if ($camp_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$campaign = sprintf("%-12s", $row[0]);
+			$camp_color = $row[0];
+			}
+		else
+			{$campaign = 'DEAD        ';   	$camp_color = 'DEAD';}
+		if (eregi("READY|PAUSED|CLOSER",$status[$i]))
+			{$campaign = '            ';   	$camp_color = '';}
+
+		$stmt="select user from vicidial_xfer_log where lead_id='$lead_id[$i]' and closer='$closer[$i]' order by call_date desc limit 1;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$xfer_to_print = mysql_num_rows($rslt);
+		if ($xfer_to_print > 0)
+			{
+			$row=mysql_fetch_row($rslt);
+			$fronter = sprintf("%-6s", $row[0]);
+			}
+		else
+			{$fronter = '      ';}
+
+		$G = '';		$EG = '';
+		$G=""; $EG='';
+	#	if ($call_time_M_int[$i] >= 5) {$G=''; $EG='';}
+	#	if ($call_time_M_int[$i] >= 10) {$G=''; $EG='';}
+
+		echo "| $G$extension[$i]$EG | $G$user[$i]$EG | $G$sessionid[$i]$EG | $G$channel[$i]$EG | $G$status[$i]$EG | $G$start_time[$i]$EG | $G$call_time_MS[$i]$EG | $G$campaign$EG | $G$fronter$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+-----------+---------------------+--------+----------+---------+--------------+--------+\n";
+		echo "  $i agents logged in on server $server_ip\n\n";
+
+	#	echo "             - 5 minutes or more on call\n";
+	#	echo "             - Over 10 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+###################################################################################
+###### OUTBOUND CALLS
+###################################################################################
+#echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Time On VDAD                                              $NOW_TIME\n\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+echo "| CHANNEL             | STATUS | CAMPAIGN     | PHONE NUMBER       | CALLTIME | MINUTES |\n";
+echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select channel,status,campaign_id,phone_code,phone_number,call_time,UNIX_TIMESTAMP(call_time) from vicidial_auto_calls where status NOT IN('XFER') and server_ip='" . mysql_real_escape_string($server_ip) . "' order by auto_call_id desc;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-19s", $row[0]);
+			$cc=0;
+		while ( (strlen($channel) > 19) and ($cc < 100) )
+			{
+			$channel = eregi_replace(".$","",$channel);   
+			$cc++;
+			if (strlen($channel) <= 19) {$cc=101;}
+			}
+		$start_time =		sprintf("%-8s", $row[5]);
+			$cd=0;
+		while ( (strlen($start_time) > 8) and ($cd < 100) )
+			{
+			$start_time = eregi_replace("^.","",$start_time);   
+			$cd++;
+			if (strlen($start_time) <= 8) {$cd=101;}
+			}
+		$status =			sprintf("%-6s", $row[1]);
+		$campaign =			sprintf("%-12s", $row[2]);
+			$all_phone = "$row[3]$row[4]";
+		$number_dialed =	sprintf("%-18s", $all_phone);
+		$call_time_S = ($STARTtime - $row[6]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if (eregi("LIVE",$status)) {$G=''; $EG='';}
+	#	if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$status$EG | $G$campaign$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+---------------------+--------+--------------+--------------------+----------+---------+\n";
+		echo "  $i calls being placed on server $server_ip\n\n";
+
+		echo "             - LIVE CALL WAITING\n";
+	#	echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	echo "******************************* NO LIVE CALLS WAITING *********************************\n";
+	echo "***************************************************************************************\n";
+	echo "***************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDADall.php b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDADall.php new file mode 100644 index 00000000..aaf07c56 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDADall.php @@ -0,0 +1,391 @@ + LICENSE: GPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60511-1343 - Added leads and drop info at the top of the screen +# 60608-1539 - Fixed CLOSER tallies for active calls +# 60619-1658 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 60626-1453 - Added display of system load to bottom (Angelito Manansala) +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($group)) {$group='';} + +function get_server_load($windows = false) { +$os = strtolower(PHP_OS); +if(strpos($os, "win") === false) { +if(file_exists("/proc/loadavg")) { +$load = file_get_contents("/proc/loadavg"); +$load = explode(' ', $load); +return $load[0]; +} +elseif(function_exists("shell_exec")) { +$load = explode(' ', `uptime`); +return $load[count($load)-1]; +} +else { +return false; +} +} +elseif($windows) { +if(class_exists("COM")) { +$wmi = new COM("WinMgmts:\\\\."); +$cpus = $wmi->InstancesOf("Win32_Processor"); + +$cpuload = 0; +$i = 0; +while ($cpu = $cpus->Next()) { +$cpuload += $cpu->LoadPercentage; +$i++; +} + +$cpuload = round($cpuload / $i, 2); +return "$cpuload%"; +} +else { +return false; +} +} +} + +$load_ave = get_server_load(true); + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Campaign: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Campaign: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFY | REPORTS \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo " NO LIVE CALLS WAITING \n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " System Load Average: $load_ave\n\n"; + + $Aecho .= " - Paused agents\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n"; + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS \n";
+	}
+
+?>
+
+ + diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDADall_SIPmonitor.php b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDADall_SIPmonitor.php new file mode 100644 index 00000000..8d740be1 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_timeonVDADall_SIPmonitor.php @@ -0,0 +1,395 @@ + LICENSE: GPLv2 +### +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# changes: +# 50406-0920 - Added Paused agents < 1 min (Chris Doyle) +# 51130-1218 - Modified layout and info to show all servers in a vicidial system +# 60504-2023 - Modified click-to-listen for SIP phones by Angelito Manansala +# 60619-1708 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# 60626-1455 - Added display of system load to bottom (Angelito Manansala) +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($group)) {$group='';} + +function get_server_load($windows = false) { +$os = strtolower(PHP_OS); +if(strpos($os, "win") === false) { +if(file_exists("/proc/loadavg")) { +$load = file_get_contents("/proc/loadavg"); +$load = explode(' ', $load); +return $load[0]; +} +elseif(function_exists("shell_exec")) { +$load = explode(' ', `uptime`); +return $load[count($load)-1]; +} +else { +return false; +} +} +elseif($windows) { +if(class_exists("COM")) { +$wmi = new COM("WinMgmts:\\\\."); +$cpus = $wmi->InstancesOf("Win32_Processor"); + +$cpuload = 0; +$i = 0; +while ($cpu = $cpus->Next()) { +$cpuload += $cpu->LoadPercentage; +$i++; +} + +$cpuload = round($cpuload / $i, 2); +return "$cpuload%"; +} +else { +return false; +} +} +} + +$load_ave = get_server_load(true); + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + +$stmt="select campaign_id from vicidial_campaigns where active='Y';"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=40;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; +$reset_counter++; + +if (!isset($reset_counter)) {$reset_counter=0;} +if ($reset_counter > 7) + { + $reset_counter=0; + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On VDAD Campaign: $group\n"; +echo "
\n"; +echo "VICIDIAL: Realtime Campaign: \n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "         \n"; +echo "STOP | GO"; +echo "         MODIFY | REPORTS \n"; +echo "\n\n"; + + +if (!$group) {echo "

please select a campaign from the pulldown above
\n"; exit;} +else +{ +$stmt="select auto_dial_level,dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,lead_order,lead_filter_id,hopper_level from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$HOPlev = $row[8]; + +echo "
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; + +$stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$VDhop = $row[0]; + +$stmt="select dialable_leads,calls_today,drops_today,drops_today_pct from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; + +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
DIAL LEVEL:  $row[0]    STATUSES:  $row[1], $row[2], $row[3], $row[4], $row[5]     ORDER:  $row[6]     FILTER:  $row[7]    
HOPPER LEVEL:  $HOPlev     LEADS IN HOPPER:  $VDhop     DIALABLE LEADS:  $DAleads       TIME:
CALLS TODAY:  $callsTODAY     CALLS DROPPED:  $dropsTODAY     DROPPED PERCENT:  $drpctTODAY%       $NOW_TIME
"; + + +echo "\n\n"; +} +################################################################################### +###### OUTBOUND CALLS +################################################################################### +if (eregi("CLOSER",$group)) + { + $stmt="select closer_campaigns from vicidial_campaigns where campaign_id='" . mysql_real_escape_string($group) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = preg_replace("/^ | -$/","",$row[0]); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + $stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and ( (call_type='IN' and campaign_id IN($closer_campaigns)) or (campaign_id='" . mysql_real_escape_string($group) . "' and call_type='OUT') );"; + } +else + {$stmt="select status from vicidial_auto_calls where status NOT IN('XFER') and campaign_id='" . mysql_real_escape_string($group) . "';";} +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$parked_to_print = mysql_num_rows($rslt); + if ($parked_to_print > 0) + { + $i=0; + $out_total=0; + $out_ring=0; + $out_live=0; + while ($i < $parked_to_print) + { + $row=mysql_fetch_row($rslt); + + if (eregi("LIVE",$row[0])) + {$out_live++;} + else + { + if (eregi("CLOSER",$row[0])) + {$nothing=1;} + else + {$out_ring++;} + } + $out_total++; + $i++; + } + + if ($out_live > 0) {$F=''; $FG='';} + if ($out_live > 4) {$F=''; $FG='';} + if ($out_live > 9) {$F=''; $FG='';} + if ($out_live > 14) {$F=''; $FG='';} + + if (eregi("CLOSER",$group)) + {echo "$NFB$out_total$NFE current active calls      \n";} + else + {echo "$NFB$out_total$NFE calls being placed       \n";} + + echo "$NFB$out_ring$NFE calls ringing         \n"; + echo "$NFB$F  $out_live $FG$NFE calls waiting for agents       \n"; + } + else + { + echo " NO LIVE CALLS WAITING \n"; + } + + +################################################################################### +###### TIME ON SYSTEM +################################################################################### + +$agent_incall=0; +$agent_ready=0; +$agent_paused=0; +$agent_total=0; + +$Aecho = ''; +$Aecho .= "VICIDIAL: Agents Time On Calls Campaign: $group $NOW_TIME\n\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; +$Aecho .= "| STATION | USER | SESSIONID | STATUS | SERVER IP | CALL SERVER IP | MM:SS | CAMPAIGN |\n"; +$Aecho .= "+------------|--------+------------------+--------+-----------------+-----------------+---------+------------+\n"; + + +$stmt="select extension,user,conf_exten,status,server_ip,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish),call_server_ip,campaign_id from vicidial_live_agents where campaign_id='" . mysql_real_escape_string($group) . "' order by status,last_call_time;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + $agentcount=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[5]=$row[6]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $sessionid = sprintf("%-9s", $row[2]); + $status = sprintf("%-6s", $row[3]); + $server_ip = sprintf("%-15s", $row[4]); + $call_server_ip = sprintf("%-15s", $row[7]); + $campaign_id = sprintf("%-10s", $row[8]); + $call_time_S = ($STARTtime - $row[5]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} +# if ($call_time_M_int >= 10) {$G=''; $EG='';} + if (eregi("PAUSED",$row[3])) + { + if ($call_time_M_int >= 1) + {$i++; continue;} + else + {$G=''; $EG=''; $agent_paused++; $agent_total++;} + } +# if ( (strlen($row[7])> 4) and ($row[7] != "$row[4]") ) +# {$G=''; $EG='';} + + if ( (eregi("INCALL",$status)) or (eregi("QUEUE",$status)) ) {$agent_incall++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$agent_ready++; $agent_total++;} + if ( (eregi("READY",$status)) or (eregi("CLOSER",$status)) ) {$G=''; $EG='';} + + $agentcount++; + #$Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + $sessionid=trim($sessionid); + $Aecho .= "| $G$extension$EG | $G$user$EG | $G$sessionid$EG LISTEN | $G$status$EG | $G$server_ip$EG | $G$call_server_ip$EG | $G$call_time_MS$EG | $G$campaign_id$EG |\n"; + + $i++; + } + + $Aecho .= "+------------|--------+-----------+--------+-----------------+-----------------+---------+------------+\n"; + $Aecho .= " $agentcount agents logged in on all servers\n"; + $Aecho .= " System Load Average: $load_ave\n\n"; + + $Aecho .= " - Paused agents\n"; + # $Aecho .= " - Balanced call\n"; + $Aecho .= " - Agent waiting for call\n"; + $Aecho .= " - Over 5 minutes on call\n\n"; + $Aecho .= " NOTE: Click LISTEN to monitor agent call, you must have softphone installed on you machine.\n\n"; + + + if ($agent_ready > 0) {$B=''; $BG='';} + if ($agent_ready > 4) {$B=''; $BG='';} + if ($agent_ready > 9) {$B=''; $BG='';} + if ($agent_ready > 14) {$B=''; $BG='';} + + + echo "\n
\n"; + + echo "$NFB$agent_total$NFE agents logged in         \n"; + echo "$NFB$agent_incall$NFE agents in calls       \n"; + echo "$NFB$B  $agent_ready $BG$NFE agents waiting       \n"; + echo "$NFB$agent_paused$NFE paused agents       \n"; + + echo "
";
+		echo "";
+		echo "$Aecho";
+	}
+	else
+	{
+	echo " NO AGENTS ON CALLS \n";
+	}
+
+?>
+
+ + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_timeoncall.php b/agc_2-X/trunk/VICIDIAL_web/AST_timeoncall.php new file mode 100644 index 00000000..074160c3 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_timeoncall.php @@ -0,0 +1,202 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1043 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Call\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Call                        $NOW_TIME    REPORTS\n\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+echo "| STATION    | SESSIONID | CHANNEL   | NUMBER DIALED    | START TIME          | MINUTES |\n";
+echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+
+$stmt="SELECT count(*) from live_sip_channels where server_ip='" . mysql_real_escape_string($server_ip) . "';";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="select extension from live_channels where server_ip='" . mysql_real_escape_string($server_ip) . "';";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$ext_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_zap_counter=0;
+	$sessions = '';
+	while ($i < $ext_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if (preg_match("/^8600/i",$row[0]))
+			{
+			$sessions .= "$row[0]|";
+			}
+		$i++;
+		}
+	$sessions = preg_replace("/\|$/",'',$sessions);
+
+	if ($DB) {echo "SESSIONS: -$sessions-\n";}
+
+	$stmt="select * from live_sip_channels where server_ip='" . mysql_real_escape_string($server_ip) . "' order by channel;";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	$live_calls_counter=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		if ( (preg_match("/Zap\/|internal|ring/i",$row[3])) or (preg_match("/Local\//i",$row[0])) )
+			{
+			if ($DB) {echo "NOT STATION |$row[0]|$row[3]|\n";}
+			$session_id = '';
+			}
+		else 
+			{
+			if (preg_match("/$row[3]/i",$sessions))
+				{
+				if ($DB) {echo "LIVE STATION|$row[0]|$row[3]|\n";}
+				$session_id = $row[3];
+				$station = preg_replace("/SIP\//",'',$row[0]);
+				$station = preg_replace("/-.*/",'',$station);
+			
+				$LIVE_sessions[$live_calls_counter] =			"$session_id";
+				$LIVE_sessions_FORMAT[$live_calls_counter] =	sprintf("%-9s", $session_id);
+				$LIVE_stations[$live_calls_counter] =			"$station";
+				$LIVE_stations_FORMAT[$live_calls_counter] =	sprintf("%-10s", $station);
+
+		#		echo "| $station | $session_id | \n";
+
+				$live_calls_counter++;
+				}
+			else
+				{
+				if ($DB) {echo "NOT STATIONZ|$row[0]|$row[3]|\n";}
+				$session_id = '';
+				}
+			}
+
+		$i++;
+		}
+
+		if ($live_calls_counter > 0)
+		{
+		$i=0;
+		$LC_counter = $live_calls_counter;
+
+		while ($i < $live_calls_counter)
+			{
+			$stmt="select channel,extension,number_dialed,start_time,start_epoch from call_log where extension='$LIVE_stations[$i]' and server_ip='" . mysql_real_escape_string($server_ip) . "' order by uniqueid desc LIMIT 1;";
+			$rslt=mysql_query($stmt, $link);
+			if ($DB) {echo "$stmt\n";}
+			$parked_to_print = mysql_num_rows($rslt);
+			$row=mysql_fetch_row($rslt);
+
+			$channel =			sprintf("%-9s", $row[0]);
+			$number_dialed =	sprintf("%-16s", $row[2]);
+			$start_time =		sprintf("%-19s", $row[3]);
+			$call_time_S = ($STARTtime - $row[4]);
+
+			$call_time_M = ($call_time_S / 60);
+			$call_time_M = round($call_time_M, 2);
+			$call_time_M_int = intval("$call_time_M");
+			$call_time_SEC = ($call_time_M - $call_time_M_int);
+			$call_time_SEC = ($call_time_SEC * 60);
+			$call_time_SEC = round($call_time_SEC, 0);
+			if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+			$call_time_MS = "$call_time_M_int:$call_time_SEC";
+			$call_time_MS =		sprintf("%7s", $call_time_MS);
+			$G = '';		$EG = '';
+			if ($call_time_M_int >= 12) {$G=''; $EG='';}
+			if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+			echo "| $G$LIVE_stations_FORMAT[$i]$EG | $G$LIVE_sessions_FORMAT[$i]$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+			$i++;
+			}
+
+		echo "+------------+-----------+-----------+------------------+---------------------+---------+\n";
+		echo "  $i stations on live calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on live call\n";
+		echo "             - Over 30 minutes on live call\n";
+
+		}
+		else
+		{
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*************************************** NO LIVE STATIONS ********************************\n";
+		echo "*****************************************************************************************\n";
+		echo "*****************************************************************************************\n";
+		}
+
+	}
+	else
+	{
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*************************************** NO LIVE STATIONS ********************************\n";
+	echo "*****************************************************************************************\n";
+	echo "*****************************************************************************************\n";
+	}
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/AST_timeonpark.php b/agc_2-X/trunk/VICIDIAL_web/AST_timeonpark.php new file mode 100644 index 00000000..3cedd09f --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/AST_timeonpark.php @@ -0,0 +1,219 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1042 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} + elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +$timeONEhoursAGO = ($STARTtime - 3600); +$epochHALFhoursAGO = ($STARTtime - 1860); +$timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); +$timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); + +$reset_counter++; + +if ($reset_counter > 7) + { + $reset_counter=0; + + $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + + if ($DB) + { + $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + + } + } + +?> + + + + + +\n"; +echo"\n"; +echo "VICIDIAL: Time On Park\n"; +echo "
\n\n";
+
+echo "VICIDIAL: Time On Park         $NOW_TIME    REPORTS\n\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------+-----------------+---------------------+---------+\n";
+
+#$link=mysql_connect("localhost", "cron", "1234");
+# $linkX=mysql_connect("localhost", "cron", "1234");
+#mysql_select_db("asterisk");
+
+$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='" . mysql_real_escape_string($server_ip) . "' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$parked_to_print = mysql_num_rows($rslt);
+	if ($parked_to_print > 0)
+	{
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 1) {$G=''; $EG='';}
+		if ($call_time_M_int >= 6) {$G=''; $EG='';}
+
+		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------+-----------------+---------------------+---------+\n";
+		echo "  $i callers waiting on server $server_ip\n\n";
+
+		echo "             - 1 minute or more on hold\n";
+		echo "             - Over 5 minutes on hold\n";
+
+		}
+	else
+	{
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	echo "******************** NO LIVE CALLS WAITING *********************\n";
+	echo "****************************************************************\n";
+	echo "****************************************************************\n";
+	}
+
+###################################################################################
+###### TIME ON INBOUND CALLS
+###################################################################################
+echo "\n\n";
+echo "----------------------------------------------------------------------------------------";
+echo "\n\n";
+echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
+echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+
+
+$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='" . mysql_real_escape_string($server_ip) . "' order by uniqueid;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$talking_to_print = mysql_num_rows($rslt);
+	if ($talking_to_print > 0)
+	{
+	$i=0;
+	while ($i < $talking_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+
+		$extension =		sprintf("%-10s", $row[0]);
+		$user =				sprintf("%-6s", $row[1]);
+		$channel =			sprintf("%-10s", $row[2]);
+		$number_dialed =	sprintf("%-15s", $row[3]);
+		$start_time =		sprintf("%-19s", $row[4]);
+		$call_time_S = ($STARTtime - $row[5]);
+
+		$call_time_M = ($call_time_S / 60);
+		$call_time_M = round($call_time_M, 2);
+		$call_time_M_int = intval("$call_time_M");
+		$call_time_SEC = ($call_time_M - $call_time_M_int);
+		$call_time_SEC = ($call_time_SEC * 60);
+		$call_time_SEC = round($call_time_SEC, 0);
+		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
+		$call_time_MS = "$call_time_M_int:$call_time_SEC";
+		$call_time_MS =		sprintf("%7s", $call_time_MS);
+		$G = '';		$EG = '';
+		if ($call_time_M_int >= 12) {$G=''; $EG='';}
+		if ($call_time_M_int >= 31) {$G=''; $EG='';}
+
+		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";
+
+		$i++;
+		}
+
+		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
+		echo "  $i agents on calls on server $server_ip\n\n";
+
+		echo "             - 12 minutes or more on call\n";
+		echo "             - Over 30 minutes on call\n";
+
+	}
+	else
+	{
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	echo "********************************* NO AGENTS ON CALLS *********************************\n";
+	echo "**************************************************************************************\n";
+	echo "**************************************************************************************\n";
+	}
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/admin.php b/agc_2-X/trunk/VICIDIAL_web/admin.php new file mode 100644 index 00000000..816dd7d1 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/admin.php @@ -0,0 +1,6514 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["user_level"])) {$user_level=$_GET["user_level"];} + elseif (isset($_POST["user_level"])) {$user_level=$_POST["user_level"];} +if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];} + elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} + elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["park_ext"])) {$park_ext=$_GET["park_ext"];} + elseif (isset($_POST["park_ext"])) {$park_ext=$_POST["park_ext"];} +if (isset($_GET["park_file_name"])) {$park_file_name=$_GET["park_file_name"];} + elseif (isset($_POST["park_file_name"])) {$park_file_name=$_POST["park_file_name"];} +if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} + elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} +if (isset($_GET["allow_closers"])) {$allow_closers=$_GET["allow_closers"];} + elseif (isset($_POST["allow_closers"])) {$allow_closers=$_POST["allow_closers"];} +if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} + elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["next_agent_call"])) {$next_agent_call=$_GET["next_agent_call"];} + elseif (isset($_POST["next_agent_call"])) {$next_agent_call=$_POST["next_agent_call"];} +if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} + elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} +if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} + elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} + elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} +if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} + elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["group_color"])) {$group_color=$_GET["group_color"];} + elseif (isset($_POST["group_color"])) {$group_color=$_POST["group_color"];} +if (isset($_GET["fronter_display"])) {$fronter_display=$_GET["fronter_display"];} + elseif (isset($_POST["fronter_display"])) {$fronter_display=$_POST["fronter_display"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["group_name"])) {$group_name=$_GET["group_name"];} + elseif (isset($_POST["group_name"])) {$group_name=$_POST["group_name"];} +if (isset($_GET["dial_status_a"])) {$dial_status_a=$_GET["dial_status_a"];} + elseif (isset($_POST["dial_status_a"])) {$dial_status_a=$_POST["dial_status_a"];} +if (isset($_GET["dial_status_b"])) {$dial_status_b=$_GET["dial_status_b"];} + elseif (isset($_POST["dial_status_b"])) {$dial_status_b=$_POST["dial_status_b"];} +if (isset($_GET["dial_status_c"])) {$dial_status_c=$_GET["dial_status_c"];} + elseif (isset($_POST["dial_status_c"])) {$dial_status_c=$_POST["dial_status_c"];} +if (isset($_GET["dial_status_d"])) {$dial_status_d=$_GET["dial_status_d"];} + elseif (isset($_POST["dial_status_d"])) {$dial_status_d=$_POST["dial_status_d"];} +if (isset($_GET["dial_status_e"])) {$dial_status_e=$_GET["dial_status_e"];} + elseif (isset($_POST["dial_status_e"])) {$dial_status_e=$_POST["dial_status_e"];} +if (isset($_GET["lead_order"])) {$lead_order=$_GET["lead_order"];} + elseif (isset($_POST["lead_order"])) {$lead_order=$_POST["lead_order"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} + elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} +if (isset($_GET["campaign_rec_exten"])) {$campaign_rec_exten=$_GET["campaign_rec_exten"];} + elseif (isset($_POST["campaign_rec_exten"])) {$campaign_rec_exten=$_POST["campaign_rec_exten"];} +if (isset($_GET["campaign_recording"])) {$campaign_recording=$_GET["campaign_recording"];} + elseif (isset($_POST["campaign_recording"])) {$campaign_recording=$_POST["campaign_recording"];} +if (isset($_GET["campaign_rec_filename"])) {$campaign_rec_filename=$_GET["campaign_rec_filename"];} + elseif (isset($_POST["campaign_rec_filename"])) {$campaign_rec_filename=$_POST["campaign_rec_filename"];} +if (isset($_GET["hotkey"])) {$hotkey=$_GET["hotkey"];} + elseif (isset($_POST["hotkey"])) {$hotkey=$_POST["hotkey"];} +if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} + elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} +if (isset($_GET["old_campaign_id"])) {$old_campaign_id=$_GET["old_campaign_id"];} + elseif (isset($_POST["old_campaign_id"])) {$old_campaign_id=$_POST["old_campaign_id"];} +if (isset($_GET["OLDuser_group"])) {$OLDuser_group=$_GET["OLDuser_group"];} + elseif (isset($_POST["OLDuser_group"])) {$OLDuser_group=$_POST["OLDuser_group"];} +if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];} + elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];} +if (isset($_GET["selectable"])) {$selectable=$_GET["selectable"];} + elseif (isset($_POST["selectable"])) {$selectable=$_POST["selectable"];} +if (isset($_GET["HKstatus"])) {$HKstatus=$_GET["HKstatus"];} + elseif (isset($_POST["HKstatus"])) {$HKstatus=$_POST["HKstatus"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["delete_users"])) {$delete_users=$_GET["delete_users"];} + elseif (isset($_POST["delete_users"])) {$delete_users=$_POST["delete_users"];} +if (isset($_GET["delete_user_groups"])) {$delete_user_groups=$_GET["delete_user_groups"];} + elseif (isset($_POST["delete_user_groups"])) {$delete_user_groups=$_POST["delete_user_groups"];} +if (isset($_GET["delete_lists"])) {$delete_lists=$_GET["delete_lists"];} + elseif (isset($_POST["delete_lists"])) {$delete_lists=$_POST["delete_lists"];} +if (isset($_GET["delete_campaigns"])) {$delete_campaigns=$_GET["delete_campaigns"];} + elseif (isset($_POST["delete_campaigns"])) {$delete_campaigns=$_POST["delete_campaigns"];} +if (isset($_GET["delete_ingroups"])) {$delete_ingroups=$_GET["delete_ingroups"];} + elseif (isset($_POST["delete_ingroups"])) {$delete_ingroups=$_POST["delete_ingroups"];} +if (isset($_GET["delete_remote_agents"])) {$delete_remote_agents=$_GET["delete_remote_agents"];} + elseif (isset($_POST["delete_remote_agents"])) {$delete_remote_agents=$_POST["delete_remote_agents"];} +if (isset($_GET["load_leads"])) {$load_leads=$_GET["load_leads"];} + elseif (isset($_POST["load_leads"])) {$load_leads=$_POST["load_leads"];} +if (isset($_GET["campaign_detail"])) {$campaign_detail=$_GET["campaign_detail"];} + elseif (isset($_POST["campaign_detail"])) {$campaign_detail=$_POST["campaign_detail"];} +if (isset($_GET["ast_admin_access"])) {$ast_admin_access=$_GET["ast_admin_access"];} + elseif (isset($_POST["ast_admin_access"])) {$ast_admin_access=$_POST["ast_admin_access"];} +if (isset($_GET["ast_delete_phones"])) {$ast_delete_phones=$_GET["ast_delete_phones"];} + elseif (isset($_POST["ast_delete_phones"])) {$ast_delete_phones=$_POST["ast_delete_phones"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} +if (isset($_GET["delete_scripts"])) {$delete_scripts=$_GET["delete_scripts"];} + elseif (isset($_POST["delete_scripts"])) {$delete_scripts=$_POST["delete_scripts"];} +if (isset($_GET["script_id"])) {$script_id=$_GET["script_id"];} + elseif (isset($_POST["script_id"])) {$script_id=$_POST["script_id"];} +if (isset($_GET["script_name"])) {$script_name=$_GET["script_name"];} + elseif (isset($_POST["script_name"])) {$script_name=$_POST["script_name"];} +if (isset($_GET["script_comments"])) {$script_comments=$_GET["script_comments"];} + elseif (isset($_POST["script_comments"])) {$script_comments=$_POST["script_comments"];} +if (isset($_GET["script_text"])) {$script_text=$_GET["script_text"];} + elseif (isset($_POST["script_text"])) {$script_text=$_POST["script_text"];} +if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} + elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} +if (isset($_GET["get_call_launch"])) {$get_call_launch=$_GET["get_call_launch"];} + elseif (isset($_POST["get_call_launch"])) {$get_call_launch=$_POST["get_call_launch"];} +if (isset($_GET["am_message_exten"])) {$am_message_exten=$_GET["am_message_exten"];} + elseif (isset($_POST["am_message_exten"])) {$am_message_exten=$_POST["am_message_exten"];} +if (isset($_GET["amd_send_to_vmx"])) {$amd_send_to_vmx=$_GET["amd_send_to_vmx"];} + elseif (isset($_POST["amd_send_to_vmx"])) {$amd_send_to_vmx=$_POST["amd_send_to_vmx"];} +if (isset($_GET["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_GET["xferconf_a_dtmf"];} + elseif (isset($_POST["xferconf_a_dtmf"])) {$xferconf_a_dtmf=$_POST["xferconf_a_dtmf"];} +if (isset($_GET["xferconf_a_number"])) {$xferconf_a_number=$_GET["xferconf_a_number"];} + elseif (isset($_POST["xferconf_a_number"])) {$xferconf_a_number=$_POST["xferconf_a_number"];} +if (isset($_GET["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_GET["xferconf_b_dtmf"];} + elseif (isset($_POST["xferconf_b_dtmf"])) {$xferconf_b_dtmf=$_POST["xferconf_b_dtmf"];} +if (isset($_GET["xferconf_b_number"])) {$xferconf_b_number=$_GET["xferconf_b_number"];} + elseif (isset($_POST["xferconf_b_number"])) {$xferconf_b_number=$_POST["xferconf_b_number"];} +if (isset($_GET["modify_leads"])) {$modify_leads=$_GET["modify_leads"];} + elseif (isset($_POST["modify_leads"])) {$modify_leads=$_POST["modify_leads"];} +if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} + elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} +if (isset($_GET["change_agent_campaign"])) {$change_agent_campaign=$_GET["change_agent_campaign"];} + elseif (isset($_POST["change_agent_campaign"])) {$change_agent_campaign=$_POST["change_agent_campaign"];} +if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} + elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} +if (isset($_GET["alt_number_dialing"])) {$alt_number_dialing=$_GET["alt_number_dialing"];} + elseif (isset($_POST["alt_number_dialing"])) {$alt_number_dialing=$_POST["alt_number_dialing"];} +if (isset($_GET["scheduled_callbacks"])) {$scheduled_callbacks=$_GET["scheduled_callbacks"];} + elseif (isset($_POST["scheduled_callbacks"])) {$scheduled_callbacks=$_POST["scheduled_callbacks"];} +if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} + elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} +if (isset($_GET["lead_filter_name"])) {$lead_filter_name=$_GET["lead_filter_name"];} + elseif (isset($_POST["lead_filter_name"])) {$lead_filter_name=$_POST["lead_filter_name"];} +if (isset($_GET["lead_filter_comments"])) {$lead_filter_comments=$_GET["lead_filter_comments"];} + elseif (isset($_POST["lead_filter_comments"])) {$lead_filter_comments=$_POST["lead_filter_comments"];} +if (isset($_GET["lead_filter_sql"])) {$lead_filter_sql=$_GET["lead_filter_sql"];} + elseif (isset($_POST["lead_filter_sql"])) {$lead_filter_sql=$_POST["lead_filter_sql"];} +if (isset($_GET["agentonly_callbacks"])) {$agentonly_callbacks=$_GET["agentonly_callbacks"];} + elseif (isset($_POST["agentonly_callbacks"])) {$agentonly_callbacks=$_POST["agentonly_callbacks"];} +if (isset($_GET["agentcall_manual"])) {$agentcall_manual=$_GET["agentcall_manual"];} + elseif (isset($_POST["agentcall_manual"])) {$agentcall_manual=$_POST["agentcall_manual"];} +if (isset($_GET["vicidial_recording"])) {$vicidial_recording=$_GET["vicidial_recording"];} + elseif (isset($_POST["vicidial_recording"])) {$vicidial_recording=$_POST["vicidial_recording"];} +if (isset($_GET["vicidial_transfers"])) {$vicidial_transfers=$_GET["vicidial_transfers"];} + elseif (isset($_POST["vicidial_transfers"])) {$vicidial_transfers=$_POST["vicidial_transfers"];} +if (isset($_GET["delete_filters"])) {$delete_filters=$_GET["delete_filters"];} + elseif (isset($_POST["delete_filters"])) {$delete_filters=$_POST["delete_filters"];} +if (isset($_GET["alter_agent_interface_options"])) {$alter_agent_interface_options=$_GET["alter_agent_interface_options"];} + elseif (isset($_POST["alter_agent_interface_options"])) {$alter_agent_interface_options=$_POST["alter_agent_interface_options"];} +if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} + elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} +if (isset($_GET["drop_call_seconds"])) {$drop_call_seconds=$_GET["drop_call_seconds"];} + elseif (isset($_POST["drop_call_seconds"])) {$drop_call_seconds=$_POST["drop_call_seconds"];} +if (isset($_GET["safe_harbor_message"])) {$safe_harbor_message=$_GET["safe_harbor_message"];} + elseif (isset($_POST["safe_harbor_message"])) {$safe_harbor_message=$_POST["safe_harbor_message"];} +if (isset($_GET["safe_harbor_exten"])) {$safe_harbor_exten=$_GET["safe_harbor_exten"];} + elseif (isset($_POST["safe_harbor_exten"])) {$safe_harbor_exten=$_POST["safe_harbor_exten"];} +if (isset($_GET["drop_message"])) {$drop_message=$_GET["drop_message"];} + elseif (isset($_POST["drop_message"])) {$drop_message=$_POST["drop_message"];} +if (isset($_GET["drop_exten"])) {$drop_exten=$_GET["drop_exten"];} + elseif (isset($_POST["drop_exten"])) {$drop_exten=$_POST["drop_exten"];} +if (isset($_GET["call_time_id"])) {$call_time_id=$_GET["call_time_id"];} + elseif (isset($_POST["call_time_id"])) {$call_time_id=$_POST["call_time_id"];} +if (isset($_GET["call_time_name"])) {$call_time_name=$_GET["call_time_name"];} + elseif (isset($_POST["call_time_name"])) {$call_time_name=$_POST["call_time_name"];} +if (isset($_GET["call_time_comments"])) {$call_time_comments=$_GET["call_time_comments"];} + elseif (isset($_POST["call_time_comments"])) {$call_time_comments=$_POST["call_time_comments"];} +if (isset($_GET["ct_default_start"])) {$ct_default_start=$_GET["ct_default_start"];} + elseif (isset($_POST["ct_default_start"])) {$ct_default_start=$_POST["ct_default_start"];} +if (isset($_GET["ct_default_stop"])) {$ct_default_stop=$_GET["ct_default_stop"];} + elseif (isset($_POST["ct_default_stop"])) {$ct_default_stop=$_POST["ct_default_stop"];} +if (isset($_GET["ct_sunday_start"])) {$ct_sunday_start=$_GET["ct_sunday_start"];} + elseif (isset($_POST["ct_sunday_start"])) {$ct_sunday_start=$_POST["ct_sunday_start"];} +if (isset($_GET["ct_sunday_stop"])) {$ct_sunday_stop=$_GET["ct_sunday_stop"];} + elseif (isset($_POST["ct_sunday_stop"])) {$ct_sunday_stop=$_POST["ct_sunday_stop"];} +if (isset($_GET["ct_monday_start"])) {$ct_monday_start=$_GET["ct_monday_start"];} + elseif (isset($_POST["ct_monday_start"])) {$ct_monday_start=$_POST["ct_monday_start"];} +if (isset($_GET["ct_monday_stop"])) {$ct_monday_stop=$_GET["ct_monday_stop"];} + elseif (isset($_POST["ct_monday_stop"])) {$ct_monday_stop=$_POST["ct_monday_stop"];} +if (isset($_GET["ct_tuesday_start"])) {$ct_tuesday_start=$_GET["ct_tuesday_start"];} + elseif (isset($_POST["ct_tuesday_start"])) {$ct_tuesday_start=$_POST["ct_tuesday_start"];} +if (isset($_GET["ct_tuesday_stop"])) {$ct_tuesday_stop=$_GET["ct_tuesday_stop"];} + elseif (isset($_POST["ct_tuesday_stop"])) {$ct_tuesday_stop=$_POST["ct_tuesday_stop"];} +if (isset($_GET["ct_wednesday_start"])) {$ct_wednesday_start=$_GET["ct_wednesday_start"];} + elseif (isset($_POST["ct_wednesday_start"])) {$ct_wednesday_start=$_POST["ct_wednesday_start"];} +if (isset($_GET["ct_wednesday_stop"])) {$ct_wednesday_stop=$_GET["ct_wednesday_stop"];} + elseif (isset($_POST["ct_wednesday_stop"])) {$ct_wednesday_stop=$_POST["ct_wednesday_stop"];} +if (isset($_GET["ct_thursday_start"])) {$ct_thursday_start=$_GET["ct_thursday_start"];} + elseif (isset($_POST["ct_thursday_start"])) {$ct_thursday_start=$_POST["ct_thursday_start"];} +if (isset($_GET["ct_thursday_stop"])) {$ct_thursday_stop=$_GET["ct_thursday_stop"];} + elseif (isset($_POST["ct_thursday_stop"])) {$ct_thursday_stop=$_POST["ct_thursday_stop"];} +if (isset($_GET["ct_friday_start"])) {$ct_friday_start=$_GET["ct_friday_start"];} + elseif (isset($_POST["ct_friday_start"])) {$ct_friday_start=$_POST["ct_friday_start"];} +if (isset($_GET["ct_friday_stop"])) {$ct_friday_stop=$_GET["ct_friday_stop"];} + elseif (isset($_POST["ct_friday_stop"])) {$ct_friday_stop=$_POST["ct_friday_stop"];} +if (isset($_GET["ct_saturday_start"])) {$ct_saturday_start=$_GET["ct_saturday_start"];} + elseif (isset($_POST["ct_saturday_start"])) {$ct_saturday_start=$_POST["ct_saturday_start"];} +if (isset($_GET["ct_saturday_stop"])) {$ct_saturday_stop=$_GET["ct_saturday_stop"];} + elseif (isset($_POST["ct_saturday_stop"])) {$ct_saturday_stop=$_POST["ct_saturday_stop"];} +if (isset($_GET["state_call_time_state"])) {$state_call_time_state=$_GET["state_call_time_state"];} + elseif (isset($_POST["state_call_time_state"])) {$state_call_time_state=$_POST["state_call_time_state"];} +if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];} + elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];} +if (isset($_GET["delete_call_times"])) {$delete_call_times=$_GET["delete_call_times"];} + elseif (isset($_POST["delete_call_times"])) {$delete_call_times=$_POST["delete_call_times"];} +if (isset($_GET["modify_call_times"])) {$modify_call_times=$_GET["modify_call_times"];} + elseif (isset($_POST["modify_call_times"])) {$modify_call_times=$_POST["modify_call_times"];} +if (isset($_GET["wrapup_seconds"])) {$wrapup_seconds=$_GET["wrapup_seconds"];} + elseif (isset($_POST["wrapup_seconds"])) {$wrapup_seconds=$_POST["wrapup_seconds"];} +if (isset($_GET["wrapup_message"])) {$wrapup_message=$_GET["wrapup_message"];} + elseif (isset($_POST["wrapup_message"])) {$wrapup_message=$_POST["wrapup_message"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["attempt_delay"])) {$attempt_delay=$_GET["attempt_delay"];} + elseif (isset($_POST["attempt_delay"])) {$attempt_delay=$_POST["attempt_delay"];} +if (isset($_GET["attempt_maximum"])) {$attempt_maximum=$_GET["attempt_maximum"];} + elseif (isset($_POST["attempt_maximum"])) {$attempt_maximum=$_POST["attempt_maximum"];} + + if (isset($script_id)) {$script_id= strtoupper($script_id);} + if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS ONLY ### +$user_level = ereg_replace("[^0-9]","",$user_level); +$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds); +$xferconf_a_number = ereg_replace("[^0-9]","",$xferconf_a_number); +$xferconf_b_number = ereg_replace("[^0-9]","",$xferconf_b_number); +$drop_call_seconds = ereg_replace("[^0-9]","",$drop_call_seconds); +$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext); +$safe_harbor_exten = ereg_replace("[^0-9]","",$safe_harbor_exten); +$am_message_exten = ereg_replace("[^0-9]","",$am_message_exten); +$campaign_rec_exten = ereg_replace("[^0-9]","",$campaign_rec_exten); +$campaign_vdad_exten = ereg_replace("[^0-9]","",$campaign_vdad_exten); +$drop_exten = ereg_replace("[^0-9]","",$drop_exten); +$dial_timeout = ereg_replace("[^0-9]","",$dial_timeout); +$park_ext = ereg_replace("[^0-9]","",$park_ext); +$hopper_level = ereg_replace("[^0-9]","",$hopper_level); +$agent_choose_ingroups = ereg_replace("[^0-9]","",$agent_choose_ingroups); +$hotkeys_active = ereg_replace("[^0-9]","",$hotkeys_active); +$agentonly_callbacks = ereg_replace("[^0-9]","",$agentonly_callbacks); +$agentcall_manual = ereg_replace("[^0-9]","",$agentcall_manual); +$vicidial_recording = ereg_replace("[^0-9]","",$vicidial_recording); +$vicidial_transfers = ereg_replace("[^0-9]","",$vicidial_transfers); +$closer_default_blended = ereg_replace("[^0-9]","",$closer_default_blended); +$alter_agent_interface_options = ereg_replace("[^0-9]","",$alter_agent_interface_options); +$delete_users = ereg_replace("[^0-9]","",$delete_users); +$delete_user_groups = ereg_replace("[^0-9]","",$delete_user_groups); +$delete_scripts = ereg_replace("[^0-9]","",$delete_scripts); +$delete_remote_agents = ereg_replace("[^0-9]","",$delete_remote_agents); +$delete_lists = ereg_replace("[^0-9]","",$delete_lists); +$delete_ingroups = ereg_replace("[^0-9]","",$delete_ingroups); +$delete_filters = ereg_replace("[^0-9]","",$delete_filters); +$delete_campaigns = ereg_replace("[^0-9]","",$delete_campaigns); +$delete_call_times = ereg_replace("[^0-9]","",$delete_call_times); +$load_leads = ereg_replace("[^0-9]","",$delete_call_times); +$campaign_detail = ereg_replace("[^0-9]","",$campaign_detail); +$ast_delete_phones = ereg_replace("[^0-9]","",$ast_delete_phones); +$ast_admin_access = ereg_replace("[^0-9]","",$ast_admin_access); +$modify_leads = ereg_replace("[^0-9]","",$modify_leads); +$change_agent_campaign = ereg_replace("[^0-9]","",$change_agent_campaign); +$modify_call_times = ereg_replace("[^0-9]","",$modify_call_times); +$ct_wednesday_stop = ereg_replace("[^0-9]","",$ct_wednesday_stop); +$ct_wednesday_start = ereg_replace("[^0-9]","",$ct_wednesday_start); +$ct_tuesday_stop = ereg_replace("[^0-9]","",$ct_tuesday_stop); +$ct_tuesday_start = ereg_replace("[^0-9]","",$ct_tuesday_start); +$ct_thursday_stop = ereg_replace("[^0-9]","",$ct_thursday_stop); +$ct_thursday_start = ereg_replace("[^0-9]","",$ct_thursday_start); +$ct_sunday_stop = ereg_replace("[^0-9]","",$ct_sunday_stop); +$ct_sunday_start = ereg_replace("[^0-9]","",$ct_sunday_start); +$ct_saturday_stop = ereg_replace("[^0-9]","",$ct_saturday_stop); +$ct_saturday_start = ereg_replace("[^0-9]","",$ct_saturday_start); +$ct_monday_stop = ereg_replace("[^0-9]","",$ct_monday_stop); +$ct_monday_start = ereg_replace("[^0-9]","",$ct_monday_start); +$ct_friday_stop = ereg_replace("[^0-9]","",$ct_friday_stop); +$ct_friday_start = ereg_replace("[^0-9]","",$ct_friday_start); +$ct_default_stop = ereg_replace("[^0-9]","",$ct_default_stop); +$ct_default_start = ereg_replace("[^0-9]","",$ct_default_start); +$number_of_lines = ereg_replace("[^0-9]","",$number_of_lines); +$user_start = ereg_replace("[^0-9]","",$user_start); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +$remote_agent_id = ereg_replace("[^0-9]","",$remote_agent_id); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$attempt_maximum = ereg_replace("[^0-9]","",$attempt_maximum); +$attempt_delay = ereg_replace("[^0-9]","",$attempt_delay); +$hotkey = ereg_replace("[^0-9]","",$hotkey); +$list_id = ereg_replace("[^0-9]","",$list_id); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); +$allow_closers = ereg_replace("[^NY]","",$allow_closers); +$reset_hopper = ereg_replace("[^NY]","",$reset_hopper); +$amd_send_to_vmx = ereg_replace("[^NY]","",$amd_send_to_vmx); +$alt_number_dialing = ereg_replace("[^NY]","",$alt_number_dialing); +$safe_harbor_message = ereg_replace("[^NY]","",$safe_harbor_message); +$selectable = ereg_replace("[^NY]","",$selectable); +$reset_list = ereg_replace("[^NY]","",$reset_list); +$fronter_display = ereg_replace("[^NY]","",$fronter_display); +$drop_message = ereg_replace("[^NY]","",$drop_message); +$use_internal_dnc = ereg_replace("[^NY]","",$use_internal_dnc); + +### ALPHA-NUMERIC ONLY ### +$user = ereg_replace("[^0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^0-9a-zA-Z]","",$pass); +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$script_id = ereg_replace("[^0-9a-zA-Z]","",$script_id); +$submit = ereg_replace("[^0-9a-zA-Z]","",$submit); +$CoNfIrM = ereg_replace("[^0-9a-zA-Z]","",$CoNfIrM); +$campaign_cid = ereg_replace("[^0-9a-zA-Z]","",$campaign_cid); +$get_call_launch = ereg_replace("[^0-9a-zA-Z]","",$get_call_launch); +$campaign_recording = ereg_replace("[^0-9a-zA-Z]","",$campaign_recording); +$ADD = ereg_replace("[^0-9a-zA-Z]","",$ADD); +$dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$dial_prefix); +$state_call_time_state = ereg_replace("[^0-9a-zA-Z]","",$state_call_time_state); +$scheduled_callbacks = ereg_replace("[^0-9a-zA-Z]","",$scheduled_callbacks); + +### DIGITS and Dots +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$auto_dial_level = ereg_replace("[^\.0-9]","",$auto_dial_level); + +### DIGITS and spaces and hash and star and comma +$xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_a_dtmf); +$xferconf_b_dtmf = ereg_replace("[^ \,\*\#0-9]","",$xferconf_b_dtmf); + +### ALPHA-NUMERIC and underscore and dash +$dial_status_e = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_e); +$dial_status_d = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_d); +$dial_status_c = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_c); +$dial_status_b = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_b); +$dial_status_a = ereg_replace("[^-\_0-9a-zA-Z]","",$dial_status_a); +$stage = ereg_replace("[^-\_0-9a-zA-Z]","",$stage); +$lead_filter_id = ereg_replace("[^-\_0-9a-zA-Z]","",$lead_filter_id); +$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id); +$old_campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_campaign_id); +$park_file_name = ereg_replace("[^-\_0-9a-zA-Z]","",$park_file_name); +$next_agent_call = ereg_replace("[^-\_0-9a-zA-Z]","",$next_agent_call); +$local_call_time = ereg_replace("[^-\_0-9a-zA-Z]","",$local_call_time); +$call_time_id = ereg_replace("[^-\_0-9a-zA-Z]","",$call_time_id); +$phone_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_pass); +$phone_login = ereg_replace("[^-\_0-9a-zA-Z]","",$phone_login); +$group_id = ereg_replace("[^-\_0-9a-zA-Z]","",$group_id); +$user_group = ereg_replace("[^-\_0-9a-zA-Z]","",$user_group); +$OLDuser_group = ereg_replace("[^-\_0-9a-zA-Z]","",$OLDuser_group); +$state_rule = ereg_replace("[^-\_0-9a-zA-Z]","",$state_rule); + +### ALPHA-NUMERIC and spaces +$lead_order = ereg_replace("[^ 0-9a-zA-Z]","",$lead_order); +### ALPHA-NUMERIC and hash +$group_color = ereg_replace("[^\#0-9a-zA-Z]","",$group_color); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$group_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$group_name); +$campaign_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_name); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$wrapup_message = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$wrapup_message); +$status = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status); +$HKstatus = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$HKstatus); +$status_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$status_name); +$script_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_name); +$script_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$script_comments); +$list_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$list_name); +$lead_filter_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_name); +$lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comments); +$campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); +$call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); +$call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); + +### remove semi-colons ### +$lead_filter_sql = ereg_replace(";","",$lead_filter_sql); + +### VARIABLES TO BE mysql_real_escape_string ### +# $web_form_address +# $script_text + +##### END VARIABLE FILTERING FOR SECURITY ##### + + +# AST GUI database administration +# admin.php +# +# CHANGES +# 50315-1110 - Added Custom Campaign Statuses +# 50317-1438 - Added Fronter Display var to inbound groups +# 50322-1355 - Added custom callerID per campaign +# 50517-1356 - Added user_groups sections and user_group to vicidial_users +# 50517-1440 - Added ability to logout (must click OK with empty user/pass) +# 50602-1622 - Added lead loader pages to load new files into vicidial_list +# 50620-1351 - Added custom vdad transfer AGI extension per campaign +# 50810-1414 - modified in groups to kick out spaces and dashes +# 50908-2136 - Added Custom Campaign HotKeys +# 50914-0950 - Fixed user search by user_group +# 50926-1358 - Modified to allow for language translation +# 50926-1615 - Added WeBRooTWritablE write controls +# 51020-1008 - Added editable web address and park ext - NEW dial campaigns +# 51020-1056 - Added fields and help for campaign recording control +# 51123-1335 - Altered code to function in php globals=off +# 51208-1038 - Added user_level changes, function controls and default user phones +# 51208-1556 - Added deletion of users/lists/campaigns/in groups/remote agents +# 51213-1706 - Added add/delete/modify vicidial scripts +# 51214-1737 - Added preview of vicidial script in popup window +# 51219-1225 - Added campaign and ingroups script selector and get_call_launch field +# 51222-1055 - Added am_message_exten to campaigns to allow for AM Message button +# 51222-1125 - Fixed new vicidial_campaigns default values not being assigned bug +# 51222-1156 - Added LOG OUT ALL AGENTS ON THIS CAMPAIGN button to campaign screen +# 60204-0659 - Fixed hopper reset bug +# 60207-1413 - Added AMD send to voicemail extension and xfer-conf dtmf presets +# 60213-1100 - Added several vicidial_users permissions fields +# 60215-1319 - Added On-hold CallBacks display and links +# 60227-1226 - Fixed vicidial_inbound_groups insert bug +# 60413-1308 - Fixed list display to have 1 row/status: count and time zone tables +# - Added status name in selected dial statuses in campaign screen +# 60417-1416 - Added vicidial_lead_filters sections +# - Changed the header links to color-coded sectional with sublinks below +# - Added filter name and script name to campaign and in-group modify sections +# - Added callback and alt dial options to campaigns section +# - Added callback, alt dial and other options to users section +# 60419-1628 - Alter Callbacks display to include status and LIVE listings, reordered +# 60421-1441 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60425-2355 - Added agent options to vicidial_users, reformatted user page +# 60502-1627 - Added drop_call_seconds and safe_harbor_ fields to campaign screen +# 60503-1228 - Added drop_call_seconds and drop_ fields to inbound groups screen +# 60505-1117 - Added initial framework for new local_call_times tables and definitions +# 60506-1033 - More revisions to the local_call_time section +# 60508-1354 - Finished call_times and state_call_times sections +# - Added modify/delete options for call_times +# 60509-1311 - Functionalize campaign dialable leads calculation +# - Change state_call_times selection from call_times to only allow one per state +# - Added dialable leads count popup to campaign screen if auto-calc is disabled +# - Added test dialable leads count popup to filter screen +# 60510-1050 - Added Wrapup seconds and Wrapup message to campaigns screen +# 60608-1401 - Added allowable inbound_groups checkboxes to CLOSER campaign detail screen +# 60609-1051 - Added add-to-dnc in LISTS section +# 60613-1415 - Added lead recycling options to campaign detail screen +# 60619-1523 - Added variable filtering to eliminate SQL injection attack threat +# 60622-1216 - Fixed HotKey addition form issues and variable filtering +# 60623-1159 - Fixed Scheduled Callbacks over-filtering bug and filter_sql bug +# + +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time + +$version = '1.1.12-3'; +$build = '60623-1159'; + +$STARTtime = date("U"); + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or ($auth<1)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGuser_level =$row[4]; + $LOGdelete_users =$row[8]; + $LOGdelete_user_groups =$row[9]; + $LOGdelete_lists =$row[10]; + $LOGdelete_campaigns =$row[11]; + $LOGdelete_ingroups =$row[12]; + $LOGdelete_remote_agents =$row[13]; + $LOGload_leads =$row[14]; + $LOGcampaign_detail =$row[15]; + $LOGdelete_scripts =$row[18]; + $LOGdelete_filters =$row[29]; + $LOGalter_agent_interface =$row[30]; + $LOGdelete_call_times =$row[32]; + $LOGmodify_call_times =$row[33]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDIAL ADMIN: "; + +if (!isset($ADD)) {$ADD=0;} + +if ($ADD==1) {$hh='users'; echo "Add New User";} +if ($ADD==11) {$hh='campaigns'; echo "Add New Campaign";} +if ($ADD==111) {$hh='lists'; echo "Add New List";} +if ($ADD==121) {$hh='lists'; echo "Add New DNC";} +if ($ADD==1111) {$hh='ingroups'; echo "Add New In-Group";} +if ($ADD==11111) {$hh='remoteagent'; echo "Add New Remote Agents";} +if ($ADD==111111) {$hh='usergroups'; echo "Add New Users Group";} +if ($ADD==1111111) {$hh='scripts'; echo "Add New Script";} +if ($ADD==11111111) {$hh='filters'; echo "Add New Filter";} +if ($ADD==111111111) {$hh='times'; echo "Add New Call Time";} +if ($ADD==1111111111) {$hh='times'; echo "Add New State Call Time";} +if ($ADD==2) {$hh='users'; echo "New User Addition";} +if ($ADD==21) {$hh='campaigns'; echo "New Campaign Addition";} +if ($ADD==22) {$hh='campaigns'; echo "New Campaign Status Addition";} +if ($ADD==23) {$hh='campaigns'; echo "New Campaign HotKey Addition";} +if ($ADD==25) {$hh='campaigns'; echo "New Campaign Lead Recycle Addition";} +if ($ADD==211) {$hh='lists'; echo "New List Addition";} +if ($ADD==2111) {$hh='ingroups'; echo "New In-Group Addition";} +if ($ADD==21111) {$hh='remoteagent'; echo "New Remote Agents Addition";} +if ($ADD==211111) {$hh='usergroups'; echo "New Users Group Addition";} +if ($ADD==2111111) {$hh='scripts'; echo "New Script Addition";} +if ($ADD==21111111) {$hh='filters'; echo "New Filter Addition";} +if ($ADD==211111111) {$hh='times'; echo "New Call Time Addition";} +if ($ADD==2111111111) {$hh='times'; echo "New State Call Time Addition";} +if ($ADD==3) {$hh='users'; echo "Modify User";} +if ($ADD==31) {$hh='campaigns'; echo "Modify Campaign";} +if ($ADD==34) {$hh='campaigns'; echo "Modify Campaign - Basic View";} +if ($ADD==311) {$hh='lists'; echo "Modify List";} +if ($ADD==3111) {$hh='ingroups'; echo "Modify In-Group";} +if ($ADD==31111) {$hh='remoteagent'; echo "Modify Remote Agents";} +if ($ADD==311111) {$hh='usergroups'; echo "Modify Users Groups";} +if ($ADD==3111111) {$hh='scripts'; echo "Modify Script";} +if ($ADD==31111111) {$hh='filters'; echo "Modify Filter";} +if ($ADD==311111111) {$hh='times'; echo "Modify Call Time";} +if ($ADD==321111111) {$hh='times'; echo "Modify Call Time State Definitions List";} +if ($ADD==3111111111) {$hh='times'; echo "Modify State Call Time";} +if ($ADD=="4A") {$hh='users'; echo "Modify User - Admin";} +if ($ADD=="4B") {$hh='users'; echo "Modify User - Admin";} +if ($ADD==4) {$hh='users'; echo "Modify User";} +if ($ADD==41) {$hh='campaigns'; echo "Modify Campaign";} +if ($ADD==42) {$hh='campaigns'; echo "Modify Campaign Status";} +if ($ADD==43) {$hh='campaigns'; echo "Modify Campaign HotKey";} +if ($ADD==44) {$hh='campaigns'; echo "Modify Campaign - Basic View";} +if ($ADD==45) {$hh='campaigns'; echo "Modify Campaign Lead Recycle";} +if ($ADD==411) {$hh='lists'; echo "Modify List";} +if ($ADD==4111) {$hh='ingroups'; echo "Modify In-Group";} +if ($ADD==41111) {$hh='remoteagent'; echo "Modify Remote Agents";} +if ($ADD==411111) {$hh='usergroups'; echo "Modify Users Groups";} +if ($ADD==4111111) {$hh='scripts'; echo "Modify Script";} +if ($ADD==41111111) {$hh='filters'; echo "Modify Filter";} +if ($ADD==411111111) {$hh='times'; echo "Modify Call Time";} +if ($ADD==4111111111) {$hh='times'; echo "Modify State Call Time";} +if ($ADD==5) {$hh='users'; echo "Delete User";} +if ($ADD==51) {$hh='campaigns'; echo "Delete Campaign";} +if ($ADD==52) {$hh='campaigns'; echo "Logout Agents";} +if ($ADD==511) {$hh='lists'; echo "Delete List";} +if ($ADD==5111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==51111) {$hh='remoteagent'; echo "Delete Remote Agents";} +if ($ADD==511111) {$hh='usergroups'; echo "Delete Users Group";} +if ($ADD==5111111) {$hh='scripts'; echo "Delete Script";} +if ($ADD==51111111) {$hh='filters'; echo "Delete Filter";} +if ($ADD==511111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==5111111111) {$hh='times'; echo "Delete State Call Time";} +if ($ADD==6) {$hh='users'; echo "Delete User";} +if ($ADD==61) {$hh='campaigns'; echo "Delete Campaign";} +if ($ADD==62) {$hh='campaigns'; echo "Logout Agents";} +if ($ADD==65) {$hh='campaigns'; echo "Delete Lead Recycle";} +if ($ADD==611) {$hh='lists'; echo "Delete List";} +if ($ADD==6111) {$hh='ingroups'; echo "Delete In-Group";} +if ($ADD==61111) {$hh='remoteagent'; echo "Delete Remote Agents";} +if ($ADD==611111) {$hh='usergroups'; echo "Delete Users Group";} +if ($ADD==6111111) {$hh='scripts'; echo "Delete Script";} +if ($ADD==61111111) {$hh='filters'; echo "Delete Filter";} +if ($ADD==611111111) {$hh='times'; echo "Delete Call Time";} +if ($ADD==6111111111) {$hh='times'; echo "Delete State Call Time";} +if ($ADD==73) {$hh='campaigns'; echo "Dialable Lead Count";} +if ($ADD==7111111) {$hh='scripts'; echo "Preview Script";} +if ($ADD==0) {$hh='users'; echo "Users List";} +if ($ADD==8) {$hh='users'; echo "CallBacks Within Agent";} +if ($ADD==81) {$hh='campaigns'; echo "CallBacks Within Campaign";} +if ($ADD==811) {$hh='campaigns'; echo "CallBacks Within List";} +if ($ADD==10) {$hh='campaigns'; echo "Campaigns";} +if ($ADD==100) {$hh='lists'; echo "Lists";} +if ($ADD==1000) {$hh='ingroups'; echo "In-Groups";} +if ($ADD==10000) {$hh='remoteagent'; echo "Remote Agents";} +if ($ADD==100000) {$hh='usergroups'; echo "User Groups";} +if ($ADD==1000000) {$hh='scripts'; echo "Scripts";} +if ($ADD==10000000) {$hh='filters'; echo "Filters";} +if ($ADD==100000000) {$hh='times'; echo "Call Times";} +if ($ADD==1000000000) {$hh='times'; echo "State Call Times";} +if ($ADD==55) {$hh='users'; echo "Search Form";} +if ($ADD==66) {$hh='users'; echo "Search Results";} +if ($ADD==99999) {$hh='users'; echo "HELP";} + +if ( ($ADD>9) && ($ADD < 99998) ) + { + ##### get scripts listing for dynamic pulldown + $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $scripts_to_print = mysql_num_rows($rslt); + $scripts_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($scripts_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $scripts_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $scriptname_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + ##### get filters listing for dynamic pulldown + $stmt="SELECT lead_filter_id,lead_filter_name,lead_filter_sql from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + $filters_list="<option value=\"\">NONE</option>\n"; + + $o=0; + while ($filters_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $filters_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $filtername_list["$rowx[0]"] = "$rowx[1]"; + $filtersql_list["$rowx[0]"] = "$rowx[2]"; + $o++; + } + + ##### get call_times listing for dynamic pulldown + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $times_to_print = mysql_num_rows($rslt); + + $o=0; + while ($times_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $call_times_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $call_timename_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + } + +if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or ($ADD==21) or ($ADD==31) or ($ADD==41) or ($ADD=="4A") or ($ADD=="4B") ) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "<option value=\"$rowx[0]\">$rowx[0] - $rowx[1]</option>\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ($ADD==31) + { + $stmt="SELECT closer_campaigns from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + if ($ADD==3) + { + $stmt="SELECT closer_campaigns from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "<input type=\"checkbox\" name=\"groups[]\" value=\"$group_id_value\""; + $p=0; + while ($p<100) + { + if ($group_id_value == $groups[$p]) + { + $groups_list .= " CHECKED"; + $groups_value .= " $group_id_value"; + } + $p++; + } + $groups_list .= "> $group_id_value - $group_name_value<BR>\n"; + $o++; + } + if (strlen($groups_value)>2) {$groups_value .= " -";} + } + + + + + +$NWB = "   <a href=\"javascript:openNewWindow('$PHP_SELF?ADD=99999"; +$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>"; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
VICIDIAL ADMIN: HELP


\n"; + +?> +VICIDIAL_USERS TABLE

+ +
+User ID - This field is where you put the VICIDIAL users ID number, can be up to 8 digits in length, Must be at least 2 characters in length. + +
+
+
+Password - This field is where you put the VICIDIAL users password. Must be at least 2 characters in length. + +
+
+
+Full Name - This field is where you put the VICIDIAL users full name. Must be at least 2 characters in length. + +
+
+
+User Level - This menu is where you select the VICIDIAL users user level. Must be a level of 1 to log into VICIDIAL, Must be level greater than 2 to log in as a closer, Must be user level 8 or greater to get into admin web section. + +
+
+
+User Group - This menu is where you select the VICIDIAL users group that this user will belong to. This does not have any restrictions at this time, this is just to subdivide users and allow for future features based upon it. + +
+
+
+Phone Login - Here is where you can set a default phone login value for when the user logs into vicidial.php. This value will populate the phone_login automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. + +
+
+
+Phone Pass - Here is where you can set a default phone pass value for when the user logs into vicidial.php. This value will populate the phone_pass automatically when the user logs in with their user-pass-campaign in the vicidial.php login screen. + +
+
+
+HotKeys Active - This option if set to 1 allows the user to use the HotKeys quick-dispositioning function in vicidial.php. + +
+
+
+Agent Choose Ingroups - This option if set to 1 allows the user to choose the ingroups that they will receive calls from when they login to a CLOSER or INBOUND campaign. Otherwise the Manager will need to set this in their user detail screen of the admin page. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + +
+
+
+Scheduled Callbacks - This option allows an agent to disposition a call as CALLBK and choose the data and time at which the lead will be re-activated. + +
+
+
+Agent-Only Callbacks - This option allows an agent to set a callback so that they are the only Agent that can call the customer back. This also allows the agent to see their callback listings and call them back any time they want to. + +
+
+
+Agent Call Manual - This option allows an agent to manually enter a new lead into the system and call them. This also allows the calling of any phone number from their vicidial screen and puts that call into their session. Use this option with caution. + +
+
+
+Vicidial Recording - This option can prevent an agent from doing any recordings after they log in to vicidial. This option must be on for vicidial to follow the campaign recording session. + +
+
+
+Vicidial Transfers - This option can prevent an agent from opening the transfer - conference session of vicidial. If this is disabled, the agent cannot third party call or blind transfer any calls. + +
+
+
+Closer Default Blended - This option simply defaults the Blended checkbox on a CLOSER login screen. + +
+
+
+Alter Agent Interface Options - This option if set to 1 allows the administrative user to modify the Agents interface options in admin.php. + +
+
+
+Delete Users - This option if set to 1 allows the user to delete other users of equal or lesser user level from the system. + +
+
+
+Delete User Groups - This option if set to 1 allows the user to delete user groups from the system. + +
+
+
+Delete Lists - This option if set to 1 allows the user to delete vicidial lists from the system. + +
+
+
+Delete Campaigns - This option if set to 1 allows the user to delete vicidial campaigns from the system. + +
+
+
+Delete In-Groups - This option if set to 1 allows the user to delete vicidial In-Groups from the system. + +
+
+
+Delete Remote Agents - This option if set to 1 allows the user to delete vicidial remote agents from the system. + +
+
+
+Load Leads - This option if set to 1 allows the user to load vicidial leads into the vicidial_list table by way of the web based lead loader. + +
+
+
+Campaign Detail - This option if set to 1 allows the user to view and modify the campaign detail screen elements. + +
+
+
+AGC Admin Access - This option if set to 1 allows the user to login to the astGUIclient admin pages. + +
+
+
+AGC Delete Phones - This option if set to 1 allows the user to delete phone entries in the astGUIclient admin pages. + +
+
+
+Delete Scripts - This option if set to 1 allows the user to delete Campaign scripts in the script modification screen. + +
+
+
+Modify Leads - This option if set to 1 allows the user to modify leads in the admin section lead search results page. + +
+
+
+Change Agent Campaign - This option if set to 1 allows the user to alter the campaign that an agent is logged into while they are logged into it. + +
+
+
+Delete Filters - This option allows the user to be able to delete vicidial lead filters from the system. + +
+
+
+Delete Call Times - This option allows the user to be able to delete vicidial call times records and vicidial state call times records from the system. + +
+
+
+Modify Call Times - This option allows the user to view and modify the call times and state call times records. A user doesn't need this option enabled if they only need to change the call times option on the campaigns screen. + + + + +



+ +VICIDIAL_CAMPAIGNS TABLE

+
+
+Campaign ID - This is the short name of the campaign, it is not editable after initial submission, cannot contain spaces and must be between 2 and 8 characters in length. + +
+
+
+Campaign Name - This is the description of the campaign, it must be between 6 and 40 characters in length. + +
+
+
+Active - This is where you set the campaign to Active or Inactive. If Inactive, noone can log into it. + +
+
+
+Park Extension - This is where you can customize the on-hold music for VICIDIAL. Make sure the extension is in place in the extensions.conf and that it points to the filename below. + +
+
+
+Park File Name - This is where you can customize the on-hold music for VICIDIAL. Make sure the filename is 10 characters in length or less and that the file is in place in the /var/lib/asterisk/sounds directory. + +
+
+
+Web Form - This is where you can set the custom web page that will be opened when the user clicks on the WEB FORM button. + +
+
+
+Allow Closers - This is where you can set whether the users of this campaign will have the option to send the call to a closer. + +
+
+
+Dial Status - This is where you set the statuses that you are wanting to dial on within the lists that are active for the campaign below + +
+
+
+List Order - This menu is where you select how the leads that match the statuses selected above will be put in the lead hopper: +
  - DOWN: select the first leads loaded into the vicidial_list table +
  - UP: select the last leads loaded into the vicidial_list table +
  - UP PHONE: select the highest phone number and works its way down +
  - DOWN PHONE: select the lowest phone number and works its way up +
  - UP LAST NAME: starts with last names starting with Z and works its way down +
  - DOWN LAST NAME: starts with last names starting with A and works its way up +
  - UP COUNT: starts with most called leads and works its way down +
  - DOWN COUNT: starts with least called leads and works its way up +
  - DOWN COUNT 2nd NEW: starts with least called leads and works its way up inserting a NEW lead in every other lead - Must NOT have NEW selected in the dial statuses +
  - DOWN COUNT 3nd NEW: starts with least called leads and works its way up inserting a NEW lead in every third lead - Must NOT have NEW selected in the dial statuses +
  - DOWN COUNT 4th NEW: starts with least called leads and works its way up inserting a NEW lead in every forth lead - Must NOT have NEW selected in the dial statuses + +
+
+
+Hopper Level - This is how many leads the VDhopper script tries to keep in the vicidial_hopper table for this campaign. If running VDhopper script every minute, make this slightly greater than the number of leads you go through in a minute. + +
+
+
+Lead Filter - This is a method of filtering your leads using a fragment of a SQL query. Use this feature with caution, it is easy to stop dialing accidentally with the slightest alteration to the SQL statement. Default is NONE. + +
+
+
+Force Reset of Hopper - This allows you to wipe out the hopper contents upon form submission. It should be filled again when the VDhopper script runs. + +
+
+
+Auto Dial Level - This is where you set how many lines VICIDIAL should use per active agent. zero 0 means auto dialing is off and the agents will click to dial each number. Otherwise VICIDIAL will keep dialing lines equal to active agents multiplied by the dial level to arrive at how many lines this campaign on each server should allow. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. +
  - overall_user_level: orders by the user_level of the agent as defined in the vicidial_users table a higher user_level will receive more calls. + +
+
+
+Local Call Time - This is where you set during which hours you would like to dial, as determined by the local time in the are in which you are calling. This is controlled by area code and is adjusted for Daylight Savings time if applicable. General Guidelines in the USA for Business to Business is 9am to 5pm and Business to Consumer calls is 9am to 9pm. + +
+
+
+Dial Timeout - If defined, calls that would normally hangup after the timeout defined in extensions.conf would instead timeout at this amount of seconds if it is less than the extensions.conf timeout. This allows for quickly changing dial timeouts from server to server and limiting the effects to a single campaign. If you are having a lot of Answering Machine or Voicemail calls you may want to try changing this value to between 21-26 and see if results improve. + +
+
+
+Dial Prefix - This field allows for more easily changing a path of dialing to go out through a different method without doing a reload in Asterisk. Default is 9 based upon a 91NXXNXXXXXX in the dialplan - extensions.conf. + +
+
+
+Campaign CallerID - This field allows for the sending of a custom callerid number on the outbound calls. This is the number that would show up on the callerid of the person you are calling. The default is UNKNOWN. If you are using T1 or E1s to dial out this option is only available if you are using PRIs - ISDN T1s or E1s - that have the custom callerid feature turned on, this will not work with Robbed-bit service(RBS) circuits. This will also work through most VOIP(SIP or IAX trunks) providers that allow dynamic outbound callerID. The custom callerID only applies to calls placed for the VICIDIAL campaign directly, any 3rd party calls or transfers will not send the custom callerID. NOTE: Sometimes putting UNKNOWN or PRIVATE in the field will yield the sending of your default callerID number by your carrier with the calls. You may want to test this and put 0000000000 in the callerid field instead if you do not want to send you CallerID. + +
+
+
+Campaign VDAD extension - This field allows for a custom VDAD transfer extension. This allows you to use different VDADtransfer...agi scripts depending upon your campaign. The default transfer AGI - exten 8365 agi-VDADtransfer.agi - just immediately sends the calls on to agents as soon as they are picked up. An additional sample political survey AGI is also now included - 8366 agi-VDADtransferSURVEY.agi - that plays a message to the called person and allows them to make a choice by pressing buttons - effectively pre-screening the lead - . Please note that except for surveys, political calls and charities this form of calling is illegal in the United States. + +
+
+
+Campaign Rec extension - This field allows for a custom recording extension to be used with VICIDIAL. This allows you to use different extensions depending upon how long you want to allow a maximum recording and what type of codec you want to record in. The default exten is 8309 which if you follow the SCRATCH_INSTALL examples will record in the WAV format for upto one hour. Another option included in the examples is 8310 which will record in GSM format for upto one hour. + +
+
+
+Campaign Recording - This menu allows you to choose what level of recording is allowed on this campaign. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. + +
+
+
+Campaign Rec Filename - This field allows you to customize the name of the recording when Campaign recording is ONDEMAND or ALLCALLS. The allowed variables are CAMPAIGN CUSTPHONE FULLDATE TINYDATE EPOCH AGENT. The default is FULLDATE_AGENT and would look like this 20051020-103108_6666. Another example is CAMPAIGN_TINYDATE_CUSTPHONE which would look like this TESTCAMP_51020103108_3125551212. 50 char max. + +
+
+
+Campaign Script - This menu allows you to choose the script that will appear on the agents screen for this campaign. Select NONE to show no script for this campaign. + +
+
+
+Get Call Launch - This menu allows you to choose whether you want to auto-launch the web-form page in a separate window, auto-switch to the SCRIPT tab or do nothing when a call is sent to the agent for this campaign. + +
+
+
+Answering Machine Message - This field is for entering in an extension to blind transfer calls to when the agent gets an answering machine and clicks on the Answering Machine Message button in the transfer conference frame. You must set this exten up in the dialplan - extensions.conf - and make sure it plays an audio file then hangs up. + +
+
+
+AMD send to vm exten - This menu allows you to define whether a message is left on an answering machine when it is detected. the call will be immediately forwarded to the Answering-Machine-Message extension if AMD is active and it is determined that the call is an answering machine. + +
+
+
+Xfer-Conf DTMF - These four fields allow for you to have two sets of Transfer Conference and DTMF presets. When the call or campaign is loaded, the vicidial.php script will show two buttons on the transfer-conference frame and auto-populate the number-to-dial and the send-dtmf fields when pressed. + +
+
+
+Agent Alt Num Dialing - This option allows an agent to manually dial the alternate phone number or address3 field after the main number has been called. + +
+
+
+Scheduled Callbacks - This option allows an agent to disposition a call as CALLBK and choose the data and time at which the lead will be re-activated. + +
+
+
+Drop Call Seconds - The number of seconds from the time the customer line is picked up until the call is considered a DROP, only applies to outbound calls. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Safe Harbor Message - If set to Y will play a message to customer after the Drop Call Seconds timeout is reached without being transferred to an agent. This setting will override sending to a voicemail box if this is set to Y. + +
+
+
+Safe Harbor Exten - This is the dialplan extension that the desired Safe Harbor audio file is located at on your server. + +
+
+
+Wrapup Seconds - The number of seconds to force an agent to wait before allowing them to receive or dial another call. The timer begins as soon as an agent hangs up on their customer - or in the case of alternate number dialing when the agent finishes the lead - Default is 0 seconds. If the timer runs out before the agent has dispositioned the call, the agent still will NOT move on to the next call until they select a disposition. + +
+
+
+Wrapup Message - This is a campaign-specific message to be displayed on the wrapup screen if wrapup seconds is set. + +
+
+
+Wrapup Message - This is a campaign-specific message to be displayed on the wrapup screen if wrapup seconds is set. + +
+
+
+Use Internal DNC List - This defines whether this campaign is to filter leads against the Internal DNC list. If it is set to Y, the hopper will look for each phone number in the DNC list before placing it in the hopper. If it is in the DNC list then it will change that lead status to DNCL so it cannot be dialed. Default is N. + +
+
+
+Allowed Inbound Groups - For CLOSER campaigns only. Here is where you select the inbound groups you want agents in this CLOSER campaign to be able to take calls from. It is important for BLENDED inbound/outbound campaigns only to select the inbound groups that are used for agents in this campaign. The calls coming into the inbound groups selected here will be counted as active calls for a blended campaign even if all agents in the campaign are not logged in to receive calls from all of those selected inbound groups. + + + +



+ +VICIDIAL_LISTS TABLE

+
+
+List ID - This is the numerical name of the list, it is not editable after initial submission, must contain only numbers and must be between 2 and 8 characters in length. + +
+
+
+List Name - This is the description of the list, it must be between 2 and 20 characters in length. + +
+
+
+Campaign - This is the campaign that this list belongs to. A list can only be dialed on a single campaign at one time. + +
+
+
+Active - This defines whether the list is to be dialed on or not. + +
+
+
+Reset Lead-Called-Status for this list - This resets all leads in this list to N for "not called since last reset" and means that any lead can now be called if it is the right status as defined in the campaign screen. + +
+
+
+VICIDIAL DNC List - This Do Not Call list contains every lead that has been set to a status of DNC in the system. Through the LISTS - ADD NUMBER TO DNC page you are able to manually add a number to this list so that it will not be called by campaigns that use the internal DNC list. + + + +



+ +VICIDIAL_INBOUND_GROUPS TABLE

+
+
+Group ID - This is the short name of the inbound group, it is not editable after initial submission, must not contain any spaces and must be between 2 and 20 characters in length. + +
+
+
+Group Name - This is the description of the group, it must be between 2 and 30 characters in length. Cannot include dashes, plusses or spaces . + +
+
+
+Group Color - This is the color that displays in the VICIDIAL client app when a call comes in on this group. It must be between 2 and 7 characters long. If this is a hex color definition you must remember to put a # at the beginning of the string or VICIDIAL will not work properly. + +
+
+
+Active - This determines whether this group show up in the selection box when a VICIDIAL agent logs in. + +
+
+
+Web Form - This is the custom address that clicking on the WEB FORM button in VICIDIAL will take you to for calls that come in on this group. + +
+
+
+Next Agent Call - This determines which agent receives the next call that is available: +
  - random: orders by the random update value in the vicidial_live_agents table +
  - oldest_call_start: orders by the last time an agent was sent a call. Results in agents receiving about the same number of calls overall. +
  - oldest_call_finish: orders by the last time an agent finished a call. AKA agent waiting longest receives first call. +
  - overall_user_level: orders by the user_level of the agent as defined in the vicidial_users table a higher user_level will receive more calls. + +
+
+
+Fronter Display - This field determines whether the inbound VICIDIAL agent would have the fronter name - if there is one - displayed in the Status field when the call comes to the agent. + +
+
+
+Campaign Script - This menu allows you to choose the script that will appear on the agents screen for this campaign. Select NONE to show no script for this campaign. + +
+
+
+Get Call Launch - This menu allows you to choose whether you want to auto-launch the web-form page in a separate window, auto-switch to the SCRIPT tab or do nothing when a call is sent to the agent for this campaign. + +
+
+
+Xfer-Conf DTMF - These four fields allow for you to have two sets of Transfer Conference and DTMF presets. When the call or campaign is loaded, the vicidial.php script will show two buttons on the transfer-conference frame and auto-populate the number-to-dial and the send-dtmf fields when pressed. + +
+
+
+Drop Call Seconds - The number of seconds from the time the customer line is picked up until the call is considered a DROP, only applies to outbound calls. + +
+
+
+Voicemail - If defined, calls that would normally DROP would instead be directed to this voicemail box to hear and leave a message. + +
+
+
+Drop Message - If set to Y will play a message to customer after the Drop Call Seconds timeout is reached without being transferred to an agent. This setting will override sending to a voicemail box if this is set to Y. + +
+
+
+Drop Exten - This is the dialplan extension that the desired Dropped call audio file is located at on your server. + + + +



+ +VICIDIAL_REMOTE_AGENTS TABLE

+
+
+User ID Start - This is the starting User ID that is used when the remote agent entries are inserted into the system. If the Number of Lines is set higher than 1, this number is incremented by one until each line has an entry. Make sure you create a new VICIDIAL user account with a user level of 4 or great if you want them to be able to use the vdremote.php page for remote web access of this account. + +
+
+
+Number of Lines - This defines how many remote agent entries the system creates, and determines how many lines it thinks it can safely send to the number below. + +
+
+
+Server IP - A remote agent entry is only good for one specific server, here is where you select which server you want. + +
+
+
+External Extension - This is the number that you want the calls forwarded to. Make sure that it is a full dialplan number and that if you need a 9 at the beginning you put it in here. Test by dialing this number from a phone on the system. + +
+
+
+Status - Here is where you turn the remote agent on and off. As soon as the agent is Active the system assumes that it can send calls to it. It may take up to 30 seconds once you change the status to Inactive to stop receiving calls. + +
+
+
+Campaign - Here is where you select the campaign that these remote agents will be logged into. Inbound needs to use the CLOSER campaign and select the inbound campaigns below that you want to receive calls from. + +
+
+
+Inbound Groups - Here is where you select the inbound groups you want to receive calls from if you have selected the CLOSER campaign. + + +



+ +VICIDIAL_CAMPAIGN_LISTS

+
+
+The lists within this campaign are listed here, whether they are active is denoted by the Y or N and you can go to the list screen by clicking on the list ID in the first column. + + +



+ +VICIDIAL_CAMPAIGN_STATUSES TABLE

+
+
+Through the use of custom campaign statuses, you can have statuses that only exist for a specific campaign. The Status must be 1-8 characters in length, the description must be 2-30 characters in length and Selectable defines whether it shows up in VICIDIAL as a disposition. + + + +



+ +VICIDIAL_CAMPAIGN_HOTKEYS TABLE

+
+
+Through the use of custom campaign hotkeys, agents that use the vicidial web-client can hangup and disposition calls just by pressing a single key on their keyboard. + + + + +



+ +VICIDIAL_LEAD_RECYCLE TABLE

+
+
+Through the use of lead recycling, you can call specific statuses of leads again at a specified interval without resetting the entire list. Lead recycling is campaign-specific and does not have to be a selected dialable status in your campaign. The attempt delay field is the number of seconds until the lead can be placed back in the hopper, this number must be at least 120 seconds. The attempt maximum field is the maximum number of times that a lead of this status can be attempted before the list needs to be reset, this number can be from 1 to 10. You can activate and deactivate a lead recycle entry with the provided links. This feature only works in auto-dial mode, where dial level is greater than 0. + + + + + +



+ +VICIDIAL_USER_GROUPS TABLE

+
+
+User Group - This is the short name of a Vicidial User group, try not to use any spaces or punctuation for this field. max 20 characters, minimum of 2 characters. + +
+
+
+Group Name - This is the description of the vicidial user group max of 40 characters. + + + + + +



+ +VICIDIAL_SCRIPTS TABLE

+
+
+Script ID - This is the short name of a Vicidial Script. This needs to be a unique identifier. Try not to use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Script Name - This is the title of a Vicidial Script. This is a short summary of the script. max 50 characters, minimum of 2 characters. There should be no spaces or punctuation of any kind in theis field. + +
+
+Script Comments - This is where you can place comments for a Vicidial Script such as -changed to free upgrade on Sept 23-. max 255 characters, minimum of 2 characters. + +
+
+Script Text - This is where you place the content of a Vicidial Script. Minimum of 2 characters. You can have customer information be auto-populated in this script using "--A--field--B--" where field is one of the following fieldnames: vendor_lead_code, source_id, list_id, gmt_offset_now, called_since_last_reset, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments. For example, this sentence would print the persons name in it----

Hello, can I speak with --A--first_name--B-- --A--last_name--B-- please? Well hello --A--title--B-- --A--last_name--B-- how are you today?

This would read----

Hello, can I speak with John Doe please? Well hello Mr. Doe how are you today? + +
+
+
+Active - This determines whether this script can be selected to be used by a campaign. + + + + + +



+ +VICIDIAL_LEAD_FILTERS TABLE

+
+
+Filter ID - This is the short name of a Vicidial Lead Filter. This needs to be a unique identifier. Do not use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Filter Name - This is a more descriptive name of the Filter. This is a short summary of the filter. max 30 characters, minimum of 2 characters. + +
+
+Filter Comments - This is where you can place comments for a Vicidial Filter such as -calls all California leads-. max 255 characters, minimum of 2 characters. + +
+
+Filter SQL - This is where you place the SQL query fragment that you want to filter by. do not begin or end with an AND, that will be added by the hopper cron script automatically. an example SQL query that would work here is- called_count > 4 and called_count < 8 -. + + + + + +



+ +VICIDIAL_CALL TIMES TABLE

+
+
+Call Time ID - This is the short name of a Vicidial Call Time Definition. This needs to be a unique identifier. Do not use any spaces or punctuation for this field. max 10 characters, minimum of 2 characters. + +
+
+Call Time Name - This is a more descriptive name of the Call Time Definition. This is a short summary of the Call Time definition. max 30 characters, minimum of 2 characters. + +
+
+Call Time Comments - This is where you can place comments for a Vicidial Call Time Definition such as -10am to 4pm with extra call state restrictions-. max 255 characters. + +
+
+Default Start and Stop Times - This is the default time that calling will be allowed to be started or stopped within this call time definition if the day-of-the-week start time is not defined. 0 is midnight. To prevent calling completely set this field to 2400 and set the Default Stop time to 2400. To allow calling 24 hours a day set the start time to 0 and the stop time to 2400. + +
+
+Weekday Start and Stop Times - These are the custom times per day that can be set for the call time definition. same rules apply as with the Default start and stop times. + +
+
+State Call Time Definitions - This is the list of State specific call time definitions that are followed in this Call Time Definition. + +
+
+State Call Time State - This is the two letter code for the state that this calling time definition is for. For this to be in effect the local call time that is set in the campaign must have this state call time record in it as well as all of the leads having two letter state codes in them. + + + + +



+ +VICIDIAL LIST LOADER FUNCTIONALITY

+
+
+The VICIDIAL basic web-based lead loader is designed simply to take a lead file - up to 8MB in size - that is either tab or pipe delimited and load it into the vicidial_list table. There is also a new beta version super lead loader that allows for field choosing and TXT- Plain Text, CSV- Comma Separated Values and XLS- Excel file formats. The lead loader does not do data validation or check for duplicates in itself or other lists, so that is something you need to do before you load the leads. Also, make sure that you have created the list that these leads are to be under so that you can use them. There is also the matter of time-zone-coding these leads. You may want to increase the frequency that the ADMIN_adjust_GMTnow_on_leads.pl is being run in the cron on your Asterisk server so that any loaded leads can be coded faster. Here is a list of the fields in their proper order for the lead files: +
    +
  1. Vendor Lead Code - shows up in the Vendor ID field of the GUI +
  2. Source Code - internal use only for admins and DBAs +
  3. List ID - the list number that these leads will show up under +
  4. Phone Code - the prefix for the phone number - 1 for US, 01144 for UK, 01161 for AUS, etc +
  5. Phone Number - must be at least 8 digits long +
  6. Title - title of the customer - Mr. Ms. Mrs, etc... +
  7. First Name +
  8. Middle Initial +
  9. Last Name +
  10. Address Line 1 +
  11. Address Line 2 +
  12. Address Line 3 +
  13. City +
  14. State - limited to 2 characters +
  15. Province +
  16. Postal Code +
  17. Country +
  18. Gender +
  19. Date of Birth +
  20. Alternate Phone Number +
  21. Email Address +
  22. Security Phrase +
  23. Comments +
+ +
NOTES: The Excel Lead loader functionality is enabled by a series of perl scripts and needs to have a properly configured /home/cron/AST_SERVER_conf.pl file in place on the web server. Also, a couple perl modules must be loaded for it to work as well - OLE-Storage_Lite and Spreadsheet-ParseExcel. You can check for runtime errors in these by looking at your apache error_log file. + +







+







+THE END +
+\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$dial_status_a = $row[3]; +$dial_status_b = $row[4]; +$dial_status_c = $row[5]; +$dial_status_d = $row[6]; +$dial_status_e = $row[7]; +$local_call_time = $row[16]; +if ($lead_filter_id=='') + { + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') + { + $lead_filter_id='NONE'; + } + } + +$stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; +$rslt=mysql_query($stmt, $link); +$lists_to_print = mysql_num_rows($rslt); +$camp_lists=''; +$o=0; +while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; +if (ereg("Y", $rowx[1])) {$camp_lists .= "'$rowx[0]',";} +} +$camp_lists = eregi_replace(".$","",$camp_lists); + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + +echo "

\n"; +echo "Show Dialable Leads Count -

\n"; +echo "CAMPAIGN: $campaign_id
\n"; +echo "LISTS: $camp_lists
\n"; +echo "STATUSES: $dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e
\n"; +echo "FILTER: $lead_filter_id
\n"; +echo "CALL TIME: $local_call_time

\n"; + +### call function to calculate and print dialable leads +dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + +echo "

\n"; +echo "\n"; + +exit; +} + + +###################### +# ADD=7111111 view sample script with test variables +###################### + +if ($ADD==7111111) +{ + ##### TEST VARIABLES ##### + $vendor_lead_code = 'VENDORLEADCODE'; + $list_id = 'LISTID'; + $gmt_offset_now = 'GMTOFFSET'; + $phone_code = '1'; + $phone_number = '7275551212'; + $title = 'Mr.'; + $first_name = 'JOHN'; + $middle_initial = 'Q'; + $last_name = 'PUBLIC'; + $address1 = '1234 Main St.'; + $address2 = 'Apt. 3'; + $address3 = 'ADDRESS3'; + $city = 'CHICAGO'; + $state = 'IL'; + $province = 'PROVINCE'; + $postal_code = '33760'; + $country_code = 'USA'; + $gender = 'M'; + $date_of_birth = '1970-01-01'; + $alt_phone = '3125551212'; + $email = 'test@test.com'; + $security_phrase = 'SECUTIRY'; + $comments = 'COMMENTS FIELD'; + $RGfullname = 'JOE AGENT'; + $RGuser = '6666'; + +echo "\n"; +echo "\n"; +echo "\n"; +echo ""; + +$stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$script_name = $row[1]; +$script_text = $row[3]; + +$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text); +$script_text = eregi_replace('--A--list_id--B--',"$list_id",$script_text); +$script_text = eregi_replace('--A--gmt_offset_now--B--',"$gmt_offset_now",$script_text); +$script_text = eregi_replace('--A--phone_code--B--',"$phone_code",$script_text); +$script_text = eregi_replace('--A--phone_number--B--',"$phone_number",$script_text); +$script_text = eregi_replace('--A--title--B--',"$title",$script_text); +$script_text = eregi_replace('--A--first_name--B--',"$first_name",$script_text); +$script_text = eregi_replace('--A--middle_initial--B--',"$middle_initial",$script_text); +$script_text = eregi_replace('--A--last_name--B--',"$last_name",$script_text); +$script_text = eregi_replace('--A--address1--B--',"$address1",$script_text); +$script_text = eregi_replace('--A--address2--B--',"$address2",$script_text); +$script_text = eregi_replace('--A--address3--B--',"$address3",$script_text); +$script_text = eregi_replace('--A--city--B--',"$city",$script_text); +$script_text = eregi_replace('--A--state--B--',"$state",$script_text); +$script_text = eregi_replace('--A--province--B--',"$province",$script_text); +$script_text = eregi_replace('--A--postal_code--B--',"$postal_code",$script_text); +$script_text = eregi_replace('--A--country_code--B--',"$country_code",$script_text); +$script_text = eregi_replace('--A--gender--B--',"$gender",$script_text); +$script_text = eregi_replace('--A--date_of_birth--B--',"$date_of_birth",$script_text); +$script_text = eregi_replace('--A--alt_phone--B--',"$alt_phone",$script_text); +$script_text = eregi_replace('--A--email--B--',"$email",$script_text); +$script_text = eregi_replace('--A--security_phrase--B--',"$security_phrase",$script_text); +$script_text = eregi_replace('--A--comments--B--',"$comments",$script_text); +$script_text = eregi_replace('--A--fullname--B--',"$RGfullname",$script_text); +$script_text = eregi_replace('--A--user--B--',"$RGuser",$script_text); +$script_text = eregi_replace("\n","
",$script_text); + + +echo ""; + +echo "Preview Script: $script_id
\n"; +echo "
\n"; +echo "
$script_name
\n"; +echo "$script_text\n"; +echo "
\n"; + +echo "\n"; + +exit; +} + + + + +######################### HTML HEADER BEGIN ####################################### +if ($hh=='users') {$users_hh='bgcolor ="#FFFF99"'; $users_fc='BLACK';} # yellow + else {$users_hh=''; $users_fc='WHITE';} +if ($hh=='campaigns') {$campaigns_hh='bgcolor ="#FFCC99"'; $campaigns_fc='BLACK';} # orange + else {$campaigns_hh=''; $campaigns_fc='WHITE';} +if ($hh=='lists') {$lists_hh='bgcolor ="#FFCCCC"'; $lists_fc='BLACK';} # red + else {$lists_hh=''; $lists_fc='WHITE';} +if ($hh=='ingroups') {$ingroups_hh='bgcolor ="#CC99FF"'; $ingroups_fc='BLACK';} # purple + else {$ingroups_hh=''; $ingroups_fc='WHITE';} +if ($hh=='remoteagent') {$remoteagent_hh='bgcolor ="#CCFFCC"'; $remoteagent_fc='BLACK';} # green + else {$remoteagent_hh=''; $remoteagent_fc='WHITE';} +if ($hh=='usergroups') {$usergroups_hh='bgcolor ="#CCFFFF"'; $usergroups_fc='BLACK';} # cyan + else {$usergroups_hh=''; $usergroups_fc='WHITE';} +if ($hh=='scripts') {$scripts_hh='bgcolor ="#99FFCC"'; $scripts_fc='BLACK';} # light teal + else {$scripts_hh=''; $scripts_fc='WHITE';} +if ($hh=='filters') {$filters_hh='bgcolor ="#CCCCCC"'; $filters_fc='BLACK';} # grey + else {$filters_hh=''; $filters_fc='WHITE';} +if ($hh=='times') {$times_hh='bgcolor ="#99FF33"'; $times_fc='BLACK';} # hard teal + else {$times_hh=''; $times_fc='WHITE';} + +?> + + + + +\n"; +?> +
+ + + + + + + + + + + + + + + + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + 1) { + ?> + + + + + +
  VICIDIAL ADMIN - Logout  
> SIZE=1> USERS > SIZE=1> CAMPAIGNS > SIZE=1> LISTS > SIZE=1> SCRIPTS > SIZE=1> FILTERS > SIZE=1> IN-GROUPS > SIZE=1> CALL TIMES > SIZE=1> USER GROUPS > SIZE=1> REMOTE AGENTS > REPORTS
  LIST USERS     |     ADD A NEW USER     |     SEARCH FOR A USER
  ADD CAMPAIGN     |     LIST CAMPAIGNS
  SHOW LISTS     |     ADD NEW LIST     |     SEARCH FOR A LEAD |     ADD NUMBER TO DNC           |     LOAD NEW LEADS
  ADD SCRIPT     |     VIEW SCRIPTS
  ADD FILTER     |     VIEW FILTERS
  SHOW IN-GROUPS     |     ADD NEW IN-GROUP
  SHOW CALL TIMES     |     ADD NEW CALL TIME     |     SHOW STATE CALL TIMES     |     ADD NEW STATE CALL TIME  
  ADD USER GROUP     |     LIST USER GROUPS     |     GROUP HOURLY
  SHOW REMOTE AGENTS     |     ADD NEW REMOTE AGENTS
 
+
\n"; +echo ""; + +echo "
ADD A NEW USER
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "$NWB#vicidial_users-user_group$NWE\n"; +echo "\n"; +echo "
User Number: $NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group:
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW CAMPAIGN FORM SCREEN +###################### + +if ($ADD==11) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW CAMPAIGN\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Campaign ID: $NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $NWB#vicidial_campaigns-park_ext$NWE
Park Filename: $NWB#vicidial_campaigns-park_file_name$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW LIST FORM SCREEN +###################### + +if ($ADD==111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: (digits only)$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
\n"; + +} + + +###################### +# ADD=121 display the ADD NUMBER TO DNC FORM SCREEN and add a new number +###################### + +if ($ADD==121) +{ +echo "
\n"; +echo ""; + +if (strlen($phone_number) > 2) + { + $stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
DNC NOT ADDED - This phone number is already in the Do Not Call List: $phone_number

\n";} + else + { + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');"; + $rslt=mysql_query($stmt, $link); + + echo "
DNC ADDED: $phone_number

\n"; + + ### LOG INSERTION TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW DNC NUMBER|$PHP_AUTH_USER|$ip|'$phone_number'|\n"); + fclose($fp); + } + } + } + +echo "
ADD A NUMBER TO THE DNC LIST\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
Phone Number: (digits only)$NWB#vicidial_list-dnc$NWE
\n"; + +} + + +###################### +# ADD=1111 display the ADD NEW INBOUND GROUP SCREEN +###################### + +if ($ADD==1111) +{ +echo "
\n"; +echo ""; + +echo "
ADD A NEW INBOUND GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group ID: (no spaces)$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
\n"; + +} + + +###################### +# ADD=11111 display the ADD NEW REMOTE AGENTS SCREEN +###################### + +if ($ADD==11111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW REMOTE AGENTS\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + +###################### +# ADD=111111 display the ADD NEW USERS GROUP SCREEN +###################### + +if ($ADD==111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW USERS GROUP\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +} + + +###################### +# ADD=1111111 display the ADD NEW SCRIPT SCREEN +###################### + +if ($ADD==1111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW SCRIPT\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Script ID: (no spaces or punctuation)$NWB#vicidial_scripts-script_id$NWE
Script Name: (title of the script)$NWB#vicidial_scripts-script_name$NWE
Script Comments: $NWB#vicidial_scripts-script_comments$NWE
Active: $NWB#vicidial_scripts-active$NWE
Script Text: $NWB#vicidial_scripts-script_text$NWE
\n"; + +} + + +###################### +# ADD=11111111 display the ADD NEW FILTER SCREEN +###################### + +if ($ADD==11111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW FILTER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Filter ID: (no spaces or punctuation)$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter Name: (short description of the filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter Comments: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; +} + + +###################### +# ADD=111111111 display the ADD NEW CALL TIME SCREEN +###################### + +if ($ADD==111111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW CALL TIME\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
Call Time ID: (no spaces or punctuation)$NWB#vicidial_call_times-call_time_id$NWE
Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Day and time options will appear once you have created the Call Time Definition
\n"; +} + + +###################### +# ADD=1111111111 display the ADD NEW STATE CALL TIME SCREEN +###################### + +if ($ADD==1111111111) +{ +echo "
\n"; +echo ""; + +echo "
ADD NEW STATE CALL TIME\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "
State Call Time ID: (no spaces or punctuation)$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: (no spaces or punctuation)$NWB#vicidial_call_times-state_call_time_state$NWE
State Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
State Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Day and time options will appear once you have created the Call Time Definition
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 2 series, validates form data and inserts the new record into the database +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=2 adds the new user to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER NOT ADDED - there is already a user in the system with this user number\n";} + else + { + if ( (strlen($user) < 2) or (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user) > 8) ) + { + echo "
USER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
user id must be between 2 and 8 characters long\n"; + echo "
full name and password must be at least 2 characters long\n"; + } + else + { + echo "
USER ADDED: $user\n"; + + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass) values('$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A USER |$PHP_AUTH_USER|$ip|'$user','$pass','$full_name','$user_level','$user_group','$phone_login','$phone_pass'|\n"); + fclose($fp); + } + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new campaign to the system +###################### + +if ($ADD==21) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN NOT ADDED - there is already a campaign in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($campaign_id) > 8) or (strlen($campaign_name) < 6) or (strlen($campaign_name) > 40) ) + { + echo "
CAMPAIGN NOT ADDED - Please go back and look at the data you entered\n"; + echo "
campaign ID must be between 2 and 8 characters in length\n"; + echo "
campaign name must be between 6 and 40 characters in length\n"; + } + else + { + echo "
CAMPAIGN ADDED: $campaign_id\n"; + + $stmt="INSERT INTO vicidial_campaigns (campaign_id,campaign_name,active,dial_status_a,lead_order,park_ext,park_file_name,web_form_address,allow_closers,hopper_level,auto_dial_level,next_agent_call,local_call_time,voicemail_ext,campaign_script,get_call_launch) values('$campaign_id','$campaign_name','$active','NEW','DOWN','$park_ext','$park_file_name','" . mysql_real_escape_string($web_form_address) . "','$allow_closers','$hopper_level','$auto_dial_level','$next_agent_call','$local_call_time','$voicemail_ext','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_campaign_stats (campaign_id) values('$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + echo ""; + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + + } + } +$ADD=31; +} + +###################### +# ADD=22 adds the new campaign status to the system +###################### + +if ($ADD==22) +{ + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name\n";} + else + { + $stmt="SELECT count(*) from vicidial_statuses where status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) ) + { + echo "
CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 8 characters in length\n"; + echo "
status name must be between 2 and 30 characters in length\n"; + } + else + { + echo "
CAMPAIGN STATUS ADDED: $campaign_id - $status\n"; + + $stmt="INSERT INTO vicidial_campaign_statuses values('$status','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN STATUS |$PHP_AUTH_USER|$ip|'$status','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } + } +$ADD=31; +} + + +###################### +# ADD=23 adds the new campaign hotkey to the system +###################### + +if ($ADD==23) +{ + $HKstatus_data = explode('-----',$HKstatus); + $status = $HKstatus_data[0]; + $status_name = $HKstatus_data[1]; + + echo ""; + $stmt="SELECT count(*) from vicidial_campaign_hotkeys where campaign_id='$campaign_id' and hotkey='$hotkey' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN HOTKEY NOT ADDED - there is already a campaign-hotkey in the system with this hotkey\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAIGN HOTKEY NOT ADDED - Please go back and look at the data you entered\n"; + echo "
hotkey must be a single character between 1 and 9 \n"; + echo "
status must be between 1 and 8 characters in length\n"; + } + else + { + echo "
CAMPAIGN HOTKEY ADDED: $campaign_id - $status - $hotkey\n"; + + $stmt="INSERT INTO vicidial_campaign_hotkeys values('$status','$hotkey','$status_name','$selectable','$campaign_id');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CAMPAIGN HOTKEY |$PHP_AUTH_USER|$ip|'$status','$hotkey','$status_name','$selectable','$campaign_id'|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=25 adds the new campaign lead recycle entry to the system +###################### + +if ($ADD==25) +{ + $status = eregi_replace("-----.*",'',$status); + echo ""; + $stmt="SELECT count(*) from vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - there is already a lead-recycle for this campaign with this status\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT ADDED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD RECYCLE ADDED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="INSERT INTO vicidial_lead_recycle(campaign_id,status,attempt_delay,attempt_maximum,active) values('$campaign_id','$status','$attempt_delay','$attempt_maximum','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new list to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
LIST NOT ADDED - there is already a list in the system with this ID\n";} + else + { + if ( (strlen($campaign_id) < 2) or (strlen($list_name) < 2) or (strlen($list_id) < 2) or (strlen($list_id) > 8) ) + { + echo "
LIST NOT ADDED - Please go back and look at the data you entered\n"; + echo "
List ID must be between 2 and 8 characters in length\n"; + echo "
List name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST ADDED: $list_id\n"; + + $stmt="INSERT INTO vicidial_lists values('$list_id','$list_name','$campaign_id','$active');"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW LIST |$PHP_AUTH_USER|$ip|'$list_id','$list_name','$campaign_id','$active'|\n"); + fclose($fp); + } + } + } +$ADD=311; +} + + + +###################### +# ADD=2111 adds the new inbound group to the system +###################### + +if ($ADD==2111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
GROUP NOT ADDED - there is already a group in the system with this ID\n";} + else + { + if ( (strlen($group_id) < 2) or (strlen($group_name) < 2) or (strlen($group_color) < 2) or (strlen($group_id) > 20) or (eregi(' ',$group_id)) or (eregi("\-",$group_id)) or (eregi("\+",$group_id)) ) + { + echo "
GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group ID must be between 2 and 20 characters in length and contain no ' -+'.\n"; + echo "
Group name and group color must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_inbound_groups (group_id,group_name,group_color,active,web_form_address,voicemail_ext,next_agent_call,fronter_display,ingroup_script,get_call_launch) values('$group_id','$group_name','$group_color','$active','" . mysql_real_escape_string($web_form_address) . "','$voicemail_ext','$next_agent_call','$fronter_display','$script_id','$get_call_launch');"; + $rslt=mysql_query($stmt, $link); + + echo "
GROUP ADDED: $group_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW GROUP |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000; +} + + +###################### +# ADD=21111 adds new remote agents to the system +###################### + +if ($ADD==21111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_remote_agents where server_ip='$server_ip' and user_start='$user_start';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
REMOTE AGENTS NOT ADDED - there is already a remote agents entry starting with this userID\n";} + else + { + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT ADDED - Please go back and look at the data you entered\n"; + echo "
User ID start and external extension must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_remote_agents values('','$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value');"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|'$user_start','$number_of_lines','$server_ip','$conf_exten','$status','$campaign_id','$groups_value'|\n"); + fclose($fp); + } + } + } +$ADD=10000; +} + +###################### +# ADD=211111 adds new user group to the system +###################### + +if ($ADD==211111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
USER GROUP NOT ADDED - there is already a user group entry with this name\n";} + else + { + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_user_groups values('$user_group','$group_name');"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP ADDED: $user_start\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW USER GROUP ENTRY |$PHP_AUTH_USER|$ip|'$user_group','$group_name'|\n"); + fclose($fp); + } + } + } +$ADD=100000; +} + +###################### +# ADD=2111111 adds new script to the system +###################### + +if ($ADD==2111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SCRIPT NOT ADDED - there is already a script entry with this name\n";} + else + { + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Script name, description and text must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_scripts values('$script_id','$script_name','$script_comments','" . mysql_real_escape_string($script_text) . "','$active');"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT ADDED: $script_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=1000000; +} + + +###################### +# ADD=21111111 adds new filter to the system +###################### + +if ($ADD==21111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
FILTER NOT ADDED - there is already a filter entry with this ID\n";} + else + { + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Filter ID, name and SQL must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_lead_filters SET lead_filter_id='$lead_filter_id',lead_filter_name='$lead_filter_name',lead_filter_comments='$lead_filter_comments',lead_filter_sql='$lead_filter_sql';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER ADDED: $lead_filter_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=10000000; +} + + +###################### +# ADD=211111111 adds new call time definition to the system +###################### + +if ($ADD==211111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered\n"; + echo "
Call Time ID and name must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_call_times SET call_time_id='$call_time_id',call_time_name='$call_time_name',call_time_comments='$call_time_comments';"; + $rslt=mysql_query($stmt, $link); + + echo "
CALL TIME ADDED: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + } +$ADD=311111111; +} + + +###################### +# ADD=2111111111 adds new state call time definition to the system +###################### + +if ($ADD==2111111111) +{ + echo ""; + $stmt="SELECT count(*) from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
STATE CALL TIME DEFINITION NOT ADDED - there is already a call time entry with this ID\n";} + else + { + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
STATE CALL TIME DEFINITION NOT ADDED - Please go back and look at the data you entered\n"; + echo "
State Call Time ID, name and state must be at least 2 characters in length\n"; + } + else + { + $stmt="INSERT INTO vicidial_state_call_times SET state_call_time_id='$call_time_id',state_call_time_name='$call_time_name',state_call_time_comments='$call_time_comments',state_call_time_state='$state_call_time_state';"; + $rslt=mysql_query($stmt, $link); + + echo "
STATE CALL TIME ADDED: $call_time_id\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|ADD A NEW STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + } +$ADD=3111111111; +} + + + + +###################################################################################################### +###################################################################################################### +####### 4 series, record modifications submitted and DB is modified, then on to 3 series forms below +###################################################################################################### +###################################################################################################### + + + +###################### +# ADD=4A submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4A") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + +###################### +# ADD=4B submit user modifications to the system - ADMIN +###################### + +if ($ADD=="4B") +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED - ADMIN: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + + + +###################### +# ADD=4 submit user modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + if ( (strlen($pass) < 2) or (strlen($full_name) < 2) or (strlen($user_level) < 1) ) + { + echo "
USER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Password and Full Name each need ot be at least 2 characters in length\n"; + } + else + { + echo "
USER MODIFIED: $user\n"; + + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER INFO |$PHP_AUTH_USER|$ip|pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass' where user='$user'|\n"); + fclose($fp); + } + } + +$ADD=3; # go to user modification below +} + +###################### +# ADD=41 submit campaign modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level', next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=42 delete campaign status in the system +###################### + +if ($ADD==42) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN STATUS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN STATUS DELETED: $campaign_id - $status\n"; + + $stmt="DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=43 delete campaign hotkey in the system +###################### + +if ($ADD==43) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($hotkey) < 1) ) + { + echo "
CAMPAIGN HOTKEY NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign id needs to be at least 2 characters in length\n"; + echo "
the campaign status needs to be at least 1 characters in length\n"; + echo "
the campaign hotkey needs to be at least 1 characters in length\n"; + } + else + { + echo "
CUSTOM CAMPAIGN HOTKEY DELETED: $campaign_id - $status - $hotkey\n"; + + $stmt="DELETE FROM vicidial_campaign_hotkeys where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE CAMPAIGN STATUS|$PHP_AUTH_USER|$ip|DELETE FROM vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status' and hotkey='$hotkey'|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=44 submit campaign modifications to the system - Basic View +###################### + +if ($ADD==44) +{ + echo ""; + + if ( (strlen($campaign_name) < 6) or (strlen($active) < 1) ) + { + echo "
CAMPAIGN NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
the campaign name needs to be at least 6 characters in length\n"; + } + else + { + echo "
CAMPAIGN MODIFIED: $campaign_id\n"; + + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',hopper_level='$hopper_level', auto_dial_level='$auto_dial_level',lead_filter_id='$lead_filter_id' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmtA, $link); + + if ($reset_hopper == 'Y') + { + echo "
RESETTING CAMPAIGN LEAD HOPPER\n"; + echo "
- Wait 1 minute before dialing next number\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and status='READY';"; + $rslt=mysql_query($stmt, $link); + + ### LOG HOPPER RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|CAMPAIGN HOPPERRESET|$PHP_AUTH_USER|$ip|campaign_name='$campaign_name'|\n"); + fclose($fp); + } + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CAMPAIGN INFO|$PHP_AUTH_USER|$ip|$stmtA|$reset_hopper|\n"); + fclose($fp); + } + } + +$ADD=34; # go to campaign modification form below +} + +###################### +# ADD=45 modify campaign lead recycle in the system +###################### + +if ($ADD==45) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or ($attempt_delay < 120) or ($attempt_maximum < 1) or ($attempt_maximum > 10) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD MODIFIED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="UPDATE vicidial_lead_recycle SET attempt_delay='$attempt_delay',attempt_maximum='$attempt_maximum',active='$active' where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=411 submit list modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + if ( (strlen($list_name) < 2) or (strlen($campaign_id) < 2) ) + { + echo "
LIST NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
list name must be at least 2 characters in length\n"; + } + else + { + echo "
LIST MODIFIED: $list_id\n"; + + $stmt="UPDATE vicidial_lists set list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + if ($reset_list == 'Y') + { + echo "
RESETTING LIST-CALLED-STATUS\n"; + $stmt="UPDATE vicidial_list set called_since_last_reset='N' where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + ### LOG RESET TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|RESET LIST CALLED |$PHP_AUTH_USER|$ip|list_name='$list_name'|\n"); + fclose($fp); + } + } + if ($campaign_id != "$old_campaign_id") + { + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($old_campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id' and campaign_id='$old_campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY LIST INFO |$PHP_AUTH_USER|$ip|list_name='$list_name',campaign_id='$campaign_id',active='$active' where list_id='$list_id'|\n"); + fclose($fp); + } + } + +$ADD=311; # go to list modification form below +} + + +###################### +# ADD=4111 modify in-group info in the system +###################### + +if ($ADD==4111) +{ + echo ""; + + if ( (strlen($group_name) < 2) or (strlen($group_color) < 2) ) + { + echo "
GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
group name and group color must be at least 2 characters in length\n"; + } + else + { + echo "
GROUP MODIFIED: $group_id\n"; + + $stmt="UPDATE vicidial_inbound_groups set group_name='$group_name', group_color='$group_color', active='$active', web_form_address='" . mysql_real_escape_string($web_form_address) . "', voicemail_ext='$voicemail_ext', next_agent_call='$next_agent_call', fronter_display='$fronter_display', ingroup_script='$script_id', get_call_launch='$get_call_launch', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',drop_message='$drop_message',drop_call_seconds='$drop_call_seconds',drop_exten='$drop_exten' where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY GROUP INFO |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111; # go to in-group modification form below +} + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($server_ip) < 2) or (strlen($user_start) < 2) or (strlen($campaign_id) < 2) or (strlen($conf_exten) < 2) ) + { + echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
User ID Start and External Extension must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_remote_agents set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|set user_start='$user_start', number_of_lines='$number_of_lines', server_ip='$server_ip', conf_exten='$conf_exten', status='$status', campaign_id='$campaign_id', closer_campaigns='$groups_value' where remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + } + +$ADD=31111; # go to remote agents modification form below +} + + + +###################### +# ADD=411111 modify user group info in the system +###################### + +if ($ADD==411111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or (strlen($group_name) < 2) ) + { + echo "
USER GROUP NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Group name and description must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group';"; + $rslt=mysql_query($stmt, $link); + + echo "
USER GROUP MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY USER GROUP ENTRY |$PHP_AUTH_USER|$ip|UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name' where user_group='$OLDuser_group'|\n"); + fclose($fp); + } + } + +$ADD=311111; # go to user group modification form below +} + +###################### +# ADD=4111111 modify script in the system +###################### + +if ($ADD==4111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or (strlen($script_name) < 2) or (strlen($script_text) < 2) ) + { + echo "
SCRIPT NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Script name, description and text must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_scripts set script_name='$script_name', script_comments='$script_comments', script_text='" . mysql_real_escape_string($script_text) . "', active='$active' where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
SCRIPT MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY SCRIPT ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111; # go to script modification form below +} + + +###################### +# ADD=41111111 modify filter in the system +###################### + +if ($ADD==41111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or (strlen($lead_filter_name) < 2) or (strlen($lead_filter_sql) < 2) ) + { + echo "
FILTER NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Filter ID, name and SQL must be at least 2 characters in length\n"; + } + else + { + $stmt="UPDATE vicidial_lead_filters set lead_filter_name='$lead_filter_name', lead_filter_comments='$lead_filter_comments', lead_filter_sql='$lead_filter_sql' where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
FILTER MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY FILTER ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31111111; # go to filter modification form below +} + + +###################### +# ADD=411111111 modify call time in the system +###################### + +if ($ADD==411111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) ) + { + echo "
CALL TIME NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
Call Time ID and name must be at least 2 characters in length\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_call_times set call_time_name='$call_time_name', call_time_comments='$call_time_comments', ct_default_start='$ct_default_start', ct_default_stop='$ct_default_stop', ct_sunday_start='$ct_sunday_start', ct_sunday_stop='$ct_sunday_stop', ct_monday_start='$ct_monday_start', ct_monday_stop='$ct_monday_stop', ct_tuesday_start='$ct_tuesday_start', ct_tuesday_stop='$ct_tuesday_stop', ct_wednesday_start='$ct_wednesday_start', ct_wednesday_stop='$ct_wednesday_stop', ct_thursday_start='$ct_thursday_start', ct_thursday_stop='$ct_thursday_stop', ct_friday_start='$ct_friday_start', ct_friday_stop='$ct_friday_stop', ct_saturday_start='$ct_saturday_start', ct_saturday_stop='$ct_saturday_stop' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
CALL TIME MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY CALL TIME ENTRY |$stmt|\n"); + fclose($fp); + } + } + +$ADD=311111111; # go to call time modification form below +} + + +###################### +# ADD=4111111111 modify state call time in the system +###################### + +if ($ADD==4111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or (strlen($call_time_name) < 2) or (strlen($state_call_time_state) < 2) ) + { + echo "
STATE CALL TIME NOT MODIFIED - Please go back and look at the data you entered\n"; + echo "
State Call Time ID, name and state must be at least 2 characters in length\n"; + } + else + { + $ct_default_start = preg_replace('/\D/', '', $ct_default_start); + $ct_default_stop = preg_replace('/\D/', '', $ct_default_stop); + $ct_sunday_start = preg_replace('/\D/', '', $ct_sunday_start); + $ct_sunday_stop = preg_replace('/\D/', '', $ct_sunday_stop); + $ct_monday_start = preg_replace('/\D/', '', $ct_monday_start); + $ct_monday_stop = preg_replace('/\D/', '', $ct_monday_stop); + $ct_tuesday_start = preg_replace('/\D/', '', $ct_tuesday_start); + $ct_tuesday_stop = preg_replace('/\D/', '', $ct_tuesday_stop); + $ct_wednesday_start = preg_replace('/\D/', '', $ct_wednesday_start); + $ct_wednesday_stop = preg_replace('/\D/', '', $ct_wednesday_stop); + $ct_thursday_start = preg_replace('/\D/', '', $ct_thursday_start); + $ct_thursday_stop = preg_replace('/\D/', '', $ct_thursday_stop); + $ct_friday_start = preg_replace('/\D/', '', $ct_friday_start); + $ct_friday_stop = preg_replace('/\D/', '', $ct_friday_stop); + $ct_saturday_start = preg_replace('/\D/', '', $ct_saturday_start); + $ct_saturday_stop = preg_replace('/\D/', '', $ct_saturday_stop); + $stmt="UPDATE vicidial_state_call_times set state_call_time_name='$call_time_name', state_call_time_comments='$call_time_comments', sct_default_start='$ct_default_start', sct_default_stop='$ct_default_stop', sct_sunday_start='$ct_sunday_start', sct_sunday_stop='$ct_sunday_stop', sct_monday_start='$ct_monday_start', sct_monday_stop='$ct_monday_stop', sct_tuesday_start='$ct_tuesday_start', sct_tuesday_stop='$ct_tuesday_stop', sct_wednesday_start='$ct_wednesday_start', sct_wednesday_stop='$ct_wednesday_stop', sct_thursday_start='$ct_thursday_start', sct_thursday_stop='$ct_thursday_stop', sct_friday_start='$ct_friday_start', sct_friday_stop='$ct_friday_stop', sct_saturday_start='$ct_saturday_start', sct_saturday_stop='$ct_saturday_stop', state_call_time_state='$state_call_time_state' where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
STATE CALL TIME MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY STATE CALL TIME ENTRY|$stmt|\n"); + fclose($fp); + } + } + +$ADD=3111111111; # go to state call time modification form below +} + + + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of user +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($user) < 2) or ($LOGdelete_users < 1) ) + { + echo "
USER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + echo "
USER DELETION CONFIRMATION: $user\n"; + echo "

Click here to delete user $user


\n"; + } + +$ADD='3'; # go to user modification below +} + +###################### +# ADD=51 confirmation before deletion of campaign +###################### + +if ($ADD==51) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAIGN NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + echo "
CAMPAIGN DELETION CONFIRMATION: $campaign_id\n"; + echo "

Click here to delete campaign $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=52 confirmation before logging all agents out of campaign of campaign +###################### + +if ($ADD==52) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + echo "
AGENT LOGOUT CONFIRMATION: $campaign_id\n"; + echo "

Click here to log all agents out of $campaign_id


\n"; + } + +$ADD='31'; # go to campaign modification below +} + +###################### +# ADD=511 confirmation before deletion of list +###################### + +if ($ADD==511) +{ + echo ""; + + if ( (strlen($list_id) < 2) or ($LOGdelete_lists < 1) ) + { + echo "
LIST NOT DELETED - Please go back and look at the data you entered\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + echo "
LIST DELETION CONFIRMATION: $list_id\n"; + echo "

Click here to delete list and all of its leads $list_id


\n"; + } + +$ADD='311'; # go to campaign modification below +} + +###################### +# ADD=5111 confirmation before deletion of in-group +###################### + +if ($ADD==5111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + echo "
IN-GROUP DELETION CONFIRMATION: $group_id\n"; + echo "

Click here to delete in-group $group_id


\n"; + } + +$ADD='3111'; # go to in-group modification below +} + +###################### +# ADD=51111 confirmation before deletion of remote agent record +###################### + +if ($ADD==51111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTE AGENT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + echo "
REMOTE AGENT DELETION CONFIRMATION: $remote_agent_id\n"; + echo "

Click here to delete remote agent $remote_agent_id


\n"; + } + +$ADD='31111'; # go to remote agent modification below +} + +###################### +# ADD=511111 confirmation before deletion of user group record +###################### + +if ($ADD==511111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($LOGdelete_user_groups < 1) ) + { + echo "
USER GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + echo "
USER GROUP DELETION CONFIRMATION: $user_group\n"; + echo "

Click here to delete user group $user_group


\n"; + } + +$ADD='311111'; # go to user group modification below +} + +###################### +# ADD=5111111 confirmation before deletion of script record +###################### + +if ($ADD==5111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Script_id must be at least 2 characters in length\n"; + } + else + { + echo "
SCRIPT DELETION CONFIRMATION: $script_id\n"; + echo "

Click here to delete script $script_id


\n"; + } + +$ADD='3111111'; # go to script modification below +} + +###################### +# ADD=51111111 confirmation before deletion of filter record +###################### + +if ($ADD==51111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Filter ID must be at least 2 characters in length\n"; + } + else + { + echo "
FILTER DELETION CONFIRMATION: $lead_filter_id\n"; + echo "

Click here to delete filter $lead_filter_id


\n"; + } + +$ADD='31111111'; # go to filter modification below +} + +###################### +# ADD=511111111 confirmation before deletion of call time record +###################### + +if ($ADD==511111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + echo "
CALL TIME DELETION CONFIRMATION: $call_time_id\n"; + echo "

Click here to delete call time $call_time_id


\n"; + } + +$ADD='311111111'; # go to call time modification below +} + +###################### +# ADD=5111111111 confirmation before deletion of call time record +###################### + +if ($ADD==5111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
STATE CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + echo "
STATE CALL TIME DELETION CONFIRMATION: $call_time_id\n"; + echo "

Click here to delete state call time $call_time_id


\n"; + } + +$ADD='3111111111'; # go to state call time modification below +} + + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete user record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( ( strlen($user) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_users < 1) ) + { + echo "
USER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_users where user='$user' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING USER!!!!|$PHP_AUTH_USER|$ip|user='$user'|\n"); + fclose($fp); + } + echo "
USER DELETION COMPLETED: $user\n"; + echo "

\n"; + } + +$ADD='0'; # go to user list +} + +###################### +# ADD=61 delete campaign record +###################### + +if ($ADD==61) +{ + echo ""; + + if ( ( strlen($campaign_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_campaigns < 1) ) + { + echo "
CAMPAIGN NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_campaigns where campaign_id='$campaign_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($campaign_id)\n"; + $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!DELETING CAMPAIGN!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
CAMPAIGN DELETION COMPLETED: $campaign_id\n"; + echo "

\n"; + } + +$ADD='10'; # go to campaigns list +} + +###################### +# ADD=62 Logout all agents fro a campaign +###################### + +if ($ADD==62) +{ + echo ""; + + if (strlen($campaign_id) < 2) + { + echo "
AGENTS NOT LOGGED OUT OF CAMPAIGN - Please go back and look at the data you entered\n"; + echo "
Campaign_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_live_agents where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!AGENT LOGOUT!!!!!!|$PHP_AUTH_USER|$ip|campaign_id='$campaign_id'|\n"); + fclose($fp); + } + echo "
AGENT LOGOUT COMPLETED: $campaign_id\n"; + echo "

\n"; + } + +$ADD='31'; # go to campaign modification below +} + + +###################### +# ADD=65 delete campaign lead recycle in the system +###################### + +if ($ADD==65) +{ + echo ""; + + if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) ) + { + echo "
CAMPAIGN LEAD RECYCLE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
status must be between 1 and 6 characters in length\n"; + echo "
attempt delay must be at least 120 seconds\n"; + echo "
maximum attempts must be from 1 to 10\n"; + } + else + { + echo "
CAMPAIGN LEAD RECYCLE DELETED: $campaign_id - $status - $attempt_delay\n"; + + $stmt="DELETE FROM vicidial_lead_recycle where campaign_id='$campaign_id' and status='$status';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|DELETE LEAD RECYCLE |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + } + } + +$ADD=31; # go to campaign modification form below +} + +###################### +# ADD=611 delete list record and all leads within it +###################### + +if ($ADD==611) +{ + echo ""; + + if ( ( strlen($list_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_lists < 1) ) + { + echo "
LIST NOT DELETED - Please go back and look at the data you entered\n"; + echo "
List_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lists where list_id='$list_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST HOPPER LEADS FROM OLD CAMPAIGN HOPPER ($list_id)\n"; + $stmt="DELETE from vicidial_hopper where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + echo "
REMOVING LIST LEADS FROM VICIDIAL_LIST TABLE\n"; + $stmt="DELETE from vicidial_list where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING LIST!!!!|$PHP_AUTH_USER|$ip|list_id='$list_id'|\n"); + fclose($fp); + } + echo "
LIST DELETION COMPLETED: $list_id\n"; + echo "

\n"; + } + +$ADD='100'; # go to lists list +} + +###################### +# ADD=6111 delete in-group record +###################### + +if ($ADD==6111) +{ + echo ""; + + if ( (strlen($group_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_ingroups < 1) ) + { + echo "
IN-GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Group_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_inbound_groups where group_id='$group_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING IN-GROUP!!|$PHP_AUTH_USER|$ip|group_id='$group_id'|\n"); + fclose($fp); + } + echo "
IN-GROUP DELETION COMPLETED: $group_id\n"; + echo "

\n"; + } + +$ADD='1000'; # go to in-group list +} + +###################### +# ADD=61111 delete remote agent record +###################### + +if ($ADD==61111) +{ + echo ""; + + if ( (strlen($remote_agent_id) < 1) or ($CoNfIrM != 'YES') or ($LOGdelete_remote_agents < 1) ) + { + echo "
REMOTE AGENT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Remote_agent_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_remote_agents where remote_agent_id='$remote_agent_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING RMTAGENT!!|$PHP_AUTH_USER|$ip|remote_agent_id='$remote_agent_id'|\n"); + fclose($fp); + } + echo "
REMOTE AGENT DELETION COMPLETED: $remote_agent_id\n"; + echo "

\n"; + } + +$ADD='10000'; # go to remote agents list +} + +###################### +# ADD=611111 delete user group record +###################### + +if ($ADD==611111) +{ + echo ""; + + if ( (strlen($user_group) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_user_groups < 1) ) + { + echo "
USER GROUP NOT DELETED - Please go back and look at the data you entered\n"; + echo "
User_group be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_user_groups where user_group='$user_group' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING USRGROUP!!|$PHP_AUTH_USER|$ip|user_group='$user_group'|\n"); + fclose($fp); + } + echo "
USER GROUP DELETION COMPLETED: $user_group\n"; + echo "

\n"; + } + +$ADD='100000'; # go to user group list +} + +###################### +# ADD=6111111 delete script record +###################### + +if ($ADD==6111111) +{ + echo ""; + + if ( (strlen($script_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_scripts < 1) ) + { + echo "
SCRIPT NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Script_id be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_scripts where script_id='$script_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING SCRIPT!!!!|$PHP_AUTH_USER|$ip|script_id='$script_id'|\n"); + fclose($fp); + } + echo "
SCRIPT DELETION COMPLETED: $script_id\n"; + echo "

\n"; + } + +$ADD='1000000'; # go to script list +} + + +###################### +# ADD=61111111 delete filter record +###################### + +if ($ADD==61111111) +{ + echo ""; + + if ( (strlen($lead_filter_id) < 2) or ($CoNfIrM != 'YES') or ($LOGdelete_filters < 1) ) + { + echo "
FILTER NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Filter ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_lead_filters where lead_filter_id='$lead_filter_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING FILTER!!!!|$PHP_AUTH_USER|$ip|lead_filter_id='$lead_filter_id'|\n"); + fclose($fp); + } + echo "
FILTER DELETION COMPLETED: $lead_filter_id\n"; + echo "

\n"; + } + +$ADD='10000000'; # go to filter list +} + + +###################### +# ADD=611111111 delete call times record +###################### + +if ($ADD==611111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_call_times where call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
CALL TIME DELETION COMPLETED: $call_time_id\n"; + echo "

\n"; + } + +$ADD='100000000'; # go to call times list +} + + +###################### +# ADD=6111111111 delete call times record +###################### + +if ($ADD==6111111111) +{ + echo ""; + + if ( (strlen($call_time_id) < 2) or ($LOGdelete_call_times < 1) ) + { + echo "
STATE CALL TIME NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Call Time ID must be at least 2 characters in length\n"; + } + else + { + $stmt="DELETE from vicidial_state_call_times where state_call_time_id='$call_time_id' limit 1;"; + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT call_time_id,ct_state_call_times from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\" order by call_time_id;"; + $rslt=mysql_query($stmt, $link); + $sct_to_print = mysql_num_rows($rslt); + $sct_list=''; + + $o=0; + while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_ids[$o] = "$rowx[0]"; + $sct_states[$o] = "$rowx[1]"; + $o++; + } + $o=0; + + while ($sct_to_print > $o) { + $sct_states[$o] = eregi_replace("\|$call_time_id\|",'|',$sct_states[$o]); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$sct_states[$o]' where call_time_id='$sct_ids[$o]';"; + $rslt=mysql_query($stmt, $link); + echo "$stmt\n"; + echo "State Rule Removed: $sct_ids[$o]
\n"; + $o++; + } + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!DELETING CALL TIME!|$PHP_AUTH_USER|$ip|state_call_time_id='$call_time_id'|\n"); + fclose($fp); + } + echo "
STATE CALL TIME DELETION COMPLETED: $call_time_id\n"; + echo "

\n"; + } + +$ADD='1000000000'; # go to call times list +} + + + + + + +###################################################################################################### +###################################################################################################### +####### 3 series, record modification forms +###################################################################################################### +###################################################################################################### + + + + +###################### +# ADD=3 modify user info in the system +###################### + +if ($ADD==3) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_level = $row[4]; + $user_group = $row[5]; + $phone_login = $row[6]; + $phone_pass = $row[7]; + $delete_users = $row[8]; + $delete_user_groups = $row[9]; + $delete_lists = $row[10]; + $delete_campaigns = $row[11]; + $delete_ingroups = $row[12]; + $delete_remote_agents = $row[13]; + $load_leads = $row[14]; + $campaign_detail = $row[15]; + $ast_admin_access = $row[16]; + $ast_delete_phones = $row[17]; + $delete_scripts = $row[18]; + $modify_leads = $row[19]; + $hotkeys_active = $row[20]; + $change_agent_campaign =$row[21]; + $agent_choose_ingroups =$row[22]; + $scheduled_callbacks = $row[24]; + $agentonly_callbacks = $row[25]; + $agentcall_manual = $row[26]; + $vicidial_recording = $row[27]; + $vicidial_transfers = $row[28]; + $delete_filters = $row[29]; + $alter_agent_interface_options =$row[30]; + $closer_default_blended = $row[31]; + $delete_call_times = $row[32]; + $modify_call_times = $row[33]; + +if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) + { + echo "
You do not have permissions to modify this user: $row[1]\n"; + } +else + { + echo "
MODIFY A USERS RECORD: $row[1]\n"; + if ($LOGuser_level > 8) + {echo "\n";} + else + { + if ($LOGalter_agent_interface == "1") + {echo "\n";} + else + {echo "\n";} + } + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ( ($LOGuser_level > 8) or ($LOGalter_agent_interface == "1") ) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($LOGuser_level > 8) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo "
User Number: $row[1]$NWB#vicidial_users-user$NWE
Password: $NWB#vicidial_users-pass$NWE
Full Name: $NWB#vicidial_users-full_name$NWE
User Level: $NWB#vicidial_users-user_level$NWE
User Group: $NWB#vicidial_users-user_group$NWE
Phone Login: $NWB#vicidial_users-phone_login$NWE
Phone Pass: $NWB#vicidial_users-phone_pass$NWE
AGENT INTERFACE OPTIONS:
Agent Choose Ingroups: $NWB#vicidial_users-agent_choose_ingroups$NWE
HotKeys Active: $NWB#vicidial_users-hotkeys_active$NWE
Scheduled Callbacks: $NWB#vicidial_users-scheduled_callbacks$NWE
Agent-Only Callbacks: $NWB#vicidial_users-agentonly_callbacks$NWE
Agent Call Manual: $NWB#vicidial_users-agentcall_manual$NWE
Vicidial Recording: $NWB#vicidial_users-vicidial_recording$NWE
Vicidial Transfers: $NWB#vicidial_users-vicidial_transfers$NWE
Closer Default Blended: $NWB#vicidial_users-closer_default_blended$NWE
Inbound Groups: \n"; + echo "$groups_list"; + echo "$NWB#vicidial_users-closer_campaigns$NWE
ADMIN INTERFACE OPTIONS:
Alter Agent Interface Options: $NWB#vicidial_users-alter_agent_interface_options$NWE
Delete Users: $NWB#vicidial_users-delete_users$NWE
Delete User Groups: $NWB#vicidial_users-delete_user_groups$NWE
Delete Lists: $NWB#vicidial_users-delete_lists$NWE
Delete Campaigns: $NWB#vicidial_users-delete_campaigns$NWE
Delete In-Groups: $NWB#vicidial_users-delete_ingroups$NWE
Delete Remote Agents: $NWB#vicidial_users-delete_remote_agents$NWE
Delete Scripts: $NWB#vicidial_users-delete_scripts$NWE
Load Leads: $NWB#vicidial_users-load_leads$NWE
Campaign Detail: $NWB#vicidial_users-campaign_detail$NWE
AGC Admin Access: $NWB#vicidial_users-ast_admin_access$NWE
AGC Delete Phones: $NWB#vicidial_users-ast_delete_phones$NWE
Modify Leads: $NWB#vicidial_users-modify_leads$NWE
Change Agent Campaign: $NWB#vicidial_users-change_agent_campaign$NWE
Delete Filters: $NWB#vicidial_users-delete_filters$NWE
Delete Call Times: $NWB#vicidial_users-delete_call_times$NWE
Modify Call Times: $NWB#vicidial_users-modify_call_times$NWE
\n"; + + if ($LOGdelete_users > 0) + { + echo "

DELETE THIS USER\n"; + } + echo "

Click here for user time sheet\n"; + echo "

Click here for user status\n"; + echo "

Click here for user stats\n"; + echo "

Click here for user CallBack Holds\n"; + } + +} + + +###################### +# ADD=31 modify campaign info in the system - Detail view +###################### + +if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed + +if ($ADD==31) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $campaign_rec_exten = $row[22]; + $campaign_recording = $row[23]; + $campaign_rec_filename = $row[24]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $am_message_exten = $row[27]; + $amd_send_to_vmx = $row[28]; + $xferconf_a_dtmf = $row[29]; + $xferconf_a_number = $row[30]; + $xferconf_b_dtmf = $row[31]; + $xferconf_b_number = $row[32]; + $alt_number_dialing = $row[33]; + $scheduled_callbacks = $row[34]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $drop_call_seconds = $row[36]; + $safe_harbor_message = $row[37]; + $safe_harbor_exten = $row[38]; + $display_dialable_count = $row[39]; + $wrapup_seconds = $row[40]; + $wrapup_message = $row[41]; +# $closer_campaigns = $row[42]; + $use_internal_dnc = $row[43]; + +echo "
MODIFY A CAMPAIGNS RECORD: $row[0] - Basic View"; +echo " | Detail View | "; +echo "Realtime Screen\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +if (eregi("CLOSER", $campaign_id)) + { + echo "\n"; + } + + + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: - Filename: $NWB#vicidial_campaigns-park_ext$NWE
Web Form: $NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Local Call Time: $NWB#vicidial_campaigns-local_call_time$NWE
Dial Timeout: in seconds$NWB#vicidial_campaigns-dial_timeout$NWE
Dial Prefix: for 91NXXNXXXXXX value would be 9, for no dial prefix use X$NWB#vicidial_campaigns-dial_prefix$NWE
Campaign CallerID: $NWB#vicidial_campaigns-campaign_cid$NWE
Campaign VDAD exten: $NWB#vicidial_campaigns-campaign_vdad_exten$NWE
Campaign Rec exten: $NWB#vicidial_campaigns-campaign_rec_exten$NWE
Campaign Recording: $NWB#vicidial_campaigns-campaign_recording$NWE
Campaign Rec Filename: $NWB#vicidial_campaigns-campaign_rec_filename$NWE
Script: $NWB#vicidial_campaigns-campaign_script$NWE
Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE
Answering Machine Message: $NWB#vicidial_campaigns-am_message_exten$NWE
AMD Send to VM exten: $NWB#vicidial_campaigns-amd_send_to_vmx$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf Number 1: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Transfer-Conf Number 2: $NWB#vicidial_campaigns-xferconf_a_dtmf$NWE
Alt Number Dialing: $NWB#vicidial_campaigns-alt_number_dialing$NWE
Scheduled Callbacks: $NWB#vicidial_campaigns-scheduled_callbacks$NWE
Drop Call Seconds: $NWB#vicidial_campaigns-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_campaigns-voicemail_ext$NWE
Use Safe Harbor Message: $NWB#vicidial_campaigns-safe_harbor_message$NWE
Safe Harbor Exten: $NWB#vicidial_campaigns-safe_harbor_exten$NWE
Wrapup Seconds: $NWB#vicidial_campaigns-wrapup_seconds$NWE
Wrapup Message: $NWB#vicidial_campaigns-wrapup_message$NWE
Use Internal DNC List: $NWB#vicidial_campaigns-use_internal_dnc$NWE
Allowed Inbound Groups:
"; + echo " $NWB#vicidial_campaigns-closer_campaigns$NWE
\n"; + echo "$groups_list"; + echo "
\n"; + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - HIDE

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - SHOW

"; + } + + + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "Click here to see all CallBack Holds in this campaign

\n"; +echo "
\n"; + + + + +echo "
\n"; +echo "
CUSTOM STATUSES WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_statuses$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
STATUSDESCRIPTIONSELECTABLEDELETE
$rowx[0]$rowx[1]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN STATUS
\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Description:   \n"; +echo "Selectable:   \n"; +echo "
\n"; + +echo "

\n"; + + + +echo "
CUSTOM HOTKEYS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_hotkeys$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_campaign_hotkeys where campaign_id='$campaign_id' order by hotkey"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
HOTKEYSTATUSDESCRIPTIONDELETE
$rowx[1]$rowx[0]$rowx[2]DELETE
\n"; + +echo "
ADD NEW CUSTOM CAMPAIGN HOTKEY
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Hotkey:   \n"; +echo "Status:   \n"; +echo "
\n"; +echo "

\n"; + + + +echo "

LEAD RECYCLING WITHIN THIS CAMPAIGN:   $NWB#vicidial_lead_recycle$NWE
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT * from vicidial_lead_recycle where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $recycle_to_print = mysql_num_rows($rslt); + $o=0; + while ($recycle_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + +echo "
STATUSATTEMPT DELAYATTEMPT MAXIMUMACTIVE DELETE
$rowx[2]
\n"; + echo "\n"; + echo "\n"; + echo "
DELETE
\n"; + +echo "
ADD NEW CAMPAIGN LEAD RECYCLE
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Status:   \n"; +echo "Attempt Delay: \n"; +echo "Attempt Maximum: \n"; +echo "
\n"; + +echo "

\n"; + +echo "LOG ALL AGENTS OUT OF THIS CAMPAIGN

\n"; + +if ($LOGdelete_campaigns > 0) + { + echo "

DELETE THIS CAMPAIGN\n"; + } + +} + + +###################### +# ADD=34 modify campaign info in the system - Basic View +###################### + +if ($ADD==34) +{ + if ($stage=='show_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='Y' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } + if ($stage=='hide_dialable') + { + $stmt="UPDATE vicidial_campaigns set display_dialable_count='N' where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + } +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns where campaign_id='$campaign_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dial_status_a = $row[3]; + $dial_status_b = $row[4]; + $dial_status_c = $row[5]; + $dial_status_d = $row[6]; + $dial_status_e = $row[7]; + $lead_order = $row[8]; + $hopper_level = $row[13]; + $auto_dial_level = $row[14]; + $next_agent_call = $row[15]; + $local_call_time = $row[16]; + $voicemail_ext = $row[17]; + $dial_timeout = $row[18]; + $dial_prefix = $row[19]; + $campaign_cid = $row[20]; + $campaign_vdad_exten = $row[21]; + $script_id = $row[25]; + $get_call_launch = $row[26]; + $lead_filter_id = $row[35]; + if ($lead_filter_id=='') {$lead_filter_id='NONE';} + $display_dialable_count = $row[39]; + +echo "
MODIFY A CAMPAIGN'S RECORD: $row[0] - Basic View | "; +echo "Detail View | "; +echo "Realtime Screen\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; +echo "
Campaign ID: $row[0]$NWB#vicidial_campaigns-campaign_id$NWE
Campaign Name: $NWB#vicidial_campaigns-campaign_name$NWE
Active: $NWB#vicidial_campaigns-active$NWE
Park Extension: $row[9] - $row[10]$NWB#vicidial_campaigns-park_ext$NWE
Web Form: $row[11]$NWB#vicidial_campaigns-web_form_address$NWE
Allow Closers: $row[12] $NWB#vicidial_campaigns-allow_closers$NWE
Dial status 1: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 2: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 3: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 4: $NWB#vicidial_campaigns-dial_status$NWE
Dial status 5: $NWB#vicidial_campaigns-dial_status$NWE
List Order: $NWB#vicidial_campaigns-lead_order$NWE
Lead Filter: $NWB#vicidial_campaigns-lead_filter_id$NWE
Hopper Level: $NWB#vicidial_campaigns-hopper_level$NWE
Force Reset of Hopper: $NWB#vicidial_campaigns-force_reset_hopper$NWE
Auto Dial Level: (0 = off)$NWB#vicidial_campaigns-auto_dial_level$NWE
Script: $script_id
Get Call Launch: $get_call_launch
\n"; + +echo "
\n"; +echo "
LISTS WITHIN THIS CAMPAIGN:   $NWB#vicidial_campaign_lists$NWE
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT list_id,active,list_name from vicidial_lists where campaign_id='$campaign_id'"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
LIST IDLIST NAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + +$filterSQL = $filtersql_list[$lead_filter_id]; +$filterSQL = eregi_replace("^and|and$|^or|or$","",$filterSQL); +if (strlen($filterSQL)>4) + {$fSQL = "and $filterSQL";} +else + {$fSQL = '';} + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This campaign has $active_lists active lists and $inactive_lists inactive lists

\n"; + + +if ($display_dialable_count == 'Y') + { + ### call function to calculate and print dialable leads + dialable_leads($DB,$link,$local_call_time,$dial_status_a,$dial_status_b,$dial_status_c,$dial_status_d,$dial_status_e,$camp_lists,$fSQL); + echo " - HIDE

"; + } +else + { + echo "Popup Dialable Leads Count"; + echo " - SHOW

"; + } + + + + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id='$campaign_id' and status IN('READY')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $hopper_leads = "$rowx[0]"; + +echo "This campaign has $hopper_leads leads in the dial hopper

\n"; +echo "Click here to see what leads are in the hopper right now

\n"; +echo "Click here to see all CallBack Holds in this campaign

\n"; +echo "
\n"; + +echo "
\n"; + +echo "LOG ALL AGENTS OUT OF THIS CAMPAIGN

\n"; + + +if ($LOGdelete_campaigns > 0) + { + echo "

DELETE THIS CAMPAIGN\n"; + } + + +} + + +###################### +# ADD=311 modify list info in the system +###################### + +if ($ADD==311) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $campaign_id = $row[2]; + $active = $row[3]; + + # grab names of global statuses and statuses in the selected campaign + $stmt="SELECT * from vicidial_statuses order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($statuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + + $stmt="SELECT * from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status"; + $rslt=mysql_query($stmt, $link); + $Cstatuses_to_print = mysql_num_rows($rslt); + + $o=0; + while ($Cstatuses_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $statuses_list["$rowx[0]"] = "$rowx[1]"; + $o++; + } + # end grab status names + + +echo "
MODIFY A LISTS RECORD: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
List ID: $row[0]$NWB#vicidial_lists-list_id$NWE
List Name: $NWB#vicidial_lists-list_name$NWE
Campaign: $NWB#vicidial_lists-campaign_id$NWE
Active: $NWB#vicidial_lists-active$NWE
Reset Lead-Called-Status for this list: $NWB#vicidial_lists-reset_list$NWE
\n"; + +echo "
\n"; +echo "
STATUSES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by status,called_since_last_reset order by status,called_since_last_reset"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + $o=0; + if ($lead_list['count'] > 0) + { + while (list($dispo,) = each($lead_list[$since_reset])) + { + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if ($dispo == 'CBHOLD') + { + $CLB=""; + $CLE=""; + } + else + { + $CLB=''; + $CLE=''; + } + + echo "\n"; + $o++; + } + } + +echo "\n"; +echo "\n"; + +echo "
STATUSSTATUS NAMECALLEDNOT CALLED
$CLB$dispo$CLE$statuses_list[$dispo]".$lead_list['Y'][$dispo]."".$lead_list['N'][$dispo]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + +echo "
\n"; +echo "
TIME ZONES WITHIN THIS LIST:
\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT gmt_offset_now,called_since_last_reset,count(*) from vicidial_list where list_id='$list_id' group by gmt_offset_now,called_since_last_reset order by gmt_offset_now,called_since_last_reset"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + + $o=0; + $plus='+'; + $lead_list['count'] = 0; + $lead_list['Y_count'] = 0; + $lead_list['N_count'] = 0; + while ($statuses_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + + $lead_list['count'] = ($lead_list['count'] + $rowx[2]); + if ($rowx[1] == 'N') + { + $since_reset = 'N'; + $since_resetX = 'Y'; + } + else + { + $since_reset = 'Y'; + $since_resetX = 'N'; + } + $lead_list[$since_reset][$rowx[0]] = ($lead_list[$since_reset][$rowx[0]] + $rowx[2]); + $lead_list[$since_reset.'_count'] = ($lead_list[$since_reset.'_count'] + $rowx[2]); + #If opposite side is not set, it may not in the future so give it a value of zero + if (!isset($lead_list[$since_resetX][$rowx[0]])) + { + $lead_list[$since_resetX][$rowx[0]]=0; + } + $o++; + } + + if ($lead_list['count'] > 0) + { + while (list($tzone,) = each($lead_list[$since_reset])) + { + $LOCALzone=3600 * $tzone; + $LOCALdate=gmdate("D M Y H:i", time() + $LOCALzone); + + if ($tzone >= 0) {$DISPtzone = "$plus$tzone";} + else {$DISPtzone = "$tzone";} + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + } + } + +echo "\n"; +echo "\n"; + +echo "
GMT OFFSET NOW (local time)CALLEDNOT CALLED
".$DISPtzone."     ($LOCALdate)".$lead_list['Y'][$tzone]."".$lead_list['N'][$tzone]."
SUBTOTALS$lead_list[Y_count]$lead_list[N_count]
TOTAL$lead_list[count]

\n"; +unset($lead_list); + + + + + + + + $leads_in_list = 0; + $leads_in_list_N = 0; + $leads_in_list_Y = 0; + $stmt="SELECT status,called_count,count(*) from vicidial_list where list_id='$list_id' group by status,called_count order by status,called_count"; + $rslt=mysql_query($stmt, $link); + $status_called_to_print = mysql_num_rows($rslt); + + $o=0; + $sts=0; + $first_row=1; + $all_called_first=1000; + $all_called_last=0; + while ($status_called_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $leads_in_list = ($leads_in_list + $rowx[2]); + $count_statuses[$o] = "$rowx[0]"; + $count_called[$o] = "$rowx[1]"; + $count_count[$o] = "$rowx[2]"; + $all_called_count[$rowx[1]] = ($all_called_count[$rowx[1]] + $rowx[2]); + + if ( (strlen($status[$sts]) < 1) or ($status[$sts] != "$rowx[0]") ) + { + if ($first_row) {$first_row=0;} + else {$sts++;} + $status[$sts] = "$rowx[0]"; + $status_called_first[$sts] = "$rowx[1]"; + if ($status_called_first[$sts] < $all_called_first) {$all_called_first = $status_called_first[$sts];} + } + $leads_in_sts[$sts] = ($leads_in_sts[$sts] + $rowx[2]); + $status_called_last[$sts] = "$rowx[1]"; + if ($status_called_last[$sts] > $all_called_last) {$all_called_last = $status_called_last[$sts];} + + $o++; + } + + + + +echo "
\n"; +echo "
CALLED COUNTS WITHIN THIS LIST:
\n"; +echo "\n"; +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + + $sts=0; + $statuses_called_to_print = count($status); + while ($statuses_called_to_print > $sts) + { + $Pstatus = $status[$sts]; + if (eregi("1$|3$|5$|7$|9$", $sts)) + {$bgcolor='bgcolor="#B9CBFD"'; $AB='bgcolor="#9BB9FB"';} + else + {$bgcolor='bgcolor="#9BB9FB"'; $AB='bgcolor="#B9CBFD"';} +# echo "$status[$sts]|$status_called_first[$sts]|$status_called_last[$sts]|$leads_in_sts[$sts]|\n"; +# echo "$status[$sts]|"; + echo ""; + + $first = $all_called_first; + while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $sts)) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + else + { + if (eregi("0$|2$|4$|6$|8$", $first)) {$AB='bgcolor="#9BB9FB"';} + else{$AB='bgcolor="#B9CBFD"';} + } + + $called_printed=0; + $o=0; + while ($status_called_to_print > $o) + { + if ( ($count_statuses[$o] == "$Pstatus") and ($count_called[$o] == "$first") ) + { + $called_printed++; + echo ""; + } + + + $o++; + } + if (!$called_printed) + {echo "";} + $first++; + } + echo "\n\n"; + + $sts++; + } + +echo ""; +$first = $all_called_first; +while ($first <= $all_called_last) + { + if (eregi("1$|3$|5$|7$|9$", $first)) {$AB='bgcolor="#AFEEEE"';} + else{$AB='bgcolor="#E0FFFF"';} + echo ""; + $first++; + } +echo "\n"; + +echo "
STATUSSTATUS NAME$firstSUBTOTAL
$Pstatus$statuses_list[$Pstatus] $count_count[$o]  $leads_in_sts[$sts]
TOTAL$all_called_count[$first]$leads_in_list

\n"; + + + + + +echo "
\n"; + +if ($LOGdelete_lists > 0) + { + echo "

DELETE THIS LIST\n"; + } + +} + + + +###################### +# ADD=3111 modify in-group info in the system +###################### + +if ($ADD==3111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups where group_id='$group_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $group_name = $row[1]; + $group_color = $row[2]; + $active = $row[3]; + $web_form_address = $row[4]; + $voicemail_ext = $row[5]; + $next_agent_call = $row[6]; + $fronter_display = $row[7]; + $script_id = $row[8]; + $get_call_launch = $row[9]; + $xferconf_a_dtmf = $row[10]; + $xferconf_a_number = $row[11]; + $xferconf_b_dtmf = $row[12]; + $xferconf_b_number = $row[13]; + $drop_call_seconds = $row[14]; + $drop_message = $row[15]; + $drop_exten = $row[16]; + +echo "
MODIFY A GROUPS RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + +echo "\n"; + + +echo "\n"; +echo "
Group ID: $row[0]$NWB#vicidial_inbound_groups-group_id$NWE
Group Name: $NWB#vicidial_inbound_groups-group_name$NWE
Group Color: $NWB#vicidial_inbound_groups-group_color$NWE
Active: $NWB#vicidial_inbound_groups-active$NWE
Web Form: $NWB#vicidial_inbound_groups-web_form_address$NWE
Next Agent Call: $NWB#vicidial_inbound_groups-next_agent_call$NWE
Fronter Display: $NWB#vicidial_inbound_groups-fronter_display$NWE
Script: $NWB#vicidial_inbound_groups-ingroup_script$NWE
Get Call Launch: $NWB#vicidial_inbound_groups-get_call_launch$NWE
Transfer-Conf DTMF 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf Number 1: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf DTMF 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Transfer-Conf Number 2: $NWB#vicidial_inbound_groups-xferconf_a_dtmf$NWE
Drop Call Seconds: $NWB#vicidial_inbound_groups-drop_call_seconds$NWE
Voicemail: $NWB#vicidial_inbound_groups-voicemail_ext$NWE
Use Drop Message: $NWB#vicidial_inbound_groups-drop_message$NWE
Drop Exten: $NWB#vicidial_inbound_groups-drop_exten$NWE
\n"; + +echo "

\n"; + +echo "
\n"; + +if ($LOGdelete_ingroups > 0) + { + echo "

DELETE THIS IN-GROUP\n"; + } + +} + + + +###################### +# ADD=31111 modify remote agents info in the system +###################### + +if ($ADD==31111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='$remote_agent_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: (numbers only, incremented)$NWB#vicidial_remote_agents-user_start$NWE
Number of Lines: (numbers only)$NWB#vicidial_remote_agents-number_of_lines$NWE
Server IP: $NWB#vicidial_remote_agents-server_ip$NWE
External Extension: (dialplan number dialed to reach agents)$NWB#vicidial_remote_agents-conf_exten$NWE
Status: $NWB#vicidial_remote_agents-status$NWE
Campaign: $NWB#vicidial_remote_agents-campaign_id$NWE
Inbound Groups: \n"; +echo "$groups_list"; +echo "$NWB#vicidial_remote_agents-closer_campaigns$NWE
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + + +if ($LOGdelete_remote_agents > 0) + { + echo "

DELETE THIS REMOTE AGENT\n"; + } + +} + + +###################### +# ADD=311111 modify user group info in the system +###################### + +if ($ADD==311111) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups where user_group='$user_group';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $user_group = $row[0]; + $group_name = $row[1]; +echo ""; + +echo "
MODIFY A USERS GROUP ENTRY\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Group: (no spaces or punctuation)$NWB#vicidial_user_groups-user_group$NWE
Description: (description of group)$NWB#vicidial_user_groups-group_name$NWE
\n"; + +if ($LOGdelete_user_groups > 0) + { + echo "

DELETE THIS USER GROUP\n"; + } + +} + + +###################### +# ADD=3111111 modify script info in the system +###################### + +if ($ADD==3111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts where script_id='$script_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $script_name = $row[1]; + $script_comments = $row[2]; + $script_text = $row[3]; + $active = $row[4]; +echo ""; + +echo "
MODIFY A SCRIPT\n"; +echo "\n"; +echo "\n"; +echo "
Script ID: $script_id$NWB#vicidial_scripts-script_name$NWE
Script Name: (title of the script)$NWB#vicidial_scripts-script_name$NWE
Script Comments: $NWB#vicidial_scripts-script_comments$NWE
Active: $NWB#vicidial_scripts-active$NWE
Script Text:

Preview Script
$NWB#vicidial_scripts-script_text$NWE
\n"; + +if ($LOGdelete_scripts > 0) + { + echo "

DELETE THIS SCRIPT\n"; + } + +} + + +###################### +# ADD=31111111 modify filter info in the system +###################### + +if ($ADD==31111111) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lead_filters where lead_filter_id='$lead_filter_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $lead_filter_name = $row[1]; + $lead_filter_comments = $row[2]; + $lead_filter_sql = $row[3]; +echo ""; + +echo "
MODIFY A FILTER\n"; +echo "\n"; +echo "\n"; +echo "
Filter ID: $lead_filter_id$NWB#vicidial_lead_filters-lead_filter_id$NWE
Filter Name: (short description of the filter)$NWB#vicidial_lead_filters-lead_filter_name$NWE
Filter Comments: $NWB#vicidial_lead_filters-lead_filter_comments$NWE
Filter SQL: $NWB#vicidial_lead_filters-lead_filter_sql$NWE
\n"; + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + +echo "

"; +echo "
TEST ON CAMPAIGN:
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +if ($LOGdelete_filters > 0) + { + echo "

DELETE THIS FILTER\n"; + } + +} + + +###################### +# ADD=321111111 modify call time definition info in the system +###################### + +if ($ADD==321111111) +{ +if ($LOGmodify_call_times==1) +{ + +if ( ($stage=="ADD") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + if (eregi("\|$",$ct_state_call_times)) + {$ct_state_call_times = "$ct_state_call_times$state_rule\|";} + else + {$ct_state_call_times = "$ct_state_call_times\|$state_rule\|";} + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "State Rule Added: $state_rule
\n"; + } +if ( ($stage=="REMOVE") and (strlen($state_rule)>0) ) + { + $stmt="SELECT ct_state_call_times from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $ct_state_call_times = $row[0]; + + $ct_state_call_times = eregi_replace("\|$state_rule\|",'|',$ct_state_call_times); + $stmt="UPDATE vicidial_call_times set ct_state_call_times='$ct_state_call_times' where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + echo "State Rule Removed: $state_rule
\n"; + } + +$ADD=311111111; +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + +###################### +# ADD=311111111 modify call time definition info in the system +###################### + +if ($ADD==311111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +$ct_srs=1; +$b=0; +$srs_SQL =''; +if (strlen($ct_state_call_times)>2) + { + $state_rules = explode('|',$ct_state_call_times); + $ct_srs = ((count($state_rules)) - 1); + } +echo "\n"; +echo "\n"; +while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>0) + { + $stmt="SELECT state_call_time_state,state_call_time_name from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + echo "\n"; + $srs_SQL .= "'$state_rules[$b]',"; + $srs_state_SQL .= "'$row[0]',"; + } + $b++; + } +if (strlen($srs_SQL)>2) + { + $srs_SQL = "$srs_SQL''"; + $srs_state_SQL = "$srs_state_SQL''"; + $srs_SQL = "where state_call_time_id NOT IN($srs_SQL) and state_call_time_state NOT IN($srs_state_SQL)"; + } +else + {$srs_SQL='';} +$stmt="SELECT state_call_time_id,state_call_time_name from vicidial_state_call_times $srs_SQL order by state_call_time_id;"; +$rslt=mysql_query($stmt, $link); +$sct_to_print = mysql_num_rows($rslt); +$sct_list=''; + +$o=0; +while ($sct_to_print > $o) { + $rowx=mysql_fetch_row($rslt); + $sct_list .= "\n"; + $o++; +} +echo "\n"; +echo "\n"; + +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_call_times where call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $call_time_name = $row[1]; + $call_time_comments = $row[2]; + $ct_default_start = $row[3]; + $ct_default_stop = $row[4]; + $ct_sunday_start = $row[5]; + $ct_sunday_stop = $row[6]; + $ct_monday_start = $row[7]; + $ct_monday_stop = $row[8]; + $ct_tuesday_start = $row[9]; + $ct_tuesday_stop = $row[10]; + $ct_wednesday_start = $row[11]; + $ct_wednesday_stop = $row[12]; + $ct_thursday_start = $row[13]; + $ct_thursday_stop = $row[14]; + $ct_friday_start = $row[15]; + $ct_friday_stop = $row[16]; + $ct_saturday_start = $row[17]; + $ct_saturday_stop = $row[18]; + $ct_state_call_times = $row[19]; + +echo ""; + +echo "
MODIFY A CALL TIME\n"; +echo "\n"; +echo "\n"; +echo "
Call Time ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Default Start: Default Stop: $NWB#vicidial_call_times-ct_default_start$NWE
Sunday Start: Sunday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Monday Start: Monday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Tuesday Start: Tuesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Wednesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Thursday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Friday Start: Friday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Saturday Start: Saturday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Active State Call Time Definitions for this Record:  
$state_rules[$b] - REMOVE $row[0] - $row[1]
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "Add state call time rule:


\n"; +echo "CAMPAIGNS USING THIS CALL TIME:
\n"; +echo "\n"; + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where local_call_time='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + $CT_camp_id = $row[1]; + $CT_camp_name = $row[2]; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

DELETE THIS CALL TIME DEFINITION\n"; + } +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + +###################### +# ADD=3111111111 modify state call time definition info in the system +###################### + +if ($ADD==3111111111) +{ + +if ($LOGmodify_call_times==1) +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$call_time_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $state_call_time_state =$row[1]; + $call_time_name = $row[2]; + $call_time_comments = $row[3]; + $ct_default_start = $row[4]; + $ct_default_stop = $row[5]; + $ct_sunday_start = $row[6]; + $ct_sunday_stop = $row[7]; + $ct_monday_start = $row[8]; + $ct_monday_stop = $row[9]; + $ct_tuesday_start = $row[10]; + $ct_tuesday_stop = $row[11]; + $ct_wednesday_start = $row[12]; + $ct_wednesday_stop = $row[13]; + $ct_thursday_start = $row[14]; + $ct_thursday_stop = $row[15]; + $ct_friday_start = $row[16]; + $ct_friday_stop = $row[17]; + $ct_saturday_start = $row[18]; + $ct_saturday_stop = $row[19]; + +echo ""; + +echo "
MODIFY A STATE CALL TIME
\n"; +echo "\n"; +echo "\n"; +echo "
Call Time ID: $call_time_id$NWB#vicidial_call_times-call_time_id$NWE
State Call Time State: $NWB#vicidial_call_times-state_call_time_state$NWE
State Call Time Name: (short description of the call time)$NWB#vicidial_call_times-call_time_name$NWE
State Call Time Comments: $NWB#vicidial_call_times-call_time_comments$NWE
Default Start: Default Stop: $NWB#vicidial_call_times-ct_default_start$NWE
Sunday Start: Sunday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Monday Start: Monday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Tuesday Start: Tuesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Wednesday Start: Wednesday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Thursday Start: Thursday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Friday Start: Friday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE
Saturday Start: Saturday Stop: $NWB#vicidial_call_times-ct_sunday_start$NWE


\n"; +echo "CALL TIMES USING THIS STATE CALL TIME:
\n"; +echo "\n"; + + $stmt="SELECT call_time_id,call_time_name from vicidial_call_times where ct_state_call_times LIKE \"%|$call_time_id|%\";"; + $rslt=mysql_query($stmt, $link); + $camps_to_print = mysql_num_rows($rslt); + $o=0; + while ($camps_to_print > $o) { + $row=mysql_fetch_row($rslt); + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]
\n"; +echo "

\n"; + +if ($LOGdelete_call_times > 0) + { + echo "

DELETE THIS STATE CALL TIME DEFINITION\n"; + } + +} +else +{ +echo "You are not authorized to view this page. Please go back."; +} + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo "
\n"; +echo ""; + +echo "
SEARCH FOR A USER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "
User Number:
Full Name:
User Level:
User Group:
\n"; + +} + +###################### +# ADD=66 user search results +###################### + +if ($ADD==66) +{ +echo "
\n"; + echo ""; + + $SQL = ''; + if ($user) {$SQL .= " user LIKE \"%$user%\" and";} + if ($full_name) {$SQL .= " full_name LIKE \"%$full_name%\" and";} + if ($user_level > 0) {$SQL .= " user_level LIKE \"%$user_level%\" and";} + if ($user_group) {$SQL .= " user_group = '$user_group' and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from vicidial_users $SQL order by full_name desc;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS | STATUS | TIME
\n"; + +} + + +###################################################################################################### +###################################################################################################### +####### 8 series, Callback lists +###################################################################################################### +###################################################################################################### + +###################### +# ADD=8 find all callbacks on hold by a User +###################### +if ($ADD==8) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and user='$user' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
USER CALLBACK HOLD LISTINGS: $user\n"; +$ADD='82'; +} + +###################### +# ADD=81 find all callbacks on hold within a Campaign +###################### +if ($ADD==81) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and campaign_id='$campaign_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN CALLBACK HOLD LISTINGS: $campaign_id\n"; +$ADD='82'; +} + +###################### +# ADD=811 find all callbacks on hold within a List +###################### +if ($ADD==811) +{ + echo ""; + + $stmt="SELECT * from vicidial_callbacks where status IN('ACTIVE','LIVE') and list_id='$list_id' order by recipient,status desc,callback_time"; + $rslt=mysql_query($stmt, $link); + $cb_to_print = mysql_num_rows($rslt); + +echo "
LIST CALLBACK HOLD LISTINGS: $list_id\n"; +$ADD='82'; +} + +###################### +# ADD=82 display all callbacks on hold +###################### +if ($ADD==82) +{ +echo "
\n"; +echo "
\n"; +echo "\n"; + + $o=0; + while ($cb_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
LEADLISTCAMPAIGNENTRY DATECALLBACK DATEUSERRECIPIENTSTATUS
$row[1]$row[2]$row[3]$row[5]$row[6]$row[8]$row[9]$row[4]
\n"; +} + + + +###################################################################################################### +###################################################################################################### +####### 0 series, displays and searches +###################################################################################################### +###################################################################################################### + +###################### +# ADD=0 display all active users +###################### +if ($ADD==0) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_users order by full_name"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1]$row[3]$row[4]$row[5]MODIFY | STATS | STATUS | TIME
\n"; +} + +###################### +# ADD=10 display all campaigns +###################### +if ($ADD==10) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
CAMPAIGN LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3]$row[4]$row[5] $row[6]$row[7]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all lists +###################### +if ($ADD==100) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_lists order by list_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
LIST LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]$row[5] $row[3]$row[7]  MODIFY
\n"; +} + + + +###################### +# ADD=1000 display all inbound groups +###################### +if ($ADD==1000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
INBOUND GROUP LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[5]  MODIFY
\n"; +} + + +###################### +# ADD=10000 display all remote agents +###################### +if ($ADD==10000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_remote_agents order by server_ip,campaign_id,user_start"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
REMOTE AGENTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[1] $row[2] $row[3] $row[4] $row[5] $row[6]MODIFY
\n"; +} + + +###################### +# ADD=100000 display all user groups +###################### +if ($ADD==100000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_user_groups order by user_group"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
USER GROUPS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=1000000 display all scripts +###################### +if ($ADD==1000000) +{ +echo "
\n"; + echo ""; + + $stmt="SELECT * from vicidial_scripts order by script_id"; + $rslt=mysql_query($stmt, $link); + $people_to_print = mysql_num_rows($rslt); + +echo "
SCRIPTS LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($people_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=10000000 display all filters +###################### +if ($ADD==10000000) +{ +echo "\r\n"; + } +} + diff --git a/agc_2-X/trunk/VICIDIAL_web/listloader_super.pl b/agc_2-X/trunk/VICIDIAL_web/listloader_super.pl new file mode 100644 index 00000000..a36765d0 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/listloader_super.pl @@ -0,0 +1,691 @@ +#!/usr/bin/perl + +### listloader_super.pl +### +### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 +### +# +# +# CHANGES +# 60616-1548 - Added listID override feature to force all leads into same list +# - Added gmt_offset_now lookup for each lead +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + } + else + { + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + } +} +### end parsing run-time options ### + +use Spreadsheet::ParseExcel; +use Time::Local; +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$vars=$ARGV[0]; +@xls_fields=split(/\,/, $vars); + +$|=0; +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$pulldate="$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + + ### Grab Server values from the database + $stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + +$total=0; $good=0; $bad=0; +open(STMT_FILE, "> listloader_stmts.txt"); + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +my($iR, $iC, $oWkS, $oWkC); + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[0]]; + if ($oWkC) {$vendor_lead_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[1]]; + if ($oWkC) {$source_code=$oWkC->Value; } + $source_id=$source_code; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[2]]; + if ($oWkC) {$list_id=$oWkC->Value; } + $gmt_offset = '0'; + $called_since_last_reset='N'; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[3]]; + if ($oWkC) {$phone_code=$oWkC->Value; } + $phone_code=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[4]]; + if ($oWkC) {$phone_number=$oWkC->Value; } + $phone_number=~s/[^0-9]//g; + $USarea = substr($phone_number, 0, 3); + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[5]]; + if ($oWkC) {$title=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[6]]; + if ($oWkC) {$first_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[7]]; + if ($oWkC) {$middle_initial=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[8]]; + if ($oWkC) {$last_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[9]]; + if ($oWkC) {$address1=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[10]]; + if ($oWkC) {$address2=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[11]]; + if ($oWkC) {$address3=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[12]]; + if ($oWkC) {$city=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[13]]; + if ($oWkC) {$state=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[14]]; + if ($oWkC) {$province=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[15]]; + if ($oWkC) {$postal_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[16]]; + if ($oWkC) {$country_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[17]]; + if ($oWkC) {$gender=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[18]]; + if ($oWkC) {$date_of_birth=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[19]]; + if ($oWkC) {$alt_phone=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[20]]; + if ($oWkC) {$email=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[21]]; + if ($oWkC) {$security_phrase=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][$xls_fields[22]]; + if ($oWkC) {$comments=$oWkC->Value; } + $comments=~s/^\s*(.*?)\s*$/$1/; + + if (length($phone_number)>8) { + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &USA_dstcalc; + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + sleep(1); +# flush(); + } + } +} + +if ($multi_insert_counter > 0) { + $stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; +} + +print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total"; + +exit; + + + + + + +sub USA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +#********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $USA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } + } else { + $USA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $USA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } + } else { + $USA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/VICIDIAL_web/log_test.php b/agc_2-X/trunk/VICIDIAL_web/log_test.php new file mode 100644 index 00000000..cd7a86b7 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/log_test.php @@ -0,0 +1,37 @@ + LICENSE: GPLv2 +# + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$fp = fopen ("./closer_SQL_updates.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + fwrite ($fp, "CLOSER SQL UPDATE|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + + +exit; + + + +?> + + +Hello + + diff --git a/agc_2-X/trunk/VICIDIAL_web/new_listloader_superL.php b/agc_2-X/trunk/VICIDIAL_web/new_listloader_superL.php new file mode 100644 index 00000000..6c0ac713 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/new_listloader_superL.php @@ -0,0 +1,1364 @@ + LICENSE: GPLv2 +# +# AST GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60113-1603 - Fixed a few bugs in Excel import +# 60421-1624 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1240 - added listID override +# 60616-1604 - added gmt lookup for each lead +# 60619-1651 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. + +$version = '1.1.12-1'; +$build = '60619-1651'; + + +require("dbconnect.php"); + +### links used for testing +#$link=mysql_connect("10.10.10.15", "cron", "1234"); +#mysql_select_db("asterisk"); +#$WeBServeRRooT = '/home/www/htdocs'; + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +if (isset($_GET["submit_file"])) {$submit_file=$_GET["submit_file"];} + elseif (isset($_POST["submit_file"])) {$submit_file=$_POST["submit_file"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["leadfile_name"])) {$leadfile_name=$_GET["leadfile_name"];} + elseif (isset($_POST["leadfile_name"])) {$leadfile_name=$_POST["leadfile_name"];} +if (isset($_GET["file_layout"])) {$file_layout=$_GET["file_layout"];} + elseif (isset($_POST["file_layout"])) {$file_layout=$_POST["file_layout"];} +if (isset($_GET["OK_to_process"])) {$OK_to_process=$_GET["OK_to_process"];} + elseif (isset($_POST["OK_to_process"])) {$OK_to_process=$_POST["OK_to_process"];} +if (isset($_GET["vendor_lead_code_field"])) {$vendor_lead_code_field=$_GET["vendor_lead_code_field"];} + elseif (isset($_POST["vendor_lead_code_field"])) {$vendor_lead_code_field=$_POST["vendor_lead_code_field"];} +if (isset($_GET["source_id_field"])) {$source_id_field=$_GET["source_id_field"];} + elseif (isset($_POST["source_id_field"])) {$source_id_field=$_POST["source_id_field"];} +if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} + elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} +if (isset($_GET["phone_code_field"])) {$phone_code_field=$_GET["phone_code_field"];} + elseif (isset($_POST["phone_code_field"])) {$phone_code_field=$_POST["phone_code_field"];} +if (isset($_GET["phone_number_field"])) {$phone_number_field=$_GET["phone_number_field"];} + elseif (isset($_POST["phone_number_field"])) {$phone_number_field=$_POST["phone_number_field"];} +if (isset($_GET["title_field"])) {$title_field=$_GET["title_field"];} + elseif (isset($_POST["title_field"])) {$title_field=$_POST["title_field"];} +if (isset($_GET["first_name_field"])) {$first_name_field=$_GET["first_name_field"];} + elseif (isset($_POST["first_name_field"])) {$first_name_field=$_POST["first_name_field"];} +if (isset($_GET["middle_initial_field"])) {$middle_initial_field=$_GET["middle_initial_field"];} + elseif (isset($_POST["middle_initial_field"])) {$middle_initial_field=$_POST["middle_initial_field"];} +if (isset($_GET["last_name_field"])) {$last_name_field=$_GET["last_name_field"];} + elseif (isset($_POST["last_name_field"])) {$last_name_field=$_POST["last_name_field"];} +if (isset($_GET["address1_field"])) {$address1_field=$_GET["address1_field"];} + elseif (isset($_POST["address1_field"])) {$address1_field=$_POST["address1_field"];} +if (isset($_GET["address2_field"])) {$address2_field=$_GET["address2_field"];} + elseif (isset($_POST["address2_field"])) {$address2_field=$_POST["address2_field"];} +if (isset($_GET["address3_field"])) {$address3_field=$_GET["address3_field"];} + elseif (isset($_POST["address3_field"])) {$address3_field=$_POST["address3_field"];} +if (isset($_GET["city_field"])) {$city_field=$_GET["city_field"];} + elseif (isset($_POST["city_field"])) {$city_field=$_POST["city_field"];} +if (isset($_GET["state_field"])) {$state_field=$_GET["state_field"];} + elseif (isset($_POST["state_field"])) {$state_field=$_POST["state_field"];} +if (isset($_GET["province_field"])) {$province_field=$_GET["province_field"];} + elseif (isset($_POST["province_field"])) {$province_field=$_POST["province_field"];} +if (isset($_GET["postal_code_field"])) {$postal_code_field=$_GET["postal_code_field"];} + elseif (isset($_POST["postal_code_field"])) {$postal_code_field=$_POST["postal_code_field"];} +if (isset($_GET["country_code_field"])) {$country_code_field=$_GET["country_code_field"];} + elseif (isset($_POST["country_code_field"])) {$country_code_field=$_POST["country_code_field"];} +if (isset($_GET["gender_field"])) {$gender_field=$_GET["gender_field"];} + elseif (isset($_POST["gender_field"])) {$gender_field=$_POST["gender_field"];} +if (isset($_GET["date_of_birth_field"])) {$date_of_birth_field=$_GET["date_of_birth_field"];} + elseif (isset($_POST["date_of_birth_field"])) {$date_of_birth_field=$_POST["date_of_birth_field"];} +if (isset($_GET["alt_phone_field"])) {$alt_phone_field=$_GET["alt_phone_field"];} + elseif (isset($_POST["alt_phone_field"])) {$alt_phone_field=$_POST["alt_phone_field"];} +if (isset($_GET["email_field"])) {$email_field=$_GET["email_field"];} + elseif (isset($_POST["email_field"])) {$email_field=$_POST["email_field"];} +if (isset($_GET["security_phrase_field"])) {$security_phrase_field=$_GET["security_phrase_field"];} + elseif (isset($_POST["security_phrase_field"])) {$security_phrase_field=$_POST["security_phrase_field"];} +if (isset($_GET["comments_field"])) {$comments_field=$_GET["comments_field"];} + elseif (isset($_POST["comments_field"])) {$comments_field=$_POST["comments_field"];} +if (isset($_GET["list_id_override"])) {$list_id_override=$_GET["list_id_override"];} + elseif (isset($_POST["list_id_override"])) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); + +# $country_field=$_GET["country_field"]; if (!$country_field) {$country_field=$_POST["country_field"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('new_listloader_superL.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +function macfontfix($fontsize) { + + $browser = getenv("HTTP_USER_AGENT"); + $pctype = explode("(", $browser); + if (ereg("Mac",$pctype[1])) { + /* Browser is a Mac. If not Netscape 6, raise fonts */ + + $blownbrowser = explode('/', $browser); + $ver = explode(' ', $blownbrowser[1]); + $ver = $ver[0]; + if ($ver >= 5.0) return $fontsize; else return ($fontsize+2); + + } else return $fontsize; /* Browser is not a Mac - don't touch fonts */ +} + +echo "\n"; + +?> + + + +VICIDIAL ADMIN: Super Lead Loader + + +
method=post onSubmit="ParseFileName()" enctype="multipart/form-data"> + + +
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_lead_filters order by lead_filter_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
LEAD FILTER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1]MODIFY
\n"; +} + + +###################### +# ADD=100000000 display all call times +###################### +if ($ADD==100000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_call_times order by call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
CALL TIME LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[3] $row[4] MODIFY
\n"; +} + +###################### +# ADD=1000000000 display all state call times +###################### +if ($ADD==1000000000) +{ +echo "
\n"; + + echo ""; + + $stmt="SELECT * from vicidial_state_call_times order by state_call_time_id"; + $rslt=mysql_query($stmt, $link); + $filters_to_print = mysql_num_rows($rslt); + +echo "
STATE CALL TIME LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($filters_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2] $row[3] $row[4] MODIFY
\n"; +} + + + + + +echo "
\n"; + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BUILD: $build
\n"; + + +?> + + +
+ + + +1) + { + $g=0; + $p='13'; + $GMT_gmt[0] = ''; + $GMT_hour[0] = ''; + $GMT_day[0] = ''; + while ($p > -13) + { + $pzone=3600 * $p; + $pmin=(gmdate("i", time() + $pzone)); + $phour=( (gmdate("G", time() + $pzone)) * 100); + $pday=gmdate("w", time() + $pzone); + $tz = sprintf("%.2f", $p); + $GMT_gmt[$g] = "$tz"; + $GMT_day[$g] = "$pday"; + $GMT_hour[$g] = ($phour + $pmin); + $p = ($p - 0.25); + $g++; + } + + $stmt="SELECT * FROM vicidial_call_times where call_time_id='$local_call_time';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $Gct_default_start = "$rowx[3]"; + $Gct_default_stop = "$rowx[4]"; + $Gct_sunday_start = "$rowx[5]"; + $Gct_sunday_stop = "$rowx[6]"; + $Gct_monday_start = "$rowx[7]"; + $Gct_monday_stop = "$rowx[8]"; + $Gct_tuesday_start = "$rowx[9]"; + $Gct_tuesday_stop = "$rowx[10]"; + $Gct_wednesday_start = "$rowx[11]"; + $Gct_wednesday_stop = "$rowx[12]"; + $Gct_thursday_start = "$rowx[13]"; + $Gct_thursday_stop = "$rowx[14]"; + $Gct_friday_start = "$rowx[15]"; + $Gct_friday_stop = "$rowx[16]"; + $Gct_saturday_start = "$rowx[17]"; + $Gct_saturday_stop = "$rowx[18]"; + $Gct_state_call_times = "$rowx[19]"; + + $ct_states = ''; + $ct_state_gmt_SQL = ''; + $ct_srs=0; + $b=0; + if (strlen($Gct_state_call_times)>2) + { + $state_rules = explode('|',$Gct_state_call_times); + $ct_srs = ((count($state_rules)) - 2); + } + while($ct_srs >= $b) + { + if (strlen($state_rules[$b])>1) + { + $stmt="SELECT * from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Gstate_call_time_id = "$row[0]"; + $Gstate_call_time_state = "$row[1]"; + $Gsct_default_start = "$row[4]"; + $Gsct_default_stop = "$row[5]"; + $Gsct_sunday_start = "$row[6]"; + $Gsct_sunday_stop = "$row[7]"; + $Gsct_monday_start = "$row[8]"; + $Gsct_monday_stop = "$row[9]"; + $Gsct_tuesday_start = "$row[10]"; + $Gsct_tuesday_stop = "$row[11]"; + $Gsct_wednesday_start = "$row[12]"; + $Gsct_wednesday_stop = "$row[13]"; + $Gsct_thursday_start = "$row[14]"; + $Gsct_thursday_stop = "$row[15]"; + $Gsct_friday_start = "$row[16]"; + $Gsct_friday_stop = "$row[17]"; + $Gsct_saturday_start = "$row[18]"; + $Gsct_saturday_stop = "$row[19]"; + + $ct_states .="'$Gstate_call_time_state',"; + + $r=0; + $state_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gsct_sunday_start==0) and ($Gsct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_sunday_start) and ($GMT_hour[$r]<$Gsct_sunday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gsct_monday_start==0) and ($Gsct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_monday_start) and ($GMT_hour[$r]<$Gsct_monday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gsct_tuesday_start==0) and ($Gsct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_tuesday_start) and ($GMT_hour[$r]<$Gsct_tuesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gsct_wednesday_start==0) and ($Gsct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_wednesday_start) and ($GMT_hour[$r]<$Gsct_wednesday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gsct_thursday_start==0) and ($Gsct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_thursday_start) and ($GMT_hour[$r]<$Gsct_thursday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gsct_friday_start==0) and ($Gsct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_friday_start) and ($GMT_hour[$r]<$Gsct_friday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gsct_saturday_start==0) and ($Gsct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gsct_default_start) and ($GMT_hour[$r]<$Gsct_default_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gsct_saturday_start) and ($GMT_hour[$r]<$Gsct_saturday_stop) ) + {$state_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + $state_gmt = "$state_gmt'99'"; + $ct_state_gmt_SQL .= "or (state='$Gstate_call_time_state' and gmt_offset_now IN($state_gmt)) "; + } + + $b++; + } + if (strlen($ct_states)>2) + { + $ct_states = eregi_replace(",$",'',$ct_states); + $ct_statesSQL = "and state NOT IN($ct_states)"; + } + else + { + $ct_statesSQL = ""; + } + + $r=0; + $default_gmt=''; + while($r < $g) + { + if ($GMT_day[$r]==0) #### Sunday local time + { + if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==1) #### Monday local time + { + if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==2) #### Tuesday local time + { + if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==3) #### Wednesday local time + { + if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==4) #### Thursday local time + { + if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==5) #### Friday local time + { + if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + if ($GMT_day[$r]==6) #### Saturday local time + { + if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) + { + if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + else + { + if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) + {$default_gmt.="'$GMT_gmt[$r]',";} + } + } + $r++; + } + + $default_gmt = "$default_gmt'99'"; + $all_gmtSQL = "(gmt_offset_now IN($default_gmt) $ct_statesSQL) $ct_state_gmt_SQL"; + + $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN('$dial_status_a','$dial_status_b','$dial_status_c','$dial_status_d','$dial_status_e') and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; + #$DB=1; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $rslt_rows = mysql_num_rows($rslt); + if ($rslt_rows) + { + $rowx=mysql_fetch_row($rslt); + $active_leads = "$rowx[0]"; + } + else {$active_leads = '0';} + + echo "This campaign has $active_leads leads to be dialed in those lists\n"; + } + else + { + echo "no active lists selected for this campaign\n"; + } + } +else + { + echo "no active lists selected for this campaign\n"; + } +##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### +} +?> diff --git a/agc_2-X/trunk/VICIDIAL_web/admin_modify_lead.php b/agc_2-X/trunk/VICIDIAL_web/admin_modify_lead.php new file mode 100644 index 00000000..9dad4f62 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/admin_modify_lead.php @@ -0,0 +1,476 @@ + LICENSE: GPLv2 +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + +### AST GUI database administration modify lead in vicidial_list +### admin_modify_lead.php + +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead + +# CHANGES +# +# 60419-1705 - Added ability to change lead callback record from USERONLY to ANYONE or USERONLY-user +# 60421-1459 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60609-1112 - Added DNC list addition if status changed to DNC +# 60619-1539 - Added variable filtering to eliminate SQL injection attack threat +# + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Lead record modification + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "information modified

\n"; + echo "\n"; + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + +} +else +{ + + if ($CBchangeUSERtoANY == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to ANYONE
\n"; + } + if ($CBchangeUSERtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record user changed to $CBuser
\n"; + } + if ($CBchangeANYtoUSER == 'YES') + { + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + } + + + + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $dispo = "$row[3]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') ) + { + ### find any vicidial_callback records for this lead + $stmt="select * from vicidial_callbacks where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $CB_to_print = mysql_num_rows($rslt); + $rowx=mysql_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + } + else + { + echo "
No Callback records found
\n"; + } + } + + + + + + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + +echo "

\n"; + +echo "
\n"; + +echo "CALLS TO THIS LEAD:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where lead_id='" . mysql_real_escape_string($lead_id) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD
$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]
\n"; + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/admin_search_lead.php b/agc_2-X/trunk/VICIDIAL_web/admin_search_lead.php new file mode 100644 index 00000000..a727e3a1 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/admin_search_lead.php @@ -0,0 +1,224 @@ + LICENSE: GPLv2 +### +### AST GUI database administration search for lead info +### admin_modify_lead.php +# +# this is the administration lead information modifier screen, the administrator just needs to enter the leadID and then they can view and modify the information in the record for that lead +# +# changes: +# 60620-1055 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# - Changed results to multi-record +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name,modify_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[0]; + $LOGmodify_leads =$row[1]; + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +?> + + + +VICIDIAL ADMIN: Lead Search + +Lead Lookup + + + +
\n"; + echo "
\n"; + echo "\n"; + echo "Please enter a:
Vendor ID(vendor lead code): or \n"; + echo "
a Home Phone Number: or\n"; + echo "
a lead ID:

\n"; + echo "
\n"; + echo "\n
\n"; + echo "\n"; + exit; + } + +else + { + + if ($vendor_id) + { + $stmt="SELECT * from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' order by modify_date desc limit 1000"; + } + else + { + if ($phone) + { + $stmt="SELECT * from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' order by modify_date desc limit 1000"; + } + else + { + if ($lead_id) + { + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' order by modify_date desc limit 1000"; + } + else + { + print "ERROR: you must search for something! Go back and search for something"; + exit; + } + } + } + if ($DB) + { + echo "\n\n$stmt\n\n"; + } + + $rslt=mysql_query($stmt, $link); + $results_to_print = mysql_num_rows($rslt); + if ($results_to_print < 1) + { + echo date("l F j, Y G:i:s A"); + echo "\n

\n"; + echo "The search variables you entered are not active in the system

\n"; + echo "Please go back and double check the information you entered and submit again\n"; + echo "
\n"; + echo "\n"; + exit; + } + else + { + echo "RESULTS: $results_to_print

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysql_fetch_row($rslt); + $o++; + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD IDSTATUSVENDOR IDLAST AGENTLIST IDPHONENAMECITYSECURITYLAST CALL
$o$row[0]$row[3]$row[5]$row[4]$row[7]$row[11]$row[13] $row[15]$row[19]$row[28]$row[2]
\n"; + } + } + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\nNEW SEARCH"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; + + +?> + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/closer-fronter_popup.php b/agc_2-X/trunk/VICIDIAL_web/closer-fronter_popup.php new file mode 100644 index 00000000..84d31c97 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/closer-fronter_popup.php @@ -0,0 +1,515 @@ + LICENSE: GPLv2 +### +# this is the closer popup of a specific call that starts recording the call and allows you to go and fetch info on that caller in the local CRM system. +# CHANGES +# +# 60620-1020 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +# $ext_context = 'default'; defined in dbconnect file + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name from vicidial_users where user='$user' and pass='$pass'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + if ( (strlen($customer_zap_channel)>2) and (eregi('zap',$customer_zap_channel)) ) + { + echo "\n\n"; + echo "\n\n"; + + } + else + { + echo "Bad channel: $customer_zap_channel\n"; + echo "Make sure the Zap channel is live and try again\n"; + exit; + } + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "VICIDIAL FRONTER-CLOSER: Popup\n"; +echo "\n"; + +if (eregi('CL_UNIV',$channel_group)) + { + ?> + + \n"; + echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n"; + echo "\n"; + } +?> + + +
+ + 0) +{ + +# $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RZ$FILE_datetime$user"; + + ### insert a NEW record to the vicidial_manager table to be processed + + $channel = $customer_zap_channel; + $channel = eregi_replace('Zap/', "", $channel); + $SIPexten = eregi_replace('SIP/', "", $SIPexten); + $filename = "$REC_TIME$US$SIPexten"; + +# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: Zap/$channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + # Local/78600098@demo-6617,2 + + $stmt = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Originate','$DTqueryCID','Channel: $local_DEF$conf_silent_prefix" . mysql_real_escape_string($session_id) . "$local_AMP$ext_context','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: " . mysql_real_escape_string($filename) . "','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('Zap/" . mysql_real_escape_string($channel) . "','" . mysql_real_escape_string($server_ip) . "','SIP/" . mysql_real_escape_string($SIPexten) . "','$NOW_TIME','$STARTtime','" . mysql_real_escape_string($filename) . "')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='" . mysql_real_escape_string($filename) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + + echo "Recording command sent for channel $channel - $filename - $recording_id       $NOW_TIME\n

\n"; + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "Call Referred by: $user - $full_name\n

\n"; + + $url = "http://10.10.99.2/vicidial/closer_dispo.php?lead_id=$lead_id&channel=$channel&server_ip=$server_ip&extension=$SIPexten&call_began=$STARTtime&parked_time=$parked_time&DB=$DB"; + + echo "View Customer Info and Disposition Call\n

\n"; + + + +# $stmt="UPDATE park_log set grab_time='$NOW_TIME',status='TALKING',extension='$extension',user='$user' where parked_time='$parked_time' and server_ip='$server_ip' and channel='$channel'"; +# if ($DB) {echo "|$stmt|\n";} +# $fp = fopen ("./closer_SQL_updates.txt", "a"); +# fwrite ($fp, "$date|$user|$stmt|\n"); +# fclose($fp); +# $rslt=mysql_query($stmt, $link); + +########################################################################################### +####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX +########################################################################################### +if (eregi('CL_TEST',$channel_group)) + { + echo "GALLERIA TEST CLOSER GROUP: $channel_group\n"; + + $stmt="SELECT user,phone_number from vicidial_list where lead_id='" . mysql_real_escape_string($parked_by) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $fronter=$row[0]; + $search_phone=$row[1]; + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ -- INTERNAL CALL GALLERIA FRONT --
\n"; + $group_color='#99FF99'; + } + if (eregi('CL_GALLER2',$channel_group)) + { + echo "
-- TouchAsia CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER3',$channel_group)) + { + echo "
-- DebitSupplies CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER4',$channel_group)) + { + echo "
-- Vishnu CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
New Search
Reservation Number:
Confirmation #:
Phone #:


Back
+ +
+ + + Close this window\n

\n"; +} +else +{ + echo "Record command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Please go back and try again\n

\n"; +# echo "
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/closer-fronter_popup2.php b/agc_2-X/trunk/VICIDIAL_web/closer-fronter_popup2.php new file mode 100644 index 00000000..2ecd56d1 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/closer-fronter_popup2.php @@ -0,0 +1,430 @@ + LICENSE: GPLv2 +### +# this is the closer popup of a specific call that starts recording the call and allows you to go and fetch info on that caller in the local CRM system. +# CHANGES +# +# 60620-1025 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +#$DB = '1'; # DEBUG override +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; +$parked_time = $STARTtime; + +# $ext_context = 'default'; defined in dbconnect file +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if (!$auth) + { + if ( (strlen($PHP_AUTH_USER)>1) and ( (eregi("tsr",$PHP_AUTH_PW)) or (eregi("sales",$PHP_AUTH_PW)) ) ) + { + $auth=1; + $user = $PHP_AUTH_USER; + $pass = $PHP_AUTH_PW; + } + } + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER - $user - $PHP_AUTH_USER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name from vicidial_users where user='$user' and pass='$pass'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + if ( (strlen($customer_zap_channel)>2) and ( (eregi('zap',$customer_zap_channel)) or (eregi('iax',$customer_zap_channel)) ) ) + { + echo "\n\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + } + else + { + echo "Bad channel: $customer_zap_channel\n"; + echo "Make sure the Zap channel is live and try again\n"; + exit; + } + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "VICIDIAL FRONTER-CLOSER: Popup\n"; +echo "\n"; + +if (eregi('CL_UNIV',$channel_group)) + { + ?> + + \n"; + echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n"; + echo "\n"; + } +?> + + +
+ + 0) +{ + +# $stmt="DELETE from parked_channels where server_ip='$server_ip' and parked_time='$parked_time' and channel='$channel' LIMIT 1"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RZ$FILE_datetime$user"; + + ### insert a NEW record to the vicidial_manager table to be processed + + $channel = $customer_zap_channel; +# $channel = eregi_replace('Zap/', "", $channel); + $SIPexten = eregi_replace('SIP/', "", $SIPexten); + $filename = "$REC_TIME$US$SIPexten"; + +# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: Zap/$channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + + # Local/78600098@demo-6617,2 + + $stmt = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Originate','$DTqueryCID','Channel: $local_DEF$conf_silent_prefix" . mysql_real_escape_string($session_id) . "$local_AMP$ext_context','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: " . mysql_real_escape_string($filename) . "','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','" . mysql_real_escape_string($server_ip) . "','SIP/" . mysql_real_escape_string($SIPexten) . "','$NOW_TIME','$STARTtime','" . mysql_real_escape_string($filename) . "')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='" . mysql_real_escape_string($filename) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + + echo "Recording command sent for channel $channel - $filename - $recording_id       $NOW_TIME\n

\n"; + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($fronter) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "Call Referred by: $fronter - $full_name\n

\n"; + + $url = "http://10.10.10.196/vicidial/closer_dispo.php?lead_id=$lead_id&channel=$channel&server_ip=$server_ip&extension=$SIPexten&call_began=$STARTtime&parked_time=$parked_time&DB=$DB"; + + echo "View Customer Info and Disposition Call\n

\n"; + + + $stmt="SELECT group_name,group_color from vicidial_inbound_groups where group_id='" . mysql_real_escape_string($channel_group) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $group_name = $row[0]; + $group_color = $row[1]; + + echo "
\n"; + echo "
$channel_group - $group_name

\n\n"; + +########################################################################################### +####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX +########################################################################################### + +if (eregi('CL',$channel_group)) + { + if (strlen($phone) > 9) {$search_phone = $phone;} + if ( (strlen($search_phone) < 10) or (strlen($fronter) < 1) ) + { + echo "\n"; + $stmt="SELECT user,phone_number from vicidial_list where lead_id='$parked_by';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($fronter) < 1) {$fronter=$row[0];} + if (strlen($search_phone) < 10) {$search_phone=$row[1];} + } + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
New Search
Reservation Number:
Confirmation #:
Phone #:


Back
+ +
+ + + Close this window\n

\n"; +} +else +{ + echo "Record command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Please go back and try again\n

\n"; +# echo "
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/closer.php b/agc_2-X/trunk/VICIDIAL_web/closer.php new file mode 100644 index 00000000..59599edb --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/closer.php @@ -0,0 +1,353 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) +# CHANGES +# +# 60620-1032 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["group_selected"])) {$group_selected=$_GET["group_selected"];} + elseif (isset($_POST["group_selected"])) {$group_selected=$_POST["group_selected"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["groupselect"])) {$groupselect=$_GET["groupselect"];} + elseif (isset($_POST["groupselect"])) {$groupselect=$_POST["groupselect"];} +if (isset($_GET["PHONE_LOGIN"])) {$PHONE_LOGIN=$_GET["PHONE_LOGIN"];} + elseif (isset($_POST["PHONE_LOGIN"])) {$PHONE_LOGIN=$_POST["PHONE_LOGIN"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["debugvars"])) {$debugvars=$_GET["debugvars"];} + elseif (isset($_POST["debugvars"])) {$debugvars=$_POST["debugvars"];} +if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];} + elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './closer_popup.php'; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + +$color_class[0] = 'green'; +$color_class[1] = 'red'; +$color_class[2] = 'blue'; +$color_class[3] = 'purple'; +$color_class[4] = 'orange'; +$color_class[5] = 'green'; +$color_class[6] = 'red'; +$color_class[7] = 'blue'; +$color_class[8] = 'purple'; +$color_class[9] = 'orange'; +?> + + + + + +VICIDIAL CLOSER: Main + + +
+ + 0) + { + $stmt="SELECT dialplan_number,server_ip from phones where extension='" . mysql_real_escape_string($extension) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dialplan_number=$row[0]; + $server_ip=$row[1]; + + if (!$group_selected) + { + $stmt="select distinct channel_group from park_log;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $groups_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + echo "
Please select the groups you want to pick calls up from:
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Inbound Call Groups:
\n"; + $o=0; + while ($groups_to_print > $o) + { + $group_form_print = sprintf("%-20s", $groups[$o]); + echo "$group_form_print
\n"; + $o++; + } + echo "
\n"; + echo "\n"; + echo "


\n"; + } + else + { + $o=0; + while($o < $group_selected) + { + $form_groups = "$form_groups&groupselect[$o]=$groupselect[$o]"; + $o++; + } + + $stmt="INSERT INTO vicidial_user_log values('','" . mysql_real_escape_string($user) . "','LOGIN','CLOSER','$NOW_TIME','$STARTtime');"; + $rslt=mysql_query($stmt, $link); + + echo "\n"; + echo"\n"; + + echo "extension found, forwarding you to closer page, please wait 3 seconds...
\n"; + } + + } + else + { + echo "The extension you entered does not exist, please try again
\n"; + echo "
Please enter your phone_ID: \n"; + echo "\n"; + echo "phone station ID:   \n"; + echo "\n"; + echo "


\n"; + } + + } + else + { + echo "
Please enter your phone_ID: \n"; + echo "\n"; + echo "phone station ID:   \n"; + echo "\n"; + echo "


\n"; + } + +exit; + +} + +$o=0; +while($o < $group_selected) +{ + $listen_groups = "$listen_groups     $groupselect[$o]"; + $form_groups = "$form_groups&groupselect[$o]=$groupselect[$o]"; + $o++; +} + + +echo "\n"; +echo"\n"; + +#CHANNEL SERVER CHANNEL_GROUP EXTENSION PARKED_BY PARKED_TIME +#---------------------------------------------------------------------------------------------- +#Zap/73-1 10.10.11.11 IN_800_TPP_CS TPPpark 7275338730 2004-04-22 12:41:00 + + + +echo "$NOW_TIME           $PHP_AUTH_USER - $fullname - CALLS SENT TO: $dialplan_number

\n"; + +echo "Click on the channel below that you would like to have directed to your phone
\n"; + +echo "
\n";
+echo "CHANNEL    SERVER        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME         \n";
+echo "---------------------------------------------------------------------------------------------- \n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='" . mysql_real_escape_string($server_ip) . "'";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='" . mysql_real_escape_string($server_ip) . "' and channel_group LIKE \"CL_%\" order by channel_group,parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$park_extension =	sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		$G='';   $EG='';
+		$o=0;
+		$with_color=0;
+		while($o < $group_selected)
+			{
+				if (eregi("$groupselect[$o]",$channel_group))
+					{
+					$G=""; $EG='';
+					$with_color++;
+					}
+				$o++;
+			}
+		if ($with_color)
+			{
+			if (eregi('CL_GAL',$row[2]))
+				{
+				echo "$G$channel$server$channel_group$park_extension                     $parked_time $EG\n";
+				}
+			else
+				{
+				echo "$G$channel$server$channel_group$park_extension$parked_by$parked_time $EG\n";
+				}
+			}
+#	
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "********************************************************************************************** \n";
+	echo "********************************************************************************************** \n";
+	echo "*************************************** NO PARKED CALLS ************************************** \n";
+	echo "********************************************************************************************** \n";
+	echo "********************************************************************************************** \n";
+	}
+
+echo "  \n\n";
+echo "looking for calls on these groups:\n";
+$o=0;
+while($o < $group_selected)
+{
+	$group_print =		sprintf("%-20s", $groupselect[$o]);
+	echo "             - $group_print\n";
+	$o++;
+}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/closer_dispo.php b/agc_2-X/trunk/VICIDIAL_web/closer_dispo.php new file mode 100644 index 00000000..54e61219 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/closer_dispo.php @@ -0,0 +1,329 @@ + LICENSE: GPLv2 +### +# this is the closer disposition screen of a call that has been grabbed. This allows the closer to modify customer information and disposition the call +# CHANGES +# +# 60619-1641 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL CLOSER: Call Disposition +\n"; +?> + + +
+ + 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','" . mysql_real_escape_string($call_began) . "','$STARTtime','" . mysql_real_escape_string($call_length) . "','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from live_channels where server_ip='$server_ip' and channel='" . mysql_real_escape_string($channel) . "' and extension like \"%" . mysql_real_escape_string($extension) . "%\""; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $parked_count = $row[0]; + + if ($parked_count > 0) + { + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Hangup','$DTqueryCID','Channel: " . mysql_real_escape_string($channel) . "','','','','','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Hangup command sent for channel $channel       $NOW_TIME\n

\n"; + + echo "\n"; + } + else + { + echo "Hangup command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "
\n"; + } +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Campaign ID: $campaign_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/closer_popup.php b/agc_2-X/trunk/VICIDIAL_web/closer_popup.php new file mode 100644 index 00000000..e12f02c3 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/closer_popup.php @@ -0,0 +1,453 @@ + LICENSE: GPLv2 +### +# this is the closer popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# CHANGES +# +# 60620-1029 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["group_selected"])) {$group_selected=$_GET["group_selected"];} + elseif (isset($_POST["group_selected"])) {$group_selected=$_POST["group_selected"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["groupselect"])) {$groupselect=$_GET["groupselect"];} + elseif (isset($_POST["groupselect"])) {$groupselect=$_POST["groupselect"];} +if (isset($_GET["PHONE_LOGIN"])) {$PHONE_LOGIN=$_GET["PHONE_LOGIN"];} + elseif (isset($_POST["PHONE_LOGIN"])) {$PHONE_LOGIN=$_POST["PHONE_LOGIN"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["debugvars"])) {$debugvars=$_GET["debugvars"];} + elseif (isset($_POST["debugvars"])) {$debugvars=$_POST["debugvars"];} +if (isset($_GET["parked_by"])) {$parked_by=$_GET["parked_by"];} + elseif (isset($_POST["parked_by"])) {$parked_by=$_POST["parked_by"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +#$DB=1; +$US = '_'; +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$REC_TIME = date("Ymd-His"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "VICIDIAL CLOSER: Popup\n"; +echo "\n"; + +if (eregi('CL_UNIV',$channel_group)) + { + ?> + + \n"; + echo "function WaitFirefix() {setTimeout(document.forms[0].search_phone.focus(), 1000)}\n"; + echo "\n"; + } +?> + + +
+ + 0) +{ + $stmt="DELETE from parked_channels where server_ip='" . mysql_real_escape_string($server_ip) . "' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + + #$monitor_channel = eregi_replace('Zap/', "", $channel); + $monitor_channel = eregi_replace('-1', "", $channel); + $SIPexten = $extension; + $filename = "$REC_TIME$US$SIPexten"; + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + +# $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Monitor','$DTqueryCID','Channel: $monitor_channel','File: $filename','Callerid: $DTqueryCID','','','','','','','')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + +# $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$monitor_channel','$server_ip','SIP/$SIPexten','$NOW_TIME','$STARTtime','$filename')"; +# if ($DB) {echo "|$stmt|\n";} +# $rslt=mysql_query($stmt, $link); + +# $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; +# $rslt=mysql_query($stmt, $link); +# if ($DB) {echo "$stmt\n";} +# $row=mysql_fetch_row($rslt); +# $recording_id = $row[0]; + +# echo "Recording command sent for channel $channel - $filename - $recording_id
\n"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for channel $channel       $NOW_TIME\n

\n"; + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($parked_by) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + echo "Call Referred by: $parked_by - $full_name\n

\n"; + + $url = "http://10.10.10.196/vicidial/closer_dispo.php?lead_id=$parked_by&channel=$channel&server_ip=$server_ip&extension=$extension&call_began=$STARTtime&parked_time=$parked_time&DB=$DB"; + + echo "View Customer Info and Disposition Call\n

\n"; + + + + $stmt="UPDATE park_log set grab_time='$NOW_TIME',status='TALKING',extension='" . mysql_real_escape_string($extension) . "',user='$PHP_AUTH_USER' where parked_time='" . mysql_real_escape_string($parked_time) . "' and server_ip='" . mysql_real_escape_string($server_ip) . "' and channel='" . mysql_real_escape_string($channel) . "'"; + if ($DB) {echo "|$stmt|\n";} + $fp = fopen ("./closer_SQL_updates.txt", "a"); + fwrite ($fp, "$date|$PHP_AUTH_USER|$stmt|\n"); + fclose($fp); + + + $rslt=mysql_query($stmt, $link); + +########################################################################################### +####### HERE IS WHERE YOU DEFINE DIFFERENT CONTENTS DEPENDING UPON THE CHANNEL_GROUP PREFIX +########################################################################################### +if (eregi('CL_TEST',$channel_group)) + { + echo "GALLERIA TEST CLOSER GROUP: $channel_group\n"; + + $stmt="SELECT user,phone_number from vicidial_list where lead_id='" . mysql_real_escape_string($parked_by) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $fronter=$row[0]; + $search_phone=$row[1]; + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ -- INTERNAL CALL GALLERIA FRONT --
\n"; + $group_color='#99FF99'; + } + if (eregi('CL_GALLER2',$channel_group)) + { + echo "
-- TouchAsia CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER3',$channel_group)) + { + echo "
-- DebitSupplies CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + if (eregi('CL_GALLER4',$channel_group)) + { + echo "
-- Vishnu CALL Simple Escapes FRONT --
\n"; + $group_color='#FF9999'; + } + + + ?> +
+ + + + + + + + + + + + + + + +
COF MW Customer Search
Phone number
+
+

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
New Search
Reservation Number:
Confirmation #:
Phone #:


Back
+ +
+ + + Close this window\n

\n"; +} +else +{ + echo "Redirect command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/count.htm b/agc_2-X/trunk/VICIDIAL_web/count.htm new file mode 100644 index 00000000..51f8a361 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/count.htm @@ -0,0 +1 @@ + diff --git a/agc_2-X/trunk/VICIDIAL_web/dbconnect.php b/agc_2-X/trunk/VICIDIAL_web/dbconnect.php new file mode 100644 index 00000000..88078fc7 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/dbconnect.php @@ -0,0 +1,20 @@ + LICENSE: GPLv2 +# + +$link=mysql_connect("localhost", "cron", "1234"); +mysql_select_db("asterisk"); + +$local_DEF = 'Local/'; +$conf_silent_prefix = '7'; +$local_AMP = '@'; +$ext_context = 'demo'; +$recording_exten = '8309'; + +#$WeBServeRRooT = '/home/www/htdocs'; +$WeBServeRRooT = '/usr/local/apache2/htdocs'; +$WeBRooTWritablE = '1'; + +?> \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/group_hourly_stats.php b/agc_2-X/trunk/VICIDIAL_web/group_hourly_stats.php new file mode 100644 index 00000000..b7eb1b31 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/group_hourly_stats.php @@ -0,0 +1,252 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1014 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["date_with_hour"])) {$date_with_hour=$_GET["date_with_hour"];} + elseif (isset($_POST["date_with_hour"])) {$date_with_hour=$_POST["date_with_hour"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$date_with_hour_default = date("Y-m-d H"); +$date_no_hour_default = $TODAY; + +if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} + $date_no_hour = $date_with_hour; + $date_no_hour = eregi_replace(" ([0-9]{2})",'',$date_no_hour); +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + +# $stmt="SELECT full_name from vicidial_users where user='$user';"; +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: Group Hourly Stats +\n"; +?> + + +
+ + + + + += '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDtotal[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDday[$o] = "$row[0]"; + + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $VDcount[$o] = "$row[0]"; + $o++; + } + +echo "
  VICIDIAL ADMIN: Group Hourly Stats  
\n"; + +echo "
\n"; + +echo "TSR HOUR COUNTS: $group | $status | $date_with_hour | $date_no_hour\n"; + +echo "
\n"; +echo "\n"; + + $day_calls=0; + $hour_calls=0; + $total_calls=0; + $o=0; + while($o < $tsrs_to_print) + { + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $VDtotal[$o]); + $hour_calls = ($hour_calls + $VDcount[$o]); + $day_calls = ($day_calls + $VDday[$o]); + + $o++; + } + +echo "\n"; + + +} + +echo "
TSR ID   $status   TOTAL CALLS   $status DAY    
$VDuser[$o] $VDname[$o] $VDcount[$o] $VDtotal[$o] $VDday[$o]MODIFY | STATS
TOTAL $status $hour_calls $total_calls $day_calls
\n"; +echo "

\n"; + + + echo "
Please enter the group you want to get hourly stats for:
\n"; + echo "\n"; + echo "group:
\n"; + echo "status:   (example: XFER)
\n"; + echo "date with hour:   (example: 2004-06-25 14)
\n"; + echo "\n"; + echo "


\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/help.gif b/agc_2-X/trunk/VICIDIAL_web/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/VICIDIAL_web/help.gif differ diff --git a/agc_2-X/trunk/VICIDIAL_web/listloader.php b/agc_2-X/trunk/VICIDIAL_web/listloader.php new file mode 100644 index 00000000..920505a8 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/listloader.php @@ -0,0 +1,698 @@ + LICENSE: GPLv2 +# +# AST Web GUI lead loader from formatted file +# +# CHANGES +# 50602-1640 - First version created by Joe Johnson +# 51128-1108 - Removed PHP global vars requirement +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60616-1006 - added listID override and gmt_offset lookup while loading +# 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. +# + +$version = '1.1.12'; +$build = '60619-1652'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$leadfile=$_FILES["leadfile"]; + $LF_orig = $_FILES['leadfile']['name']; + $LF_path = $_FILES['leadfile']['tmp_name']; +$submit_file=$_GET["submit_file"]; if (!$submit_file) {$submit_file=$_POST["submit_file"];} +$list_id_override=$_GET["list_id_override"]; if (!$list_id_override) {$list_id_override=$_POST["list_id_override"];} + $list_id_override = (preg_replace("/\D/","",$list_id_override)); +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + + +#$DB=1; +#$DBX=1; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$list_id_override = ereg_replace("[^0-9]","",$list_id_override); + + +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +$admDIR = "$HTTPprotocol$server_name$script_name"; +$admDIR = eregi_replace('listloader.php','',$admDIR); +$admSCR = 'admin.php'; +$NWB = "   \"HELP\""; + + +$secX = date("U"); +$hour = date("H"); +$min = date("i"); +$sec = date("s"); +$mon = date("m"); +$mday = date("d"); +$year = date("Y"); +$isdst = date("I"); +$Shour = date("H"); +$Smin = date("i"); +$Ssec = date("s"); +$Smon = date("m"); +$Smday = date("d"); +$Syear = date("Y"); +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + ### Grab Server GMT value from the database + $stmt="SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $rslt=mysql_query($stmt, $link); + $gmt_recs = mysql_num_rows($rslt); + if ($gmt_recs > 0) + { + $row=mysql_fetch_row($rslt); + $DBSERVER_GMT = "$row[0]"; + if (strlen($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + if ($isdst) {$SERVER_GMT++;} + } + else + { + $SERVER_GMT = date("O"); + $SERVER_GMT = eregi_replace("\+","",$SERVER_GMT); + $SERVER_GMT = ($SERVER_GMT + 0); + $SERVER_GMT = ($SERVER_GMT / 100); + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +#if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + + +?> + + + + + + method=post enctype="multipart/form-data"> +
+ + + + + + + + + + + + + +
Load leads from this file:
List ID Override: (numbers only or leave blank for values in the file)
CLICK HERE TO GO TO THE SUPER LEAD LOADER (BETA VERSION)     BACK TO ADMIN
+ +document.forms[0].leadfile.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + $pulldate=date("Y-m-d H:i:s"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("./vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city = $row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) + { + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $gmt_offset = '0'; + $called_since_last_reset='N'; + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =='1') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### MEXICO ### + if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### AUSTRALIA ### + if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + + if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + print ""; +} else if (filesize($leadfile)>8388608) { + print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + diff --git a/agc_2-X/trunk/VICIDIAL_web/listloader.pl b/agc_2-X/trunk/VICIDIAL_web/listloader.pl new file mode 100644 index 00000000..753c31f7 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/listloader.pl @@ -0,0 +1,690 @@ +#!/usr/bin/perl + +### listloader.pl +### +### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 +### +# +# +# CHANGES +# 60616-1548 - Added listID override feature to force all leads into same list +# - Added gmt_offset_now lookup for each lead +# + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + } + else + { + if ($args =~ /--forcelistid=/i) + { + @data_in = split(/--forcelistid=/,$args); + $forcelistid = $data_in[1]; + print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; + } + else + {$forcelistid = '';} + } +} +### end parsing run-time options ### + + +use Spreadsheet::ParseExcel; +use Time::Local; +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$|=0; +$secX = time(); + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +$pulldate0 = "$year-$mon-$mday $hour:$min:$sec"; +$pulldate="$year-$mon-$mday $hour:$min:$sec"; +$inSD = $pulldate0; +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + + ### Grab Server values from the database + $stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBSERVER_GMT = "$record->[0]"; + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + } + } + + $LOCAL_GMT_OFF = $SERVER_GMT; + $LOCAL_GMT_OFF_STD = $SERVER_GMT; + +if ($isdst) {$LOCAL_GMT_OFF++;} +if ($DB) {print "SEED TIME $secX : $year-$mon-$mday $hour:$min:$sec LOCAL GMT OFFSET NOW: $LOCAL_GMT_OFF\n";} + + + +$total=0; $good=0; $bad=0; +print "
Processing Excel file...\n"; +open(STMT_FILE, "> listloader_stmts.txt"); + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +my($iR, $iC, $oWkS, $oWkC); + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for($iR = 0 ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { + + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user = ""; + $oWkC = $oWkS->{Cells}[$iR][0]; + if ($oWkC) {$vendor_lead_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][1]; + if ($oWkC) {$source_code=$oWkC->Value; } + $source_id=$source_code; + $oWkC = $oWkS->{Cells}[$iR][2]; + if ($oWkC) {$list_id=$oWkC->Value; } + $gmt_offset = '0'; + $called_since_last_reset='N'; + $oWkC = $oWkS->{Cells}[$iR][3]; + if ($oWkC) {$phone_code=$oWkC->Value; } + $phone_code=~s/[^0-9]//g; + $oWkC = $oWkS->{Cells}[$iR][4]; + if ($oWkC) {$phone_number=$oWkC->Value; } + $phone_number=~s/[^0-9]//g; + $USarea = substr($phone_number, 0, 3); + $oWkC = $oWkS->{Cells}[$iR][5]; + if ($oWkC) {$title=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][6]; + if ($oWkC) {$first_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][7]; + if ($oWkC) {$middle_initial=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][8]; + if ($oWkC) {$last_name=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][9]; + if ($oWkC) {$address1=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][10]; + if ($oWkC) {$address2=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][11]; + if ($oWkC) {$address3=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][12]; + if ($oWkC) {$city=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][13]; + if ($oWkC) {$state=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][14]; + if ($oWkC) {$province=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][15]; + if ($oWkC) {$postal_code=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][16]; + if ($oWkC) {$country=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][17]; + if ($oWkC) {$gender=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][18]; + if ($oWkC) {$date_of_birth=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][19]; + if ($oWkC) {$alt_phone=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][20]; + if ($oWkC) {$email=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][21]; + if ($oWkC) {$security_phrase=$oWkC->Value; } + $oWkC = $oWkS->{Cells}[$iR][22]; + if ($oWkC) {$comments=$oWkC->Value; } + $comments=~s/^\s*(.*?)\s*$/$1/; + + if (length($phone_number)>8) { + if (length($forcelistid) > 0) + { + $list_id = $forcelistid; # set list_id to override value + } + + $PC_processed=0; + ### UNITED STATES ### + if ($phone_code =~ /^1$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### MEXICO ### + if ($phone_code =~ /^52$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### AUSTRALIA ### + if ($phone_code =~ /^61$/) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + ### ALL OTHER COUNTRY CODES ### + if (!$PC_processed) + { + $stmtA = "select * from vicidial_phone_codes where country_code='$phone_code';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + $rec_countW=0; + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + { + $gmt_offset = $recordA->[4]; $gmt_offset =~ s/\+| //gi; + $dst = $recordA->[5]; + $dst_range = $recordA->[6]; + $PC_processed++; + } + } + } + + ### Find out if DST to raise the gmt offset ### + $AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); + $AC_localtime = ($secX + (3600 * $AC_GMT_diff)); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($AC_localtime); + $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";} + $dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + + $AC_processed=0; + if ( (!$AC_processed) && ($dst_range =~ /FSA-LSO/) ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + &USA_dstcalc; + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSM-LSO/) ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + &GBR_dstcalc; + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /LSO-LSM/) ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + &AUS_dstcalc; + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-LSM/) ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + &AUST_dstcalc; + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } + if ( (!$AC_processed) && ($dst_range =~ /FSO-TSM/) ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + &NZL_dstcalc; + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } + if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + sleep(1); +# flush(); + } + } +} + +if ($multi_insert_counter > 0) { + $stmtZ = "INSERT INTO vicidial_list values ".substr($multistmt, 0, -1).";"; + $dbhA->query("$stmtZ"); + print STMT_FILE $stmtZ."\r\n"; +} + +print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + +exit; + + + + + + +sub USA_dstcalc { +#********************************************************************** +# FSA-LSO +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in April and last Sunday in October at 2 am. +# INPUTS: +# mm INTEGER Month. +# dd INTEGER Day of the month. +# ns INTEGER Seconds into the day. +# dow INTEGER Day of week (0=Sunday, to 6=Saturday) +# OPTIONAL INPUT: +# timezone INTEGER hour difference UTC - local standard time +# (DEFAULT is blank) +# make calculations based on UTC time, +# which means shift at 10:00 UTC in April +# and 9:00 UTC in October +# OUTPUT: +# INTEGER 1 = DST, 0 = not DST +#********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; return 0; + } elsif ($mm >= 5 && $mm <= 9) { + $USA_DST=1; return 1; + } elsif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 7200) { + $USA_DST=0; return 0; + } else { + $USA_DST=1; return 1; + } + } + } else { + $USA_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $USA_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; return 1; + } else { + $USA_DST=0; return 0; + } + } + } else { + $USA_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub GBR_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in March and last Sunday in October at 1 am. +#********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; return 0; + } elsif ($mm >= 4 && $mm <= 9) { + $GBR_DST=1; return 1; + } elsif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $GBR_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; return 0; + } else { + $GBR_DST=1; return 1; + } + } + } else { + $GBR_DST=1; return 1; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $GBR_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; return 1; + } else { + $GBR_DST=0; return 0; + } + } + } else { + $GBR_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + +sub AUS_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on last Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUS_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUS_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; return 1; + } else { + $AUS_DST=0; return 0; + } + } + } else { + $AUS_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; return 0; + } elsif ($dd < ($dow+25)) { + $AUS_DST=0; return 0; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; return 0; + } else { + $AUS_DST=1; return 1; + } + } + } else { + $AUS_DST=1; return 1; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub AUST_dstcalc { +#********************************************************************** +# TASMANIA ONLY +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and last Sunday in March at 1 am. +#********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $AUST_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; return 1; + } elsif ($dd < ($dow+25)) { + $AUST_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; return 1; + } else { + $AUST_DST=0; return 0; + } + } + } else { + $AUST_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $AUST_DST=0; return 0; + } else { + $AUST_DST=1; return 1; + } + } + } else { + $AUST_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc + + + + + +sub NZL_dstcalc { +#********************************************************************** +# This is returns 1 if Daylight Savings Time is in effect and 0 if +# Standard time is in effect. +# Based on first Sunday in October and third Sunday in March at 1 am. +#********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; return 1; + } elsif ($mm >= 4 && $mm <= 9) { + $NZL_DST=0; return 0; + } elsif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; return 1; + } elsif ($dd < ($dow+14)) { + $NZL_DST=1; return 1; + } elsif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; return 1; + } else { + $NZL_DST=0; return 0; + } + } + } else { + $NZL_DST=0; return 0; + } + } elsif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; return 1; + } elsif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 && $ns < (7200+$timezone*3600)) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } else { + if ($dow == 0 && $ns < 3600) { + $NZL_DST=0; return 0; + } else { + $NZL_DST=1; return 1; + } + } + } else { + $NZL_DST=0; return 0; + } + } # end of month checks +} # end of subroutine dstcalc diff --git a/agc_2-X/trunk/VICIDIAL_web/listloaderMAIN.php b/agc_2-X/trunk/VICIDIAL_web/listloaderMAIN.php new file mode 100644 index 00000000..67ee25bc --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/listloaderMAIN.php @@ -0,0 +1,79 @@ + LICENSE: GPLv2 +# +# this is the main frame page for the lead loading section. This is where you +# would upload a file and have it inserted into vicidial_list +# +# changes: +# 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT load_leads from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGload_leads =$row[0]; + + if ($LOGload_leads < 1) + { + echo "You do not have permissions to load leads\n"; + exit; + } + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + +VICIDIAL: Lead Loader Module + + + + + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/listloader_rowdisplay.pl b/agc_2-X/trunk/VICIDIAL_web/listloader_rowdisplay.pl new file mode 100644 index 00000000..fc2b4fc7 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/listloader_rowdisplay.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +### listloader_rowdisplay.pl +### +### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 +### + +use Spreadsheet::ParseExcel; +use Time::Local; +use Net::MySQL; + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +my($iR, $iC, $oWkS, $oWkC); +$var_str=""; + +foreach $oWkS (@{$oBook->{Worksheet}}) { + for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { + $oWkC = $oWkS->{Cells}[0][$iC]; + if ($oWkC) { + $var_str.=$oWkC->Value."|"; + } else { + $var_str.="|"; + } + } +} + +@xls_row=split(/\|/, $var_str); + + +$dbhA->query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1"); + +if ($dbhA->has_selected_record) { + $rslt = $dbhA->create_record_iterator(); + my @row = $rslt->get_field_names(); + for ($i=0; $i\r\n"; + print "
".$field_name.": \r\n"; + print " \r\n"; + print "
+ + + + + + + + + + + + + + + + + +
Load leads from this file:
List ID Override: (numbers only or leave blank for values in the file)
File layout to use:Standard VICIDIAL    Custom layout
        
CLICK HERE TO GO TO THE BASIC LEAD LOADER         BACK TO ADMIN
SUPER LIST LOADER-     VERSION:     BUILD:
+ + +document.forms[0].leadfile.disabled=true;document.forms[0].list_id_override.disabled=true; document.forms[0].submit_file.disabled=true; document.forms[0].reload_page.disabled=true;"; + flush(); + $total=0; $good=0; $bad=0; + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Processing $delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + # copy($leadfile, "./vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + print "
Processing Excel file... \n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

\n"; + } + # print "$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field"; + passthru("$WeBServeRRooT/vicidial/listloader_super.pl $vendor_lead_code_field,$source_id_field,$list_id_field,$phone_code_field,$phone_number_field,$title_field,$first_name_field,$middle_initial_field,$last_name_field,$address1_field,$address2_field,$address3_field,$city_field,$state_field,$province_field,$postal_code_field,$country_code_field,$gender_field,$date_of_birth_field,$alt_phone_field,$email_field,$security_phrase_field,$comments_field, --forcelistid=$list_id_override"); + } else { + # copy($leadfile, "./vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[$vendor_lead_code_field]; + $source_code = $row[$source_id_field]; + $source_id=$source_code; + $list_id = $row[$list_id_field]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[$phone_code_field]); + $phone_number = eregi_replace("[^0-9]", "", $row[$phone_number_field]); + $USarea = substr($phone_number, 0, 3); + $title = $row[$title_field]; + $first_name = $row[$first_name_field]; + $middle_initial = $row[$middle_initial_field]; + $last_name = $row[$last_name_field]; + $address1 = $row[$address1_field]; + $address2 = $row[$address2_field]; + $address3 = $row[$address3_field]; + $city =$row[$city_field]; + $state = $row[$state_field]; + $province = $row[$province_field]; + $postal_code = $row[$postal_code_field]; + $country_code = $row[$country_code_field]; + $gender = $row[$gender_field]; + $date_of_birth = $row[$date_of_birth_field]; + $alt_phone = $row[$alt_phone_field]; + $email = $row[$email_field]; + $security_phrase = $row[$security_phrase_field]; + $comments = trim($row[$comments_field]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + } + print ""; + } + +if ($leadfile && filesize($LF_path)<=8388608) { + $total=0; $good=0; $bad=0; + if ($file_layout=="standard") { + + print ""; + flush(); + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + + if (count($field_check)>=5) { + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $total=0; $good=0; $bad=0; + print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + while (!feof($file)) { + $record++; + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + + if (strlen($buffer)>0) { + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } else { + print "
ERROR: The file does not have the required number of fields to process it.
"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.xls", "r"); + + passthru("$WeBServeRRooT/vicidial/listloader.pl --forcelistid=$list_id_override"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + while($row=fgetcsv($file, 1000, ",")) { + $pulldate=date("Y-m-d H:i:s"); + $entry_date = "$pulldate"; + $modify_date = ""; + $status = "NEW"; + $user =""; + $vendor_lead_code = $row[0]; + $source_code = $row[1]; + $source_id=$source_code; + $list_id = $row[2]; + $gmt_offset = '0'; + $called_since_last_reset='N'; + $phone_code = eregi_replace("[^0-9]", "", $row[3]); + $phone_number = eregi_replace("[^0-9]", "", $row[4]); + $USarea = substr($phone_number, 0, 3); + $title = $row[5]; + $first_name = $row[6]; + $middle_initial = $row[7]; + $last_name = $row[8]; + $address1 = $row[9]; + $address2 = $row[10]; + $address3 = $row[11]; + $city =$row[12]; + $state = $row[13]; + $province = $row[14]; + $postal_code = $row[15]; + $country_code = $row[16]; + $gender = $row[17]; + $date_of_birth = $row[18]; + $alt_phone = $row[19]; + $email = $row[20]; + $security_phrase = $row[21]; + $comments = trim($row[22]); + + if (strlen($phone_number)>8) { + + if (strlen($list_id_override)>0) + { + # print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + $list_id = $list_id_override; + } + + $gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear); + + + if ($multi_insert_counter > 8) { + ### insert good deal into pending_transactions table ### + $stmtZ = "INSERT INTO vicidial_list values$multistmt('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0);"; + $rslt=mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + $multistmt=''; + $multi_insert_counter=0; + + } else { + $multistmt .= "('','$entry_date','$modify_date','$status','$user','$vendor_lead_code','$source_id','$list_id','$gmt_offset','$called_since_last_reset','$phone_code','$phone_number','$title','$first_name','$middle_initial','$last_name','$address1','$address2','$address3','$city','$state','$province','$postal_code','$country_code','$gender','$date_of_birth','$alt_phone','$email','$security_phrase','$comments',0),"; + $multi_insert_counter++; + } + + $good++; + } else { + if ($bad < 10) {print "
record $total BAD- PHONE: $phone_number ROW: |$row[0]|\n";} + $bad++; + } + $total++; + if ($total%100==0) { + print ""; + usleep(1000); + flush(); + } + } + if ($multi_insert_counter!=0) { + $stmtZ = "INSERT INTO vicidial_list values".substr($multistmt, 0, -1).";"; + mysql_query($stmtZ, $link); + if ($WeBRooTWritablE > 0) + {fwrite($stmt_file, $stmtZ."\r\n");} + } + + print "

Done
GOOD: $good       BAD: $bad       TOTAL: $total
"; + + } + print ""; + + } else { + print "
"; + flush(); + print "\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + + $rslt=mysql_query("select vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments from vicidial_list limit 1", $link); + + + if (!eregi(".csv", $leadfile_name) && !eregi(".xls", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + $buffer=fgets($file, 4096); + $tab_count=substr_count($buffer, "\t"); + $pipe_count=substr_count($buffer, "|"); + + if ($tab_count>$pipe_count) {$delimiter="\t"; $delim_name="tab";} else {$delimiter="|"; $delim_name="pipe";} + $field_check=explode($delimiter, $buffer); + flush(); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + print "
Processing $delim_name-delimited file...\n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + $buffer=rtrim(fgets($file, 4096)); + $buffer=stripslashes($buffer); + $row=explode($delimiter, eregi_replace("[\'\"]", "", $buffer)); + + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } else if (!eregi(".csv", $leadfile_name)) { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.xls"); + passthru("$WeBServeRRooT/vicidial/listloader_rowdisplay.pl"); + } else { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.csv"); + $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.csv", "r"); + $stmt_file=fopen("listloader_stmts.txt", "w"); + + print "
Processing CSV file... \n"; + + if (strlen($list_id_override)>0) + { + print "

LIST ID OVERRIDE FOR THIS FILE: $list_id_override

"; + } + + $total=0; $good=0; $bad=0; + $row=fgetcsv($file, 1000, ","); + for ($i=0; $i\r\n"; + print "
\r\n"; + print " \r\n"; + print " \r\n"; + + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + #print " \r\n"; + } + } + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print "
VICIDIAL ColumnFile data
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
".strtoupper(eregi_replace("_", " ", mysql_field_name($rslt, $i))).":
$row[$i]
        
\r\n"; + # } + print ""; + } +} else if (filesize($leadfile)>8388608) { + print "
ERROR: File exceeds the 8MB limit.
"; +} +?> + + + + + + + + + 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### MEXICO ### +if ($phone_code =='52') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### AUSTRALIA ### +if ($phone_code =='61') + { + $stmt="select * from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } +### ALL OTHER COUNTRY CODES ### +if (!$PC_processed) + { + $PC_processed++; + $stmt="select * from vicidial_phone_codes where country_code='$phone_code';"; + $rslt=mysql_query($stmt, $link); + $pc_recs = mysql_num_rows($rslt); + if ($pc_recs > 0) + { + $row=mysql_fetch_row($rslt); + $gmt_offset = $row[4]; $gmt_offset = eregi_replace("\+","",$gmt_offset); + $dst = $row[5]; + $dst_range = $row[6]; + $PC_processed++; + } + } + +### Find out if DST to raise the gmt offset ### +$AC_GMT_diff = ($gmt_offset - $LOCAL_GMT_OFF_STD); +$AC_localtime = mktime(($Shour + $AC_GMT_diff), $Smin, $Ssec, $Smon, $Smday, $Syear); + $hour = date("H",$AC_localtime); + $min = date("i",$AC_localtime); + $sec = date("s",$AC_localtime); + $mon = date("m",$AC_localtime); + $mday = date("d",$AC_localtime); + $wday = date("w",$AC_localtime); + $year = date("Y",$AC_localtime); +$dsec = ( ( ($hour * 3600) + ($min * 60) ) + $sec ); + +$AC_processed=0; +if ( (!$AC_processed) and ($dst_range == 'FSA-LSO') ) + { + if ($DBX) {print " First Sunday April to Last Sunday October\n";} + #********************************************************************** + # FSA-LSO + # This is returns 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in April and last Sunday in October at 2 am. + # INPUTS: + # mm INTEGER Month. + # dd INTEGER Day of the month. + # ns INTEGER Seconds into the day. + # dow INTEGER Day of week (0=Sunday, to 6=Saturday) + # OPTIONAL INPUT: + # timezone INTEGER hour difference UTC - local standard time + # (DEFAULT is blank) + # make calculations based on UTC time, + # which means shift at 10:00 UTC in April + # and 9:00 UTC in October + # OUTPUT: + # INTEGER 1 = DST, 0 = not DST + #********************************************************************** + + $USA_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 4 || $mm > 10) { + $USA_DST=0; + } elseif ($mm >= 5 and $mm <= 9) { + $USA_DST=1; + } elseif ($mm == 4) { + if ($dd > 7) { + $USA_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } else { + if ($dow == 0 and $ns < 7200) { + $USA_DST=0; + } else { + $USA_DST=1; + } + } + } else { + $USA_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $USA_DST=1; + } elseif ($dd < ($dow+25)) { + $USA_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (7200+($timezone-1)*3600)) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } else { # local time calculations + if ($ns < 7200) { + $USA_DST=1; + } else { + $USA_DST=0; + } + } + } else { + $USA_DST=0; + } + } # end of month checks + + if ($DBX) {print " DST: $USA_DST\n";} + if ($USA_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'LSM-LSO') ) + { + if ($DBX) {print " Last Sunday March to Last Sunday October\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in March and last Sunday in October at 1 am. + #********************************************************************** + + $GBR_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $GBR_DST=0; + } elseif ($mm >= 4 and $mm <= 9) { + $GBR_DST=1; + } elseif ($mm == 3) { + if ($dd < 25) { + $GBR_DST=0; + } elseif ($dd < ($dow+25)) { + $GBR_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=0; + } else { + $GBR_DST=1; + } + } + } else { + $GBR_DST=1; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $GBR_DST=1; + } elseif ($dd < ($dow+25)) { + $GBR_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $GBR_DST=1; + } else { + $GBR_DST=0; + } + } + } else { + $GBR_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $GBR_DST\n";} + if ($GBR_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'LSO-LSM') ) + { + if ($DBX) {print " Last Sunday October to Last Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on last Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUS_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUS_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUS_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUS_DST=1; + } elseif ($dd < ($dow+25)) { + $AUS_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=1; + } else { + $AUS_DST=0; + } + } + } else { + $AUS_DST=0; + } + } elseif ($mm == 10) { + if ($dd < 25) { + $AUS_DST=0; + } elseif ($dd < ($dow+25)) { + $AUS_DST=0; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } else { # local time calculations + if ($ns < 3600) { + $AUS_DST=0; + } else { + $AUS_DST=1; + } + } + } else { + $AUS_DST=1; + } + } # end of month checks + if ($DBX) {print " DST: $AUS_DST\n";} + if ($AUS_DST) {$gmt_offset++;} + $AC_processed++; + } + +if ( (!$AC_processed) and ($dst_range == 'FSO-LSM') ) + { + if ($DBX) {print " First Sunday October to Last Sunday March\n";} + #********************************************************************** + # TASMANIA ONLY + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and last Sunday in March at 1 am. + #********************************************************************** + + $AUST_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $AUST_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $AUST_DST=0; + } elseif ($mm == 3) { + if ($dd < 25) { + $AUST_DST=1; + } elseif ($dd < ($dow+25)) { + $AUST_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $AUST_DST=1; + } else { + $AUST_DST=0; + } + } + } else { + $AUST_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $AUST_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $AUST_DST=0; + } else { + $AUST_DST=1; + } + } + } else { + $AUST_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $AUST_DST\n";} + if ($AUST_DST) {$gmt_offset++;} + $AC_processed++; + } +if ( (!$AC_processed) and ($dst_range == 'FSO-TSM') ) + { + if ($DBX) {print " First Sunday October to Third Sunday March\n";} + #********************************************************************** + # This is s 1 if Daylight Savings Time is in effect and 0 if + # Standard time is in effect. + # Based on first Sunday in October and third Sunday in March at 1 am. + #********************************************************************** + + $NZL_DST=0; + $mm = $mon; + $dd = $mday; + $ns = $dsec; + $dow= $wday; + + if ($mm < 3 || $mm > 10) { + $NZL_DST=1; + } elseif ($mm >= 4 and $mm <= 9) { + $NZL_DST=0; + } elseif ($mm == 3) { + if ($dd < 14) { + $NZL_DST=1; + } elseif ($dd < ($dow+14)) { + $NZL_DST=1; + } elseif ($dow == 0) { + if ($timezone) { # UTC calculations + if ($ns < (3600+($timezone-1)*3600)) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } else { # local time calculations + if ($ns < 3600) { + $NZL_DST=1; + } else { + $NZL_DST=0; + } + } + } else { + $NZL_DST=0; + } + } elseif ($mm == 10) { + if ($dd > 7) { + $NZL_DST=1; + } elseif ($dd >= ($dow+1)) { + if ($timezone) { + if ($dow == 0 and $ns < (7200+$timezone*3600)) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } else { + if ($dow == 0 and $ns < 3600) { + $NZL_DST=0; + } else { + $NZL_DST=1; + } + } + } else { + $NZL_DST=0; + } + } # end of month checks + if ($DBX) {print " DST: $NZL_DST\n";} + if ($NZL_DST) {$gmt_offset++;} + $AC_processed++; + } +if (!$AC_processed) + { + if ($DBX) {print " No DST Method Found\n";} + if ($DBX) {print " DST: 0\n";} + $AC_processed++; + } + +return $gmt_offset; +} \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/record_conf_1_hour.php b/agc_2-X/trunk/VICIDIAL_web/record_conf_1_hour.php new file mode 100644 index 00000000..59ae1f09 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/record_conf_1_hour.php @@ -0,0 +1,156 @@ + LICENSE: GPLv2 +### +# grab: $server_ip $station $session_id +# +# CHANGES +# +# 60620-1011 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["station"])) {$station=$_GET["station"];} + elseif (isset($_POST["station"])) {$station=$_POST["station"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["NEW_RECORDING"])) {$NEW_RECORDING=$_GET["NEW_RECORDING"];} + elseif (isset($_POST["NEW_RECORDING"])) {$NEW_RECORDING=$_POST["NEW_RECORDING"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$MYSQL_datetime = date("Y-m-d H:i:s"); +$FILE_datetime = date("Ymd-His_"); +$secX = $STARTtime; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL RECORD CONFERENCE: 1 hour +\n"; +?> + + +
+ + 8) && (strlen($session_id) > 3) && (strlen($station) > 3) ) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $conf_silent_prefix = '7'; + $ext_context = 'demo'; + + $stmt="INSERT INTO vicidial_manager values('','','$MYSQL_datetime','NEW','N','" . mysql_real_escape_string($server_ip) . "','','Originate','RB$FILE_datetime" . mysql_real_escape_string($station) . "','Channel: $local_DEF$conf_silent_prefix" . mysql_real_escape_string($session_id) . "$local_AMP$ext_context','Context: $ext_context','Exten: 8309','Priority: 1','Callerid: $FILE_datetime" . mysql_real_escape_string($station) . "','','','','','')"; + echo "|$stmt|\n

\n"; + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('" . mysql_real_escape_string($session_id) . "','" . mysql_real_escape_string($server_ip) . "','" . mysql_real_escape_string($station) . "','$MYSQL_datetime','$secX','$FILE_datetime" . mysql_real_escape_string($station) . "')"; + echo "|$stmt|\n

\n"; + $rslt=mysql_query($stmt, $link); + + echo "Recording started\n

\n"; + echo "Back to main recording screen\n

\n"; + } + else + { + echo "ERROR!!!! Not all info entered properly\n

\n"; + echo "|$server_ip| |$session_id| |$station|\n

\n"; + echo "Back to main recording screen\n

\n"; + } +} +else +{ +echo "
Start recording a conference for 1 hour:
\n"; +echo "\n"; +echo "server_ip: | \n"; +echo "session_id: | \n"; +echo "station: | \n"; +echo "\n"; +echo "


\n"; + + + +} +?> + + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/remote_dispo.php b/agc_2-X/trunk/VICIDIAL_web/remote_dispo.php new file mode 100644 index 00000000..da249fba --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/remote_dispo.php @@ -0,0 +1,327 @@ + LICENSE: GPLv2 +### +# this is the remote agent disposition screen for calls sent to remote agents. This allows the remote agent to modify customer information and disposition the call + +# CHANGES +# +# 60619-1626 - Added variable filtering to eliminate SQL injection attack threat +# + + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["channel_group"])) {$channel_group=$_GET["channel_group"];} + elseif (isset($_POST["channel_group"])) {$channel_group=$_POST["channel_group"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["customer_zap_channel"])) {$customer_zap_channel=$_GET["customer_zap_channel"];} + elseif (isset($_POST["customer_zap_channel"])) {$customer_zap_channel=$_POST["customer_zap_channel"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 2;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICIDIAL-CLOSER\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $fullname = $row[0]; + fwrite ($fp, "VD_CLOSER|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + } + else + { + fwrite ($fp, "VD_CLOSER|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +VICIDIAL REMOTE: Call Disposition +\n"; +?> + + +
+ +"; + +if ($end_call > 0) +{ + +$call_length = ($STARTtime - $call_began); + + ### insert a NEW record to the vicidial_closer_log table + $stmt="UPDATE vicidial_closer_log set end_epoch='$STARTtime', length_in_sec='" . mysql_real_escape_string($call_length) . "', status='" . mysql_real_escape_string($status) . "', user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by start_epoch desc limit 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysql_real_escape_string($status) . "',first_name='" . mysql_real_escape_string($first_name) . "',last_name='" . mysql_real_escape_string($last_name) . "',address1='" . mysql_real_escape_string($address1) . "',address2='" . mysql_real_escape_string($address2) . "',address3='" . mysql_real_escape_string($address3) . "',city='" . mysql_real_escape_string($city) . "',state='" . mysql_real_escape_string($state) . "',province='" . mysql_real_escape_string($province) . "',postal_code='" . mysql_real_escape_string($postal_code) . "',country_code='" . mysql_real_escape_string($country_code) . "',alt_phone='" . mysql_real_escape_string($alt_phone) . "',email='" . mysql_real_escape_string($email) . "',security_phrase='" . mysql_real_escape_string($security) . "',comments='" . mysql_real_escape_string($comments) . "',user='$PHP_AUTH_USER' where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Call has been dispositioned       $NOW_TIME\n

\n"; + + echo "\n"; + +} +else +{ + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + + $stmt="SELECT * from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $lead_id = "$row[0]"; + $tsr = "$row[4]"; + $vendor_id = "$row[5]"; + $list_id = "$row[7]"; + $campaign_id = "$row[8]"; + $phone_code = "$row[10]"; + $phone_number = "$row[11]"; + $title = "$row[12]"; + $first_name = "$row[13]"; # + $middle_initial = "$row[14]"; + $last_name = "$row[15]"; # + $address1 = "$row[16]"; # + $address2 = "$row[17]"; # + $address3 = "$row[18]"; # + $city = "$row[19]"; # + $state = "$row[20]"; # + $province = "$row[21]"; # + $postal_code = "$row[22]"; # + $country_code = "$row[23]"; # + $gender = "$row[24]"; + $date_of_birth = "$row[25]"; + $alt_phone = "$row[26]"; # + $email = "$row[27]"; # + $security = "$row[28]"; # + $comments = "$row[29]"; # + + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "
Vendor ID: $vendor_id     Campaign ID: $campaign_id
Fronter: $tsr     List ID: $list_id
First Name:   \n"; + echo " Last Name:
Address 1 :
Address 2 :
Address 3 :
City :
State:   \n"; + echo " Postal Code:
Province :
Country :
Alt Phone :
Email :
Security :
Comments :
Disposition:
\n"; + echo "


\n"; + + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + + + + + +} + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/server_stats.php b/agc_2-X/trunk/VICIDIAL_web/server_stats.php new file mode 100644 index 00000000..a427f5c0 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/server_stats.php @@ -0,0 +1,96 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60620-1037 - Added Link back to Admin section +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="select * from servers;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$servers_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $i++; + } +?> + + + + + +VICIDIAL: Server Stats and Reports +VICIDIAL: Server Stats and Reports                           +BACK TO ADMIN

+ + +

+
+ $o)
+	{
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	echo "\n";
+	$o++;
+	}
+
+?>
+
SERVERDESCRIPTIONIP ADDRESSACTIVEVDAD timeVDcall timePARK timeCLOSER/INBOUND time
$server_id[$o]$server_description[$o]$server_ip[$o]$active[$o]LINKLINKLINKLINK
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/test.txt b/agc_2-X/trunk/VICIDIAL_web/test.txt new file mode 100644 index 00000000..70c379b6 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/test.txt @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/agc_2-X/trunk/VICIDIAL_web/user_stats.php b/agc_2-X/trunk/VICIDIAL_web/user_stats.php new file mode 100644 index 00000000..bdada227 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/user_stats.php @@ -0,0 +1,316 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1743 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + } + + + + +?> + + +VICIDIAL ADMIN: User Stats +\n"; +?> + + +
+ + + + + +\n"; +echo "
  VICIDIAL ADMIN: User Stats for  
  \n"; + +echo "
\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by status order by status"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + +echo "
\n"; + +echo "TALK TIME AND STATUS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from vicidial_log where user='" . mysql_real_escape_string($user) . "' and call_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and call_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + +echo "\n"; +echo "
STATUSCOUNTHOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
TOTAL CALLS $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LOGIN/LOGOUT TIME:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT event,event_epoch,event_date,campaign_id from vicidial_user_log where user='" . mysql_real_escape_string($user) . "' and event_date >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and event_date <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("LOGIN", $row[0])) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + if (ereg("LOGIN", $row[0])) + { + $event_start_seconds = $row[1]; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + if (ereg("LOGOUT", $row[0])) + { + if ($event_start_seconds) + { + $event_stop_seconds = $row[1]; + $event_seconds = ($event_stop_seconds - $event_start_seconds); + $total_login_time = ($total_login_time + $event_seconds); + $event_hours = ($event_seconds / 3600); + $event_hours = round($event_hours, 2); + $event_hours_int = intval("$event_hours"); + $event_minutes = ($event_hours - $event_hours_int); + $event_minutes = ($event_minutes * 60); + $event_minutes_int = round($event_minutes, 0); + if ($event_minutes_int < 10) {$event_minutes_int = "0$event_minutes_int";} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + $event_start_seconds=''; + $event_stop_seconds=''; + } + else + { + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + +$total_login_hours = ($total_login_time / 3600); +$total_login_hours = round($total_login_hours, 2); +$total_login_hours_int = intval("$total_login_hours"); +$total_login_minutes = ($total_login_hours - $total_login_hours_int); +$total_login_minutes = ($total_login_minutes * 60); +$total_login_minutes_int = round($total_login_minutes, 0); +if ($total_login_minutes_int < 10) {$total_login_minutes_int = "0$total_login_minutes_int";} + +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
EVENT DATE CAMPAIGNHOURS:MINUTES
$row[0] $row[2] $row[3]
$row[0] $row[2] $row[3] $event_hours_int:$event_minutes_int
$row[0] $row[2] $row[3]
TOTAL $total_login_hours_int:$total_login_minutes_int
\n"; + + +echo "

\n"; + +echo "
\n"; + +echo "LAST 50 CALLS:\n"; +echo "\n"; +echo "\n"; + + $stmt="select * from vicidial_log where user='" . mysql_real_escape_string($user) . "' order by uniqueid desc limit 50;"; + $rslt=mysql_query($stmt, $link); + $logs_to_print = mysql_num_rows($rslt); + + $u=0; + while ($logs_to_print > $u) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $u++; + } + + +echo "
DATE/TIME LENGTH STATUS PHONE CAMPAIGN LIST LEAD
$row[4] $row[7] $row[8] $row[10] $row[3] $row[2] $row[1]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/user_status.php b/agc_2-X/trunk/VICIDIAL_web/user_status.php new file mode 100644 index 00000000..8efe670f --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/user_status.php @@ -0,0 +1,238 @@ + LICENSE: GPLv2 +### +# CHANGES +# +# 60619-1738 - Added variable filtering to eliminate SQL injection attack threat +# + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $stmt="SELECT full_name,change_agent_campaign from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $change_agent_campaign=$row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + + $stmt="SELECT full_name from vicidial_users where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + + $stmt="SELECT * from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agents_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $agents_to_print) + { + $row=mysql_fetch_row($rslt); + $Aserver_ip = $row[2]; + $Asession_id = $row[3]; + $Aextension = $row[4]; + $Astatus = $row[5]; + $Acampaign = $row[7]; + $Alast_call = $row[14]; + $Acl_campaigns = $row[15]; + $i++; + } + + } + +$stmt="select * from vicidial_campaigns;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $groups[$i] =$row[0]; + $i++; + } + + + +?> + + +VICIDIAL ADMIN: User Status +\n"; +?> + + +
+
+ + + + +\n"; +echo "
  VICIDIAL ADMIN: User Status for  
  \n"; + +if ($stage == "live_campaign_change") +{ + $stmt="UPDATE vicidial_live_agents set campaign_id='" . mysql_real_escape_string($group) . "' where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name changed to $group campaign
\n"; + + exit; +} + +if ($stage == "log_agent_out") +{ + $stmt="DELETE from vicidial_live_agents where user='" . mysql_real_escape_string($user) . "';"; + $rslt=mysql_query($stmt, $link); + + echo "Agent $user - $full_name has been emergency logged out, make sure they close their web browser
\n"; + + exit; +} + +if ($agents_to_print > 0) +{ + echo "
";
+	echo "Agent Logged in at server:  $Aserver_ip\n";
+	echo "               in session:  $Asession_id\n";
+	echo "               from phone:  $Aextension\n";
+	echo "Agent is in campaign:       $Acampaign\n";
+	echo "              status:       $Astatus\n";
+	echo " hungup last call at:       $Alast_call\n";
+	echo "       Closer groups:       $Acl_campaigns\n\n";
+
+	echo "
"; + + + if ($change_agent_campaign > 0) + { + echo "\n"; + echo "\n"; + echo "\n"; + echo "Current Campaign: \n"; + echo "
\n"; + + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } +} + +else +{ + echo "Agent is not logged in\n
"; + +} + + +echo "           $user - $full_name - \n"; + +echo "VICIDIAL Time Sheet\n"; + +echo "
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + +echo "|$stage|$group|"; + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/VICIDIAL_web/vdremote.php b/agc_2-X/trunk/VICIDIAL_web/vdremote.php new file mode 100644 index 00000000..dfe11fa3 --- /dev/null +++ b/agc_2-X/trunk/VICIDIAL_web/vdremote.php @@ -0,0 +1,602 @@ + LICENSE: GPLv2 +# +# Changes +# 50307-1721 - First version +# 51123-1502 - removed requirement of PHP Globals=on +# 60421-1229 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1603 - Added variable filtering to eliminate SQL injection attack threat +# +# make sure you have added a user to the vicidial_users MySQL table with at least user_level 4 to access this page the first time + +$version = '1.1.12'; +$build = '60619-1603'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["force_logout"])) {$force_logout=$_GET["force_logout"];} + elseif (isset($_POST["force_logout"])) {$force_logout=$_POST["force_logout"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["remote_agent_id"])) {$remote_agent_id=$_GET["remote_agent_id"];} + elseif (isset($_POST["remote_agent_id"])) {$remote_agent_id=$_POST["remote_agent_id"];} +if (isset($_GET["user_start"])) {$user_start=$_GET["user_start"];} + elseif (isset($_POST["user_start"])) {$user_start=$_POST["user_start"];} +if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];} + elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +if (!isset($force_logout)) {$force_logout = 0;} + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + +$popup_page = './closer_popup.php'; +$STARTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 3;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + header ("Content-type: text/html; charset=utf-8"); + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + + $stmt="SELECT count(*) from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $authx=$row[0]; + + if($authx>0) + { + $stmt="SELECT remote_agent_id,server_ip,number_of_lines from vicidial_remote_agents where user_start='$PHP_AUTH_USER';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id=$row[0]; + $server_ip=$row[1]; + if (!$number_of_lines) {$number_of_lines=$row[2];} + + fwrite ($fp, "VDremote|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + echo "This remote agent does not exist: |$PHP_AUTH_USER|\n"; + exit; + } + } + else + { + fwrite ($fp, "VDremote|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +echo "\n"; +echo "\n"; +echo "\n"; +if ($ADD==61111) + { + echo"\n"; + } +echo "\n"; +?> + +VICIDIAL REMOTE AGENTS: $LOGfullname - $PHP_AUTH_USER "; + +if (!$ADD) {$ADD="31111";} +if ($ADD==31111) {echo "Modify Remote Agents";} +if ($ADD==41111) {echo "Modify Remote Agents";} +if ($ADD==61111) {echo "Remote Agent Status";} +if ($ADD==71111) {echo "Remote Agent Closer Stats";} + + +if (strlen($ADD)>4) + { + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rslt=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rslt); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $servers_list .= "\n"; + $o++; + } + + ##### get campaigns listing for dynamic pulldown + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; + $rslt=mysql_query($stmt, $link); + $campaigns_to_print = mysql_num_rows($rslt); + $campaigns_list=''; + + $o=0; + while ($campaigns_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $campaigns_list .= "\n"; + $o++; + } + + ##### get inbound groups listing for checkboxes + if ( (($ADD==31111) or ($ADD==31111)) and (count($groups)<1) ) + { + $stmt="SELECT closer_campaigns from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $closer_campaigns = $row[0]; + $closer_campaigns = preg_replace("/ -$/","",$closer_campaigns); + $groups = explode(" ", $closer_campaigns); + } + + $stmt="SELECT group_id,group_name from vicidial_inbound_groups order by group_id"; + $rslt=mysql_query($stmt, $link); + $groups_to_print = mysql_num_rows($rslt); + $groups_list=''; + $groups_value=''; + + $o=0; + while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $group_id_value = $rowx[0]; + $group_name_value = $rowx[1]; + $groups_list .= "2) {$groups_value .= " -";} + } + +?> + + + +
+
+ + + +
  VICIDIAL REMOTE AGENTS:   Logout  
  MODIFY | ">STATUS | ">INBOUND STATS
+"; + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]
\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: $user_start
Number of Lines: (numbers only)
Server IP: $row[3]
External Extension: (number dialed to reach agents [i.e. 913125551212])
Status:
Campaign: $campaign_id
Inbound Groups: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + + + +###################### +# ADD=41111 modify remote agents info in the system +###################### + +if ($ADD==41111) +{ + echo ""; + + if ( (strlen($number_of_lines) < 1) or (strlen($conf_exten) < 2) ) + {echo "
REMOTE AGENTS NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + $stmt="UPDATE vicidial_remote_agents set number_of_lines='" . mysql_real_escape_string($number_of_lines) . "', conf_exten='" . mysql_real_escape_string($conf_exten) . "', status='" . mysql_real_escape_string($status) . "', closer_campaigns='" . mysql_real_escape_string($groups_value) . "' where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + +# echo "$stmt\n"; + echo "
REMOTE AGENTS MODIFIED\n"; + + ### LOG CHANGES TO LOG FILE ### + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|MODIFY REMOTE AGENTS ENTRY |$PHP_AUTH_USER|$ip|$stmt|\n"); + fclose($fp); + + } + + $stmt="SELECT * from vicidial_remote_agents where remote_agent_id='" . mysql_real_escape_string($remote_agent_id) . "';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $remote_agent_id = $row[0]; + $user_start = $row[1]; + $number_of_lines = $row[2]; + $server_ip = $row[3]; + $conf_exten = $row[4]; + $status = $row[5]; + $campaign_id = $row[6]; + +echo "
MODIFY A REMOTE AGENTS ENTRY: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
User ID Start: $user_start
Number of Lines: (numbers only)
Server IP: $row[3]
External Extension: (number dialed to reach agents [i.e. 913125551212])
Status:
Campaign: $campaign_id
Inbound Groups: \n"; +echo "$groups_list"; +echo "
\n"; +echo "NOTE: It can take up to 30 seconds for changes submitted on this screen to go live\n"; + +} + + + + +###################### +# ADD=61111 status of remote agent in the system and active calls and queue +###################### + +if ($ADD==61111) +{ + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'" . mysql_real_escape_string($nextuser) . "',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + echo "VICIDIAL: Remote Agent Time On Calls $NOW_TIME\n\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo "| STATION | USER | LEADID | CHANNEL | STATUS | START TIME | MINUTES |\n"; + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select extension,user,lead_id,channel,status,last_call_time,UNIX_TIMESTAMP(last_call_time),UNIX_TIMESTAMP(last_call_finish) from vicidial_live_agents where status NOT IN('PAUSED') and server_ip='" . mysql_real_escape_string($server_ip) . "' and user IN($users_list) order by extension;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $leadlink=0; + $row=mysql_fetch_row($rslt); + if (eregi("READY|PAUSED",$row[4])) + { + $row[3]=''; + $row[5]=' - WAITING - '; + $row[6]=$row[7]; + } + $extension = sprintf("%-10s", $row[0]); + $user = sprintf("%-6s", $row[1]); + $leadid = sprintf("%-12s", $row[2]); + if ($row[2] > 0) + { + $leadidLINK=$row[2]; + $leadlink++; + if ( eregi("QUEUE",$row[4]) ) {$row[6]=$STARTtime;} + $leadid = "$leadid"; + } + $channel = sprintf("%-10s", $row[3]); + $cc=0; + while ( (strlen($channel) > 10) and ($cc < 100) ) + { + $channel = eregi_replace(".$","",$channel); + $cc++; + if (strlen($channel) <= 10) {$cc=101;} + } + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = ($STARTtime - $row[6]); + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + if ($call_time_M_int >= 5) {$G=''; $EG='';} + if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$extension$EG | $G$user$EG | $G$leadid$EG | $G$channel$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+------------|--------+--------------+------------+--------+---------------------+---------+\n"; + echo " $i agents logged in on server $server_ip\n\n"; + + echo " - 5 minutes or more on call\n"; + echo " - Over 10 minutes on call\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* NO AGENTS ON CALLS *********************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + +###################### +# ADD=71111 stats for remote agents from closer logs(vicidial_closer_log) +###################### + +if ($ADD==71111) +{ + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n\n"; + echo "
";
+
+	 if ( (strlen($server_ip) < 2) or (strlen($user) < 2) )
+		{echo "
REMOTE AGENTS ERROR - Please go back and look at the data you entered\n";} + else + { + + $users_list = ''; + $k=0; + while($k < $number_of_lines) + { + $nextuser=($user + $k); + $users_list .= "'$nextuser',"; + $k++; + } + $users_list = preg_replace("/.$/","",$users_list); + + $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list);"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $in_calls = $row[0]; + $in_time = $row[1]; + $in_time_M = ($in_time / 60); + $in_time_M = round($in_time_M, 2); + $in_time_M_int = intval("$in_time_M"); + $in_time_SEC = ($in_time_M - $in_time_M_int); + $in_time_SEC = ($in_time_SEC * 60); + $in_time_SEC = round($in_time_SEC, 0); + if ($in_time_SEC < 10) {$in_time_SEC = "0$in_time_SEC";} + $in_time_MS = "$in_time_M_int:$in_time_SEC"; + $in_time_MS = sprintf("%7s", $in_time_MS); + + echo "VICIDIAL: Remote Agent inbound stats $NOW_TIME\n\n"; + echo "\n"; + echo "Total calls taken $query_date: $in_calls\n"; + echo "Total talk time on $query_date: $in_time_MS (minutes:seconds)\n"; + echo "\n"; + echo "\n"; + echo "Call list for $query_date:\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + echo "| USER | LEADID | GROUP | PHONE NUM | STATUS | CALL TIME | MINUTES |\n"; + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + + + $stmt="select user,lead_id,campaign_id,phone_number,status,call_date,length_in_sec from vicidial_closer_log where call_date >= '$query_date 00:00:01' and call_date <= '$query_date 23:59:59' and user IN($users_list) order by call_date;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $talking_to_print = mysql_num_rows($rslt); + if ($talking_to_print > 0) + { + $i=0; + while ($i < $talking_to_print) + { + $row=mysql_fetch_row($rslt); + $user = sprintf("%-8s", $row[0]); + $leadid = sprintf("%-10s", $row[1]); + $group = sprintf("%-14s", $row[2]); + $phone = sprintf("%-10s", $row[3]); + $status = sprintf("%-6s", $row[4]); + $start_time = sprintf("%-19s", $row[5]); + $call_time_S = $row[6]; + + $call_time_M = ($call_time_S / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $call_time_MS = sprintf("%7s", $call_time_MS); + $G = ''; $EG = ''; + # if ($call_time_M_int >= 5) {$G=''; $EG='';} + # if ($call_time_M_int >= 10) {$G=''; $EG='';} + + echo "| $G$user$EG | $G$leadid$EG | $G$group$EG | $G$phone$EG | $G$status$EG | $G$start_time$EG | $G$call_time_MS$EG |\n"; + + $i++; + } + + echo "+----------+------------+----------------+------------+--------+---------------------+---------+\n"; + # echo " $i agents logged in on server $server_ip\n\n"; + + # echo " - 5 minutes or more on call\n"; + # echo " - Over 10 minutes on call\n"; + + } + else + { + echo "**************************************************************************************\n"; + echo "********************************* NO CALLS ON THIS DAY *******************************\n"; + echo "**************************************************************************************\n"; + } + } + +echo "
\n\n"; + +} + + + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/agc/active_list_refresh.php b/agc_2-X/trunk/agc/active_list_refresh.php new file mode 100644 index 00000000..7ea0bff0 --- /dev/null +++ b/agc_2-X/trunk/agc/active_list_refresh.php @@ -0,0 +1,482 @@ + LICENSE: GPLv2 +### +### This script is designed purely to serve updates of the live data to the display scripts +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $ADD - ('1','2','3','4','5') +### - $order - ('asc','desc') +### - $format - ('text','table','menu','selectlist','textarea') +### - $bgcolor - ('#123456','white','black','etc...') +### - $txtcolor - ('#654321','black','white','etc...') +### - $txtsize - ('1','2','3','etc...') +### - $selectsize - ('2','3','4','etc...') +### - $selectfontsize - ('8','10','12','etc...') +### - $selectedext - ('cc100') +### - $selectedtrunk - ('Zap/25-1') +### - $selectedlocal - ('SIP/cc100') +### - $textareaheight - ('8','10','12','etc...') +### - $textareawidth - ('8','10','12','etc...') +### - $field_name - ('extension','busyext','extension_xfer','etc...') +### + +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1118 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +### security strip all non-alphanumeric characters out of the variables ### + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + $ADD=ereg_replace("[^0-9]","",$ADD); + $order=ereg_replace("[^0-9a-zA-Z]","",$order); + $format=ereg_replace("[^0-9a-zA-Z]","",$format); + $bgcolor=ereg_replace("[^\#0-9a-zA-Z]","",$bgcolor); + $txtcolor=ereg_replace("[^\#0-9a-zA-Z]","",$txtcolor); + $txtsize=ereg_replace("[^0-9a-zA-Z]","",$txtsize); + $selectsize=ereg_replace("[^0-9a-zA-Z]","",$selectsize); + $selectfontsize=ereg_replace("[^0-9a-zA-Z]","",$selectfontsize); + $selectedext=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedext); + $selectedtrunk=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedtrunk); + $selectedlocal=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedlocal); + $textareaheight=ereg_replace("[^0-9a-zA-Z]","",$textareaheight); + $textareawidth=ereg_replace("[^0-9a-zA-Z]","",$textareawidth); + $field_name=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$field_name); + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.8'; +$build = '60619-1118'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "List Display: "; +if ($ADD==1) {echo "Live Extensions";} +if ($ADD==2) {echo "Busy Extensions";} +if ($ADD==3) {echo "Outside Lines";} +if ($ADD==4) {echo "Local Extensions";} +if ($ADD==5) {echo "Conferences";} +if ($ADD==99999) {echo "HELP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/agc/astguiclient.php b/agc_2-X/trunk/agc/astguiclient.php new file mode 100644 index 00000000..614ce146 --- /dev/null +++ b/agc_2-X/trunk/agc/astguiclient.php @@ -0,0 +1,2899 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1357 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1103 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +#require_once("htglobalize.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '1.1.12'; +$build = '60619-1103'; + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +$fp = fopen ("./astguiclient_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "astGUIclient web client: Login\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
User Login:
User Password:
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + else + { + fwrite ($fp, "VICIDIAL|FAIL|$date|$user|$pass|$ip|$browser|\n"); + fclose($fp); + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "astGUIclient web client: Phone Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone Login
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "astGUIclient web client: Phone Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Phone Login
 
Sorry, your phone login and password are not active in this system, please try again:
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "astGUIclient web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +LOGOUT
\n"; ?> +
Main PanelActive Lines PanelConferences PanelCheck VoicemailLive Call
+
+ + +

Logout
+
+ + +
TRUNK HANGUP

+ Active Trunks Menu
+ Hangup Trunk   |   + Hijack Trunk   |   + Listen Trunk   |   + Refresh   |   + Back to Main Window +
+
+ + +
LOCAL HANGUP

+ Active Local Menu
+ Hangup Local   |   + Hijack Local   |   + Listen Local   |   + Refresh   |   + Back to Main Window +
+
+ + + + + + + +
LIVE CALL TRANSFER
Channel to be transferred: Channel
Extensions:
Extensions Menu
+
+ Send to selected extension

+ Send to selected vmail box

+ Send to this number:


+ Refresh


+ Back to Main Window

+
Conferences:
(click on a number below to send to a conference)
Send my channel too
Conferences Menu
+
+ + + + + +
LOCAL Extensions Dial
Phone calling from: Channel
Extensions:
Extensions Menu
+
+ Call selected extension

+ Call selected vmail box

+ Refresh


+ Back to Main Window

+
+
+ + +
PARKED CALLS:
+ Back to Main Window

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     NEW:     OLD:             MANUAL DIAL       DIAL
PARKED CALLS: 0                LOCAL DIAL EXTENSIONS
OUTBOUND CALLS:
INBOUND CALLS:
astGUIclient web-client VERSION: BUILD:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
FAVORITES       edit
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
FAVORITES

 
SUBMIT FAVORITES CHANGES - requires logout
BACK TO MAIN WINDOW - ignore changes made
+
+ +
+ + + + + + + + + + + + + +
+PAUSE | START     Refresh rate: 1000 ms Faster | Slower

+
Initializing..
+
Active Extensions
+REFRESH | +ORDER | +
Outside Lines
+REFRESH | +ORDER | +
Local Extensions
+REFRESH | +ORDER | +
+ Data Goes Here

+
+ Data Goes Here

Trunk Action +
+ Data Goes Here

Local Action +
+
+ + + + +
+ + +Conferences List + + + +
+Click on a conference room number on the left for info on that conference +
+ + + +
+ + + + + + + + + + + + + + diff --git a/agc_2-X/trunk/agc/call_log_display.php b/agc_2-X/trunk/agc/call_log_display.php new file mode 100644 index 00000000..28d3ea87 --- /dev/null +++ b/agc_2-X/trunk/agc/call_log_display.php @@ -0,0 +1,196 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the inbound and outbound calls for a specific phone +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### - $in_limit - ('10','20','50','100',...) +### - $out_limit - ('10','20','50','100',...) +### + +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1202 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.8'; +$build = '60619-1202'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Call Log Display"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/agc/conf_exten_check.php b/agc_2-X/trunk/agc/conf_exten_check.php new file mode 100644 index 00000000..8915d813 --- /dev/null +++ b/agc_2-X/trunk/agc/conf_exten_check.php @@ -0,0 +1,262 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1201 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$version = '0.0.9'; +$build = '60619-1201'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Conf Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten is not valid\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + $Acampaign=$row[1]; + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where server_ip='$server_ip' and status NOT IN('XFER') and campaign_id='$Acampaign';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + } + else + { + $Astatus='N'; + $RingCalls='N'; + } + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Status: ' . $Astatus . '|CampCalls: ' . $RingCalls . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $ChannelA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$ChannelA[$counter] ~"; + # echo "$ChannelA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten is not valid or Exten $exten is not valid\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + echo "Conference $conf_exten has been registered to $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/agc/dbconnect.php b/agc_2-X/trunk/agc/dbconnect.php new file mode 100644 index 00000000..16c021d5 --- /dev/null +++ b/agc_2-X/trunk/agc/dbconnect.php @@ -0,0 +1,18 @@ + LICENSE: GPLv2 +# +$link=mysql_connect("localhost", "cron", "1234"); +mysql_select_db("asterisk"); + +$local_DEF = 'Local/'; +$conf_silent_prefix = '7'; +$local_AMP = '@'; +$ext_context = 'demo'; +$recording_exten = '8309'; + +#$WeBServeRRooT = '/home/www/htdocs'; +$WeBServeRRooT = '/usr/local/apache2/htdocs'; +$WeBRooTWritablE = '1'; + +?> diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK.gif new file mode 100644 index 00000000..30703a78 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_e.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_e.gif new file mode 100644 index 00000000..600cef89 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_e.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_es.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_es.gif new file mode 100644 index 00000000..600cef89 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_ptbr.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_ptbr.gif new file mode 100644 index 00000000..3670af28 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_BLINK_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF.gif new file mode 100644 index 00000000..5b7e4c75 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF_es.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF_es.gif new file mode 100644 index 00000000..ec9c1d55 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF_ptbr.gif new file mode 100644 index 00000000..3b1c4644 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_ON.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_ON.gif new file mode 100644 index 00000000..ad55916d Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_ON.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_ON_es.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_ON_es.gif new file mode 100644 index 00000000..442a8084 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_ON_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_check_voicemail_ON_ptbr.gif b/agc_2-X/trunk/agc/images/agc_check_voicemail_ON_ptbr.gif new file mode 100644 index 00000000..ae53a393 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_check_voicemail_ON_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_live_call_OFF.gif b/agc_2-X/trunk/agc/images/agc_live_call_OFF.gif new file mode 100644 index 00000000..3752fb5e Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_live_call_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_live_call_OFF_es.gif b/agc_2-X/trunk/agc/images/agc_live_call_OFF_es.gif new file mode 100644 index 00000000..1ff376d8 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_live_call_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_live_call_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/agc_live_call_OFF_ptbr.gif new file mode 100644 index 00000000..86a71723 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_live_call_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_live_call_ON.gif b/agc_2-X/trunk/agc/images/agc_live_call_ON.gif new file mode 100644 index 00000000..ed8ba2dd Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_live_call_ON.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_live_call_ON_es.gif b/agc_2-X/trunk/agc/images/agc_live_call_ON_es.gif new file mode 100644 index 00000000..041d398f Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_live_call_ON_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_live_call_ON_ptbr.gif b/agc_2-X/trunk/agc/images/agc_live_call_ON_ptbr.gif new file mode 100644 index 00000000..c0601666 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_live_call_ON_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_active_lines.gif b/agc_2-X/trunk/agc/images/agc_tab_active_lines.gif new file mode 100644 index 00000000..9f8eaf67 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_active_lines.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_active_lines_el.gif b/agc_2-X/trunk/agc/images/agc_tab_active_lines_el.gif new file mode 100644 index 00000000..1bea40dc Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_active_lines_el.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_active_lines_es.gif b/agc_2-X/trunk/agc/images/agc_tab_active_lines_es.gif new file mode 100644 index 00000000..bdefd015 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_active_lines_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_active_lines_ptbr.gif b/agc_2-X/trunk/agc/images/agc_tab_active_lines_ptbr.gif new file mode 100644 index 00000000..1465ea6e Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_active_lines_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_astguiclient.gif b/agc_2-X/trunk/agc/images/agc_tab_astguiclient.gif new file mode 100644 index 00000000..30373576 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_astguiclient.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_astguiclient_ptbr.gif b/agc_2-X/trunk/agc/images/agc_tab_astguiclient_ptbr.gif new file mode 100644 index 00000000..30373576 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_astguiclient_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_conferences.gif b/agc_2-X/trunk/agc/images/agc_tab_conferences.gif new file mode 100644 index 00000000..e3c80662 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_conferences.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_conferences_el.gif b/agc_2-X/trunk/agc/images/agc_tab_conferences_el.gif new file mode 100644 index 00000000..91282b42 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_conferences_el.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_conferences_es.gif b/agc_2-X/trunk/agc/images/agc_tab_conferences_es.gif new file mode 100644 index 00000000..14ab7171 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_conferences_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_conferences_ptbr.gif b/agc_2-X/trunk/agc/images/agc_tab_conferences_ptbr.gif new file mode 100644 index 00000000..14ab7171 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_conferences_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_main.gif b/agc_2-X/trunk/agc/images/agc_tab_main.gif new file mode 100644 index 00000000..6e687e44 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_main.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_main_el.gif b/agc_2-X/trunk/agc/images/agc_tab_main_el.gif new file mode 100644 index 00000000..4eaf0aa3 Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_main_el.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_main_es.gif b/agc_2-X/trunk/agc/images/agc_tab_main_es.gif new file mode 100644 index 00000000..b5fc2a5e Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_main_es.gif differ diff --git a/agc_2-X/trunk/agc/images/agc_tab_main_ptbr.gif b/agc_2-X/trunk/agc/images/agc_tab_main_ptbr.gif new file mode 100644 index 00000000..b5fc2a5e Binary files /dev/null and b/agc_2-X/trunk/agc/images/agc_tab_main_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/blank.gif b/agc_2-X/trunk/agc/images/blank.gif new file mode 100644 index 00000000..3a469695 Binary files /dev/null and b/agc_2-X/trunk/agc/images/blank.gif differ diff --git a/agc_2-X/trunk/agc/images/br.gif b/agc_2-X/trunk/agc/images/br.gif new file mode 100644 index 00000000..423b8a0c Binary files /dev/null and b/agc_2-X/trunk/agc/images/br.gif differ diff --git a/agc_2-X/trunk/agc/images/de.gif b/agc_2-X/trunk/agc/images/de.gif new file mode 100644 index 00000000..4dd34f6a Binary files /dev/null and b/agc_2-X/trunk/agc/images/de.gif differ diff --git a/agc_2-X/trunk/agc/images/down.gif b/agc_2-X/trunk/agc/images/down.gif new file mode 100644 index 00000000..32d0a007 Binary files /dev/null and b/agc_2-X/trunk/agc/images/down.gif differ diff --git a/agc_2-X/trunk/agc/images/el.gif b/agc_2-X/trunk/agc/images/el.gif new file mode 100644 index 00000000..9e79d8bf Binary files /dev/null and b/agc_2-X/trunk/agc/images/el.gif differ diff --git a/agc_2-X/trunk/agc/images/en.gif b/agc_2-X/trunk/agc/images/en.gif new file mode 100644 index 00000000..cb45f5f4 Binary files /dev/null and b/agc_2-X/trunk/agc/images/en.gif differ diff --git a/agc_2-X/trunk/agc/images/es.gif b/agc_2-X/trunk/agc/images/es.gif new file mode 100644 index 00000000..308ea3cb Binary files /dev/null and b/agc_2-X/trunk/agc/images/es.gif differ diff --git a/agc_2-X/trunk/agc/images/fr.gif b/agc_2-X/trunk/agc/images/fr.gif new file mode 100644 index 00000000..21fb3d19 Binary files /dev/null and b/agc_2-X/trunk/agc/images/fr.gif differ diff --git a/agc_2-X/trunk/agc/images/it.gif b/agc_2-X/trunk/agc/images/it.gif new file mode 100644 index 00000000..6c7b1792 Binary files /dev/null and b/agc_2-X/trunk/agc/images/it.gif differ diff --git a/agc_2-X/trunk/agc/images/pt.gif b/agc_2-X/trunk/agc/images/pt.gif new file mode 100644 index 00000000..646b76ac Binary files /dev/null and b/agc_2-X/trunk/agc/images/pt.gif differ diff --git a/agc_2-X/trunk/agc/images/remove.gif b/agc_2-X/trunk/agc/images/remove.gif new file mode 100644 index 00000000..89b0521c Binary files /dev/null and b/agc_2-X/trunk/agc/images/remove.gif differ diff --git a/agc_2-X/trunk/agc/images/up.gif b/agc_2-X/trunk/agc/images/up.gif new file mode 100644 index 00000000..0d55544f Binary files /dev/null and b/agc_2-X/trunk/agc/images/up.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber.gif b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber.gif new file mode 100644 index 00000000..a5a080d6 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF.gif new file mode 100644 index 00000000..75bc0e8f Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF_es.gif new file mode 100644 index 00000000..405ff336 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF_ptbr.gif new file mode 100644 index 00000000..0d297820 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_es.gif new file mode 100644 index 00000000..ca92716e Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_ptbr.gif new file mode 100644 index 00000000..8625b1c9 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_dialnextnumber_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall.gif b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall.gif new file mode 100644 index 00000000..a6779255 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF.gif new file mode 100644 index 00000000..74b1f5a1 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF_es.gif new file mode 100644 index 00000000..21991dd5 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF_ptbr.gif new file mode 100644 index 00000000..19932ad2 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_es.gif new file mode 100644 index 00000000..9acc363a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_ptbr.gif new file mode 100644 index 00000000..e37d0fb4 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_grabparkedcall_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer.gif b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer.gif new file mode 100644 index 00000000..b4fdfae8 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF.gif new file mode 100644 index 00000000..e5736ae0 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF_es.gif new file mode 100644 index 00000000..570a6e5a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF_ptbr.gif new file mode 100644 index 00000000..57918268 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_es.gif new file mode 100644 index 00000000..94d3e225 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_ptbr.gif new file mode 100644 index 00000000..5841050c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_hangupcustomer_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_parkcall.gif b/agc_2-X/trunk/agc/images/vdc_LB_parkcall.gif new file mode 100644 index 00000000..88fee283 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_parkcall.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF.gif new file mode 100644 index 00000000..8ad55010 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF_es.gif new file mode 100644 index 00000000..110ce6b0 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF_ptbr.gif new file mode 100644 index 00000000..25a6a2f2 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_parkcall_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_es.gif new file mode 100644 index 00000000..2274a27c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_parkcall_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_ptbr.gif new file mode 100644 index 00000000..b37d8358 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_parkcall_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_pause.gif b/agc_2-X/trunk/agc/images/vdc_LB_pause.gif new file mode 100644 index 00000000..3486a1c1 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_pause.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF.gif new file mode 100644 index 00000000..fce03041 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF_es.gif new file mode 100644 index 00000000..494d68a5 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF_ptbr.gif new file mode 100644 index 00000000..3d8c8759 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_pause_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_pause_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_pause_es.gif new file mode 100644 index 00000000..544a3797 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_pause_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_pause_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_pause_ptbr.gif new file mode 100644 index 00000000..bea56d65 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_pause_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_resume.gif b/agc_2-X/trunk/agc/images/vdc_LB_resume.gif new file mode 100644 index 00000000..a7d75dd8 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_resume.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF.gif new file mode 100644 index 00000000..0ae4cb9a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF_es.gif new file mode 100644 index 00000000..921d5d5e Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF_ptbr.gif new file mode 100644 index 00000000..43bb9235 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_resume_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_resume_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_resume_es.gif new file mode 100644 index 00000000..1b096144 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_resume_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_resume_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_resume_ptbr.gif new file mode 100644 index 00000000..415b22d1 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_resume_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_senddtmf.gif b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf.gif new file mode 100644 index 00000000..d19888ad Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF.gif new file mode 100644 index 00000000..08a4b392 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF_es.gif new file mode 100644 index 00000000..2d32c5e9 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF_ptbr.gif new file mode 100644 index 00000000..2d32c5e9 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_es.gif new file mode 100644 index 00000000..43964df4 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_ptbr.gif new file mode 100644 index 00000000..43964df4 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_senddtmf_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_spacer.gif b/agc_2-X/trunk/agc/images/vdc_LB_spacer.gif new file mode 100644 index 00000000..d0a4f6ed Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_spacer.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_startrecording.gif b/agc_2-X/trunk/agc/images/vdc_LB_startrecording.gif new file mode 100644 index 00000000..022103d2 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_startrecording.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF.gif new file mode 100644 index 00000000..3ee4ca62 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF_es.gif new file mode 100644 index 00000000..ff9a3447 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF_ptbr.gif new file mode 100644 index 00000000..22105778 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_startrecording_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_es.gif new file mode 100644 index 00000000..26420f78 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_startrecording_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_ptbr.gif new file mode 100644 index 00000000..15b25990 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_startrecording_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_stoprecording.gif b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording.gif new file mode 100644 index 00000000..6f3bfede Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF.gif new file mode 100644 index 00000000..2e1efe4a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF_es.gif new file mode 100644 index 00000000..2806311f Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF_ptbr.gif new file mode 100644 index 00000000..c0259410 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_es.gif new file mode 100644 index 00000000..94f9de9d Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_ptbr.gif new file mode 100644 index 00000000..8a76e860 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_stoprecording_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_transferconf.gif b/agc_2-X/trunk/agc/images/vdc_LB_transferconf.gif new file mode 100644 index 00000000..c5738519 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_transferconf.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF.gif new file mode 100644 index 00000000..dd0a579a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF_es.gif new file mode 100644 index 00000000..d0a54bf6 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF_ptbr.gif new file mode 100644 index 00000000..ebb69344 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_transferconf_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_es.gif new file mode 100644 index 00000000..10cfa495 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_transferconf_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_ptbr.gif new file mode 100644 index 00000000..f008e92c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_transferconf_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_webform.gif b/agc_2-X/trunk/agc/images/vdc_LB_webform.gif new file mode 100644 index 00000000..4d5228f3 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_webform.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF.gif b/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF.gif new file mode 100644 index 00000000..64316ced Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF_es.gif new file mode 100644 index 00000000..75a56196 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF_ptbr.gif new file mode 100644 index 00000000..75a56196 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_webform_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_webform_es.gif b/agc_2-X/trunk/agc/images/vdc_LB_webform_es.gif new file mode 100644 index 00000000..d7590d66 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_webform_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_LB_webform_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_LB_webform_ptbr.gif new file mode 100644 index 00000000..d7590d66 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_LB_webform_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_ammessage.gif b/agc_2-X/trunk/agc/images/vdc_XB_ammessage.gif new file mode 100644 index 00000000..484d01eb Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_ammessage.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_ammessage_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_ammessage_OFF.gif new file mode 100644 index 00000000..3aa94800 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_ammessage_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer.gif b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer.gif new file mode 100644 index 00000000..77c03e0b Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF.gif new file mode 100644 index 00000000..7fb481ee Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF_es.gif new file mode 100644 index 00000000..05adaac5 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF_ptbr.gif new file mode 100644 index 00000000..3a069c2b Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_es.gif new file mode 100644 index 00000000..fdad633a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_ptbr.gif new file mode 100644 index 00000000..c31c87fc Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_blindtransfer_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_channel.gif b/agc_2-X/trunk/agc/images/vdc_XB_channel.gif new file mode 100644 index 00000000..9a9ce7ba Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_channel.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_channel_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_channel_es.gif new file mode 100644 index 00000000..a4fbf1f5 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_channel_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_channel_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_channel_ptbr.gif new file mode 100644 index 00000000..a4fbf1f5 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_channel_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_code.gif b/agc_2-X/trunk/agc/images/vdc_XB_code.gif new file mode 100644 index 00000000..8fb2b8c5 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_code.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer.gif b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer.gif new file mode 100644 index 00000000..68697edc Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF.gif new file mode 100644 index 00000000..8bf2e44b Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF_es.gif new file mode 100644 index 00000000..7ef98a94 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF_ptbr.gif new file mode 100644 index 00000000..1ac7dbbb Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_es.gif new file mode 100644 index 00000000..d71bca15 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_ptbr.gif new file mode 100644 index 00000000..90ec03f8 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_dialwithcustomer_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines.gif new file mode 100644 index 00000000..4e6db07e Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF.gif new file mode 100644 index 00000000..f1ffdc12 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF_es.gif new file mode 100644 index 00000000..8f12accd Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF_ptbr.gif new file mode 100644 index 00000000..47b87225 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_es.gif new file mode 100644 index 00000000..646c8769 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_ptbr.gif new file mode 100644 index 00000000..fa0cf2fb Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupbothlines_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline.gif new file mode 100644 index 00000000..d25a105a Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF.gif new file mode 100644 index 00000000..a8fb4a3d Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF_es.gif new file mode 100644 index 00000000..3c717d09 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF_ptbr.gif new file mode 100644 index 00000000..f6d9080b Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_es.gif new file mode 100644 index 00000000..0d92a89c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_ptbr.gif new file mode 100644 index 00000000..c7d26417 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hangupxferline_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_header.gif b/agc_2-X/trunk/agc/images/vdc_XB_header.gif new file mode 100644 index 00000000..c813b9a3 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_header.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_header_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_header_es.gif new file mode 100644 index 00000000..a92c2df0 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_header_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_header_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_header_ptbr.gif new file mode 100644 index 00000000..a92c2df0 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_header_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive.gif new file mode 100644 index 00000000..8382205e Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF.gif new file mode 100644 index 00000000..3357ed2b Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_es-orig.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_es-orig.gif new file mode 100644 index 00000000..638ef859 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_es-orig.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_es.gif new file mode 100644 index 00000000..5c9a3122 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_ptbr.gif new file mode 100644 index 00000000..335e6356 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_es.gif new file mode 100644 index 00000000..b064725c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_ptbr.gif new file mode 100644 index 00000000..a34409c2 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysactive_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_hotkeysinactive_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysinactive_es.gif new file mode 100644 index 00000000..d0bf982c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_hotkeysinactive_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_internalcloser.gif b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser.gif new file mode 100644 index 00000000..a1adca76 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF.gif new file mode 100644 index 00000000..9d3489fa Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF_es.gif new file mode 100644 index 00000000..45bc4290 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF_ptbr.gif new file mode 100644 index 00000000..45bc4290 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_es.gif new file mode 100644 index 00000000..d5c05657 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_ptbr.gif new file mode 100644 index 00000000..d5c05657 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_internalcloser_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall.gif b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall.gif new file mode 100644 index 00000000..7bca06f9 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF.gif new file mode 100644 index 00000000..63594d65 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF_es.gif new file mode 100644 index 00000000..9c41a291 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF_ptbr.gif new file mode 100644 index 00000000..63594d65 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_es.gif new file mode 100644 index 00000000..9aa29708 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_ptbr.gif new file mode 100644 index 00000000..7bca06f9 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_leave3waycall_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_localcloser.gif b/agc_2-X/trunk/agc/images/vdc_XB_localcloser.gif new file mode 100644 index 00000000..0e10a2ad Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_localcloser.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF.gif new file mode 100644 index 00000000..ed11b7ac Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF_es.gif new file mode 100644 index 00000000..fbad052d Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF_ptbr.gif new file mode 100644 index 00000000..fbad052d Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_localcloser_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_es.gif new file mode 100644 index 00000000..d36e1944 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_localcloser_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_ptbr.gif new file mode 100644 index 00000000..d36e1944 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_localcloser_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_number.gif b/agc_2-X/trunk/agc/images/vdc_XB_number.gif new file mode 100644 index 00000000..33f30330 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_number.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_number_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_number_es.gif new file mode 100644 index 00000000..6d672acc Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_number_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_number_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_number_ptbr.gif new file mode 100644 index 00000000..22e82a58 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_number_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial.gif b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial.gif new file mode 100644 index 00000000..195b1a90 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF.gif b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF.gif new file mode 100644 index 00000000..7c275732 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF_es.gif new file mode 100644 index 00000000..ef710c9c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF_ptbr.gif new file mode 100644 index 00000000..72dee5c0 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_OFF_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_es.gif new file mode 100644 index 00000000..accda01c Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_ptbr.gif new file mode 100644 index 00000000..0101ea9e Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_parkcustomerdial_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_seconds.gif b/agc_2-X/trunk/agc/images/vdc_XB_seconds.gif new file mode 100644 index 00000000..92fc7f2b Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_seconds.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_seconds_es.gif b/agc_2-X/trunk/agc/images/vdc_XB_seconds_es.gif new file mode 100644 index 00000000..f4fe2b27 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_seconds_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_XB_seconds_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_XB_seconds_ptbr.gif new file mode 100644 index 00000000..f4fe2b27 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_XB_seconds_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_tab_script.gif b/agc_2-X/trunk/agc/images/vdc_tab_script.gif new file mode 100644 index 00000000..69e43b79 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_tab_script.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_tab_script_es.gif b/agc_2-X/trunk/agc/images/vdc_tab_script_es.gif new file mode 100644 index 00000000..ba4320d4 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_tab_script_es.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_tab_script_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_tab_script_ptbr.gif new file mode 100644 index 00000000..69e43b79 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_tab_script_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_tab_vicidial.gif b/agc_2-X/trunk/agc/images/vdc_tab_vicidial.gif new file mode 100644 index 00000000..1e862589 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_tab_vicidial.gif differ diff --git a/agc_2-X/trunk/agc/images/vdc_tab_vicidial_ptbr.gif b/agc_2-X/trunk/agc/images/vdc_tab_vicidial_ptbr.gif new file mode 100644 index 00000000..1e862589 Binary files /dev/null and b/agc_2-X/trunk/agc/images/vdc_tab_vicidial_ptbr.gif differ diff --git a/agc_2-X/trunk/agc/inbound_popup.php b/agc_2-X/trunk/agc/inbound_popup.php new file mode 100644 index 00000000..c92583de --- /dev/null +++ b/agc_2-X/trunk/agc/inbound_popup.php @@ -0,0 +1,351 @@ + LICENSE: GPLv2 +### +### This script is designed to open up when a live_inbound call comes in giving the user +### options of what to do with the call or options to lookup the callerID on various web sites +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $uniqueid - ('1234567890.123456',...) +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $ext_context - ('default','demo',...) +### - $ext_priority - ('1','2',...) +### - $voicemail_dump_exten - ('85026666666666') +### - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +### + +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1205 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.6'; +$build = '60619-1205'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +LIVE INBOUND CALL"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

LIVE INBOUND CALL

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid is not valid\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Channel: $row[1]
CallerID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Channel=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "CUSTOM - \n"; + + echo "
Number Dialed: $row[8]
Notes: $row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "HANGUP - \n"; + echo "SEND TO MY VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/agc/live_exten_check.php b/agc_2-X/trunk/agc/live_exten_check.php new file mode 100644 index 00000000..0c54ec4b --- /dev/null +++ b/agc_2-X/trunk/agc/live_exten_check.php @@ -0,0 +1,277 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send whether the client channel is live and to what channel it is connected +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1203 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '1.1.12'; +$build = '60619-1203'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Live Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ChannelA[$loop_count] = "$row[0]"; + $ChannelB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChannelA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChannelB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "ChannelA: $ChannelA[$counter] ~"; + echo "ChannelB: $ChannelB[$counter] ~"; + echo "ChannelBtrunk: $ChannelA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/agc/manager_send.php b/agc_2-X/trunk/agc/manager_send.php new file mode 100644 index 00000000..296094a4 --- /dev/null +++ b/agc_2-X/trunk/agc/manager_send.php @@ -0,0 +1,908 @@ + LICENSE: GPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectVD','HangupConfDial') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# + +# changes +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1158 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$secondS = ereg_replace("[^0-9]","",$secondS); + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$version = '0.0.24'; +$build = '60619-1158'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Manager Send: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "HELP";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten is not valid or queryCID $queryCID is not valid, Originate command not inserted\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nOriginateName Action not sent\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nOriginateNameVmail Action not sent\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten is not valid or queryCID $queryCID is not valid, Originate command not inserted\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Originate command sent for Exten $exten Channel $channel on $server_ip\n"; + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten is not valid or ext_context $ext_context or queryCID $queryCID is not valid, Hangup command not inserted\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or queryCID $queryCID is not valid, Hangup command not inserted\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 4)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel is not live on $call_server_ip, Checking Live Channel...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + echo "Hangup command sent for Channel $channel on $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "auto_dial_level $auto_dial_level must be set\n"; + echo "campaign $campaign must be set\n"; + echo "uniqueid $uniqueid must be set\n"; + echo "lead_id $lead_id must be set\n"; + echo "\nRedirectVD Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "parkedby $parkedby must be set\n"; + echo "\nRedirectToPark Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectFromPark Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectName Action not sent\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "extenName $extenName must be set\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirectNameVmail Action not sent\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "ExtraChannel $extrachannel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirect Action not sent\n"; + } + else + { + if ($exten == "NEXTAVAILABLE") + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Cannot find empty conference on $server_ip, Redirect command not inserted\n"; + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Channel $channel is not live on $call_server_ip, Redirect command not inserted\n"; + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n"; + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra command sent for Channel $channel and \nExtraChannel $extrachannel\n to $exten on $server_ip\n"; + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra command sent for Channel $channel on $call_server_ip and \nExtraChannel $extrachannel\n to $exten on $server_ip\n"; + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + } + } +} + + +if ($ACTION=="Redirect") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "One of these variables is not valid:\n"; + echo "Channel $channel must be greater than 2 characters\n"; + echo "queryCID $queryCID must be greater than 14 characters\n"; + echo "exten $exten must be set\n"; + echo "ext_context $ext_context must be set\n"; + echo "ext_priority $ext_priority must be set\n"; + echo "\nRedirect Action not sent\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for Channel $channel on $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or queryCID $queryCID is not valid or filename: $filename is not valid, $ACTION command not inserted\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Channel $channel is not live on $server_ip, $ACTION command not inserted\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + } + echo "$ACTION command sent for Channel $channel on $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + { + $channel_live=0; + echo "Channel $channel is not valid or exten $exten is not valid or filename: $filename is not valid, $ACTION command not inserted\n"; + } + else + { + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + # find and hang up all recordings going on in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $i++; + } + + } + echo "$ACTION command sent for Channel $channel on $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n RECORDING WILL LAST UP TO 60 MINUTES\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/agc_2-X/trunk/agc/park_calls_display.php b/agc_2-X/trunk/agc/park_calls_display.php new file mode 100644 index 00000000..872f5780 --- /dev/null +++ b/agc_2-X/trunk/agc/park_calls_display.php @@ -0,0 +1,146 @@ + LICENSE: GPLv2 +### +### This script is designed purely to send the details on the parked calls on the server +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +### - $protocol - ('SIP','Zap','IAX2',...) +### + +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1205 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.4'; +$build = '60619-1205'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Parked Calls Display"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten is not valid or protocol $protocol is not valid\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/agc/vdc_db_query.php b/agc_2-X/trunk/agc/vdc_db_query.php new file mode 100644 index 00000000..ef287987 --- /dev/null +++ b/agc_2-X/trunk/agc/vdc_db_query.php @@ -0,0 +1,1512 @@ + LICENSE: GPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') + +# changes +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# + +$version = '0.0.34'; +$build = '60623-1414'; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} + + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); + + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$MT[0]=''; + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) +{ +echo "Invalid Username/Password: |$user|$pass|\n"; +exit; +} +else +{ + +if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } +else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Database Query Script"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Group Choice $closer_choice is not valid\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Closer In Group Choice $closer_choice has been registered to user $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "HOPPER EMPTY\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) && (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + if (strlen($phone_number)>3) + { + if ($use_internal_dnc=='Y') + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC NUMBER\n"; + exit; + } + } + if ($stage=='lookup') + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id(); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='Y', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "HOPPER EMPTY\n"; + } + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "CALL NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context is not valid\n"; + exit; + } + else + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Local_out_prefix$phone_code$phone_number','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + echo "$MqueryCID\n"; + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID is not valid\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status='UPDATED' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + echo "LOG NOT ENTERED\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign is not valid\n"; + exit; + } + else + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Inserted: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOG NOT ENTERED\n"; + } + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CALL_LOG Inserted: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "LOG NOT ENTERED\n"; + # } + } + } + +if ($stage == "end") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) ) + { + echo "LOG NOT ENTERED\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id is not valid\n"; + exit; + } + else + { + if ($start_epoch < 1000) + { + if (eregi("CLOSER",$campaign)) + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user';"; + } + else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT start_epoch FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch =$row[0]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (eregi("CLOSER",$campaign)) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec',status='DONE' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + if ($auto_dial_level > 0) + { + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "LOG NOT ENTERED\n\n"; + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "$recording_id|$length_in_min|"; + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',talk_epoch='$StarTtime',dispo_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Campaign $campaign is not valid\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = trim("$row[29]"); + $called_count = trim("$row[30]"); + } + + ### update the lead status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + ### update the log status to INCALL + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + if (eregi("CLOSER",$campaign)) + { + ### update the vicidial_closer_log user to INCALL + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + + $stmt = "select campaign_id from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select * from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[1]; + $VDCL_group_color = $row[2]; + $VDCL_group_web = $row[4]; + $VDCL_fronter_display = $row[7]; + $VDCL_ingroup_script = $row[8]; + $VDCL_get_call_launch = $row[9]; + $VDCL_xferconf_a_dtmf = $row[10]; + $VDCL_xferconf_a_number = $row[11]; + $VDCL_xferconf_b_dtmf = $row[12]; + $VDCL_xferconf_b_number = $row[13]; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + } + + ### if web form is set then send on to vicidial.php for override of WEB_FORM address + if (strlen($VDCL_group_web)>5) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + else {echo "|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|\n|\n"; + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + ### If CALLBK, change vicidial_callback record to INACTIVE + if ($dispo == 'CALLBK') + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user on $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten is not valid\n"; + exit; + } +else + { + ##### Insert a LOGOUT record into the user log + $stmt="INSERT INTO vicidial_user_log values('','$user','LOGOUT','$campaign','$NOW_TIME','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vul_insert = mysql_affected_rows($link); + + ##### Remove the reservation on the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vc_remove = mysql_affected_rows($link); + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $vla_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH123459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id is not valid\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',dispo_epoch='$StarTtime',status='$dispo_choice' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + + ### CALLBACK ENTRY + if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) + { + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + } + + echo 'Lead ' . $lead_id . ' has been changed to ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id is not valid\n"; + exit; + } + else + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + } + echo "Lead $lead_id information has been updated\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage is not valid\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set status='$stage',lead_id='',uniqueid=0,callerid='',channel='', random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + if ($agent_log == 'NO') + {$donothing=1;} + else + { + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + } + if ($ACTION == 'VDADready') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + if ($ACTION == 'VDADpause') + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',pause_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + } + echo 'Agent ' . $user . ' is now in status ' . $stage . "\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list is not valid\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + +?> diff --git a/agc_2-X/trunk/agc/vicidial.php b/agc_2-X/trunk/agc/vicidial.php new file mode 100644 index 00000000..9d3763bb --- /dev/null +++ b/agc_2-X/trunk/agc/vicidial.php @@ -0,0 +1,5435 @@ + LICENSE: GPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also, you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass. +# +# This script works best with Firefox or Mozilla, but will run for a couple +# hours on Internet Explorer before the memory leaks cause a crash. +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# +# CHANGES +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +$version = '1.1.85'; +$build = '60619-1047'; + +if ($force_logout) +{ + echo "You have now logged out. Thank you\n"; + exit; +} + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$CIDdate = date("ymdHis"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + +$random = (rand(1000000, 9999999) + 10000000); + +$conf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$agentcallsstatus = '0'; # set to 1 to show agent status and call count + $campagentstatctmax = '0'; # Number of seconds for campaign call and agent stats + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +$US='_'; +$CL=':'; +$AT='@'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + + +if ($relogin == 'YES') +{ +echo "VICIDIAL web client: Re-Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Login
 
Phone Login:
Phone Password:
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "VICIDIAL web client: Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

User Login

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Campaign Login
 
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "VICIDIAL web client: Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login
 
Phone Login:
Phone Password:
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "VICIDIAL web client: Phone Login\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone Login
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$fp = fopen ("./vicidial_auth_entries.txt", "a"); +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + $user_level=$row[1]; + $VU_hotkeys_active=$row[2]; + $VU_agent_choose_ingroups=$row[3]; + $VU_scheduled_callbacks=$row[4]; + $agentonly_callbacks=$row[5]; + $agentcall_manual=$row[6]; + $VU_vicidial_recording=$row[7]; + $VU_vicidial_transfers=$row[8]; + $VU_closer_default_blended=$row[9]; + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the statuses to be dialed for your campaign as well as other campaign settings + $stmt="SELECT dial_status_a,dial_status_b,dial_status_c,dial_status_d,dial_status_e,park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $status_A = $row[0]; + $status_B = $row[1]; + $status_C = $row[2]; + $status_D = $row[3]; + $status_E = $row[4]; + $park_ext = $row[5]; + $park_file_name = $row[6]; + $web_form_address = $row[7]; + $allow_closers = $row[8]; + $auto_dial_level = $row[9]; + $dial_timeout = $row[10]; + $dial_prefix = $row[11]; + $campaign_cid = $row[12]; + $campaign_vdad_exten = $row[13]; + $campaign_rec_exten = $row[14]; + $campaign_recording = $row[15]; + $campaign_rec_filename = $row[16]; + $campaign_script = $row[17]; + $get_call_launch = $row[18]; + $campaign_am_message_exten = $row[19]; + $xferconf_a_dtmf = $row[20]; + $xferconf_a_number = $row[21]; + $xferconf_b_dtmf = $row[22]; + $xferconf_b_number = $row[23]; + $alt_number_dialing=$row[24]; + $VC_scheduled_callbacks=$row[25]; + $wrapup_seconds=$row[26]; + $wrapup_message=$row[27]; + $closer_campaigns=$row[28]; + $use_internal_dnc=$row[29]; + + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + {$alt_phone_dialing='0';} + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if (eregi("CLOSER", $VD_campaign)) + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 20;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Campaign not active, please try again
"; + } + } + else + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Login incorrect, please try again
"; + } + } + if ($VDloginDISPLAY) + { + echo "VICIDIAL web client: Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Campaign Login
 
User Login:
User Password:
Campaign: $camp_form_code

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "VICIDIAL web client: Phone Login Error\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Login Error
 
Sorry, your phone login and password are not active in this system, please try again:
 
Phone Login:
Phone Password:

VERSION: $version       BUILD: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "VICIDIAL web client\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CallerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed on this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + if ( (eregi("CLOSER", $VD_campaign)) || ($campaign_leads_to_call > 0) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log values('','$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT conf_exten FROM vicidial_conferences where server_ip = '$server_ip' and ((extension='') or (extension is null)) LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $free_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $free_conf_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + $stmt="UPDATE vicidial_conferences set extension='$SIP_user' where server_ip='$server_ip' and conf_exten='$session_id';"; + $rslt=mysql_query($stmt, $link); + print "\n"; + + } + + $stmt="UPDATE vicidial_list set status='N', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login on phone: $SIP_user to campaign: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### use manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if (eregi("CLOSER", $VD_campaign)) + { + print "\n"; + } + } + else + { + print "\n"; + + + + } + } + else + { + echo "VICIDIAL web client: VICIDIAL Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Sorry, there are no leads in the hopper for this campaign\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Password:
\n"; + echo "Campaign: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "VICIDIAL web client: VICIDIAL Campaign Login\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Login: \n
"; + echo "Password:
\n"; + echo "Campaign: $camp_form_code
\n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id(); + print "\n"; + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = rawurlencode($row[1]); + $MMscripttext[$e] = rawurlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('January','February','March','April','May','June', + 'July','August','September','October','November','December'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(0,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + + + +\n"; + + +?> + +
+ + +
+ + + +LOGOUT\n"; ?> +
+
+ + + + + + + + +
VICIDIALSCRIPT   LIVE     session ID: Live Call
+
+ + + + +

VICIDIAL
+
+ + +MANUAL DIAL
+
+ + +X ACTIVE CALLBACKS
+
+ + +
CALLBACKS FOR AGENT :
Click on a callback below to call the customer back now. If you click on a record below to call it, it will be removed from the list. +
+
+
  + Refresh +                 + Go Back +
+
+ + +
NEW MANUAL DIAL LEAD FOR :

Enter information below for the new lead you wish to call. +
+ \n"; + } + ?> + Note: all new manual dial leads will go into list 999

+ + + + + + + + + + + + + + + +
Dial Code:   (This is usually a 1 in the USA-Canada)
Phone Number:   (10 digits max - digits only)
Search Existing Leads:   (This option if checked will attempt to find the phone number in the system before inserting it as a new lead)


If you want to dial a number and have it NOT be added as a new lead, enter in the exact dialstring that you want to call in the Dial Override field below. To hangup this call you will have to open the CALLS IN THIS SESSION link at the bottom of the screen and hang it up by clicking on its channel link there.
 
Dial Override:   (digits only please)
+
+ Dial Now +                 + Go Back +
+
+ + + + +Your Status:
Calls Dialing: +
+ + + + + +
+ + Transfer - Conference
+ INTERNAL CLOSER + LOCAL CLOSER + CODE + Hangup Xfer Line + Hangup Both Lines + +
+ + Number to call   + seconds   + channel + + OVERRIDE   + D1 + D2 +
+ + Dial With Customer + Park Customer Dial + LEAVE 3-WAY CALL + Dial Blind Transfer + Blind Transfer VMail Message +
+
+
+ + + + +
Lead Dispositioned As:

+ -
+
+
+ + + + + + + +
Disposition Hot Keys: + When active, simply press the keyboard key for the desired disposition for this call. The call will then be hungup and dispositioned automatically:
+ + + + + +
+
+ + +
Noone is in your session:
+ Go Back +

+ Call Agent Again +
+
+ + +
Customer has hung up:
+ Go Back +

+ Finish and Disposition Call + +
+
+ + +
Call Wrapup: seconds remaining in wrapup

+ +

+ Finish Wrapup and Move On + +
+
+ + +

LOGOUT
+
+ + +
+
+ + +
 
+
+ + +
Any changes made to the customer information below at this time will not be comitted, You must change customer information before you Hangup the call.
+
+ + +
DISPOSITION CALL :       Hangup Again       minimize
+ End-of-call Disposition Selection +
+ PAUSE AGENT DIALING
+ CLEAR FORM | + SUBMIT +

+ WEB FORM SUBMIT +

  +
+
+ + + +
Select a CallBack Date :
+ + + Select a Date Below   +     + Hour: +   + Minutes: +   + +  
+ MY CALLBACK ONLY
";} + ?> + CB Comments:

+ + SUBMIT

+ +

  +
+
+ + +
CLOSER INBOUND GROUP SELECTION
+ Closer Inbound Group Selection +
+ BLENDED CALLING(outbound activated)
+ RESET | + SUBMIT +



  +
+
+ + + + Channel + Channel + MY CALLBACK ONLY
";} + ?> +
+ + + + + + + +
LIVE CALL TRANSFER
Channel to be transferred: Channel
Extensions:
Extensions Menu
+
+ Send to selected extension

+ Send to selected vmail box

+ Send to this number:


+ REFRESH


+ Back to Main Window

+
Conferences:
(click on a number below to send to a conference)
Send my channel too
Conferences Menu
+
+ + + + +
VICIDIAL SCRIPT
+
+ + + + + + + + + + + + + + + + + +
STATUS:
+
+Dial Next Number
+ LEAD PREVIEW
+ ALT PHONE DIAL
+ + +RECORDING FILE:
+
+
+RECORD ID:
+
+ +Start Recording
+
+Web Form
+
+Park Call
+Transfer - Conference
+
+Hangup Customer
+
+Send DTMF
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\n";} +else + {echo "\n";} +?> + +
seconds:   Channel:   Cust Time:
Customer Information:
Title:   First:   MI:   Last:
Address1:
Address2:   Address3:
City:   State:   PostCode:
Province:   Vendor ID:
Phone:   DialCode:   Alt. Phone:
Show:   Email:
Comments:
+ +
+


  + +
+ + + + +
VICIDIAL web-client version:     BUILD:               Server:              
+Show conference call channel information
+ 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +HOT KEYS INACTIVE + +
+ + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/agc_2-X/trunk/agc/voicemail_check.php b/agc_2-X/trunk/agc/voicemail_check.php new file mode 100644 index 00000000..0aa152d7 --- /dev/null +++ b/agc_2-X/trunk/agc/voicemail_check.php @@ -0,0 +1,140 @@ + LICENSE: GPLv2 +### +### This script is designed purely to check whether the voicemail box on the server defined has new and old messages +### This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +### +### required variables: +### - $server_ip +### - $session_name +### - $user +### - $pass +### optional variables: +### - $format - ('text','debug') +### - $vmail_box - ('101','1234',...) +### + +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1204 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60619-1204'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Invalid Username/Password: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Invalid server_ip: |$server_ip| or Invalid session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Invalid session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Voicemail Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "voicemail box $vmail_box is not valid\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/agc_2-X/trunk/agi-CIDtest.agi b/agc_2-X/trunk/agi-CIDtest.agi new file mode 100644 index 00000000..18186610 --- /dev/null +++ b/agc_2-X/trunk/agi-CIDtest.agi @@ -0,0 +1,175 @@ +#!/usr/bin/perl +# +# agi-CIDtest.agi +# +# this script is designed to do testing of CallerID strings and how flexible Asterisk is to assigning just CIDnum and CIDname +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8367,1,AGI(agi-CIDtest.agi,${EXTEN}) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V=1; +$M=1; + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } + + +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|\n";} + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDAD_LB_closer.agi b/agc_2-X/trunk/agi-VDAD_LB_closer.agi new file mode 100644 index 00000000..957ef955 --- /dev/null +++ b/agc_2-X/trunk/agi-VDAD_LB_closer.agi @@ -0,0 +1,557 @@ +#!/usr/bin/perl +# +# agi-VDAD_LB_transfer.agi version 0.2 +# Load Balanced - when a call comes in on this server the script looks for an agent +# on any server on the network on the same campaign to send call to. +# +# runs when a call comes in from a VICIDIAL fronter. This script will +# send the calls out to the closers that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will send the call to the specified Vmail +# box or hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound VICIDIAL calls: +#exten => _90009.,1,Answer ; Answer the line +#exten => _90009.,2,AGI(agi-VDADcloser.agi,${EXTEN}-----START) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1107 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for internal PRI transfer data string "90009*CL_uk3survy_*8301*10000123*universal***" + if ($extension =~ /^900\d\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $referring_extension = $EXT_vars[0]; # initial extension sent + $channel_group = $EXT_vars[1]; # name of the parked group + $inbound_number = $EXT_vars[2]; # extension to send call to after parsing + $parked_by = $EXT_vars[3]; # leadID + $park_extension = $EXT_vars[4]; # filename of the on-hold music file + $comment_d = $EXT_vars[5]; # N/A + $comment_e = $EXT_vars[6]; # N/A + + $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # JmmddhhmmssLLLLLLLLL + $JqueryCID = "J$CIDdate$PADlead_id"; + $callerid = $JqueryCID; + ### set the callerid to the filename of the audio for on-hold + print "SET CALLERID $JqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $JqueryCID\n"; + } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel\n";} +if ($M) {print STDERR "+++++ VDCL START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + +### Grab call parameters from vicidial_list table +$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$channel_group"; + $VDADphone = "$record->[0]"; + $VDADphone_code = "$record->[1]"; + $VDADlead_id = "$CIDlead_id"; + $VDADfronter = "$record->[2]"; + } + } + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN')"; +$dbhA->query($stmtA); + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$CIDlead_id','$VDADcampaign','$SQLdate','$VDADphone_code','$VDADphone','$VDADfronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$server_ip' where status IN('CLOSER','READY') and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $VDADcampaign %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + $VDADserver_ip = "$record->[3]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$CIDlead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$CIDlead_id|$VDADuser\n";} + + $dbhA->close; + + ### format the remote server dialstring to get the call to the overflow agent meetme room + $S='*'; + $VDADremDIALstr=''; + if( ($VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/) && ($VDADserver_ip !~ /$server_ip/) ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VDADremDIALstr = "$a$S$b$S$c$S$d$S"; + } + $VDADremDIALstr .= "$VDADconf_exten"; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADremDIALstr\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$CIDlead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$CIDlead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + +sub leading_zero($) { + $_ = $_[0]; + s/^(\d)$/0$1/; + s/^(\d\d)$/0$1/; + return $_; +} # End of the leading_zero() routine. diff --git a/agc_2-X/trunk/agi-VDAD_LB_closer_inbound.agi b/agc_2-X/trunk/agi-VDAD_LB_closer_inbound.agi new file mode 100644 index 00000000..fa8a340a --- /dev/null +++ b/agc_2-X/trunk/agi-VDAD_LB_closer_inbound.agi @@ -0,0 +1,680 @@ +#!/usr/bin/perl +# +# agi-VDAD_LB_closer_inbound.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# ## THIS IS THE LOAD-BALANCED VERSION OF THE SCRIPT ## +# +# if there are no available agents on any server, it will check every second until an agent becomes available, +# if at the end of 360 seconds it has not found an agent it will hangup the call and mark it as dropped +# +# This version asks for a 4-digit pin number to be entered and passed on as the fronter value to the closer +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Answer ; Answer the line +#exten => 1234,2,AGI(agi-VDAD_LO_closer_inbound.agi,CL_GALLERIA-----7274515134-----Closer-----park----------999-----1) +#exten => 1234,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1122 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + $phone_number=''; + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +&enter_pin_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$new_lead_id','$channel_group','$SQLdate','$phone_code','$phone_number','$fronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$server_ip' where status IN('CLOSER','READY') and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n";} + # if ($M) {print STDERR "|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + $VDADserver_ip = "$record->[3]"; + } + } + else + { + print STDERR "NNNNNNNNNN No agent record found!!!\n"; + } + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$new_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$new_lead_id|$VDADuser\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + ### format the remote server dialstring to get the call to the overflow agent meetme room + $S='*'; + if( ($VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/) && ($VDADserver_ip !~ /$server_ip/) ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VDADremDIALstr = "$a$S$b$S$c$S$d$S"; + } + $VDADremDIALstr .= "$VDADconf_exten"; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD REMOTE XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + +### you're call is very important to us, please stay on the line and you will be transferred to the next available agent \ No newline at end of file diff --git a/agc_2-X/trunk/agi-VDAD_LB_transfer.agi b/agc_2-X/trunk/agi-VDAD_LB_transfer.agi new file mode 100644 index 00000000..61cc83eb --- /dev/null +++ b/agc_2-X/trunk/agi-VDAD_LB_transfer.agi @@ -0,0 +1,532 @@ +#!/usr/bin/perl +# +# agi-VDAD_LB_transfer.agi version 0.3 +# Load Balanced - when a call comes in on this server the script looks for an agent +# on any server on the network on the same campaign to send call to. +# +# runs when a call comes in from the VICIDIAL_auto_dialer. This script will +# send the calls out to the reps that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 10 seconds(default) it has not found an agent it will hangup the call and mark it as dropped. +# +# this version "LB" Load Balance will seek out agents on the local server and the +# same campaign on other servers and transfer the calls to them over IAX trunks. +# the IAX user trunks are named based on the IP address of the home server: +# The server 10.10.10.15 would have a username of 10x10x10x15 in the iax.conf on the other servers +# Also, the home server needs to have the trunks registered, for speed and channel consistency +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8365,1,AGI(call_log.agi,${EXTEN}) +# exten => 8365,2,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 51118-2102 - first build based on agi-VDADtransfer.agi script +# 60119-1408 - fixed calleridname issue with 1.2 tree for custom CID +# 60503-1043 - Added safe harbor and drop second options from campaign +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 10; ### default number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() +{ + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VDAD START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|\n";} + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + +### Grab call parameters from vicidial_auto_calls table +$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE' where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} +if ($affected_rows > 0) + { + $stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$record->[0]"; + $VDADphone = "$record->[1]"; + $VDADphone_code = "$record->[2]"; + $VDADlead_id = "$record->[3]"; + $VDADcall_time = "$record->[4]"; + } + } + +### Grab campaign values from the database +$stmtA = "SELECT drop_call_seconds,safe_harbor_message,safe_harbor_exten FROM vicidial_campaigns where campaign_id = '$VDADcampaign';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBsafe_harbor_message = "$record->[1]"; + $DBsafe_harbor_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBsafe_harbor_message) {$safe_harbor_message = $DBsafe_harbor_message;} + if ($DBsafe_harbor_exten) {$safe_harbor_exten = $DBsafe_harbor_exten;} + } + } + + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDAD','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + + } + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < $DROP_TIME) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + $DROP_TIME); + } + } +$stmtA = "SELECT next_agent_call FROM vicidial_campaigns where campaign_id='$VDADcampaign';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + +$agent_call_order=''; +if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} +if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} +if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} +if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; +$stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and campaign_id = '$VDADcampaign' and call_time < \"$VDADcall_time\" and lead_id != '$VDADlead_id';"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } +if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$server_ip', callerid='$callerid' where status = 'READY' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and campaign_id='$VDADcampaign' and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + $VDADserver_ip = "$record->[3]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER REMOTE: |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $dbhA->close; + + ### format the remote server dialstring to get the call to the overflow agent meetme room + $S='*'; + $VDADremDIALstr=''; + if( ($VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/) && ($VDADserver_ip !~ /$server_ip/) ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VDADremDIALstr = "$a$S$b$S$c$S$d$S"; + } + $VDADremDIALstr .= "$VDADconf_exten"; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADremDIALstr\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } +else + { + print STDERR "WWWWWWWW VDAD XFER REMOTE WAIT: |$rec_countWAIT|$VDADcampaign|$channel|$callerid|$uniqueid|\n"; + } + + +### sleep for 99 hundredths of a second +usleep(1*990*1000); + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($safe_harbor_message=='Y') + { + $DROPexten = "$safe_harbor_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_campaigns where campaign_id = '$VDADcampaign' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + +sub leading_zero($) { + $_ = $_[0]; + s/^(\d)$/0$1/; + s/^(\d\d)$/0$1/; + return $_; +} # End of the leading_zero() routine. diff --git a/agc_2-X/trunk/agi-VDAD_LO_closer.agi b/agc_2-X/trunk/agi-VDAD_LO_closer.agi new file mode 100644 index 00000000..f6d93989 --- /dev/null +++ b/agc_2-X/trunk/agi-VDAD_LO_closer.agi @@ -0,0 +1,642 @@ +#!/usr/bin/perl +# +# agi-VDAD_LO_closer.agi version 0.2 +# Overflow Balanced - when a call comes in on this server the script looks for an agent +# on this server to send call to. If none available it looks for the next available +# agent on any other server on the network on the same campaign to send call to. +# +# runs when a call comes in from a VICIDIAL fronter. This script will +# send the calls out to the closers that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will send the call to the specified Vmail +# box or hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound VICIDIAL calls: +#exten => _90009.,1,Answer ; Answer the line +#exten => _90009.,2,AGI(agi-VDADcloser.agi,${EXTEN}-----START) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1150 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for internal PRI transfer data string "90009*CL_uk3survy_*8301*10000123*universal***" + if ($extension =~ /^900\d\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $referring_extension = $EXT_vars[0]; # initial extension sent + $channel_group = $EXT_vars[1]; # name of the parked group + $inbound_number = $EXT_vars[2]; # extension to send call to after parsing + $parked_by = $EXT_vars[3]; # leadID + $park_extension = $EXT_vars[4]; # filename of the on-hold music file + $comment_d = $EXT_vars[5]; # N/A + $comment_e = $EXT_vars[6]; # N/A + + $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # JmmddhhmmssLLLLLLLLL + $JqueryCID = "J$CIDdate$PADlead_id"; + $callerid = $JqueryCID; + ### set the callerid to the filename of the audio for on-hold + print "SET CALLERID $JqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $JqueryCID\n"; + } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel\n";} +if ($M) {print STDERR "+++++ VDCL START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + +### Grab call parameters from vicidial_list table +$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$channel_group"; + $VDADphone = "$record->[0]"; + $VDADphone_code = "$record->[1]"; + $VDADlead_id = "$CIDlead_id"; + $VDADfronter = "$record->[2]"; + } + } + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN')"; +$dbhA->query($stmtA); + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$CIDlead_id','$VDADcampaign','$SQLdate','$VDADphone_code','$VDADphone','$VDADfronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $VDADcampaign %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$CIDlead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$CIDlead_id|$VDADuser\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + +################################################################################################### +### noone found locally available, now check for someone on another server to take the call + + $rec_countWAITrem=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip!='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAITrem < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$server_ip' where status IN('CLOSER','READY') and server_ip!='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $VDADcampaign %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and server_ip!='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + $VDADserver_ip = "$record->[3]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER REMOTE: |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$CIDlead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$CIDlead_id|$VDADuser\n";} + + $dbhA->close; + + ### format the remote server dialstring to get the call to the overflow agent meetme room + $S='*'; + if( $VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VDADremDIALstr = "$a$S$b$S$c$S$d$S"; + } + $VDADremDIALstr .= "$VDADconf_exten"; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADremDIALstr\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER REMOTE WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + + + + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$CIDlead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$CIDlead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + +sub leading_zero($) { + $_ = $_[0]; + s/^(\d)$/0$1/; + s/^(\d\d)$/0$1/; + return $_; +} # End of the leading_zero() routine. diff --git a/agc_2-X/trunk/agi-VDAD_LO_closer_inbound.agi b/agc_2-X/trunk/agi-VDAD_LO_closer_inbound.agi new file mode 100644 index 00000000..a471b0c0 --- /dev/null +++ b/agc_2-X/trunk/agi-VDAD_LO_closer_inbound.agi @@ -0,0 +1,770 @@ +#!/usr/bin/perl +# +# agi-VDAD_LO_closer_inbound.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# ## THIS IS THE LOAD-BALANCED-OVERFLOW VERSION OF THE SCRIPT ## +# +# if there are no available agents on this server, it will check for available agents on other servers, +# then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# This version asks for a 4-digit pin number to be entered and passed on as the fronter value to the closer +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Answer ; Answer the line +#exten => 1234,2,AGI(agi-VDAD_LO_closer_inbound.agi,CL_GALLERIA-----7274515134-----Closer-----park----------999-----1) +#exten => 1234,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1214 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + $phone_number=''; + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +&enter_pin_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$new_lead_id','$channel_group','$SQLdate','$phone_code','$phone_number','$fronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n";} + # if ($M) {print STDERR "|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + else + { + print STDERR "NNNNNNNNNN No agent record found!!!\n"; + } + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$new_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$new_lead_id|$VDADuser\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + +################################################################################################### +### noone found locally available, now check for someone on another server to take the call + + $rec_countWAITrem=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip!='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAITrem = "$record->[0]"; + } + } + if ($rec_countWAITrem < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$server_ip' where status IN('CLOSER','READY') and server_ip!='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n";} + # if ($M) {print STDERR "|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and server_ip!='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + $VDADserver_ip = "$record->[3]"; + } + } + else + { + print STDERR "NNNNNNNNNN No agent record found!!!\n"; + } + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$new_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$new_lead_id|$VDADuser\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + ### format the remote server dialstring to get the call to the overflow agent meetme room + $S='*'; + if( $VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VDADremDIALstr = "$a$S$b$S$c$S$d$S"; + } + $VDADremDIALstr .= "$VDADconf_exten"; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD REMOTE XFER WAIT: |$rec_countWAITrem|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + +### you're call is very important to us, please stay on the line and you will be transferred to the next available agent \ No newline at end of file diff --git a/agc_2-X/trunk/agi-VDAD_LO_transfer.agi b/agc_2-X/trunk/agi-VDAD_LO_transfer.agi new file mode 100644 index 00000000..b2da78f6 --- /dev/null +++ b/agc_2-X/trunk/agi-VDAD_LO_transfer.agi @@ -0,0 +1,606 @@ +#!/usr/bin/perl +# +# agi-VDAD_LO_transfer.agi version 0.3 +# Overflow Balanced - when a call comes in on this server the script looks for an agent +# on this server to send call to. If none available it looks for the next available +# agent on any other server on the network on the same campaign to send call to. +# +# runs when a call comes in from the VICIDIAL_auto_dialer. This script will +# send the calls out to the reps that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 20 seconds it has not found an agent it will hangup the call and mark it as dropped. +# +# this version "LO" Load Overflow checks first with local agents then it will seek out agents on the +# same campaign on other servers and transfer the calls to them over IAX trunks. +# the IAX user trunks are named based on the IP address of the home server: +# The server 10.10.10.15 would have a username of 10x10x10x15 in the iax.conf on the other servers +# Also, the home server needs to have the trunks registered, for speed and channel consistency +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8365,1,AGI(call_log.agi,${EXTEN}) +# exten => 8365,2,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 51118-2102 - first build based on agi-VDADtransfer.agi script +# 60119-1408 - fixed calleridname issue with 1.2 tree for custom CID +# 60503-1048 - Added safe harbor and drop second options from campaign +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 10; ### default number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() +{ + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VDAD START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|\n";} + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + +### Grab call parameters from vicidial_auto_calls table +$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE' where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} +if ($affected_rows > 0) + { + $stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$record->[0]"; + $VDADphone = "$record->[1]"; + $VDADphone_code = "$record->[2]"; + $VDADlead_id = "$record->[3]"; + $VDADcall_time = "$record->[4]"; + } + } + +### Grab campaign values from the database +$stmtA = "SELECT drop_call_seconds,safe_harbor_message,safe_harbor_exten FROM vicidial_campaigns where campaign_id = '$VDADcampaign';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBsafe_harbor_message = "$record->[1]"; + $DBsafe_harbor_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBsafe_harbor_message) {$safe_harbor_message = $DBsafe_harbor_message;} + if ($DBsafe_harbor_exten) {$safe_harbor_exten = $DBsafe_harbor_exten;} + } + } + + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDAD','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + + } + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < $DROP_TIME) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + $DROP_TIME); + } + } +$stmtA = "SELECT next_agent_call FROM vicidial_campaigns where campaign_id='$VDADcampaign';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + +$agent_call_order=''; +if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} +if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} +if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} +if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; +$stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$VDADcampaign' and call_time < \"$VDADcall_time\" and lead_id != '$VDADlead_id';"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } +if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$server_ip', callerid='$callerid' where status = 'READY' and server_ip='$server_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id='$VDADcampaign' and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } +else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$VDADcampaign|$channel|$callerid|$uniqueid|\n"; + } + +################################################################################################### +### noone found locally available, now check for someone on another server to take the call + + $rec_countWAITrem=0; +$stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip!='$server_ip' and campaign_id = '$VDADcampaign' and call_time < \"$VDADcall_time\" and lead_id != '$VDADlead_id';"; +if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAITrem = "$record->[0]"; + } + } +if ($rec_countWAITrem < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$server_ip', callerid='$callerid' where status = 'READY' and server_ip!='$server_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and server_ip!='$server_ip' and campaign_id='$VDADcampaign' and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + $VDADserver_ip = "$record->[3]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER REMOTE: |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $dbhA->close; + + ### format the remote server dialstring to get the call to the overflow agent meetme room + $S='*'; + if( $VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) + { + $a = leading_zero($1); + $b = leading_zero($2); + $c = leading_zero($3); + $d = leading_zero($4); + $VDADremDIALstr = "$a$S$b$S$c$S$d$S"; + } + $VDADremDIALstr .= "$VDADconf_exten"; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADremDIALstr\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } +else + { + print STDERR "WWWWWWWW VDAD XFER REMOTE WAIT: |$rec_countWAITrem|$VDADcampaign|$channel|$callerid|$uniqueid|\n"; + } + + +### sleep for 99 hundredths of a second +usleep(1*990*1000); + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($safe_harbor_message=='Y') + { + $DROPexten = "$safe_harbor_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_campaigns where campaign_id = '$VDADcampaign' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + +sub leading_zero($) { + $_ = $_[0]; + s/^(\d)$/0$1/; + s/^(\d\d)$/0$1/; + return $_; +} # End of the leading_zero() routine. diff --git a/agc_2-X/trunk/agi-VDADautoREMINDER.agi b/agc_2-X/trunk/agi-VDADautoREMINDER.agi new file mode 100644 index 00000000..728b4270 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADautoREMINDER.agi @@ -0,0 +1,610 @@ +#!/usr/bin/perl +# +# agi-VDADautoREMINDER.agi version 0.2 +# +# runs when a call comes in from the VICIDIAL auto_dialer. This script will +# send the calls out to specified voicemail boxes in if called person presses key. +# The voicemail box is defined per-lead in the vicidial_list.security_phrase field +# This campaign does not send calls to live agents. +# +# Call statuses from this script: +# N- Call was picked up, didn't finish initial message +# MP- Initial message was played +# VM- call was sent to voicemail +# CALLBK- customer selected to be called back +# +# It is recommended that you run this campaign at a dial level of 1.0 +# It is recommended that you use remote_agents for activation of this script +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8372,1,AGI(call_log.agi,${EXTEN}) +# exten => 8372,2,AGI(agi-VDADautoREMINDER.agi,${EXTEN}) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# CHANGES +# 60313-1626 - First build +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +##### AUDIO FILES IN THIS PROGRAM ##### +$message_audio_file = 'US_reminder_message'; +$options_audio_file = 'US_reminder_options'; +# $voicemail_xfer_file = 'US_reminder_voicemail'; not used +$callback_audio_file = 'US_reminder_callback'; +$goodbye_audio_file = 'US_reminder_goodbye'; + + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; #20060310100402 + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VDAD START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$priority|\n";} + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + + +sleep(1); + +$AGI->stream_file('beep'); + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +######### INSERT/UPDATE CALL RECORD ########## +$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE' where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} +if ($affected_rows > 0) + { + $stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$record->[0]"; + $VDADphone = "$record->[1]"; + $VDADphone_code = "$record->[2]"; + $VDADlead_id = "$record->[3]"; + $VDADcall_time = "$record->[4]"; + } + } + + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','N','$VDADphone_code','$VDADphone','VDAD','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + + } + + + + +######### REMINDER CHOICE FROM RECORDINGS ######## +&reminder_choice; + +if ($pin < 1) + { + &reminder_choice; + + if ($pin < 1) + { + $AGI->stream_file("$goodbye_audio_file"); + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + + $stmtA = "UPDATE vicidial_log set end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip|$end_date_epoch|$now_date_epoch|$length_in_sec|\n";} + + $VHqueryCID = "VHNGUP$tsSQLdate"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + + sleep(1); + + exit; + } + } + +if ($V) {print STDERR "+++++ VDAD STATUS : pressed $pin|$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($pin !~ /^1|^2/) {exit;} + +if (!$DB_port) {$DB_port='3306';} + + + + + +if ($pin =~ /^1|^2/) +{ + +if ($pin == "1") ### send call to voicemail + { +# message can be left on agent vmail box +# # Thank you for your response, we will now transfer you to your agent's voicemail box. +# $AGI->stream_file("$voicemail_xfer_file"); + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_list set status='VM' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\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) {$Fhour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + $stmtA = "UPDATE vicidial_log set status='VM', end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record updated: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $VMAIL_box=0; + ### Grab Server values from the database + $stmtA = "SELECT security_phrase FROM vicidial_list where lead_id = '$CIDlead_id';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VMAIL_box = "$record->[0]"; + } + } + + ### SEND CALL TO VOICEMAIL BOX ### + print STDERR "\nexiting the VDAD app, transferring call to $voicemail_dump_exten$VMAIL_box\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $voicemail_dump_exten$VMAIL_box\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + + } + +if ($pin == "2") ### mark call as a CALLBK + { + + # Thank you for your response, your agent will be contacting you shortly. + $stmtA = "DELETE from vicidial_auto_calls where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD DONE : |$affected_rows|delete of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_list set status='CALLBK' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\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) {$Fhour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + $stmtA = "UPDATE vicidial_log set status='CALLBK', end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record updated: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $AGI->stream_file("$callback_audio_file"); + + $VHqueryCID = "VHNGUP$tsSQLdate"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + + sleep(1); + + exit; + } + +} ### end if pressed 1,2 + + + + + +else ### user pressed digit other than 1 or 2 +{ + +exit; +} + +$dbhA->close; + + + +exit; + + + + + + + + + + + +sub reminder_choice +{ +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +# Hello, this is a courtesy call from ACME Industries reminding you that the deadline for the submission of orders for the June 5th batch delivery is tomorrow, March 10th: + # second audio file +# If you would like to leave a message for your agent please press 1. +# If you would like to have your agent call you back please press 2. + # third audio file +# Thank you, Goodbye + + +######### PLAY THE MESSAGE FILE THEN WAIT 2 SECONDS FOR DIGITS ############ +$interrupt_digit = $AGI->stream_file("$message_audio_file",'12'); + print STDERR "interrupt_digit |$interrupt_digit|\n"; +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + +$channel_status = $AGI->channel_status("$channel"); + if ($V) {print STDERR "SSSSSSSSSS Channel Status: $channel_status\n";} + + if ($channel_status == 6) + { + $stmtA = "UPDATE vicidial_log set status='MP' where uniqueid = '$uniqueid' and lead_id='$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: N|$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_list set status='MP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: N|$affected_rows|$CIDlead_id\n";} + } + +while ($digit_loop_counter < 1) + { + $digit = chr($AGI->wait_for_digit('2000')); # wait 2 seconds for input or until digit pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=1; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) + { + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; + return; + } + + + +######### PLAY THE OPTIONS FILE THEN WAIT 5 SECONDS FOR DIGITS ############ +$interrupt_digit = $AGI->stream_file("$options_audio_file",'12'); + print STDERR "interrupt_digit |$interrupt_digit|\n"; +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + +while ($digit_loop_counter < 1) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until digit pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=1; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) + { + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; + return; + } +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + diff --git a/agc_2-X/trunk/agi-VDADautoREMINDERxfer.agi b/agc_2-X/trunk/agi-VDADautoREMINDERxfer.agi new file mode 100644 index 00000000..34d8c9ec --- /dev/null +++ b/agc_2-X/trunk/agi-VDADautoREMINDERxfer.agi @@ -0,0 +1,673 @@ +#!/usr/bin/perl +# +# agi-VDADautoREMINDERxfer.agi version 0.1 +# +# runs when a call comes in from the VICIDIAL auto_dialer. This script will +# send the calls out to specified voicemail boxes or specified extensions if +# called person presses specified key(1,2,3). +# The voicemail box is defined per-lead in the vicidial_list.security_phrase field +# The exten xfer number is defined per-lead in the vicidial_list.comments field +# +# Call statuses from this script: +# N- Call was picked up, didn't finish initial message +# MP- Initial message was played +# VM- call was sent to voicemail +# XFER- call was sent to specified extension +# CALLBK- customer selected to be called back +# +# It is recommended that you run this campaign at a dial level of 1.0 +# It is recommended that you use remote_agents for activation of this script +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8372,1,AGI(call_log.agi,${EXTEN}) +# exten => 8372,2,AGI(agi-VDADautoREMINDERxfer.agi,${EXTEN}) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# CHANGES +# 60511-1214 - First build +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +##### AUDIO FILES IN THIS PROGRAM ##### +$message_audio_file = 'US_reminder_message'; +$options_audio_file = 'US_reminder_options'; +# $voicemail_xfer_file = 'US_reminder_voicemail'; not used +$callback_audio_file = 'US_reminder_callback'; +$goodbye_audio_file = 'US_reminder_goodbye'; + + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; #20060310100402 + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VDAD START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$priority|\n";} + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + + +sleep(1); + +$AGI->stream_file('beep'); + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +######### INSERT/UPDATE CALL RECORD ########## +$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE' where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} +if ($affected_rows > 0) + { + $stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$record->[0]"; + $VDADphone = "$record->[1]"; + $VDADphone_code = "$record->[2]"; + $VDADlead_id = "$record->[3]"; + $VDADcall_time = "$record->[4]"; + } + } + + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','N','$VDADphone_code','$VDADphone','VDAD','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + + } + + + + +######### REMINDER CHOICE FROM RECORDINGS ######## +&reminder_choice; + +if ($pin < 1) + { + &reminder_choice; + + if ($pin < 1) + { + $AGI->stream_file("$goodbye_audio_file"); + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + + $stmtA = "UPDATE vicidial_log set end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip|$end_date_epoch|$now_date_epoch|$length_in_sec|\n";} + + $VHqueryCID = "VHNGUP$tsSQLdate"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + + sleep(1); + + exit; + } + } + +if ($V) {print STDERR "+++++ VDAD STATUS : pressed $pin|$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($pin !~ /^1|^2|^3/) {exit;} + +if (!$DB_port) {$DB_port='3306';} + + + + + +if ($pin =~ /^1|^2|^3/) +{ + +if ($pin == "1") ### send call to voicemail + { +# message can be left on agent vmail box +# # Thank you for your response, we will now transfer you to your agent's voicemail box. +# $AGI->stream_file("$voicemail_xfer_file"); + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_list set status='VM' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\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) {$Fhour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + $stmtA = "UPDATE vicidial_log set status='VM', end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record updated: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $VMAIL_box=0; + ### Grab Server values from the database + $stmtA = "SELECT security_phrase FROM vicidial_list where lead_id = '$CIDlead_id';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $VMAIL_box = "$record->[0]"; + } + } + + ### SEND CALL TO VOICEMAIL BOX ### + print STDERR "\nexiting the VDAD app, transferring call to $voicemail_dump_exten$VMAIL_box\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $voicemail_dump_exten$VMAIL_box\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + + } + +if ($pin == "2") ### mark call as a CALLBK + { + + # Thank you for your response, your agent will be contacting you shortly. + $stmtA = "DELETE from vicidial_auto_calls where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD DONE : |$affected_rows|delete of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_list set status='CALLBK' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\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) {$Fhour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + $stmtA = "UPDATE vicidial_log set status='CALLBK', end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record updated: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $AGI->stream_file("$callback_audio_file"); + + $VHqueryCID = "VHNGUP$tsSQLdate"; + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + + sleep(1); + + exit; + } + +if ($pin == "3") ### send call to extension + { +# call can be sent to extension +# # Thank you for your response, we will now transfer you to your agent's voicemail box. +# $AGI->stream_file("$voicemail_xfer_file"); + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_list set status='XFER' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\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) {$Fhour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + + $end_date_epoch = time(); + $length_in_sec = ($end_date_epoch - $now_date_epoch); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + $stmtA = "UPDATE vicidial_log set status='XFER', end_epoch='$end_date_epoch', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$CIDlead_id';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record updated: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $VMAIL_box=0; + ### Grab Server values from the database + $stmtA = "SELECT comments FROM vicidial_list where lead_id = '$CIDlead_id';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $XFER_exten = "$record->[0]"; + } + } + + ### SEND CALL TO VOICEMAIL BOX ### + print STDERR "\nexiting the VDAD app, transferring call to $XFER_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $XFER_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + + } + +} ### end if pressed 1,2,3 + + + + + +else ### user pressed digit other than 1 or 2 or 3 +{ + +exit; +} + +$dbhA->close; + + + +exit; + + + + + + + + + + + +sub reminder_choice +{ +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +# Hello, this is a courtesy call from ACME Industries reminding you that the deadline for the submission of orders for the June 5th batch delivery is tomorrow, March 10th: + # second audio file +# If you would like to leave a message for your agent please press 1. +# If you would like to have your agent call you back please press 2. + # third audio file +# Thank you, Goodbye + + +######### PLAY THE MESSAGE FILE THEN WAIT 2 SECONDS FOR DIGITS ############ +$interrupt_digit = $AGI->stream_file("$message_audio_file",'123'); + print STDERR "interrupt_digit |$interrupt_digit|\n"; +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + +$channel_status = $AGI->channel_status("$channel"); + if ($V) {print STDERR "SSSSSSSSSS Channel Status: $channel_status\n";} + + if ($channel_status == 6) + { + $stmtA = "UPDATE vicidial_log set status='MP' where uniqueid = '$uniqueid' and lead_id='$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: N|$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_list set status='MP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: N|$affected_rows|$CIDlead_id\n";} + } + +while ($digit_loop_counter < 1) + { + $digit = chr($AGI->wait_for_digit('2000')); # wait 2 seconds for input or until digit pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=1; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) + { + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; + return; + } + + + +######### PLAY THE OPTIONS FILE THEN WAIT 5 SECONDS FOR DIGITS ############ +$interrupt_digit = $AGI->stream_file("$options_audio_file",'123'); + print STDERR "interrupt_digit |$interrupt_digit|\n"; +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + +while ($digit_loop_counter < 1) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until digit pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=1; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) + { + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; + return; + } +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + diff --git a/agc_2-X/trunk/agi-VDADcloser.agi b/agc_2-X/trunk/agi-VDADcloser.agi new file mode 100644 index 00000000..4cdeb63a --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser.agi @@ -0,0 +1,532 @@ +#!/usr/bin/perl +# +# agi-VDADcloser.agi version 0.3 +# +# runs when a call comes in from a VICIDIAL fronter. This script will +# send the calls out to the closers that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will send the call to the specified Vmail +# box or hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound VICIDIAL calls: +#exten => _90009.,1,Answer ; Answer the line +#exten => _90009.,2,AGI(agi-VDADcloser.agi,${EXTEN}-----START) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60503-1242 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### default number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for internal PRI transfer data string "90009*CL_uk3survy_*8301*10000123*universal***" + if ($extension =~ /^900\d\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $referring_extension = $EXT_vars[0]; # initial extension sent + $channel_group = $EXT_vars[1]; # name of the parked group + $inbound_number = $EXT_vars[2]; # extension to send call to after parsing + $parked_by = $EXT_vars[3]; # leadID + $park_extension = $EXT_vars[4]; # filename of the on-hold music file + $comment_d = $EXT_vars[5]; # N/A + $comment_e = $EXT_vars[6]; # N/A + + $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # JmmddhhmmssLLLLLLLLL + $JqueryCID = "J$CIDdate$PADlead_id"; + $callerid = $JqueryCID; + ### set the callerid to the filename of the audio for on-hold + print "SET CALLERID $JqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $JqueryCID\n"; + } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel\n";} +if ($M) {print STDERR "+++++ VDCL START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + +### Grab call parameters from vicidial_list table +$stmtA = "SELECT phone_number,phone_code,user FROM vicidial_list where lead_id='$CIDlead_id' limit 1;"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$channel_group"; + $VDADphone = "$record->[0]"; + $VDADphone_code = "$record->[1]"; + $VDADlead_id = "$CIDlead_id"; + $VDADfronter = "$record->[2]"; + } + } + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN')"; +$dbhA->query($stmtA); + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$CIDlead_id','$VDADcampaign','$SQLdate','$VDADphone_code','$VDADphone','$VDADfronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $VDADcampaign %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$CIDlead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$CIDlead_id|$VDADuser\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$CIDlead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$CIDlead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADcloser_PHONE.agi b/agc_2-X/trunk/agi-VDADcloser_PHONE.agi new file mode 100644 index 00000000..e4838e7f --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_PHONE.agi @@ -0,0 +1,566 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_PHONE.agi version 0.3 +# +# runs when a call comes in from a VICIDIAL fronter from a foreign location. This script will +# send the calls out to the closers that are logged in. Customer data is not supplied aside from phone number, +# because the data resides on the foreign system. It is recommended that the WEB FORM page used for this would +# lookup the customer info from the foreign server as an alternate to doing the lookup in this script +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped or +# if voicemail is defined, the call will go to voicemail +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound VICIDIAL calls: +#exten => _90009.,1,Answer ; Answer the line +#exten => _90009.,2,AGI(agi-VDADcloser_PHONE.agi,${EXTEN}-----START) +# +# +#AGI Environment Dump: +# -- accountcode = +# -- callerid = unknown +# -- channel = Zap/26-1 +# -- context = default +# -- dnid = 90009*CL_MWCOF_L**2470995**7275551212*12345* +# -- enhanced = 0.0 +# -- extension = 90009*CL_MWCOF_L**2470995**7275551212*12345* +# -- language = en +# -- priority = 4 +# -- rdnis = unknown +# -- request = agi-VDADcloser_PHONE.agi +# -- type = Zap +# -- uniqueid = 1110912481.2331 +#AGI Environment Dump: |1110912481.2331|Zap/26-1|90009*CL_MWCOF_L**2470995**7275551212*12345*|Zap|J0315134801002470995| +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1243 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for internal PRI transfer data string "90009*CL_uk3survy_*8301*10000123*universal***" + ### 90009*CL_MWCOF_L**2470995**7275551212*12345* + if ($extension =~ /^900\d\d\*|^8900\d\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $referring_extension = $EXT_vars[0]; # initial extension sent + $channel_group = $EXT_vars[1]; # name of the parked group + $inbound_number = $EXT_vars[2]; # extension to send call to after parsing + $parked_by = $EXT_vars[3]; # leadID + $park_extension = $EXT_vars[4]; # filename of the on-hold music file + $cust_phone = $EXT_vars[5]; # customer phone number + $ref_agent = $EXT_vars[6]; # referral agent ID + + # $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # # JmmddhhmmssLLLLLLLLL + # $JqueryCID = "J$CIDdate$PADlead_id"; + # $callerid = $JqueryCID; + # ### set the callerid to the filename of the audio for on-hold + # print "SET CALLERID $JqueryCID\n"; + # checkresult($result); + # print STDERR "callerID changed: $JqueryCID\n"; + } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel\n";} +if ($M) {print STDERR "+++++ VDCL START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} +if (!$list_id) {$list_id = '999';} +if (!$phone_code) {$phone_code = '1';} +if (!$VLcomments) {$VLcomments = '';} +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$ref_agent','$parked_by','VDCL','$list_id','Y','$phone_code','$cust_phone','$channel_group','1','-5.00','$VLcomments');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +$CIDlead_id = $new_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + + $VDADcampaign = "$channel_group"; + $VDADphone = "$cust_phone"; + $VDADphone_code = "$phone_code"; + $VDADlead_id = "$new_lead_id"; + $VDADfronter = "$ref_agent"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','IN')"; +$dbhA->query($stmtA); + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$CIDlead_id','$VDADcampaign','$SQLdate','$VDADphone_code','$VDADphone','$VDADfronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$VDADlead_id|$CIDlead_id|insert to vicidial_closer_log\n";} + + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $VDADcampaign %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$CIDlead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$CIDlead_id|$VDADuser\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$CIDlead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$CIDlead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADcloser_inbound.agi b/agc_2-X/trunk/agi-VDADcloser_inbound.agi new file mode 100644 index 00000000..493a2f77 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inbound.agi @@ -0,0 +1,664 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inbound.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# This version asks for a 4-digit pin number to be entered and passed on as the fronter value to the closer +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Answer ; Answer the line +#exten => 1234,2,AGI(agi-VDADcloser_inbound.agi,CL_GALLERIA-----7274515134-----Closer-----park----------999-----1) +#exten => 1234,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1224 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + $phone_number=''; + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +&enter_pin_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$new_lead_id','$channel_group','$SQLdate','$phone_code','$phone_number','$fronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n";} + # if ($M) {print STDERR "|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + else + { + print STDERR "NNNNNNNNNN No agent record found!!!\n"; + } + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$new_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$new_lead_id|$VDADuser\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + +### you're call is very important to us, please stay on the line and you will be transferred to the next available agent \ No newline at end of file diff --git a/agc_2-X/trunk/agi-VDADcloser_inboundANI.agi b/agc_2-X/trunk/agi-VDADcloser_inboundANI.agi new file mode 100644 index 00000000..c5d4b466 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inboundANI.agi @@ -0,0 +1,642 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inboundANI.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# *** This version detects inbound callerID over robbed-bit T1 ANI delivery *** +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Answer ; Answer the line +#exten => 1234,2,AGI(agi-VDADcloser_inboundANI.agi,CL_GALLERIA-----7274515134-----Closer-----park----------999-----1) +#exten => 1234,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1240 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + +# if ( ($callerid =~ /\".*\"/) && ( (!$calleridname) or ($calleridname =~ /unknown/) ) ) +# { +# $calleridname = $callerid; +# $calleridname =~ s/\<\d\d\d\d\d\d\d\d\d\d\>//gi; +# $calleridname =~ s/\"|\" //gi; +# } + + $callerid =~ s/\D//gi; + $calleridname =~ s/unknown//gi; +# if ( (!$callerid) or ($callerid =~ /unknown/) ) +# {$callerid = $calleridname;} + + if (length($callerid)>0) {$phone_number = $callerid;} + else {$phone_number = '';} + if (length($calleridname)>0) {$VLcomments = $calleridname;} + else {$VLcomments = '';} + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + + ### allow for external callerid to be collected from ANI *NXXNXXXXXX*DNIS + if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $phone_number = $EXT_vars[1]; # ANI phone number + $DNIS = $EXT_vars[2]; # name of the parked group + } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +#&enter_pin_number; + +$pin = $inbound_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00','$VLcomments');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$new_lead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADcloser_inboundCID-debug.agi b/agc_2-X/trunk/agi-VDADcloser_inboundCID-debug.agi new file mode 100644 index 00000000..188c8f81 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inboundCID-debug.agi @@ -0,0 +1,665 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inboundCID.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# *** This version detects inbound callerID over PRI *** +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Ringing ; call ringing +#exten => 1234,2,Wait(1) ; Wait 1 second for CID delivery from PRI +#exten => 1234,3,Answer ; Answer the line +#exten => 1234,4,AGI(agi-VDADcloser_inboundCID.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +#exten => 1234,5,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1241 - Added drop second/message/exten options from inbound_group +# + +### open the error out file for writing ### +open(out, ">/home/cron/AGI_test-output.txt") + || die "Can't open /home/cron/AGI_test-output.txt: $!\n"; + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print out "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print out "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + + if ( ($callerid =~ /\".*\"/) && ( (!$calleridname) or ($calleridname =~ /unknown/) ) ) + { + $calleridname = $callerid; + $calleridname =~ s/\<\d\d\d\d\d\d\d\d\d\d\>//gi; + $calleridname =~ s/\"|\" //gi; + } + + $callerid =~ s/\D//gi; + $calleridname =~ s/unknown//gi; + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + if (length($callerid)>0) {$phone_number = $callerid;} + else {$phone_number = '';} + if (length($calleridname)>0) {$VLcomments = $calleridname;} + else {$VLcomments = '';} + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print out "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print out "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print out " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print out "\nINBOUND CALL VDCL STARTED\n";} + +#&enter_pin_number; + +$pin = $inbound_number; + +$fronter = $pin; + +if ($M) {print out "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print out "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print out "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print out "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print out "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +close(out); +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00','$VLcomments');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print out "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print out "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print out "\n|$stmtA|\n";} + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; +# if($M){print out "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print out "-- VDAD : |$VDADlead_id|$new_lead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print out "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print out "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print out "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print out "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print out "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print out "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print out "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print out "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print out "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print out "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print out "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + close(out); + exit; + } + } + else + { + print out "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print out "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print out "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print out "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print out "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print out "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print out "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print out "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print out "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print out "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print out "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + +close(out); + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print out "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print out "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print out "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print out "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print out "FAIL ($res)\n"; + $fail++; + } else { + # print out "PASS ($1)\n"; + $pass++; + } + } else { + print out "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADcloser_inboundCID.agi b/agc_2-X/trunk/agi-VDADcloser_inboundCID.agi new file mode 100644 index 00000000..779d711b --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inboundCID.agi @@ -0,0 +1,658 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inboundCID.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# *** This version detects inbound callerID over PRI *** +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Ringing ; call ringing +#exten => 1234,2,Wait(1) ; Wait 1 second for CID delivery from PRI +#exten => 1234,3,Answer ; Answer the line +#exten => 1234,4,AGI(agi-VDADcloser_inboundCID.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +#exten => 1234,5,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1241 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + + if ( ($callerid =~ /\".*\"/) && ( (!$calleridname) or ($calleridname =~ /unknown/) ) ) + { + $calleridname = $callerid; + $calleridname =~ s/\<\d\d\d\d\d\d\d\d\d\d\>//gi; + $calleridname =~ s/\"|\" //gi; + } + + $callerid =~ s/\D//gi; + $calleridname =~ s/unknown//gi; + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + if (length($callerid)>0) {$phone_number = $callerid;} + else {$phone_number = '';} + if (length($calleridname)>0) {$VLcomments = $calleridname;} + else {$VLcomments = '';} + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +#&enter_pin_number; + +$pin = $inbound_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00','$VLcomments');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$new_lead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADcloser_inboundCIDlookup.agi b/agc_2-X/trunk/agi-VDADcloser_inboundCIDlookup.agi new file mode 100644 index 00000000..bb426c58 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inboundCIDlookup.agi @@ -0,0 +1,671 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inboundCID.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# *** This version detects inbound callerID over PRI *** +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Ringing ; call ringing +#exten => 1234,2,Wait(1) ; Wait 1 second for CID delivery from PRI +#exten => 1234,3,Answer ; Answer the line +#exten => 1234,4,AGI(agi-VDADcloser_inboundCID.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +#exten => 1234,5,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1242 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + + if ( ($callerid =~ /\".*\"/) && ( (!$calleridname) or ($calleridname =~ /unknown/) ) ) + { + $calleridname = $callerid; + $calleridname =~ s/\<\d\d\d\d\d\d\d\d\d\d\>//gi; + $calleridname =~ s/\"|\" //gi; + } + + $callerid =~ s/\D//gi; + $calleridname =~ s/unknown//gi; + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + if (length($callerid)>0) {$phone_number = $callerid;} + else {$phone_number = '';} + if (length($calleridname)>0) {$VLcomments = $calleridname;} + else {$VLcomments = '';} + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +#&enter_pin_number; + +$pin = $inbound_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +$stmtA= "SELECT lead_id from vicidial_list where list_id='$list_id' and phone_number='$phone_number' order by modify_date limit 1;" +$dbhA->query($stmtA); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $insert_lead_id = "$record->[0]"; + } + } else { + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now,comments) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00','$VLcomments');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +} +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + +# $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; +# if($M){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); +# if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$new_lead_id|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADcloser_inbound_5ID.agi b/agc_2-X/trunk/agi-VDADcloser_inbound_5ID.agi new file mode 100644 index 00000000..d98eea4a --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inbound_5ID.agi @@ -0,0 +1,664 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inbound.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# This version asks for a 5-digit pin number to be entered and passed on as the fronter value to the closer +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Answer ; Answer the line +#exten => 1234,2,AGI(agi-VDADcloser_inbound.agi,CL_GALLERIA-----7274515134-----Closer-----park----------999-----1) +#exten => 1234,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1236 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + $phone_number=''; + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +&enter_pin_number; + +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$new_lead_id','$channel_group','$SQLdate','$phone_code','$phone_number','$fronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n";} + # if ($M) {print STDERR "|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + else + { + print STDERR "NNNNNNNNNN No agent record found!!!\n"; + } + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$new_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$new_lead_id|$VDADuser\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 5) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + +### you're call is very important to us, please stay on the line and you will be transferred to the next available agent \ No newline at end of file diff --git a/agc_2-X/trunk/agi-VDADcloser_inbound_NOCID.agi b/agc_2-X/trunk/agi-VDADcloser_inbound_NOCID.agi new file mode 100644 index 00000000..0cba80ec --- /dev/null +++ b/agc_2-X/trunk/agi-VDADcloser_inbound_NOCID.agi @@ -0,0 +1,591 @@ +#!/usr/bin/perl +# +# agi-VDADcloser_inbound_NOCID.agi version 0.3 +# +# runs when a call comes in from an inbound call. This script will +# send the calls out to the closers that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 360 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# This version asks for nothing and assumes no CID is being sent +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +# ; 2. the phone number that was called, for the log entry +# ; 3. the callerID or lead_id of the person that called(usually overridden) +# ; 4. the park extension audio file name if used +# ; 5. the status of the call initially(usually not used) +# ; 6. the list_id to insert the new lead under if it is new (and callerID available) +# ; 7. the phone dialing code to insert with the new lead if new (and callerID available) +# +# ;inbound VICIDIAL calls: +#exten => 1234,1,Answer ; Answer the line +#exten => 1234,2,AGI(agi-VDADcloser_inbound_NOCID.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +#exten => 1234,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 60504-1238 - Added drop second/message/exten options from inbound_group +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 360; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $list_id = $ARGV_vars[5]; + $phone_code = $ARGV_vars[6]; + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + $phone_number=''; + + ### allow for external callerid to be collected +# if ($extension =~ /\*\d\d\d\d\d\d\d\d\d\d\*/) +# { +# @EXT_vars = split(/\*/, $extension); +# +# $referring_extension = $EXT_vars[0]; # initial extension sent +# $channel_group = $EXT_vars[1]; # name of the parked group +# $inbound_number = $EXT_vars[2]; # extension to send call to after parsing +# $parked_by = $EXT_vars[3]; # leadID +# $park_extension = $EXT_vars[4]; # filename of the on-hold music file +# $comment_d = $EXT_vars[5]; # N/A +# $comment_e = $EXT_vars[6]; # N/A +# +# $PADlead_id = sprintf("%09s", $parked_by); while (length($PADlead_id) > 9) {chop($PADlead_id);} +# # JmmddhhmmssLLLLLLLLL +# $JqueryCID = "J$CIDdate$PADlead_id"; +# $callerid = $JqueryCID; +# ### set the callerid to the filename of the audio for on-hold +# print "SET CALLERID $JqueryCID\n"; +# checkresult($result); +# print STDERR "callerID changed: $JqueryCID\n"; +# } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + + +$AGI->stream_file('beep'); + + if ($V) {print STDERR "\nINBOUND CALL VDCL STARTED\n";} + +#&enter_pin_number; + +$pin = '123456'; +$fronter = $pin; + +if ($M) {print STDERR "+++++ INBOUND CALL VDCL STARTED : |$unique_id|$channel_group|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + + +if ($V) {print STDERR "\nINBOUND CALL RECEIVED IN FROM VDCL: $callerid $channel\n";} +if ($M) {print STDERR "+++++ INBOUND VDCL START : |$unique_id|$channel|$extension|$type|$now_date\n";} + +if ($channel =~ /Local/i) +{ +if ($M) {print STDERR "+++++ VDCL START LOCAL CHANNEL: EXITING\n";} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + +### insert a record into the vicidial_list table +$stmtA = "INSERT INTO vicidial_list (entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,called_since_last_reset,phone_code,phone_number,security_phrase,called_count,gmt_offset_now) values('$SQLdate','$tsSQLdate','INBND','$fronter','$channel_group','VDCL','$list_id','Y','$phone_code','$phone_number','$channel_group','1','-5.00');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_lead_id = "$recordA->[0]";} + } +$new_lead_id = $insert_lead_id; +if($M){print STDERR "\n|$stmtA|$new_lead_id|\n";} + + $PADlead_id = sprintf("%09s", $new_lead_id); while (length($PADlead_id) > 9) {chop($PADlead_id);} + # YmmddhhmmssLLLLLLLLL + $YqueryCID = "Y$CIDdate$PADlead_id"; + $callerid = $YqueryCID; + ### set the callerid + print "SET CALLERID $YqueryCID\n"; + checkresult($result); + print STDERR "callerID changed: $YqueryCID\n"; + +### Grab inbound_group values from the database +$stmtA = "SELECT drop_call_seconds,drop_message,drop_exten FROM vicidial_inbound_groups where group_id = '$channel_group';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBdrop_message = "$record->[1]"; + $DBdrop_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBdrop_message) {$drop_message = $DBdrop_message;} + if ($DBdrop_exten) {$drop_exten = $DBdrop_exten;} + } + } + + + +### insert a LIVE record to the vicidial_auto_calls table +$stmtA = "INSERT INTO vicidial_auto_calls values('','$server_ip','$channel_group','LIVE','$new_lead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN')"; +$dbhA->query($stmtA); +if($M){print STDERR "\n|$stmtA|\n";} + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','XFER','$phone_code','$phone_number','$fronter','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + if ($M) {print STDERR "-- VDAD : |$new_lead_id|$fronter|insert to vicidial_log: $uniqueid\n";} + +$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$new_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDCL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$stmtA = "INSERT INTO vicidial_xfer_log (lead_id,campaign_id,call_date,phone_code,phone_number,user,closer) values('$new_lead_id','$channel_group','$SQLdate','$phone_code','$phone_number','$fronter','VDXL')"; + if($M){print STDERR "\n|$stmtA|\n";} +$dbhA->query($stmtA); +if ($M) {print STDERR "-- VDXL : |$new_lead_id|insert to vicidial_closer_log\n";} + +$VDADlead_id = $new_lead_id; + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < 360) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + 360); + } + } + + $stmtA = "SELECT next_agent_call FROM vicidial_inbound_groups where group_id='$channel_group';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order='order by last_call_finish'; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$channel_group' and call_time < \"$SQLdateBEGIN\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$new_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status IN('CLOSER','READY') and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|update of vla table: $channel_group|$server_ip\n";} + # if ($M) {print STDERR "|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id LIKE \"%CLOSER%\" and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + else + { + print STDERR "NNNNNNNNNN No agent record found!!!\n"; + } + $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_xfer_log set closer='$VDADuser' where lead_id = '$new_lead_id' order by call_date desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDXL vicidial_xfer_log update: |$affected_rows|$new_lead_id|$VDADuser\n";} + + $stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$new_lead_id' order by call_date desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- closer log : |$affected_rows|update of vcl table: $new_lead_id\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$channel_group|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($drop_message=='Y') + { + $DROPexten = "$drop_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_inbound_groups where group_id = '$channel_group' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$server_ip' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vac record deleted: |$affected_rows| $channel_group|$server_ip\n";} + +# $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; +# if($M){print STDERR "\n\n|$stmtA|\n";} +# $dbhA->query("$stmtA"); +# my $affected_rows = $dbhA->get_affected_rows_length; +# if ($M) {print STDERR "-- VDCL vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where lead_id = '$new_lead_id' order by start_epoch desc limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_closer_log update: |$affected_rows|$new_lead_id\n";} + + $stmtA = "UPDATE vicidial_list set status='XDROP' where lead_id = '$new_lead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDCL vicidial_list update: |$affected_rows|$new_lead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + +### you're call is very important to us, please stay on the line and you will be transferred to the next available agent \ No newline at end of file diff --git a/agc_2-X/trunk/agi-VDADlisten_DTMF.agi b/agc_2-X/trunk/agi-VDADlisten_DTMF.agi new file mode 100644 index 00000000..b77dca74 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADlisten_DTMF.agi @@ -0,0 +1,191 @@ +#!/usr/bin/perl +# +# agi-VDADlisten_DTMF.agi version 0.1 +# +# To be initiated by an agent so during a call. Agent will click a PIN NUMBER +# link on a web form webpage that will Originate a new call to this script +# +# This script plays a beep and waits for entry of 4 digits then inserts record +# +# ***** THIS SCRIPT ONLY WORKS WITH A CROSSOVER T1 CABLE FROM ONE T1 PORT ***** +# ***** TO ANOTHER T1 PORT WHETHER ON THE SAME SERVER OR DIFFERENT ONE ***** +# +# ON THE SERVER ORIGINATING THE CALL: +#;outbound DTMF VICIDIAL calls: +#exten => _983009.,1,AGI(call_log.agi,${EXTEN}) +#exten => _983009.,2,Dial(${TRUNKY}/${EXTEN:1},60) +#exten => _983009.,3,Hangup +# +# ON THE SERVER THAT HAS THIS SCRIPT: +#;inbound DTMF VICIDIAL calls: +#exten => _83009.,1,AGI(agi-VDADlisten_DTMF.agi,${EXTEN}) +#exten => _83009.,2,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### set defaults for testing +$referring_extension = '83009'; +$phone_number = '9999999999'; +$lead_id = '999999999'; +$campaign_id = 'TESTCAMP'; +$product_code = 'ABC'; +$user = '1234'; +$pin = '0'; + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + ### allow for internal transfer data string "83009*3125551212*10000123*TESTCAMP*ABC*1234*" + if ($extension =~ /^8300\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $referring_extension = $EXT_vars[0]; # initial extension sent + $phone_number = $EXT_vars[1]; # phone number + $lead_id = $EXT_vars[2]; # lead_id in vicidial_list + $campaign_id = $EXT_vars[3]; # campaign id + $product_code = $EXT_vars[4]; # product code + $user = $EXT_vars[5]; # vicidial_user that sent the call here + } +} + + if ($V) {print STDERR "\nINBOUND DTMF CALL VDCL STARTED\n";} + +&enter_pin_number; + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +if (length($pin) < 4) {$AGI->stream_file('buzz');} +else {$AGI->stream_file('ding');} + +### insert a record into the vicidial_list_pins table +$stmtA = "INSERT INTO vicidial_list_pins (entry_time,phone_number,lead_id,campaign_id,product_code,user,digits) values('$SQLdate','$phone_number','$lead_id','$campaign_id','$product_code','$user','$pin');"; +$dbhA->query($stmtA); + $dbhA->query("select LAST_INSERT_ID() LIMIT 1;"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + while ($recordA = $iterA->each) + {$insert_pin_id = "$recordA->[0]";} + } +if($M){print STDERR "\n|$stmtA|$insert_pin_id|\n";} + + $dbhA->close; + +exit; + + + + + + + + +sub enter_pin_number +{ + +$AGI->stream_file('beep'); + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; + # $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +# $AGI->say_digits("$pin"); +} + diff --git a/agc_2-X/trunk/agi-VDADtransfer.agi b/agc_2-X/trunk/agi-VDADtransfer.agi new file mode 100644 index 00000000..3eaf2a04 --- /dev/null +++ b/agc_2-X/trunk/agi-VDADtransfer.agi @@ -0,0 +1,501 @@ +#!/usr/bin/perl +# +# agi-VDADtransfer.agi version 0.4 +# +# runs when a call comes in from the VICIDIAL_auto_dialer. This script will +# send the calls out to the reps that are logged in. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 10 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8365,1,AGI(call_log.agi,${EXTEN}) +# exten => 8365,2,AGI(agi-VDADtransfer.agi,${EXTEN}) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes: +# 50322-1246 - changed callerid handling to allow for custom callerid +# 60119-1408 - fixed calleridname issue with 1.2 tree for custom CID +# 60503-1054 - Added safe harbor and drop second options from campaign +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 10; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() +{ + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VDAD START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|\n";} + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + +if (!$DB_port) {$DB_port='3306';} + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + +### Grab call parameters from vicidial_auto_calls table +$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE' where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} +if ($affected_rows > 0) + { + $stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$record->[0]"; + $VDADphone = "$record->[1]"; + $VDADphone_code = "$record->[2]"; + $VDADlead_id = "$record->[3]"; + $VDADcall_time = "$record->[4]"; + } + } + +### Grab campaign values from the database +$stmtA = "SELECT drop_call_seconds,safe_harbor_message,safe_harbor_exten FROM vicidial_campaigns where campaign_id = '$VDADcampaign';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBsafe_harbor_message = "$record->[1]"; + $DBsafe_harbor_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBsafe_harbor_message) {$safe_harbor_message = $DBsafe_harbor_message;} + if ($DBsafe_harbor_exten) {$safe_harbor_exten = $DBsafe_harbor_exten;} + } + } + + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDAD','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + + } + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < $DROP_TIME) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + $DROP_TIME); + } + } + $stmtA = "SELECT next_agent_call FROM vicidial_campaigns where campaign_id='$VDADcampaign';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order=''; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$VDADcampaign' and call_time < \"$VDADcall_time\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status = 'READY' and server_ip='$server_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id='$VDADcampaign' and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$VDADcampaign|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($safe_harbor_message=='Y') + { + $DROPexten = "$safe_harbor_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_campaigns where campaign_id = '$VDADcampaign' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + + + + $dbhA->close; + + + +exit; + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + # print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/agi-VDADtransferSURVEY.agi b/agc_2-X/trunk/agi-VDADtransferSURVEY.agi new file mode 100644 index 00000000..d356b55a --- /dev/null +++ b/agc_2-X/trunk/agi-VDADtransferSURVEY.agi @@ -0,0 +1,651 @@ +#!/usr/bin/perl +# +# agi-VDADtransferSURVEY.agi version 0.5 +# +# runs when a call comes in from the VICIDIAL auto_dialer. This script will +# send the calls out to the reps that are logged in if called person presses key. +# +# if there are no available agents, then it will check every second until an agent becomes available, +# if at the end of 10 seconds(default) it has not found an agent it will hangup the call and mark it as dropped +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;VICIDIAL_auto_dialer transfer script: +# exten => 8366,1,AGI(call_log.agi,${EXTEN}) +# exten => 8366,2,AGI(agi-VDADtransferSURVEY.agi,${EXTEN}) +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# CHANGES +# 60119-1408 - fixed calleridname issue with 1.2 tree for custom CID +# 60503-1100 - Added safe harbor and drop second options from campaign +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +$DROP_TIME = 10; ### number of seconds to wait until you drop a waiting call + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +use Net::MySQL; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + + + +($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) {$Fhour = "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"; +$start_time=$now_date; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $SQLdateBEGIN = $SQLdate; + +$BDtarget = ($secX - 5); +($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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + +if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) ) + { + $callerid =~ s/^\"//gi; + $callerid =~ s/\".*$//gi; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + + } +if ( ( +(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) +) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + { + $callerid = $calleridname; + ### set the callerid to the ACQS value(calleridname) + print "SET CALLERID $callerid\n"; + checkresult($result); + print STDERR "callerID changed: $callerid\n"; + } + + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$VDADcampaign=''; +$VDADphone=''; +$VDADphone_code=''; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$priority|\n";} + + +$callerid =~ s/\"//gi; +$CIDlead_id = $callerid; +$CIDlead_id = substr($CIDlead_id, 11, 9); +$CIDlead_id = ($CIDlead_id + 0); + +if ($V) {print STDERR "\nCALL RECEIVED IN FROM VDAD: $callerid $channel $priority\n";} +if ($M) {print STDERR "+++++ VDAD START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$priority|\n";} + +if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) +{ +if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";} +if ($priority > 2) {sleep(1);} +exit; +} + + + + +$AGI->stream_file('beep'); + + my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +### Grab Server values from the database +$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks FROM servers where server_ip = '$server_ip';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBvoicemail_dump_exten = "$record->[0]"; + $DBext_context = "$record->[1]"; + $DBanswer_transfer_agent = "$record->[2]"; + $DBSERVER_GMT = "$record->[3]"; + $DBasterisk_version = "$record->[4]"; + $DBmax_vicidial_trunks = "$record->[5]"; + if ($DBvoicemail_dump_exten) {$voicemail_dump_exten = $DBvoicemail_dump_exten;} + if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} + if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} + if ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;} + } + } + + $stmtA = "UPDATE vicidial_list set status='PU' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\n";} + + &enter_pin_number; + +if ($V) {print STDERR "+++++ VDAD STATUS : pressed $pin|$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date\n";} + +if ($pin !~ /^1|^2|^3|^8|^0/) {exit;} + +if (!$DB_port) {$DB_port='3306';} + + + + + +if ($pin =~ /^1|^2|^3|^0/) +{ +$voter=''; + +if ($pin == "1") {$voter = 'DEMOCRAT';} +if ($pin == "2") {$voter = 'REPUBLICAN';} +if ($pin == "3") {$voter = 'INDEPENDANT';} +if ($pin == "0") {$voter = 'OPERATOR';} + +$stmtA = "UPDATE vicidial_list set security_phrase='$voter' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_list VOTER update: |$affected_rows|$CIDlead_id|$voter\n";} + +# Thank you for your response, we would now like to transfer you to a poll-taker for just a few more questions. Please stay on the line. + +$AGI->stream_file('US_pol_survey_transfer'); + +### Grab call parameters from vicidial_auto_calls table +$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE' where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} +if ($affected_rows > 0) + { + $stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADcampaign = "$record->[0]"; + $VDADphone = "$record->[1]"; + $VDADphone_code = "$record->[2]"; + $VDADlead_id = "$record->[3]"; + $VDADcall_time = "$record->[4]"; + } + } + +### Grab campaign values from the database +$stmtA = "SELECT drop_call_seconds,safe_harbor_message,safe_harbor_exten FROM vicidial_campaigns where campaign_id = '$VDADcampaign';"; +$dbhA->query("$stmtA"); +if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $DBdrop_call_seconds = "$record->[0]"; + $DBsafe_harbor_message = "$record->[1]"; + $DBsafe_harbor_exten = "$record->[2]"; + if ($DBdrop_call_seconds) {$DROP_TIME = $DBdrop_call_seconds;} + if ($DBsafe_harbor_message) {$safe_harbor_message = $DBsafe_harbor_message;} + if ($DBsafe_harbor_exten) {$safe_harbor_exten = $DBsafe_harbor_exten;} + } + } + + + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','QUEUE','$VDADphone_code','$VDADphone','VDAD','N')"; + if($M){print STDERR "\n|$stmtA|\n";} + $dbhA->query($stmtA); + + if ($M) {print STDERR "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid\n";} + + } + +$drop_timer=0; +$drop_seconds=0; +$hold_message_counter=25; +$hold_tone_counter=0; + +while ($drop_timer <= $DROP_TIME) +{ +$channel_status = $AGI->channel_status("$channel"); +if ($channel_status < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer CHECKING AGAIN...\n"; + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + + $channel_status_DC = $AGI->channel_status("$channel"); + + if ($channel_status_DC < 1) + { + print STDERR "CHANNEL $channel DOWN $channel_status $DROP_TIME|$drop_timer\n"; + if ($drop_timer < $DROP_TIME) {$drop_seconds = $drop_timer;} + $drop_timer = ($drop_timer + $DROP_TIME); + } + } + $stmtA = "SELECT next_agent_call FROM vicidial_campaigns where campaign_id='$VDADcampaign';"; + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $CAMP_callorder = "$record->[0]"; + } + } + + $agent_call_order=''; + if ($CAMP_callorder =~ /overall_user_level/i) {$agent_call_order = 'order by user_level desc,last_call_finish';} + if ($CAMP_callorder =~ /oldest_call_start/i) {$agent_call_order = 'order by last_call_time';} + if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by last_call_finish';} + if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} + + $rec_countWAIT=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where status = 'LIVE' and server_ip='$server_ip' and campaign_id = '$VDADcampaign' and call_time < \"$VDADcall_time\" and lead_id != '$VDADlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + while ( $record = $iter->each) + { + $rec_countWAIT = "$record->[0]"; + } + } + if ($rec_countWAIT < 1) + { + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid' where status = 'READY' and server_ip='$server_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD get agent: |$affected_rows|update of vla table: $VDADcampaign|$server_ip\n|$stmtA|\n";} + if ($affected_rows > 0) + { + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$server_ip' and campaign_id='$VDADcampaign' and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADconf_exten = "$record->[0]"; + $VDADuser = "$record->[1]"; + $VDADextension = "$record->[2]"; + } + } + + $stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid';"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD XFER : |$affected_rows|update of vac table: $callerid\n|$stmtA|\n";} + + $stmtA = "UPDATE vicidial_list set status='XFER' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id|XFER\n";} + + $dbhA->close; + + print STDERR "\nexiting the VDAD app, transferring call to $VDADconf_exten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + + ($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) {$Fhour = "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"; + print STDERR "\nXXXXXXXXXX VDAD transferred: start|stop $start_time|$now_date\n"; + + exit; + } + } + else + { + print STDERR "WWWWWWWW VDAD XFER WAIT: |$rec_countWAIT|$VDADcampaign|$channel|$callerid|$uniqueid|\n"; + } + + ### sleep for 99 hundredths of a second + usleep(1*990*1000); + +if ($hold_message_counter > 30) + { + $AGI->stream_file('generic_hold'); + $hold_message_counter = 0; + } + else {$hold_message_counter++;} +if ($hold_tone_counter > 3) + { + $AGI->stream_file('hold_tone'); + $hold_tone_counter = 0; + } + else {$hold_tone_counter++;} + +$drop_timer++; +} + + +if ($drop_timer >= $DROP_TIME) +{ +($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) {$Fhour = "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"; + $CIDdate = "$mon$mday$hour$min$sec"; + $tsSQLdate = "$year$mon$mday$hour$min$sec"; + $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; + $VDADvoicemail_ext = ''; + +$DROPexten = ''; +if ($drop_seconds < 1) + { + $drop_seconds = $DROP_TIME; + + if ($safe_harbor_message=='Y') + { + $DROPexten = "$safe_harbor_exten"; + } + else + { + $stmtA = "SELECT voicemail_ext FROM vicidial_campaigns where campaign_id = '$VDADcampaign' limit 1;"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + if ($dbhA->has_selected_record) + { + $iter=$dbhA->create_record_iterator; + $rec_countCUSTDATA=0; + while ( $record = $iter->each) + { + $VDADvoicemail_ext = "$record->[0]"; + $VDADvoicemail_ext =~ s/\D//gi; + $DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext"; + } + } + } + } + + + ### use STDOUT to send call to proper DROP location + $VHqueryCID = "VH$CIDdate$VDADconf_exten"; + + if (length($DROPexten)>0) + { ### if DROP extension is defined then send the dropped call there instead of hangup + print STDERR "\nexiting the VDAD app, transferring call to $DROPexten\n"; + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + { + ### insert a NEW record to the vicidial_manager table to be processed + $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$server_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; + $dbhA->query($stmtA) or die "Couldn't execute query:\n"; + if ($M) {print STDERR "-- VDAD call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager\n";} + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + + $stmtA = "UPDATE vicidial_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid\n";} + + $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} + $dbhA->query("$stmtA"); + my $affected_rows = $dbhA->get_affected_rows_length; + if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id\n";} + +} + +} ### end if pressed 1,2,3 or 0 + + + + + +else ### user pressed 8 to not be contacted again +{ + +$AGI->stream_file('US_thanks_no_contact'); + +$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vac record deleted: |$affected_rows| $VDADcampaign|$server_ip\n";} + +$stmtA = "UPDATE vicidial_log set status='DNC',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds' where uniqueid = '$uniqueid';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_log update: DNC|$affected_rows|$uniqueid\n";} + +$stmtA = "UPDATE vicidial_list set status='DNC' where lead_id = '$CIDlead_id';"; + if($M){print STDERR "\n\n|$stmtA|\n";} +$dbhA->query("$stmtA"); +my $affected_rows = $dbhA->get_affected_rows_length; +if ($M) {print STDERR "-- VDAD vicidial_list update: DNC|$affected_rows|$CIDlead_id\n";} + + +exit; +} + + $dbhA->close; + + + +exit; + +sub enter_pin_number +{ +$digit=''; +undef $digit; +$interrupt_digit=''; +undef $interrupt_digit; + +# Hello, we are conducting a simple survery today, if you are a voter and registered as a Democrat, please press 1. If you are registered as a Republican, please press 2. If you are registered as an Independant or other party please press 3. If you do not want to be contacted again, please press 8. + +$interrupt_digit = $AGI->stream_file('US_pol_survey_hello','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + + +while ($digit_loop_counter < 1) + { + $digit = chr($AGI->wait_for_digit('2000')); # wait 0.2 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=1; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + # print STDERR "FAIL ($res)\n"; + $fail++; + } else { + # print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + + + +### Hello, you've been chosen to receive a great deal on travel to Florida, if you are insterested please press one on your phone now,,,,,If you would not like to be contacted again please press 2 diff --git a/agc_2-X/trunk/agi-dtmf.agi b/agc_2-X/trunk/agi-dtmf.agi new file mode 100644 index 00000000..91cbf375 --- /dev/null +++ b/agc_2-X/trunk/agi-dtmf.agi @@ -0,0 +1,98 @@ +#!/usr/bin/perl +# +# agi-dtmf.agi - script for playing DTMF tones received as the callerid field +# +# DTMF sound files must be in /var/lib/asterisk/sounds for this to work +# +# Accepted values are: 1 2 3 4 5 6 7 8 9 0 # * , +# comma means pause for 1 second +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$|=1; +while() { + chomp; + last unless length($_); + if (/^agi_(\w+)\:\s+(.*)$/) { + $AGI{$1} = $2; + } + if (/^agi_callerid\:\s+(.*)$/) {$caller_id = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$caller_idname = $1;} +} + +print STDERR "AGI Environment Dump:\n"; +foreach $i (sort keys %AGI) { + print STDERR " -- $i = $AGI{$i}\n"; +} + +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second + +use Asterisk::AGI; +my $agi = new Asterisk::AGI; + +my $clid = $agi->get_variable('CALLERID'); +my $clidname = $agi->get_variable('CALLERIDNAME'); + +print STDERR "X. |$clid|$caller_id|$clidname|\n"; + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} + +### sleep for 5 tenths of a second +usleep(1*500*1000); + +print "STREAM FILE silence \"\"\n"; + +$caller_id = "$caller_id$caller_idname"; + +@CALLERID_DIGITS = split(//, $caller_id); + +foreach (@CALLERID_DIGITS) +{ + +if ($CALLERID_DIGITS[$g] =~ /\d/) + { + print "STREAM FILE $CALLERID_DIGITS[$g] \"\"\n"; + print STDERR "DIGIT: $CALLERID_DIGITS[$g]\n"; + } +else + { + if ($CALLERID_DIGITS[$g] =~ /\#/) {print "STREAM FILE hash \"\"\n";} + if ($CALLERID_DIGITS[$g] =~ /\*/) {print "STREAM FILE star \"\"\n";} + if ($CALLERID_DIGITS[$g] =~ /\,/) {sleep(1);} + print STDERR "NON-DIGIT: $CALLERID_DIGITS[$g]\n"; + } +$g++; + +### sleep for 20 hundredths of a second +usleep(1*150*1000); + +print "STREAM FILE silence \"\"\n"; + +### sleep for 10 hundredths of a second +usleep(1*100*1000); +} + +print "STREAM FILE silence \"\"\n"; +$result = ; +checkresult($result); + diff --git a/agc_2-X/trunk/agi-record_prompts.agi b/agc_2-X/trunk/agi-record_prompts.agi new file mode 100644 index 00000000..2e61863d --- /dev/null +++ b/agc_2-X/trunk/agi-record_prompts.agi @@ -0,0 +1,406 @@ +#!/usr/bin/perl +# +# agi-record_prompts.agi - for recording prompts to GSM file over the phone +# Saves recordings with 8-digit filenames to be played when exten is dialed +# +# ; prompt recording AGI script, ID is 4321 +# exten => 8168,1,Answer +# exten => 8168,2,AGI(agi-record_prompts.agi) +# exten => 8168,3,Hangup +# +# ; playback of recorded prompts +# exten => _851XXXXX,1,Answer +# exten => _851XXXXX,2,Playback(${EXTEN}) +# exten => _851XXXXX,3,Hangup +# +# GSM Sound Files used: +# - ld_welcome_pin_number +# - ld_invalid_pin_number +# - vm-rec-generic +# - auth-thankyou +# - vm-review +# - vm-msgsaved +# - vm-goodbye +# + +$US='_'; + +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + +} + + +$unique_id_out = $unique_id; +@NEW_ID = split(/\./, $unique_id_out); +$NEW_ID_DIF = '.0'; +$unique_id_out = "$NEW_ID[0]$NEW_ID_DIF$NEW_ID[1]"; + +$pin=''; +$stop_loop=0; +$quit_program=0; +$loop_counter=0; +$REC_id = 85100000; +$REC_next = 0; + +if (-e "/prompt_count.txt") +{ + open(test, "prompt_count.txt") || die "can't open prompt_count.txt: $!\n"; + @test = ; + close(test); + + $REC_next = ($test[0] + 1); + $REC_id = ($REC_id + $REC_next); + + open(test, ">prompt_count.txt") || die "can't open prompt_count.txt: $!\n"; + print test "$REC_next"; + close(test); +} +else +{ + open(test, ">prompt_count.txt") || die "can't open prompt_count.txt: $!\n"; + print test "1"; + close(test); + $REC_id = ($REC_id + 1); +} + +$session_recording = "$REC_id"; +print STDERR "Recording ID: $REC_id\n"; + +&welcome_1; + + + + + +print STDERR "DONE Exiting...\n"; +exit; + + + + + +##### SUBROUTINES ######################################################## +##### steps ######################################################## + +sub welcome_1 +{ +##### Play welcome message and capture PIN ######################################################## +while ( (length($pin) ne 4) && (!$stop_loop) ) + { + &enter_pin_number; + &log_transfer; + + + $loop_counter++; + if ($loop_counter > 3) {$stop_loop++; $quit_program++;} + print STDERR "\nPIN|$pin|\n"; + + } + + +##### Check PIN account in database ######################################################## +$rec_count=0; + &lookup_account; +if (!$rec_count) + { + # please enter the pin number followed by the pound key + + $AGI->stream_file('ld_invalid_pin_number'); + + $quit_program++; + } + + +##### quit program if error ######################################################## +if ($quit_program) + { + print STDERR "\nexiting the ping app\n"; + print "SET CONTEXT demo\n"; + checkresult($result); + print "SET EXTENSION 8158\n"; + checkresult($result); + print "SET PRIORITY 3\n"; + checkresult($result); + exit; + } + +&record_prompts; + + + +} + + + + + + +sub record_prompts +{ +$AGI->stream_file('beep'); +print STDERR "\nrecord_prompts AGI welcome\n"; +$AGI->stream_file('vm-rec-generic'); +$AGI->stream_file('beep'); + +$digit=''; +$interrupt_digit=''; + +$interrupt_digit = $AGI->record_file("$session_recording", 'gsm', '123456789*#', 360000, 1); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 35) {$interrupt_digit='#';} + if ($interrupt_digit == 42) {$interrupt_digit='*';} + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + +$AGI->stream_file('beep'); + +if (length($totalDTMF) > 0) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} + +&verify_recording; + +} + + + + + +sub verify_recording +{ +$digit=''; +$interrupt_digit=''; + +$interrupt_digit = $AGI->stream_file('vm-review','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$digit_loop_counter=0; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 35) {$interrupt_digit='#';} + if ($interrupt_digit == 42) {$interrupt_digit='*';} + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + $digit_loop_counter++; + } + + +while ($digit_loop_counter < 1) + { + $digit = chr($AGI->wait_for_digit('2000000')); # wait 0.2 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=1; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; + +if (length($pin)< 1) + { + &verify_recording; + } +else + { + if ($pin == '1') + { + $AGI->stream_file('auth-thankyou'); + $AGI->say_digits("$REC_id"); + $AGI->stream_file('beep'); + $AGI->say_digits("$REC_id"); + $AGI->stream_file('vm-goodbye'); + exit; + } + if ($pin == '2') + { + $AGI->stream_file("$session_recording"); + &verify_recording; + } + if ($pin == '3') + { + &record_prompts; + } + + } +} + + + + + +##### SUBROUTINES PROCESSES ######################################################## + +sub log_transfer +{ + +} + + + + + +sub lookup_account +{ + + if ($pin eq '4321') + { + $rec_count++; + } + + +} + + + + + +sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes +{ +($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) {$Fhour = "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"; +} + + + + + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; + +$interrupt_digit = $AGI->stream_file('ld_welcome_pin_number','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 0) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) + { + $digit = chr($AGI->wait_for_digit('90000')); # wait 90 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digits_being_entered=0; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/app_conference/0.gsm b/agc_2-X/trunk/app_conference/0.gsm new file mode 100644 index 00000000..8c57c411 Binary files /dev/null and b/agc_2-X/trunk/app_conference/0.gsm differ diff --git a/agc_2-X/trunk/app_conference/0.wav b/agc_2-X/trunk/app_conference/0.wav new file mode 100644 index 00000000..fe3fc124 Binary files /dev/null and b/agc_2-X/trunk/app_conference/0.wav differ diff --git a/agc_2-X/trunk/app_conference/1.gsm b/agc_2-X/trunk/app_conference/1.gsm new file mode 100644 index 00000000..7f6c842f --- /dev/null +++ b/agc_2-X/trunk/app_conference/1.gsm @@ -0,0 +1 @@ +8z*PScOȪP,r)" +E<7j2h#8誙B,65Cb (Ra.4WFR2) 8z.hK]%Mq]ͷM] %ty\ ,Yc:Sd<,iUK:B.eZ%Vn*䡝QE!t+DC5сWETbok]bcCzՔ.46_M]]Dbv])`]kʜ_uY]UU2Fr.]MtZld]C]6]Y[.jR=_a 뭺_ܭ1Z]r2բ)6A]](,Q]\gS4a&Q2c>v\udI$P`u \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/1.wav b/agc_2-X/trunk/app_conference/1.wav new file mode 100644 index 00000000..e5f5359a Binary files /dev/null and b/agc_2-X/trunk/app_conference/1.wav differ diff --git a/agc_2-X/trunk/app_conference/2.gsm b/agc_2-X/trunk/app_conference/2.gsm new file mode 100644 index 00000000..82d6e751 --- /dev/null +++ b/agc_2-X/trunk/app_conference/2.gsm @@ -0,0 +1,3 @@ +xZP4e5cU\ #n7#HVc ͌xC=A`a肹 B+3+x;4QӇx7 T_ xJB<]%]и +]t1]"0s wb2"hϣ& 0_C%,#dAxZ=a#^TIXVաs6IsBtIrx%~—b!a8sa8cF )8xZvEX]#yM02":#8txZv"%|_,äϢ)YxJA}me+6j_-gF|xK>a- +wCY 藡J,FsͮZx<>_"q- ) *Ƭs Psv_cgβrG$R 埗Y \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/2.wav b/agc_2-X/trunk/app_conference/2.wav new file mode 100644 index 00000000..c3e9edd9 Binary files /dev/null and b/agc_2-X/trunk/app_conference/2.wav differ diff --git a/agc_2-X/trunk/app_conference/3.gsm b/agc_2-X/trunk/app_conference/3.gsm new file mode 100644 index 00000000..a41d6679 --- /dev/null +++ b/agc_2-X/trunk/app_conference/3.gsm @@ -0,0 +1,2 @@ +;=PW1W#X [r)d[K%7 +$c#2+)UBV4F¬SC{4[Hnpޥꕷbªσ`gC?=W n(*En,{Q6qR=!Ʈ\b#V) h~R=ѓ \%.kn\R=pzr>ܙ=$u R=ρfGϠȵj&ayC<·+61㍂aϣpK;WClRLJ$=Rf%>##xwb LM}bj&V:3k+[? kS%vAbÝ97qݑ \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/3.wav b/agc_2-X/trunk/app_conference/3.wav new file mode 100644 index 00000000..bc37ff5d Binary files /dev/null and b/agc_2-X/trunk/app_conference/3.wav differ diff --git a/agc_2-X/trunk/app_conference/4.gsm b/agc_2-X/trunk/app_conference/4.gsm new file mode 100644 index 00000000..d2bae3f8 --- /dev/null +++ b/agc_2-X/trunk/app_conference/4.gsm @@ -0,0 +1,2 @@ +8PRW\-elG'XVb,b*V rK"bTJ5~aȋf9ZTȁ`IZ^8nYZ2!Qhzk*"xS8nƸ*"fsSzCdփHΡQTmqZsb=iB +Vbc #meTQJeS;4UQ\H'k JX+ 82U" #9k:'Q "I.Sc"7оRr%ڜD~V΢e Vqr!EKi}9EiUELyXz9#3ȭrQ Ysq[HܘaM2 \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/4.wav b/agc_2-X/trunk/app_conference/4.wav new file mode 100644 index 00000000..05f1adf8 Binary files /dev/null and b/agc_2-X/trunk/app_conference/4.wav differ diff --git a/agc_2-X/trunk/app_conference/5.gsm b/agc_2-X/trunk/app_conference/5.gsm new file mode 100644 index 00000000..239c7aca --- /dev/null +++ b/agc_2-X/trunk/app_conference/5.gsm @@ -0,0 +1 @@ +xj=P3cWcT qFܚ$DVD%CHxS&TxD?4A9E'ڸU2r [SyqxbWXWlK%a.Ռ̩ح4+Mv_dȗ˱.#IZAY \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/6.wav b/agc_2-X/trunk/app_conference/6.wav new file mode 100644 index 00000000..7c32ca36 Binary files /dev/null and b/agc_2-X/trunk/app_conference/6.wav differ diff --git a/agc_2-X/trunk/app_conference/64_Makefile b/agc_2-X/trunk/app_conference/64_Makefile new file mode 100644 index 00000000..531caf54 --- /dev/null +++ b/agc_2-X/trunk/app_conference/64_Makefile @@ -0,0 +1,115 @@ +# $Id: Makefile,v 1.9 2005/10/27 17:53:35 stevek Exp $ + +# +# Makefile, based on the Asterisk Makefile, Coypright (C) 1999, Mark Spencer +# +# Copyright (C) 2002,2003 Junghanns.NET GmbH +# +# Klaus-Peter Junghanns +# +# This program is free software and may be modified and +# distributed under the terms of the GNU Public License. +# + +.EXPORT_ALL_VARIABLES: + +# +# app_conference defines which can be passed on the command-line +# + +DESTDIR := +INSTALL_MODULES_DIR := /usr/lib/asterisk/modules +INSTALL_CONFIG_DIR := /etc/asterisk + +ASTERISK_INCLUDE_DIR := /usr/include/asterisk + +# turn app_conference debugging on or off ( 0 == OFF, 1 == ON ) +APP_CONFERENCE_DEBUG := 1 + +# 0 = OFF 1 = astdsp 2 = speex +SILDET := 2 + +# +# app_conference objects to build +# + +OBJS = app_conference.o conference.o member.o frame.o cli.o +SHAREDOS = app_conference.so + +# +# standard compile settings +# + +PROC = $(shell uname -m) +INSTALL = install +CC = gcc + +# skip asterisk includes if they are in /usr/include/asterisk +ifneq ($(shell dirname $(ASTERISK_INCLUDE_DIR)), /usr/include) +INCLUDE = -I$(ASTERISK_INCLUDE_DIR) +endif + +LIBS = -ldl -lpthread -lm +DEBUG := -g + +CFLAGS += -pipe -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE + +CFLAGS += $(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi) +CFLAGS += -DCRYPTO + +ifeq ($(APP_CONFERENCE_DEBUG), 1) +CFLAGS += -DAPP_CONFERENCE_DEBUG +endif + +# +# additional flag values for silence detection +# + +ifeq ($(SILDET), 2) +OBJS += libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o +CFLAGS += -Ilibspeex -DSILDET=2 +endif + +ifeq ($(SILDET), 1) +CFLAGS += -DSILDET=1 +endif + +OSARCH=$(shell uname -s) +ifeq (${OSARCH},Darwin) +SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace +else +SOLINK=-shared -Xlinker -x +endif + +# +# targets +# + +all: $(SHAREDOS) + +clean: + rm -f *.so *.o $(OBJS) + +app_conference.so : $(OBJS) + $(CC) -shared -Xlinker -x -o $@ $(OBJS) + +vad_test: vad_test.o libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o + $(CC) $(PROFILE) -o $@ $^ -lm + +install: all + if [ ! -d ${DESTDIR}${INSTALL_MODULES_DIR} ]; then \ + $(INSTALL) -m 755 -d ${DESTDIR}${INSTALL_MODULES_DIR} ; \ + fi + for x in $(SHAREDOS); do \ + $(INSTALL) -m 755 $$x ${DESTDIR}$(INSTALL_MODULES_DIR) ; \ + done + cp -f *.gsm /var/lib/asterisk/sounds + cp -f *.wav /var/lib/asterisk/sounds + + +#config: all +# if [ ! -d ${DESTDIR}${INSTALL_CONFIG_DIR} ]; then \ +# $(INSTALL) -m 755 -d ${DESTDIR}${INSTALL_CONFIG_DIR} ; \ +# fi +# $(INSTALL) -m 640 conf.conf ${DESTDIR}${INSTALL_CONFIG_DIR} + diff --git a/agc_2-X/trunk/app_conference/7.gsm b/agc_2-X/trunk/app_conference/7.gsm new file mode 100644 index 00000000..0260531d --- /dev/null +++ b/agc_2-X/trunk/app_conference/7.gsm @@ -0,0 +1,2 @@ +8PR=:^ +r(۞fM[E88vG(QE!f݅ Q[O*֩r<HWSwt8Dx"IGDL4:RīUXj]H䋨L~rA fa֮2_(9FܗL]ëRQh_7#uGB.Vi]McjE2[vADyac]loHtRFz􇁗Hy!Aq8!QȤc=6 B)SdޭU9"<55c=ۉmbSc_ܩHUD{7=_!1֥!S왩n:5P!ku \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/7.wav b/agc_2-X/trunk/app_conference/7.wav new file mode 100644 index 00000000..6cdce5c1 Binary files /dev/null and b/agc_2-X/trunk/app_conference/7.wav differ diff --git a/agc_2-X/trunk/app_conference/8.gsm b/agc_2-X/trunk/app_conference/8.gsm new file mode 100644 index 00000000..e931896a Binary files /dev/null and b/agc_2-X/trunk/app_conference/8.gsm differ diff --git a/agc_2-X/trunk/app_conference/8.wav b/agc_2-X/trunk/app_conference/8.wav new file mode 100644 index 00000000..3ed04b3b Binary files /dev/null and b/agc_2-X/trunk/app_conference/8.wav differ diff --git a/agc_2-X/trunk/app_conference/9.gsm b/agc_2-X/trunk/app_conference/9.gsm new file mode 100644 index 00000000..4a994705 Binary files /dev/null and b/agc_2-X/trunk/app_conference/9.gsm differ diff --git a/agc_2-X/trunk/app_conference/9.wav b/agc_2-X/trunk/app_conference/9.wav new file mode 100644 index 00000000..1439a595 Binary files /dev/null and b/agc_2-X/trunk/app_conference/9.wav differ diff --git a/agc_2-X/trunk/app_conference/LICENSE b/agc_2-X/trunk/app_conference/LICENSE new file mode 100644 index 00000000..a52b16e4 --- /dev/null +++ b/agc_2-X/trunk/app_conference/LICENSE @@ -0,0 +1,341 @@ + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/agc_2-X/trunk/app_conference/Makefile b/agc_2-X/trunk/app_conference/Makefile new file mode 100644 index 00000000..d8b54a44 --- /dev/null +++ b/agc_2-X/trunk/app_conference/Makefile @@ -0,0 +1,121 @@ +# $Id: Makefile,v 1.9 2005/10/27 17:53:35 stevek Exp $ + +# +# Makefile, based on the Asterisk Makefile, Coypright (C) 1999, Mark Spencer +# +# Copyright (C) 2002,2003 Junghanns.NET GmbH +# +# Klaus-Peter Junghanns +# +# This program is free software and may be modified and +# distributed under the terms of the GNU Public License. +# + +.EXPORT_ALL_VARIABLES: + +# +# app_conference defines which can be passed on the command-line +# + +INSTALL_PREFIX := /usr +INSTALL_MODULES_DIR := $(INSTALL_PREFIX)/lib/asterisk/modules + +ASTERISK_INCLUDE_DIR := $(HOME)/local/asterisk/asterisk/include + +# turn app_conference debugging on or off ( 0 == OFF, 1 == ON ) +APP_CONFERENCE_DEBUG := 1 + +# 0 = OFF 1 = astdsp 2 = speex +SILDET := 2 + +# +# app_conference objects to build +# + +OBJS = app_conference.o conference.o member.o frame.o cli.o +SHAREDOS = app_conference.so + +# +# standard compile settings +# + +PROC = $(shell uname -m) +INSTALL = install +CC = gcc + +INCLUDE = -I$(ASTERISK_INCLUDE_DIR) +LIBS = -ldl -lpthread -lm +DEBUG := -g + +CFLAGS = -pipe -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE +#CFLAGS += -O2 +#CFLAGS += -O3 -march=pentium3 -msse -mfpmath=sse,387 -ffast-math +# PERF: below is 10% faster than -O2 or -O3 alone. +#CFLAGS += -O3 -ffast-math -funroll-loops +# below is another 5% faster or so. +CFLAGS += -O3 -ffast-math -funroll-all-loops -fprefetch-loop-arrays -fsingle-precision-constant + +# this is fun for PPC +#CFLAGS += -mcpu=7450 -faltivec -mabi=altivec -mdynamic-no-pic + +# this is fun for x86 +CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 + + +# adding -msse -mfpmath=sse has little effect. +#CFLAGS += -O3 -msse -mfpmath=sse +#CFLAGS += $(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) +CFLAGS += $(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi) +CFLAGS += -DCRYPTO + +ifeq ($(APP_CONFERENCE_DEBUG), 1) +CFLAGS += -DAPP_CONFERENCE_DEBUG +endif + +# +# additional flag values for silence detection +# + +ifeq ($(SILDET), 2) +OBJS += libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o +CFLAGS += -Ilibspeex -DSILDET=2 +endif + +ifeq ($(SILDET), 1) +CFLAGS += -DSILDET=1 +endif + +OSARCH=$(shell uname -s) +ifeq (${OSARCH},Darwin) +SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace +else +SOLINK=-shared -Xlinker -x +endif + +# +# targets +# + +all: $(SHAREDOS) + +clean: + rm -f *.so *.o $(OBJS) + +app_conference.so : $(OBJS) + $(CC) -pg -shared -Xlinker -x -o $@ $(OBJS) + +vad_test: vad_test.o libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o + $(CC) $(PROFILE) -o $@ $^ -lm + +install: all + for x in $(SHAREDOS); do $(INSTALL) -m 755 $$x $(INSTALL_MODULES_DIR) ; done + cp -f *.gsm /var/lib/asterisk/sounds + cp -f *.wav /var/lib/asterisk/sounds + +# /var/horizon/mojo/lib/horizoncmd restart asterisk +# make sure you restart asterisk after make install + +# config: all +# cp conf.conf /etc/asterisk/ + + diff --git a/agc_2-X/trunk/app_conference/README b/agc_2-X/trunk/app_conference/README new file mode 100644 index 00000000..2a1c5141 --- /dev/null +++ b/agc_2-X/trunk/app_conference/README @@ -0,0 +1,170 @@ +app_conference is a channel-independent conference application. + +Design goals +It has several design goals which are different than meetme: + + * It does not require a zap channel for timing. + * It is very efficient when used with channels which support DTX (silence + detection/discontinuous transmission). + + * It can do VAD on channels which do not support DTX (although this + is more expensive than just mixing them, but less expensive then + encoding; therefore it might still be a win). + * It presents messages on the Monitor interface for determine which + speakers are active. + + +I believe that people other than myself are using this, but my environment is +pretty rigid, and cases outside of this aren't tested: + + * Some callers come from the PSTN via IAX2 from a box with Zaptel cards, + via uLaw. + * Other callers come from iaxclient based softphones using speex + (was GSM) via IAX2 (with DTX). + * Some conferences have a single SIP channel which listens in GSM. + + +Mixing design + + * Minimize encoding/decoding, minimize mixing. + * Minimize generational loss from trancoding. + * Usual cases are handled very efficiently: + o One speaker: That speaker's frame is sent directly to each + participant which uses the same codec. It is trancoded + _once_ for each additional codec type used by participants. + o Two speakers: Each speaker gets the other speaker's frames. + The two speaker's frames are decoded and mixed, and then + encoded _once_ for each codec type used by participants. + + +License +Naturally, app_conference is GPL. The CVS also includes parts of libspeex, +which is distributed under it's a BSD-style license. + +Getting app_conference +app_conference is available from the 'iaxclient' project on sourceforge: + + * CVS browse: http://iaxclient.cvs.sourceforge.net/iaxclient/app_conference/ + * Project page: http://sourceforge.net/projects/iaxclient/ + + +Compiling app_conference + + * just like any other asterisk application. + * Some makefile fiddling may be necessary + + +Using app_conference +There is no configuration file. Conferences are created on-the-fly. + +Dialplan syntax: Conference(ConferenceName|Flags|Priority[|VADSTART|VADCONTINUE]) + + * ConferenceName: Whatever you want to name the conference + * Flags one of more of the following: + o M: Moderator (presently same as speaker) + o S: Speaker + o L: Listener + o T: "Telephone caller" (just for stats?). + o V: Do VAD on this caller + o D: Use Denoise filter on this caller. + o d: Send manager events when DTMF is received. + o q: Do not play enter or exit sounds. + o i: use inband dtmf broadcast. + o t: use rfc dtmf signal broadcast. + * Priority: Currently ignored; was to be a "speaking priority" so a + higher priority caller could "override" others. + * VADSTART: Optional: "probability" to use to detect start of speech. + * VADCONTINUE: Optional: "probability" to use to detect continuation + of speech. + + +Features / CLI/Manager Commands + + * conference debug [ on | off ] + enable debugging for a conference + + * conference show stats show conference stats + + * conference play sound [mute] + play a sound to a conference member, optionally muting them. + +Manager Events +app_conference generates several detailed manager events so that applications +interfacing with the manager API can monitor conferences: + + * ConferenceState: sent as members begin/end speaking. + Channel: The channel + State: "speaking" or "silent" + + * ConferenceDTMF: sent when conference members send DTMF to the conference + Channel: The channel + Key: The DTMF key send [0-9*#] + + * ConferenceSoundComplete: send when the conference has finished playing + a sound to a user + Channel: The channel + Sound: The first 255 bytes of the file requested in conference play + sound CLI/Mgr command. + + +Benchmarking +It would be nice to have solid benchmarks to present, but a good size +machine should be able to handle many callers when either (a) they are +using DTX, or (b) they are listen-only. It's used often with hundreds of +simultaneous callers. + +Discussion +The iaxclient-devel mailing list is probably as good a place as any to discuss. + + +--- + +app_conference is brought to you by the letter q, and the number e + + +Matt Florell Changes for VD_app_conference tarball version. In order to use this +as seemlessly as possible for VICIDIAL it was necessary to modify the code. This +module can now be used in place of using meetme for VICIDIAL. This is +experimental, please test thoroughly before putting it in production. + +CHANGES MADE FOR VICIDIAL: + +- Default to member type of S instead of L +- Commented out many repetative NOTICEs and ERRORs +- Added entry and exit sounds except for Local/786 and Local/8500998 (VDsilent and DTMFapp) +- Added conf-onlyperson mesage to first conference participant +- Included enter.gsm and leave.gsm files as well as DTMF wav and gsm sounds +- Removed restart from "make install" and added audio file copying +- If no 'd' option is set and DTMF frames are detected, the DTMF audio will be played to the member +- Added 'q' flag to prevent playing of entry/exit sounds +- Added 'i' flag to enable playing of DTMF sounds inband to all members +- Added 't' flag to enable sending of RFC DTMF signals to all members +- Changed delimiter to pipe | from slash / to be more compliant with meetme standards + + +NOTE TO 64-BIT LINUX USERS: +If you have problems with 64-bit Linux please use the included 64_Makefile instead of the default one. + +COMPILE NOTES: + +Some Makefile alterations may be necessary for your system: + +From Alek Barkley: +I am running FC4 with latest updates ( 2.6.16 kernel ) +My CPU is AMD K6 and GCC 4.0.2. + +I edited Makefile in app_conference distribution. +To enter CPU architecture in my case -march=k6 +======================================================== +PROC = k6 +# this is fun for x86 +#CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 +CFLAGS += -march=k6 +=========================================================== + + +VD_app_conference CHANGELOG +- Release 0.4 - First VICIDIAL-centric release +- Release 0.5 - Fixed the dtmf broadcast logic and a star/hash bug + - Added 64-bit makefile thanks to Jon Hood +- Release 0.6 - Added Makefile notes and changed some Makefile flags diff --git a/agc_2-X/trunk/app_conference/VICIDIAL.txt b/agc_2-X/trunk/app_conference/VICIDIAL.txt new file mode 100644 index 00000000..92011ec2 --- /dev/null +++ b/agc_2-X/trunk/app_conference/VICIDIAL.txt @@ -0,0 +1,86 @@ +VICIDIAL and app_conference +(1.2 tree) EXPERIMENTAL!!! + +app_conference offers the plusses of being able to do conferencing +without any zaptel hardware or timers as well as doing native codec +streaming, meaning no manditory downsampling to slin like meetme. +These two features alone mean a rather significant performance boost +to companies who only use VOIP for agents and trunks as well as not +requiring the cost of zaptel hardware or the nightmare of getting +ztdummy to work on some systems. + +As of right now, I have a test system fully up and running using +app_conference with VICIDIAL on Asterisk 1.2.8. I have made several +modifications to the app_conference code to make it more of a drop-in +replacement for meetme so that it does not require any changes to the +VICIDIAL codebase. I have added entry and exit sounds(slightly +different from meetme's) as well as "only one in this conference" +message in addition to changing the default member type to speaker(S). +So far I have tested with IAX and SIP channels only and everything +works just like on meetme but I have not done any capacity testing or +tested it in production yet. + +If you want to use app_conference instead of meetme for VICIDIAL then follow these instructions: + +cd /usr/src/asterisk +wget http://www.eflo.net/files/VD_app_conference_0.6.zip +unzip VD_app_conference_0.6.zip +cd app_conference +make clean +make +make install + + +In your extensions.conf file you would replace these lines: +exten => 8600051,1,Meetme,8600051 +exten => 8600052,1,Meetme,8600052 +...continue through 8600100... +exten => 78600051,1,Meetme,8600051|q +exten => 78600052,1,Meetme,8600052|q +...continue through 78600100... +exten => 68600051,1,Meetme,8600051|mq +exten => 68600052,1,Meetme,8600052|mq +...continue through 68600100... + + +with these lines: +exten => 8600051,1,Conference(8600051) +exten => 8600052,1,Conference(8600052) +...continue through 8600100... +exten => 78600051,1,Conference(8600051|q) +exten => 78600052,1,Conference(8600052|q) +...continue through 78600100... +exten => 68600051,1,Conference(8600051|Lq) +exten => 68600052,1,Conference(8600052|Lq) +...continue through 68600100... + +NOTES: +Here are the possible feature flags for this version of app_conference: + o M: Moderator (presently same as speaker) [default] + o S: Speaker + o L: Listener + o T: "Telephone caller" (just for stats?). + o V: Do VAD on this caller + o D: Use Denoise filter on this caller. + o d: Send manager events when DTMF is received. + o q: Do not play enter or exit sounds. + o i: use inband dtmf broadcast. + o t: use rfc dtmf signal broadcast. + +COMPILE NOTES: + +Some Makefile alterations may be necessary for your system: + +From Alek Barkley: +I am running FC4 with latest updates ( 2.6.16 kernel ) +My CPU is AMD K6 and GCC 4.0.2. + +I edited Makefile in app_conference distribution. +To enter CPU architecture in my case -march=k6 +======================================================== +PROC = k6 +# this is fun for x86 +#CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 +CFLAGS += -march=k6 +=========================================================== + diff --git a/agc_2-X/trunk/app_conference/app_conference.c b/agc_2-X/trunk/app_conference/app_conference.c new file mode 100644 index 00000000..9be6c3a3 --- /dev/null +++ b/agc_2-X/trunk/app_conference/app_conference.c @@ -0,0 +1,146 @@ + +// $Id: app_conference.c,v 1.22 2005/10/26 21:02:07 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#include "app_conference.h" +#include "common.h" + +/* + +a conference has n + 1 threads, where n is the number of +members and 1 is a conference thread which sends audio +back to the members. + +each member thread reads frames from the channel and +add's them to the member's frame queue. + +the conference thread reads frames from each speaking members +queue, mixes them, and then re-queues them for the member thread +to send back to the user. + +*/ + +// +// app_conference text descriptions +// + +static char *tdesc = "Channel Independent Conference Application" ; +static char *app = "Conference" ; +static char *synopsis = "Channel Independent Conference" ; +static char *descrip = " Conference(): returns 0\n" +"if the user exits with the '#' key, or -1 if the user hangs up.\n" ; + +// +// functions defined in asterisk/module.h +// + +STANDARD_LOCAL_USER ; +LOCAL_USER_DECL; + +int unload_module( void ) +{ + ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ; + + STANDARD_HANGUP_LOCALUSERS ; // defined in asterisk/module.h + + // register conference cli functions + unregister_conference_cli() ; + + return ast_unregister_application( app ) ; +} + +int load_module( void ) +{ + ast_log( LOG_NOTICE, "loading app_conference module [ $Revision: 1.22 $ ]\n" ) ; + + // intialize conference + init_conference() ; + + // register conference cli functions + register_conference_cli() ; + + return ast_register_application( app, app_conference_main, synopsis, descrip ) ; +} + +char *description( void ) +{ + return tdesc ; +} + +int usecount( void ) +{ + int res; + STANDARD_USECOUNT( res ) ; // defined in asterisk/module.h + return res; +} + +char *key() +{ + return ASTERISK_GPL_KEY ; +} + +// +// main app_conference function +// + +int app_conference_main( struct ast_channel* chan, void* data ) +{ + int res = 0 ; + struct localuser *u ; + + // defined in asterisk/module.h + LOCAL_USER_ADD( u ) ; + + // call member thread function + res = member_exec( chan, data ) ; + + // defined in asterisk/module.h + LOCAL_USER_REMOVE( u ) ; + + return res ; +} + +// +// utility functions +// + +// now returns milliseconds +long usecdiff( struct timeval* timeA, struct timeval* timeB ) +{ + long a_secs = timeA->tv_sec - timeB->tv_sec ; + long b_secs = (long)( timeA->tv_usec / 1000 ) - (long)( timeB->tv_usec / 1000 ) ; + long u_secs = ( a_secs * 1000 ) + b_secs ; + return u_secs ; +} + +// increment a timeval by ms milliseconds +void add_milliseconds( struct timeval* tv, long ms ) +{ + // add the microseconds to the microseconds field + tv->tv_usec += ( ms * 1000 ) ; + + // calculate the number of seconds to increment + long s = ( tv->tv_usec / 1000000 ) ; + + // adjust the microsends field + if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ; + + // increment the seconds field + tv->tv_sec += s ; + + return ; +} diff --git a/agc_2-X/trunk/app_conference/app_conference.h b/agc_2-X/trunk/app_conference/app_conference.h new file mode 100644 index 00000000..695a65a9 --- /dev/null +++ b/agc_2-X/trunk/app_conference/app_conference.h @@ -0,0 +1,200 @@ + +// $Id: app_conference.h,v 1.11 2005/12/16 22:31:58 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _ASTERISK_CONF_H +#define _ASTERISK_CONF_H + +#include + +/* asterisk includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* standard includes */ +#include +#include +#include +#include + +#include + +#if (SILDET == 2) +#include "libspeex/speex_preprocess.h" +#endif + +// +// app_conference defines +// + +// debug logging level + +// LOG_NOTICE for debugging, LOG_DEBUG for production +#ifdef APP_CONFERENCE_DEBUG +#define AST_CONF_DEBUG LOG_NOTICE +#else +#define AST_CONF_DEBUG LOG_DEBUG +#endif + +// +// feature defines +// + +// number of times the last non-silent frame should be +// repeated after silence starts +//#define AST_CONF_CACHE_LAST_FRAME 1 + +// +// debug defines +// + +#define DEBUG_USE_TIMELOG + +#define DEBUG_FRAME_TIMESTAMPS + +// #define DEBUG_OUTPUT_PCM + +// +// !!! THESE CONSTANTS SHOULD BE CLEANED UP AND CLARIFIED !!! +// + +// +// sample information for AST_FORMAT_SLINEAR format +// + +#define AST_CONF_SAMPLE_RATE 8000 +#define AST_CONF_SAMPLE_SIZE 16 +#define AST_CONF_FRAME_INTERVAL 20 + +// +// so, since we cycle approximately every 20ms, +// we can compute the following values: +// +// 160 samples per 20 ms frame -or- +// ( 8000 samples-per-second * ( 20 ms / 1000 ms-per-second ) ) = 160 samples +// +// 320 bytes ( 2560 bits ) of data 20 ms frame -or- +// ( 160 samples * 16 bits-per-sample / 8 bits-per-byte ) = 320 bytes +// + +// 160 samples 16-bit signed linear +#define AST_CONF_BLOCK_SAMPLES 160 + +// 2 bytes per sample ( i.e. 16-bit ) +#define AST_CONF_BYTES_PER_SAMPLE 2 + +// 320 bytes for each 160 sample frame of 16-bit audio +#define AST_CONF_FRAME_DATA_SIZE 320 + +// 1000 ms-per-second / 20 ms-per-frame = 50 frames-per-second +#define AST_CONF_FRAMES_PER_SECOND ( 1000 / AST_CONF_FRAME_INTERVAL ) + + +// +// buffer and queue values +// + +// account for friendly offset when allocating buffer for frame +#define AST_CONF_BUFFER_SIZE ( AST_CONF_FRAME_DATA_SIZE + AST_FRIENDLY_OFFSET ) + +// maximum number of frames queued per member +#define AST_CONF_MAX_QUEUE 100 + +// minimum number of frames queued per member +#define AST_CONF_MIN_QUEUE 0 + +// number of queued frames before we start dropping +#define AST_CONF_QUEUE_DROP_THRESHOLD 4 + +// number of milliseconds between frame drops +#define AST_CONF_QUEUE_DROP_TIME_LIMIT 750 + +// +// timer and sleep values +// + +// milliseconds we're willing to wait for a channel +// event before we check for outgoing frames +#define AST_CONF_WAITFOR_LATENCY 40 + +// milliseconds to sleep before trying to process frames +#define AST_CONF_CONFERENCE_SLEEP 40 + +// milliseconds to wait between state notification updates +#define AST_CONF_NOTIFICATION_SLEEP 500 + +// +// warning threshold values +// + +// number of frames behind before warning +#define AST_CONF_OUTGOING_FRAMES_WARN 50 + +// number of milliseconds off AST_CONF_FRAME_INTERVAL before warning +#define AST_CONF_INTERVAL_WARNING 1000 + +// +// silence detection values +// + +// toggle silence detection +#define ENABLE_SILENCE_DETECTION 1 + +// silence threshold +#define AST_CONF_SILENCE_THRESHOLD 128 + +// speech tail (delay before dropping silent frames, in ms. +// #define AST_CONF_SPEECH_TAIL 180 + +// number of frames to ignore speex_preprocess() after speech detected +#define AST_CONF_SKIP_SPEEX_PREPROCESS 20 + +// our speex probability values +#define AST_CONF_PROB_START 0.05 +#define AST_CONF_PROB_CONTINUE 0.02 + +// +// format translation values +// + +// AST_FORMAT_MAX_AUDIO is 1 << 15, so we support 0..15 +#define AC_SUPPORTED_FORMATS 16 +#define AC_SLINEAR_INDEX 6 + +// +// app_conference functions +// + +// main module function +int app_conference_main( struct ast_channel* chan, void* data ) ; + +// utility functions +long usecdiff( struct timeval* timeA, struct timeval* timeB ) ; +void add_milliseconds( struct timeval* tv, long ms ) ; + +#endif + + diff --git a/agc_2-X/trunk/app_conference/cli.c b/agc_2-X/trunk/app_conference/cli.c new file mode 100644 index 00000000..d5797034 --- /dev/null +++ b/agc_2-X/trunk/app_conference/cli.c @@ -0,0 +1,332 @@ + +// $Id: cli.c,v 1.6 2005/12/21 21:34:50 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#include "cli.h" + +// +// debug functions +// + +static char conference_debug_usage[] = + "usage: conference debug [ on | off ]\n" + " enable debugging for a conference\n" +; + +static struct ast_cli_entry cli_debug = { + { "conference", "debug", NULL }, + conference_debug, + "enable debugging for a conference", + conference_debug_usage +} ; + + +int conference_debug( int fd, int argc, char *argv[] ) +{ + if ( argc < 3 ) + return RESULT_SHOWUSAGE ; + + // get the conference name + const char* name = argv[2] ; + + // get the new state + int state = 0 ; + + if ( argc == 3 ) + { + // no state specified, so toggle it + state = -1 ; + } + else + { + if ( strncasecmp( name, "YES", 4 ) == 0 ) + state = 1 ; + else if ( strncasecmp( name, "NO", 3 ) == 0 ) + state = 0 ; + else + return RESULT_SHOWUSAGE ; + } + + int new_state = set_conference_debugging( name, state ) ; + + if ( new_state == 1 ) + { + ast_cli( fd, "enabled conference debugging, name => %s, new_state => %d\n", + name, new_state ) ; + } + else if ( new_state == 0 ) + { + ast_cli( fd, "disabled conference debugging, name => %s, new_state => %d\n", + name, new_state ) ; + } + else + { + // error setting state + ast_cli( fd, "\nunable to set debugging state, name => %s\n\n", name ) ; + } + + return RESULT_SUCCESS ; +} + +// +// stats functions +// + +static char conference_show_stats_usage[] = + "usage: conference show stats\n" + " display stats for active conferences.\n" +; + +static struct ast_cli_entry cli_show_stats = { + { "conference", "show", "stats", NULL }, + conference_show_stats, + "show conference stats", + conference_show_stats_usage +} ; + +int conference_show_stats( int fd, int argc, char *argv[] ) +{ + if ( argc < 3 ) + return RESULT_SHOWUSAGE ; + + // get count of active conferences + int count = get_conference_count() ; + + ast_cli( fd, "\n\nCONFERENCE STATS, ACTIVE( %d )\n\n", count ) ; + + // if zero, go no further + if ( count <= 0 ) + return RESULT_SUCCESS ; + + // + // get the conference stats + // + + // array of stats structs + ast_conference_stats stats[ count ] ; + + // get stats structs + count = get_conference_stats( stats, count ) ; + + // make sure we were able to fetch some + if ( count <= 0 ) + { + ast_cli( fd, "!!! error fetching conference stats, available => %d !!!\n", count ) ; + return RESULT_SUCCESS ; + } + + // + // output the conference stats + // + + // output header + ast_cli( fd, "%-20.20s %-40.40s %-40.40s\n", "Name", "Connection Type", "Member Type" ) ; + ast_cli( fd, "%-20.20s %-40.40s %-40.40s\n", "----", "---------------", "-----------" ) ; + + ast_conference_stats* s = NULL ; + + char ct[64] ; + char mt[64] ; + + int i; + for ( i = 0 ; i < count ; ++i ) + { + s = &(stats[i]) ; + + // format connection type + snprintf( ct, 40, "phone( %d ), iax( %d ), sip( %d )", + s->phone, s->iaxclient, s->sip ) ; + + // format memeber type + snprintf( mt, 40, "moderators( %d ), listeners( %d )", + s->moderators, s->listeners ) ; + + // output this conferences stats + ast_cli( fd, "%-20.20s %-40.40s %-40.40s\n", (char*)( &(s->name) ), ct, mt ) ; + } + + ast_cli( fd, "\n" ) ; + + // + // drill down to specific stats + // + + if ( argc == 4 ) + { + // show stats for a particular conference + conference_show_stats_name( fd, argv[3] ) ; + } + + return RESULT_SUCCESS ; +} + +int conference_show_stats_name( int fd, const char* name ) +{ + // not implemented yet + return RESULT_SUCCESS ; +} + +// +// play sound +// + +static char conference_play_sound_usage[] = + "usage: conference play sound [mute]\n" + " play sound to conference member .\n" + " mute the channel if 'mute' is present.\n" +; + +static struct ast_cli_entry cli_play_sound = { + { "conference", "play", "sound", NULL }, + conference_play_sound, + "play a sound to a conference member", + conference_play_sound_usage +} ; + +int conference_play_sound( int fd, int argc, char *argv[] ) +{ + char *channel, *file; + int mute = 0; + struct ast_conf_member *member; + struct ast_conf_soundq *newsound; + struct ast_conf_soundq **q; + + if ( argc < 5 ) + return RESULT_SHOWUSAGE ; + + channel = argv[3]; + file = argv[4]; + + if(argc > 5 && !strcmp(argv[5], "mute")) + mute = 1; + + + member = find_member(channel, 1); + if(!member) { + ast_cli(fd, "Member %s not found\n", channel); + return RESULT_FAILURE; + } + + newsound = calloc(1,sizeof(struct ast_conf_soundq)); + newsound->stream = ast_openstream(member->chan, file, NULL); + if(!newsound->stream) { + ast_cli(fd, "Sound %s not found\n", file); + free(newsound); + ast_mutex_unlock(&member->lock); + return RESULT_FAILURE; + } + member->chan->stream = NULL; + + newsound->muted = mute; + ast_copy_string(newsound->name, file, sizeof(newsound->name)); + + // append sound to the end of the list. + for(q=&member->soundq; *q; q = &((*q)->next)) ;; + + *q = newsound; + + ast_mutex_unlock(&member->lock); + + ast_cli( fd, "Playing sound %s to member %s %s\n", + file, channel, mute ? "with mute" : ""); + + + return RESULT_SUCCESS ; +} + +// +// stop sounds +// + +static char conference_stop_sounds_usage[] = + "usage: conference stop sounds \n" + " stop sounds for conference member .\n" +; + +static struct ast_cli_entry cli_stop_sounds = { + { "conference", "stop", "sounds", NULL }, + conference_stop_sounds, + "stop sounds for a conference member", + conference_stop_sounds_usage +} ; + +int conference_stop_sounds( int fd, int argc, char *argv[] ) +{ + char *channel; + struct ast_conf_member *member; + struct ast_conf_soundq *sound; + struct ast_conf_soundq *next; + + if ( argc < 4 ) + return RESULT_SHOWUSAGE ; + + channel = argv[3]; + + member = find_member(channel, 1); + if(!member) { + ast_cli(fd, "Member %s not found\n", channel); + return RESULT_FAILURE; + } + + + + // clear all sounds + sound = member->soundq; + member->soundq = NULL; + + while(sound) { + next = sound->next; + ast_closestream(sound->stream); + free(sound); + sound = next; + } + + // reset write format, since we're done playing the sound + if ( ast_set_write_format( member->chan, member->write_format ) < 0 ) + { + ast_log( LOG_ERROR, "unable to set write format to %d\n", + member->write_format ) ; + } + + ast_mutex_unlock(&member->lock); + + ast_cli( fd, "Stopped sounds to member %s\n", channel); + + + return RESULT_SUCCESS ; +} + + +// +// cli initialization function +// + +void register_conference_cli( void ) +{ + ast_cli_register( &cli_debug ) ; + ast_cli_register( &cli_show_stats ) ; + ast_cli_register( &cli_play_sound ) ; + ast_cli_register( &cli_stop_sounds ) ; +} + +void unregister_conference_cli( void ) +{ + ast_cli_unregister( &cli_debug ) ; + ast_cli_unregister( &cli_show_stats ) ; + ast_cli_unregister( &cli_play_sound ) ; + ast_cli_unregister( &cli_stop_sounds ) ; +} diff --git a/agc_2-X/trunk/app_conference/cli.h b/agc_2-X/trunk/app_conference/cli.h new file mode 100644 index 00000000..735b284d --- /dev/null +++ b/agc_2-X/trunk/app_conference/cli.h @@ -0,0 +1,47 @@ + +// $Id: cli.h,v 1.3 2005/10/26 21:02:07 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _APP_CONF_CLI_H +#define _APP_CONF_CLI_H + +// +// includes +// + +#include "app_conference.h" +#include "common.h" + +// +// function declarations +// + +int conference_show_stats( int fd, int argc, char *argv[] ) ; +int conference_show_stats_name( int fd, const char* name ) ; + + +int conference_debug( int fd, int argc, char *argv[] ) ; +int conference_no_debug( int fd, int argc, char *argv[] ) ; + +int conference_play_sound( int fd, int argc, char *argv[] ) ; +int conference_stop_sounds( int fd, int argc, char *argv[] ) ; + +void register_conference_cli( void ) ; +void unregister_conference_cli( void ) ; + + +#endif diff --git a/agc_2-X/trunk/app_conference/common.h b/agc_2-X/trunk/app_conference/common.h new file mode 100644 index 00000000..a8015462 --- /dev/null +++ b/agc_2-X/trunk/app_conference/common.h @@ -0,0 +1,50 @@ + +// $Id: common.h,v 1.3 2005/10/26 21:02:07 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _APP_CONF_COMMON_H +#define _APP_CONF_COMMON_H + +// typedef includes +#include "conf_frame.h" + +// function includesee +#include "conference.h" +#include "member.h" +#include "frame.h" +#include "cli.h" + + +/* Utility functions */ + +/* LOG the time taken to execute a function (like lock acquisition */ +#if 1 +#define TIMELOG(func,min,message) \ + do { \ + struct timeval t1, t2; \ + int diff; \ + gettimeofday(&t1,NULL); \ + func; \ + gettimeofday(&t2,NULL); \ + if((diff = usecdiff(&t2, &t1)) > min) \ + ast_log( AST_CONF_DEBUG, "TimeLog: %s: %d ms\n", message, diff); \ + } while (0) +#else +#define TIMELOG(func,min,message) func +#endif + +#endif diff --git a/agc_2-X/trunk/app_conference/conf_frame.h b/agc_2-X/trunk/app_conference/conf_frame.h new file mode 100644 index 00000000..24cac7f9 --- /dev/null +++ b/agc_2-X/trunk/app_conference/conf_frame.h @@ -0,0 +1,61 @@ + +// $Id: conf_frame.h,v 1.3 2005/10/26 21:02:07 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _APP_CONF_STRUCTS_H +#define _APP_CONF_STRUCTS_H + +// +// includes +// + +#include "app_conference.h" +#include "common.h" + +// +// struct declarations +// + +typedef struct conf_frame +{ + // frame audio data + struct ast_frame* fr ; + + // array of converted versions for listeners + struct ast_frame* converted[ AC_SUPPORTED_FORMATS ] ; + + // pointer to the frame's owner + struct ast_conf_member* member ; // who sent this frame + + // frame meta data +// struct timeval timestamp ; +// unsigned long cycleid ; +// int priority ; + + // linked-list pointers + struct conf_frame* next ; + struct conf_frame* prev ; + + // should this frame be preserved + short static_frame ; + + // pointer to mixing buffer + char* mixed_buffer ; +} conf_frame ; + + +#endif diff --git a/agc_2-X/trunk/app_conference/conference.c b/agc_2-X/trunk/app_conference/conference.c new file mode 100644 index 00000000..4bdb64ca --- /dev/null +++ b/agc_2-X/trunk/app_conference/conference.c @@ -0,0 +1,1410 @@ + +// $Id: conference.c,v 1.7 2005/10/27 17:53:35 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#include "conference.h" +#include "regex.h" + +// +// static variables +// + +// single-linked list of current conferences +static struct ast_conference *conflist = NULL ; + +// mutex for synchronizing access to conflist +AST_MUTEX_DEFINE_STATIC(conflist_lock); +//static ast_mutex_t conflist_lock = AST_MUTEX_INITIALIZER ; + +// mutex for synchronizing calls to start_conference() and remove_conf() +AST_MUTEX_DEFINE_STATIC(start_stop_conf_lock); +//static ast_mutex_t start_stop_conf_lock = AST_MUTEX_INITIALIZER ; + +static int conference_count = 0 ; + +// +// main conference function +// + +void conference_exec( struct ast_conference *conf ) +{ + + struct ast_conf_member *member, *temp_member , *membertest; + struct conf_frame *cfr, *spoken_frames, *send_frames ; + + // count number of speakers, number of listeners + int speaker_count ; + int listener_count ; + + ast_log( AST_CONF_DEBUG, "[ $Revision: 1.7 $ ] entered conference_exec, name => %s\n", conf->name ) ; + + // timer timestamps + struct timeval base, curr, notify ; + gettimeofday( &base, NULL ) ; + gettimeofday( ¬ify, NULL ) ; + + // holds differences of curr and base + long time_diff = 0 ; + long time_sleep = 0 ; + + int since_last_slept = 0 ; + + // + // variables for checking thread frequency + // + + // count to AST_CONF_FRAMES_PER_SECOND + int tf_count = 0 ; + long tf_diff = 0 ; + float tf_frequency = 0.0 ; + + struct timeval tf_base, tf_curr ; + gettimeofday( &tf_base, NULL ) ; + + // + // main conference thread loop + // + + + while ( 42 == 42 ) + { + // update the current timestamp + gettimeofday( &curr, NULL ) ; + + // calculate difference in timestamps + time_diff = usecdiff( &curr, &base ) ; + + // calculate time we should sleep + time_sleep = AST_CONF_FRAME_INTERVAL - time_diff ; + + if ( time_sleep > 0 ) + { + // sleep for sleep_time ( as milliseconds ) + usleep( time_sleep * 1000 ) ; + + // reset since last slept counter + since_last_slept = 0 ; + + continue ; + } + else + { + // long sleep warning + if ( + since_last_slept == 0 + && time_diff > AST_CONF_CONFERENCE_SLEEP * 2 + ) + { + ast_log( + AST_CONF_DEBUG, + "long scheduling delay, time_diff => %ld, AST_CONF_FRAME_INTERVAL => %d\n", + time_diff, AST_CONF_FRAME_INTERVAL + ) ; + } + + // increment times since last slept + ++since_last_slept ; + + // sleep every other time + if ( since_last_slept % 2 ) + usleep( 0 ) ; + } + + // adjust the timer base ( it will be used later to timestamp outgoing frames ) + add_milliseconds( &base, AST_CONF_FRAME_INTERVAL ) ; + + // + // check thread frequency + // + + if ( ++tf_count >= AST_CONF_FRAMES_PER_SECOND ) + { + // update current timestamp + gettimeofday( &tf_curr, NULL ) ; + + // compute timestamp difference + tf_diff = usecdiff( &tf_curr, &tf_base ) ; + + // compute sampling frequency + tf_frequency = ( float )( tf_diff ) / ( float )( tf_count ) ; + + if ( + ( tf_frequency <= ( float )( AST_CONF_FRAME_INTERVAL - 1 ) ) + || ( tf_frequency >= ( float )( AST_CONF_FRAME_INTERVAL + 1 ) ) + ) + { + ast_log( + LOG_WARNING, + "processed frame frequency variation, name => %s, tf_count => %d, tf_diff => %ld, tf_frequency => %2.4f\n", + conf->name, tf_count, tf_diff, tf_frequency + ) ; + } + + // reset values + tf_base = tf_curr ; + tf_count = 0 ; + } + + //-----------------// + // INCOMING FRAMES // + //-----------------// + + // ast_log( AST_CONF_DEBUG, "PROCESSING FRAMES, conference => %s, step => %d, ms => %ld\n", + // conf->name, step, ( base.tv_usec / 20000 ) ) ; + + // acquire conference mutex + TIMELOG(ast_mutex_lock( &conf->lock ),1,"conf thread conf lock"); + + // update the current delivery time + conf->delivery_time = base ; + + // + // loop through the list of members + // ( conf->memberlist is a single-linked list ) + // + + // ast_log( AST_CONF_DEBUG, "begin processing incoming audio, name => %s\n", conf->name ) ; + + // reset speaker and listener count + speaker_count = 0 ; + listener_count = 0 ; + + // get list of conference members + member = conf->memberlist ; + + // reset pointer lists + spoken_frames = NULL ; + + // loop over member list to retrieve queued frames + while ( member != NULL ) + { + // acquire member mutex + TIMELOG(ast_mutex_lock( &member->lock ),1,"conf thread member lock") ; + + // check for dead members + if ( member->remove_flag == 1 ) + { + // leave message for other members of the conference + membertest = conf->memberlist ; + + int silent_exit = 0 ; + if (member->quiet_entry_exit == -1) + { + silent_exit = 1 ; + } + + while (membertest != NULL) + { + if (silent_exit < 1) + { + if(!strcmp(membertest->channel_name, member->channel_name)) + { + ast_log( LOG_ERROR, "skipping leave message on %s\n", membertest->channel_name ) ; + } + else + { + if (!basic_play_sound ( membertest->channel_name, "leave" )) + { + ast_log( LOG_ERROR, "playing conference leave message FAILED on %s\n", membertest->channel_name ) ; + } + } + } + else + { + ast_log( LOG_NOTICE, "skipping all entry messages on %s\n", membertest->channel_name ) ; + } + membertest = membertest->next; + } + + + ast_log( LOG_NOTICE, "found member slated for removal, channel => %s\n", member->channel_name ) ; + temp_member = member->next ; + remove_member( member, conf ) ; + member = temp_member ; + continue ; + } + + // get speaking member's audio frames, + if ( member->type == 'L' ) + { + // listeners never have frames + cfr = NULL ; + } + else + { + // tell member the number of frames we're going to need ( used to help dropping algorithm ) + member->inFramesNeeded = ( time_diff / AST_CONF_FRAME_INTERVAL ) - 1 ; + +// !!! TESTING !!! +if ( + conf->debug_flag == 1 + && member->inFramesNeeded > 0 +) +{ + ast_log( AST_CONF_DEBUG, "channel => %s, inFramesNeeded => %d, inFramesCount => %d\n", + member->channel_name, member->inFramesNeeded, member->inFramesCount ) ; +} + + // non-listener member should have frames, + // unless silence detection dropped them + cfr = get_incoming_frame( member ) ; + } + + // handle retrieved frames + if ( cfr == NULL ) + { + // this member is listen-only, or has not spoken + // ast_log( AST_CONF_DEBUG, "silent member, channel => %s\n", member->channel_name ) ; + +// !!! TESTING !!! +#if 0 +if ( member->speaking_state == 1 ) +{ + ast_log( AST_CONF_DEBUG, "member has stopped speaking, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; +} +#endif +if ( conf->debug_flag == 1 ) +{ + ast_log( AST_CONF_DEBUG, "member is silent, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; +} + + // mark member as silent + member->speaking_state = 0 ; + + // count the listeners + ++listener_count ; + } + else if ( cfr->fr == NULL ) + { + ast_log( AST_CONF_DEBUG, "got incoming conf_frame with null ast_frame\n" ) ; + +// !!! TESTING !!! +#if 0 +if ( member->speaking_state == 1 ) +{ + ast_log( AST_CONF_DEBUG, "member has stopped speaking, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; +} +#endif +if ( conf->debug_flag == 1 ) +{ + ast_log( AST_CONF_DEBUG, "member is silent, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; +} + + // mark member as silent + member->speaking_state = 0 ; + + // count the listeners + ++listener_count ; + } + else + { + // this speaking member has spoken + // ast_log( AST_CONF_DEBUG, "speaking member, channel => %s\n", member->channel_name ) ; + + // append the frame to the list of spoken frames + if ( spoken_frames != NULL ) + { + // add new frame to end of list + cfr->next = spoken_frames ; + spoken_frames->prev = cfr ; + } + + // point the list at the new frame + spoken_frames = cfr ; + +// !!! TESTING !!! +#if 0 +if ( member->speaking_state == 0 ) +{ + ast_log( AST_CONF_DEBUG, "member has started speaking, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; +} +#endif +if ( conf->debug_flag == 1 ) +{ + ast_log( AST_CONF_DEBUG, "member is speaking, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; +} + + // mark member as speaker + member->speaking_state = 1 ; + member->speaking_state_notify = 1 ; + + // count the speakers + ++speaker_count ; + } + + // release member mutex + ast_mutex_unlock( &member->lock ) ; + + // adjust our pointer to the next inline + member = member->next ; + } + + // + // break, if we have no more members + // + + if ( conf->membercount == 0 ) + { + ast_log( LOG_NOTICE, "removing conference, count => %d, name => %s\n", conf->membercount, conf->name ) ; + remove_conf( conf ) ; // stop the conference + break ; // break from main processing loop + } + + // ast_log( AST_CONF_DEBUG, "finished processing incoming audio, name => %s\n", conf->name ) ; + + + //---------------// + // MIXING FRAMES // + //---------------// + + // mix frames and get batch of outgoing frames + send_frames = mix_frames( spoken_frames, speaker_count, listener_count ) ; + + // accounting: if there are frames, count them as one incoming frame + if ( send_frames != NULL ) + { + // set delivery timestamp + // set_conf_frame_delivery( send_frames, base ) ; + + // ast_log( AST_CONF_DEBUG, "base => %ld.%ld %d\n", base.tv_sec, base.tv_usec, ( int )( base.tv_usec / 1000 ) ) ; + + conf->stats.frames_in++ ; + } + + //-----------------// + // OUTGOING FRAMES // + //-----------------// + + + // + // queue send frames + // + + // ast_log( AST_CONF_DEBUG, "begin queueing outgoing audio, name => %s\n", conf->name ) ; + + // + // loop over member list to queue outgoing frames + // + for ( member = conf->memberlist ; member != NULL ; member = member->next ) + { + // skip members that are not ready + if ( member->ready_for_outgoing == 0 ) + continue ; + + if ( member->speaking_state == 0 ) + { + // queue listener frame + queue_frame_for_listener( conf, member, send_frames ) ; + } + else + { + // queue speaker frame + queue_frame_for_speaker( conf, member, send_frames ) ; + } + } + + // ast_log( AST_CONF_DEBUG, "end queueing outgoing audio, name => %s\n", conf->name ) ; + + //---------// + // CLEANUP // + //---------// + + // clean up send frames + while ( send_frames != NULL ) + { + // accouting: count all frames and mixed frames + if ( send_frames->member == NULL ) + conf->stats.frames_out++ ; + else + conf->stats.frames_mixed++ ; + + // delete the frame + send_frames = delete_conf_frame( send_frames ) ; + } + + // + // notify the manager of state changes every 500 milliseconds + // + + if ( ( usecdiff( &curr, ¬ify ) / AST_CONF_NOTIFICATION_SLEEP ) >= 1 ) + { + // send the notifications + send_state_change_notifications( conf->memberlist ) ; + + // increment the notification timer base + add_milliseconds( ¬ify, AST_CONF_NOTIFICATION_SLEEP ) ; + } + + // release conference mutex + ast_mutex_unlock( &conf->lock ) ; + + // !!! TESTING !!! + // usleep( 1 ) ; + } + // end while ( 42 == 42 ) + + // + // exit the conference thread + // + + ast_log( AST_CONF_DEBUG, "exit conference_exec\n" ) ; + + // exit the thread + pthread_exit( NULL ) ; + + return ; +} + +// +// manange conference functions +// + +// called by app_conference.c:load_module() +void init_conference( void ) +{ + ast_mutex_init( &start_stop_conf_lock ) ; + ast_mutex_init( &conflist_lock ) ; +} + +struct ast_conference* start_conference( struct ast_conf_member* member ) +{ + // check input + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to handle null member\n" ) ; + return NULL ; + } + + struct ast_conference* conf = NULL ; + + // acquire mutex + ast_mutex_lock( &start_stop_conf_lock ) ; + + // look for an existing conference + ast_log( AST_CONF_DEBUG, "attempting to find requested conference\n" ) ; + conf = find_conf( member->id ) ; + + // unable to find an existing conference, try to create one + if ( conf == NULL ) + { + // create a new conference + ast_log( AST_CONF_DEBUG, "attempting to create requested conference\n" ) ; + + // create the new conference with one member + conf = create_conf( member->id, member ) ; + + // return an error if create_conf() failed + if ( conf == NULL ) + { + ast_log( LOG_ERROR, "unable to find or create requested conference\n" ) ; + ast_mutex_unlock( &start_stop_conf_lock ) ; // release mutex + return NULL ; + } + } + else + { + // + // existing conference found, add new member to the conference + // + // once we call add_member(), this thread + // is responsible for calling delete_member() + // + add_member( member, conf ) ; + + } + + // release mutex + ast_mutex_unlock( &start_stop_conf_lock ) ; + + return conf ; +} + + +struct ast_conference* find_conf( const char* name ) +{ + // no conferences exist + if ( conflist == NULL ) + { + ast_log( AST_CONF_DEBUG, "conflist has not yet been initialized, name => %s\n", name ) ; + return NULL ; + } + + // acquire mutex + ast_mutex_lock( &conflist_lock ) ; + + struct ast_conference *conf = conflist ; + + // loop through conf list + while ( conf != NULL ) + { + if ( strncasecmp( (char*)&(conf->name), name, 80 ) == 0 ) + { + // found conf name match + ast_log( AST_CONF_DEBUG, "found conference in conflist, name => %s\n", name ) ; + break ; + } + + conf = conf->next ; + } + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + if ( conf == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to find conference in conflist, name => %s\n", name ) ; + } + + return conf ; +} + +struct ast_conference* create_conf( char* name, struct ast_conf_member* member ) +{ + ast_log( AST_CONF_DEBUG, "entered create_conf, name => %s\n", name ) ; + + // + // allocate memory for conference + // + + struct ast_conference *conf = malloc( sizeof( struct ast_conference ) ) ; + + if ( conf == NULL ) + { + ast_log( LOG_ERROR, "unable to malloc ast_conference\n" ) ; + return NULL ; + } + + // + // initialize conference + // + + conf->next = NULL ; + conf->memberlist = NULL ; + + conf->membercount = 0 ; + conf->conference_thread = -1 ; + + conf->debug_flag = 0 ; + + // zero stats + memset( &conf->stats, 0x0, sizeof( ast_conference_stats ) ) ; + + // record start time + gettimeofday( &conf->stats.time_entered, NULL ) ; + + // copy name to conference + strncpy( (char*)&(conf->name), name, sizeof(conf->name) - 1 ) ; + strncpy( (char*)&(conf->stats.name), name, sizeof(conf->name) - 1 ) ; + + // initialize mutexes + ast_mutex_init( &conf->lock ) ; + + // build translation paths + + int c; + for ( c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) + { + if ( c == AC_SLINEAR_INDEX ) + conf->from_slinear_paths[ c ] = NULL; + else + conf->from_slinear_paths[ c ] =ast_translator_build_path( 1 << c, AST_FORMAT_SLINEAR); + } + + // add the initial member + add_member( member, conf ) ; + + // + // prepend new conference to conflist + // + + // acquire mutex + ast_mutex_lock( &conflist_lock ) ; + + conf->next = conflist ; + conflist = conf ; + + ast_log( AST_CONF_DEBUG, "added new conference to conflist, name => %s\n", name ) ; + + // + // spawn thread for new conference, using conference_exec( conf ) + // + + // acquire conference mutexes + ast_mutex_lock( &conf->lock ) ; + + if ( pthread_create( &conf->conference_thread, NULL, (void*)conference_exec, conf ) == 0 ) + { + // detach the thread so it doesn't leak + pthread_detach( conf->conference_thread ) ; + + // release conference mutexes + ast_mutex_unlock( &conf->lock ) ; + + ast_log( AST_CONF_DEBUG, "started conference thread for conference, name => %s\n", conf->name ) ; + } + else + { + ast_log( LOG_ERROR, "unable to start conference thread for conference %s\n", conf->name ) ; + + conf->conference_thread = -1 ; + + // release conference mutexes + ast_mutex_unlock( &conf->lock ) ; + + // clean up conference + free( conf ) ; + conf = NULL ; + } + + // count new conference + if ( conf != NULL ) + ++conference_count ; + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + return conf ; +} + +void remove_conf( struct ast_conference *conf ) +{ + // ast_log( AST_CONF_DEBUG, "attempting to remove conference, name => %s\n", conf->name ) ; + + struct ast_conference *conf_current = conflist ; + struct ast_conference *conf_temp = NULL ; + + // acquire mutex + ast_mutex_lock( &start_stop_conf_lock ) ; + + // acquire mutex + ast_mutex_lock( &conflist_lock ) ; + + // loop through list of conferences + while ( conf_current != NULL ) + { + // if conf_current point to the passed conf, + if ( conf_current == conf ) + { + if ( conf_temp == NULL ) + { + // this is the first conf in the list, so we just point + // conflist past the current conf to the next + conflist = conf_current->next ; + } + else + { + // this is not the first conf in the list, so we need to + // point the preceeding conf to the next conf in the list + conf_temp->next = conf_current->next ; + } + + // + // do some frame clean up + // + int c; + for ( c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) + { + // free the translation paths + if ( conf_current->from_slinear_paths[ c ] != NULL ) + { + ast_translator_free_path( conf_current->from_slinear_paths[ c ] ) ; + conf_current->from_slinear_paths[ c ] = NULL ; + } + } + + // calculate time in conference + struct timeval time_exited ; + gettimeofday( &time_exited, NULL ) ; + + // total time converted to seconds + long tt = ( usecdiff( &time_exited, &conf_current->stats.time_entered ) / 1000 ) ; + + // report accounting information + ast_log( LOG_NOTICE, "conference accounting, fi => %ld, fo => %ld, fm => %ld, tt => %ld\n", + conf_current->stats.frames_in, conf_current->stats.frames_out, conf_current->stats.frames_mixed, tt ) ; + + ast_log( AST_CONF_DEBUG, "removed conference, name => %s\n", conf_current->name ) ; + + ast_mutex_unlock( &conf_current->lock ) ; + + free( conf_current ) ; + conf_current = NULL ; + + break ; + } + + // save a refence to the soon to be previous conf + conf_temp = conf_current ; + + // move conf_current to the next in the list + conf_current = conf_current->next ; + } + + // count new conference + --conference_count ; + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + // release mutex + ast_mutex_unlock( &start_stop_conf_lock ) ; + + return ; +} + +// +// member-related functions +// + +void add_member( struct ast_conf_member *member, struct ast_conference *conf ) +{ + if ( conf == NULL ) + { + ast_log( LOG_ERROR, "unable to add member to NULL conference\n" ) ; + return ; + } + + // acquire the conference lock + ast_mutex_lock( &conf->lock ) ; + + member->next = conf->memberlist ; // next is now list + conf->memberlist = member ; // member is now at head of list + + // update conference stats + count_member( member, conf, 1 ) ; + + ast_log( AST_CONF_DEBUG, "member added to conference, name => %s\n", conf->name ) ; + + // release the conference lock + ast_mutex_unlock( &conf->lock ) ; + + return ; +} + +int remove_member( struct ast_conf_member* member, struct ast_conference* conf ) +{ + // check for member + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to remove NULL member\n" ) ; + return -1 ; + } + + // check for conference + if ( conf == NULL ) + { + ast_log( LOG_WARNING, "unable to remove member from NULL conference\n" ) ; + return -1 ; + } + + // + // loop through the member list looking + // for the requested member + // + + struct ast_conf_member *member_list = conf->memberlist ; + struct ast_conf_member *member_temp = NULL ; + + int count = -1 ; // default return code + + while ( member_list != NULL ) + { + if ( member_list == member ) + { + // + // log some accounting information + // + + // calculate time in conference + struct timeval time_exited ; + gettimeofday( &time_exited, NULL ) ; + long tt = ( usecdiff( &time_exited, &member->time_entered ) / 1000 ) ; // convert to seconds + + ast_log( + LOG_NOTICE, + "member accounting, channel => %s, te => %ld, fi => %ld, fid => %ld, fo => %ld, fod => %ld, tt => %ld\n", + member->channel_name, + member->time_entered.tv_sec, member->frames_in, member->frames_in_dropped, + member->frames_out, member->frames_out_dropped, tt + ) ; + + // + // if this is the first member in the linked-list, + // skip over the first member in the list, else + // + // point the previous 'next' to the current 'next', + // thus skipping the current member in the list + // + if ( member_temp == NULL ) + conf->memberlist = member->next ; + else + member_temp->next = member->next ; + + // update conference stats + count = count_member( member, conf, 0 ) ; + + // delete the member + delete_member( member ) ; + + ast_log( AST_CONF_DEBUG, "removed member from conference, name => %s, remaining => %d\n", conf->name, conf->membercount ) ; + + break ; + } + + // save a pointer to the current member, + // and then point to the next member in the list + member_temp = member_list ; + member_list = member_list->next ; + } + + // return -1 on error, or the number of members + // remaining if the requested member was deleted + return count ; +} + +int count_member( struct ast_conf_member* member, struct ast_conference* conf, short add_member ) +{ + if ( member == NULL || conf == NULL ) + { + ast_log( LOG_WARNING, "unable to count member\n" ) ; + return -1 ; + } + + short delta = ( add_member == 1 ) ? 1 : -1 ; + + // member type + if ( memberIsModerator( member ) == 1 ) + { + conf->stats.moderators += delta ; + } + else + { + // count non-moderators as listeners + conf->stats.listeners += delta ; + } + + // connection type + if ( memberIsPhoneClient( member ) == 1 ) + { + conf->stats.phone += delta ; + } + else if ( memberIsIaxClient( member ) == 1 ) + { + conf->stats.iaxclient += delta ; + } + else if ( memberIsSIPClient( member ) == 1 ) + { + conf->stats.sip += delta ; + } + + // increment member count + conf->membercount += delta ; + + return conf->membercount ; +} + +// +// queue incoming frame functions +// + +int queue_frame_for_speaker( + struct ast_conference* conf, + struct ast_conf_member* member, + conf_frame* frame +) +{ + // + // check inputs + // + + if ( conf == NULL ) + { + ast_log( LOG_WARNING, "unable to queue speaker frame with null conference\n" ) ; + return -1 ; + } + + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to queue speaker frame with null member\n" ) ; + return -1 ; + } + + // + // loop over spoken frames looking for member's appropriate match + // + + short found_flag = 0 ; + struct ast_frame* qf ; + + for ( ; frame != NULL ; frame = frame->next ) + { + if ( frame->member != member ) + continue ; + + if ( frame->fr == NULL ) + { + ast_log( LOG_WARNING, "unable to queue speaker frame with null data\n" ) ; + continue ; + } + + // + // convert and queue frame + // + + // short-cut pointer to the ast_frame + qf = frame->fr ; + + // acquire member lock + TIMELOG(ast_mutex_lock( &member->lock ),1,"queue_frame_for_speaker: memberlock") ; + + if ( qf->subclass == member->write_format ) + { + // frame is already in correct format, so just queue it + queue_outgoing_frame( member, qf, conf->delivery_time ) ; + } + else + { + // + // convert frame to member's write format + // ( calling ast_frdup() to make sure the translator's copy sticks around ) + // + qf = convert_frame_from_slinear( member->from_slinear, ast_frdup( qf ) ) ; + + if ( qf != NULL ) + { + // queue frame + queue_outgoing_frame( member, qf, conf->delivery_time ) ; + + // free frame ( the translator's copy ) + ast_frfree( qf ) ; + } + else + { + ast_log( LOG_WARNING, "unable to translate outgoing speaker frame, channel => %s\n", member->channel_name ) ; + } + } + + // release member lock + ast_mutex_unlock( &member->lock ) ; + + // set found flag + found_flag = 1 ; + + // we found the frame, skip to the next member + break ; + } + + // queue a silent frame + if ( found_flag == 0 ) + queue_silent_frame( conf, member ) ; + + return 0 ; +} + +int queue_frame_for_listener( + struct ast_conference* conf, + struct ast_conf_member* member, + conf_frame* frame +) +{ + // + // check inputs + // + + if ( conf == NULL ) + { + ast_log( LOG_WARNING, "unable to queue listener frame with null conference\n" ) ; + return -1 ; + } + + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to queue listener frame with null member\n" ) ; + return -1 ; + } + + // + // loop over spoken frames looking for member's appropriate match + // + + short found_flag = 0 ; + struct ast_frame* qf ; + + for ( ; frame != NULL ; frame = frame->next ) + { + // we're looking for a null or matching member + if ( frame->member != NULL && frame->member != member ) + continue ; + + if ( frame->fr == NULL ) + { + ast_log( LOG_WARNING, "unknown error queueing frame for listener, frame->fr == NULL\n" ) ; + continue ; + } + + // acquire member lock + TIMELOG(ast_mutex_lock( &member->lock ),1,"queue_frame_for_listener") ; + + // first, try for a pre-converted frame + qf = frame->converted[ member->write_format_index ] ; + + /* + if ( qf != NULL && (member->smooth_size_out > 0)) { + if (qf->datalen != member->smooth_size_out ) { +//ast_log (AST_CONF_DEBUG, "ignoring and freeing previously stored frame, with datalen=>%d != smooth_size_out=>%d\n",qf->datalen,member->smooth_size_out); + ast_frfree( qf ) ; + qf = NULL ; + } + } + */ + + // convert ( and store ) the frame + if ( qf == NULL ) + { + // make a copy of the slinear version of the frame + qf = ast_frdup( frame->fr ) ; + + if ( qf == NULL ) + { + ast_log( LOG_WARNING, "unable to duplicate frame\n" ) ; + continue ; + } + + // convert using the conference's translation path + qf = convert_frame_from_slinear( conf->from_slinear_paths[ member->write_format_index ], qf ) ; + if ( qf == NULL ) + ast_log( LOG_WARNING, "unable to translate frame for listener, channel => %s , member->write_format => %d , member->write_format_index %d , qf->frametype -> %d , qf->subclass -> %d, qf->datalen=> %d, qf->samples =>%d\n", member->channel_name , member->write_format, member->write_format_index, qf->frametype, qf->subclass , qf->datalen, qf->samples) ; + + // store the converted frame + // ( the frame will be free'd next time through the loop ) + frame->converted[ member->write_format_index ] = qf ; +//ast_log (AST_CONF_DEBUG, "storing converted frame into index=>%d, qf->frametype=>%d, qf->subclass=%d, qf->datalen=%d \n",member->write_format_index, qf->frametype, qf->subclass, qf->datalen); + } + + if ( qf != NULL ) + { + // duplicate the frame before queue'ing it + // ( since this member doesn't own this _shared_ frame ) + // qf = ast_frdup( qf ) ; + + if ( queue_outgoing_frame( member, qf, conf->delivery_time ) != 0 ) + { + // free the new frame if it couldn't be queue'd + ast_frfree( qf ) ; + qf = NULL ; + } + } + else + { + ast_log( LOG_WARNING, "unable to translate outgoing listener frame, channel => %s\n", member->channel_name ) ; + } + + // release member lock + ast_mutex_unlock( &member->lock ) ; + + // set found flag + found_flag = 1 ; + + // break from for loop + break ; + } + + // queue a silent frame + if ( found_flag == 0 ) + queue_silent_frame( conf, member ) ; + + return 0 ; +} + +int queue_silent_frame( + struct ast_conference* conf, + struct ast_conf_member* member +) +{ +#ifdef APP_CONFERENCE_DEBUG + // + // check inputs + // + + if ( conf == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to queue silent frame for null conference\n" ) ; + return -1 ; + } + + if ( member == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to queue silent frame for null member\n" ) ; + return -1 ; + } +#endif // APP_CONFERENCE_DEBUG + + // + // initialize static variables + // + + static conf_frame* silent_frame = NULL ; + static struct ast_frame* qf = NULL ; + + if ( silent_frame == NULL ) + { + if ( ( silent_frame = get_silent_frame() ) == NULL ) + { + ast_log( LOG_WARNING, "unable to initialize static silent frame\n" ) ; + return -1 ; + } + } + + // acquire member lock + TIMELOG(ast_mutex_lock( &member->lock ),1,"queue_silent_frame") ; + + // get the appropriate silent frame + qf = silent_frame->converted[ member->write_format_index ] ; + + if ( qf == NULL ) + { + // + // we need to do this to avoid echo on the speaker's line. + // translators seem to be single-purpose, i.e. they + // can't be used simultaneously for multiple audio streams + // + + struct ast_trans_pvt* trans = ast_translator_build_path( member->write_format, AST_FORMAT_SLINEAR ) ; + + if ( trans != NULL ) + { + // attempt ( five times ) to get a silent frame + // to make sure we provice the translator with enough data + int c; + for ( c = 0 ; c < 5 ; ++c ) + { + // translate the frame + qf = ast_translate( trans, silent_frame->fr, 0 ) ; + + // break if we get a frame + if ( qf != NULL ) break ; + } + + if ( qf != NULL ) + { + // isolate the frame so we can keep it around after trans is free'd + qf = ast_frisolate( qf ) ; + + // cache the new, isolated frame + silent_frame->converted[ member->write_format_index ] = qf ; + } + + ast_translator_free_path( trans ) ; + } + } + + // + // queue the frame, if it's not null, + // otherwise there was an error + // + if ( qf != NULL ) + { + queue_outgoing_frame( member, qf, conf->delivery_time ) ; + } + else + { + ast_log( LOG_ERROR, "unable to translate outgoing silent frame, channel => %s\n", member->channel_name ) ; + } + + // release member lock + ast_mutex_unlock( &member->lock ) ; + + return 0 ; +} + +// +// get conference stats +// + +// +// returns: -1 => error, 0 => debugging off, 1 => debugging on +// state: on => 1, off => 0, toggle => -1 +// +int set_conference_debugging( const char* name, int state ) +{ + if ( name == NULL ) + return -1 ; + + // acquire mutex + ast_mutex_lock( &conflist_lock ) ; + + struct ast_conference *conf = conflist ; + int new_state = -1 ; + + // loop through conf list + while ( conf != NULL ) + { + if ( strncasecmp( (const char*)&(conf->name), name, 80 ) == 0 ) + { + // lock conference + // ast_mutex_lock( &(conf->lock) ) ; + + // toggle or set the state + if ( state == -1 ) + conf->debug_flag = ( conf->debug_flag == 0 ) ? 1 : 0 ; + else + conf->debug_flag = ( state == 0 ) ? 0 : 1 ; + + new_state = conf->debug_flag ; + + // unlock conference + // ast_mutex_unlock( &(conf->lock) ) ; + + break ; + } + + conf = conf->next ; + } + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + return new_state ; +} + +int get_conference_count( void ) +{ + return conference_count ; +} + +int get_conference_stats( ast_conference_stats* stats, int requested ) +{ + // no conferences exist + if ( conflist == NULL ) + { + ast_log( AST_CONF_DEBUG, "conflist has not yet been initialize\n" ) ; + return 0 ; + } + + // acquire mutex + ast_mutex_lock( &conflist_lock ) ; + + // compare the number of requested to the number of available conferences + requested = ( get_conference_count() < requested ) ? get_conference_count() : requested ; + + // + // loop through conf list + // + + struct ast_conference* conf = conflist ; + int count = 0 ; + + while ( count <= requested && conf != NULL ) + { + // copy stats struct to array + stats[ count ] = conf->stats ; + + conf = conf->next ; + ++count ; + } + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + return count ; +} + +int get_conference_stats_by_name( ast_conference_stats* stats, const char* name ) +{ + // no conferences exist + if ( conflist == NULL ) + { + ast_log( AST_CONF_DEBUG, "conflist has not yet been initialized, name => %s\n", name ) ; + return 0 ; + } + + // make sure stats is null + stats = NULL ; + + // acquire mutex + ast_mutex_lock( &conflist_lock ) ; + + struct ast_conference *conf = conflist ; + + // loop through conf list + while ( conf != NULL ) + { + if ( strncasecmp( (const char*)&(conf->name), name, 80 ) == 0 ) + { + // copy stats for found conference + *stats = conf->stats ; + break ; + } + + conf = conf->next ; + } + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + return ( stats == NULL ) ? 0 : 1 ; +} + +struct ast_conf_member *find_member ( char *chan, int lock) +{ + struct ast_conf_member *found = NULL; + struct ast_conf_member *member; + struct ast_conference *conf; + + + + ast_mutex_lock( &conflist_lock ) ; + + conf = conflist; + + // loop through conf list + while ( conf != NULL && !found ) + { + // lock conference + ast_mutex_lock( &conf->lock ); + + member = conf->memberlist ; + + while (member != NULL) + { + if(!strcmp(member->channel_name, chan)) { + found = member; + if(lock) + ast_mutex_lock(&member->lock); + break; + } + member = member->next; + } + + // unlock conference + ast_mutex_unlock( &conf->lock ); + + conf = conf->next ; + } + + // release mutex + ast_mutex_unlock( &conflist_lock ) ; + + return found; +} + diff --git a/agc_2-X/trunk/app_conference/conference.h b/agc_2-X/trunk/app_conference/conference.h new file mode 100644 index 00000000..08c1018f --- /dev/null +++ b/agc_2-X/trunk/app_conference/conference.h @@ -0,0 +1,121 @@ + +// $Id: conference.h,v 1.6 2005/10/26 21:02:07 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _APP_CONF_CONFERENCE_H +#define _APP_CONF_CONFERENCE_H + +// +// includes +// + +#include "app_conference.h" +#include "common.h" + +// +// struct declarations +// + +typedef struct ast_conference_stats +{ + // conference name ( copied for ease of use ) + char name[128] ; + + // type of connection + unsigned short phone ; + unsigned short iaxclient ; + unsigned short sip ; + + // type of users + unsigned short moderators ; + unsigned short listeners ; + + // accounting data + unsigned long frames_in ; + unsigned long frames_out ; + unsigned long frames_mixed ; + + struct timeval time_entered ; + +} ast_conference_stats ; + + +struct ast_conference +{ + // conference name + char name[128] ; + + // single-linked list of members in conference + struct ast_conf_member* memberlist ; + int membercount ; + + // conference thread id + pthread_t conference_thread ; + + // conference data mutex + ast_mutex_t lock ; + + // pointer to next conference in single-linked list + struct ast_conference* next ; + + // pointer to translation paths + struct ast_trans_pvt* from_slinear_paths[ AC_SUPPORTED_FORMATS ] ; + + // conference stats + ast_conference_stats stats ; + + // keep track of current delivery time + struct timeval delivery_time ; + + // 1 => on, 0 => off + short debug_flag ; +} ; + +// +// function declarations +// + +struct ast_conference* start_conference( struct ast_conf_member* member ) ; + +void conference_exec( struct ast_conference* conf ) ; + +struct ast_conference* find_conf( const char* name ) ; +struct ast_conference* create_conf( char* name, struct ast_conf_member* member ) ; +void remove_conf( struct ast_conference* conf ) ; + +// find a particular member, locking if requested. +struct ast_conf_member *find_member ( char *chan, int lock) ; + + +int queue_frame_for_listener( struct ast_conference* conf, struct ast_conf_member* member, conf_frame* frame ) ; +int queue_frame_for_speaker( struct ast_conference* conf, struct ast_conf_member* member, conf_frame* frame ) ; +int queue_silent_frame( struct ast_conference* conf, struct ast_conf_member* member ) ; + +void add_member( struct ast_conf_member* member, struct ast_conference* conf ) ; +int remove_member( struct ast_conf_member* member, struct ast_conference* conf ) ; +int count_member( struct ast_conf_member* member, struct ast_conference* conf, short add_member ) ; + +// called by app_confernce.c:load_module() +void init_conference( void ) ; + +int get_conference_count( void ) ; +int get_conference_stats( ast_conference_stats* stats, int requested ) ; +int get_conference_stats_by_name( ast_conference_stats* stats, const char* name ) ; + +int set_conference_debugging( const char* name, int state ) ; + +#endif diff --git a/agc_2-X/trunk/app_conference/enter.gsm b/agc_2-X/trunk/app_conference/enter.gsm new file mode 100644 index 00000000..aa4dafb6 Binary files /dev/null and b/agc_2-X/trunk/app_conference/enter.gsm differ diff --git a/agc_2-X/trunk/app_conference/frame.c b/agc_2-X/trunk/app_conference/frame.c new file mode 100644 index 00000000..a50a378e --- /dev/null +++ b/agc_2-X/trunk/app_conference/frame.c @@ -0,0 +1,614 @@ + +// $Id: frame.c,v 1.7 2005/10/27 17:53:35 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#include "frame.h" + +conf_frame* mix_frames( conf_frame* frames_in, int speaker_count, int listener_count ) +{ + if ( frames_in == NULL ) + return NULL ; + + conf_frame* frames_out = NULL ; + + if ( speaker_count > 1 ) + { + if ( speaker_count == 2 && listener_count == 0 ) + { + // optimize here also? + frames_out = mix_multiple_speakers( frames_in, speaker_count, listener_count ) ; + } + else + { + // mix spoken frames for sending + // ( note: this call also releases us from free'ing spoken_frames ) + frames_out = mix_multiple_speakers( frames_in, speaker_count, listener_count ) ; + } + } + else if ( speaker_count == 1 ) + { + // pass-through frames + frames_out = mix_single_speaker( frames_in ) ; + } + else + { + // no frames to send, leave frames_out null + } + + return frames_out ; +} + +conf_frame* mix_single_speaker( conf_frame* frames_in ) +{ +#ifdef APP_CONFERENCE_DEBUG + // ast_log( AST_CONF_DEBUG, "returning single spoken frame\n" ) ; + + // + // check input + // + + if ( frames_in == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to mix single spoken frame with null frame\n" ) ; + return NULL ; + } + + if ( frames_in->fr == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to mix single spoken frame with null data\n" ) ; + return NULL ; + } + + if ( frames_in->member == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to mix single spoken frame with null member\n" ) ; + return NULL ; + } +#endif // APP_CONFERENCE_DEBUG + + // + // 'mix' the frame + // + + // copy orignal frame to converted array so listeners don't need to re-encode it + frames_in->converted[ frames_in->member->read_format_index ] = ast_frdup( frames_in->fr ) ; + + // convert frame to slinear, if we have a path + frames_in->fr = convert_frame_to_slinear( + frames_in->member->to_slinear, + frames_in->fr + ) ; + + // set the frame's member to null ( i.e. all listeners ) + frames_in->member = NULL ; + + return frames_in ; +} + +// { + // + // a little optimization for testing only: + // when two speakers ( of the same type ) and no listeners + // are in a conference, we just swamp the frame's member pointers + // +/* + if ( + listeners == 0 + && speakers == 2 + && cf_spokenFrames->member->read_format == cf_spokenFrames->next->member->write_format + && cf_spokenFrames->member->write_format == cf_spokenFrames->next->member->read_format + ) + { + struct ast_conf_member* m = NULL ; + m = cf_spokenFrames->member ; + cf_spokenFrames->member = cf_spokenFrames->next->member ; + cf_spokenFrames->next->member = m ; + return cf_spokenFrames ; + } +*/ +// } + +void set_conf_frame_delivery( conf_frame* frame, struct timeval time ) +{ + for ( ; frame != NULL ; frame = frame->next ) + { + if ( frame->fr != NULL ) + { + // copy passed timeval to frame's delivery timeval + frame->fr->delivery = time ; + } + } + + return ; +} + +conf_frame* mix_multiple_speakers( + conf_frame* frames_in, + int speakers, + int listeners +) +{ +#ifdef APP_CONFERENCE_DEBUG + // + // check input + // + + // no frames to mix + if ( ( frames_in == NULL ) || ( frames_in->fr == NULL ) ) + { + ast_log( AST_CONF_DEBUG, "passed spoken frame list was NULL\n" ) ; + return NULL ; + } + + // if less than two speakers, then no frames to mix + if ( speakers < 2 ) + { + ast_log( AST_CONF_DEBUG, "mix_multiple_speakers() called with less than two speakers\n" ) ; + return NULL ; + } +#endif // APP_CONFERENCE_DEBUG + + // + // at this point we know that there is more than one frame, + // and that the frames need to be converted to pcm to be mixed + // + // now, if there are only two frames and two members, + // we can swap them. ( but we'll get to that later. ) + // + + // + // loop through the spoken frames, making a list of spoken members, + // and converting gsm frames to slinear frames so we can mix them. + // + + // pointer to the spoken frames list + conf_frame* cf_spoken = frames_in ; + + // pointer to the new list of mixed frames + conf_frame* cf_sendFrames = NULL ; + + while ( cf_spoken != NULL ) + { + // + // while we're looping through the spoken frames, we'll + // convert the frame to a format suitable for mixing + // + // if the frame fails to convert, drop it and treat + // the speaking member like a listener by not adding + // them to the cf_sendFrames list + // + + if ( cf_spoken->member == NULL ) + { + ast_log( LOG_WARNING, "unable to determine frame member\n" ) ; + } + else + { + // ast_log( AST_CONF_DEBUG, "converting frame to slinear, channel => %s\n", cf_spoken->member->channel_name ) ; + cf_spoken->fr = convert_frame_to_slinear( + cf_spoken->member->to_slinear, + cf_spoken->fr + ) ; + + if ( cf_spoken->fr == NULL ) + { + ast_log( LOG_WARNING, "unable to convert frame to slinear\n" ) ; + } + else + { + // create new conf frame with last frame as 'next' + cf_sendFrames = create_conf_frame( cf_spoken->member, cf_sendFrames, NULL ) ; + } + } + + // point to the next spoken frame + cf_spoken = cf_spoken->next ; + } + + // if necessary, add a frame with a null member pointer. + // this frame will hold the audio mixed for all listeners + if ( listeners > 0 ) + { + cf_sendFrames = create_conf_frame( NULL, cf_sendFrames, NULL ) ; + } + + // + // mix the audio + // + + // convenience pointer that skips over the friendly offset + char* cp_listenerData ; + + // pointer to the send frames list + conf_frame* cf_send = NULL ; + + for ( cf_send = cf_sendFrames ; cf_send != NULL ; cf_send = cf_send->next ) + { + // allocate a mix buffer which fill large enough memory to + // hold a frame, and reset it's memory so we don't get noise + char* cp_listenerBuffer = malloc( AST_CONF_BUFFER_SIZE ) ; + memset( cp_listenerBuffer, 0x0, AST_CONF_BUFFER_SIZE ) ; + + // point past the friendly offset right to the data + cp_listenerData = cp_listenerBuffer + AST_FRIENDLY_OFFSET ; + + // reset the spoken list pointer + cf_spoken = frames_in ; + + // really mix the audio + for ( ; cf_spoken != NULL ; cf_spoken = cf_spoken->next ) + { + // + // if the members are equal, and they + // are not null, do not mix them. + // + if ( + ( cf_send->member == cf_spoken->member ) + && ( cf_send->member != NULL ) + ) + { + // don't mix this frame + } + else if ( cf_spoken->fr == NULL ) + { + ast_log( LOG_WARNING, "unable to mix conf_frame with null ast_frame\n" ) ; + } + else + { + // mix the new frame in with the existing buffer + mix_slinear_frames( cp_listenerData, (char*)( cf_spoken->fr->data ), cf_spoken->fr->samples ) ; + } + } + + // copy a pointer to the frame data to the conf_frame + cf_send->mixed_buffer = cp_listenerData ; + } + + // + // copy the mixed buffer to a new frame + // + + // reset the send list pointer + cf_send = cf_sendFrames ; + + while ( cf_send != NULL ) + { + cf_send->fr = create_slinear_frame( cf_send->mixed_buffer ) ; + cf_send = cf_send->next ; + } + + // + // clean up the spoken frames we were passed + // ( caller will only be responsible for free'ing returns frames ) + // + + // reset the spoken list pointer + cf_spoken = frames_in ; + + while ( cf_spoken != NULL ) + { + // delete the frame + cf_spoken = delete_conf_frame( cf_spoken ) ; + } + + // return the list of frames for sending + return cf_sendFrames ; +} + + +struct ast_frame* convert_frame_to_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) +{ + // check for null frame + if ( fr == NULL ) + { + ast_log( LOG_ERROR, "unable to translate null frame to slinear\n" ) ; + return NULL ; + } + + // we don't need to duplicate this frame since + // the normal translation would free it anyway, so + // we'll just pretend we free'd and malloc'd a new one. + if ( fr->subclass == AST_FORMAT_SLINEAR ) + return fr ; + + // check for null translator ( after we've checked that we need to translate ) + if ( trans == NULL ) + { +// ast_log( LOG_ERROR, "unable to translate frame with null translation path\n" ) ; + return fr ; + } + + // return the converted frame + return convert_frame( trans, fr ) ; +} + +struct ast_frame* convert_frame_from_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) +{ + // check for null translator ( after we've checked that we need to translate ) + if ( trans == NULL ) + { +// ast_log( LOG_ERROR, "unable to translate frame with null translation path\n" ) ; + return fr ; + } + + // check for null frame + if ( fr == NULL ) + { + ast_log( LOG_ERROR, "unable to translate null slinear frame\n" ) ; + return NULL ; + } + + // if the frame is not slinear, return an error + if ( fr->subclass != AST_FORMAT_SLINEAR ) + { + ast_log( LOG_ERROR, "unable to translate non-slinear frame\n" ) ; + return NULL ; + } + + // return the converted frame + return convert_frame( trans, fr ) ; +} + +struct ast_frame* convert_frame( struct ast_trans_pvt* trans, struct ast_frame* fr ) +{ + if ( trans == NULL ) + { + ast_log( LOG_WARNING, "unable to convert frame with null translator\n" ) ; + return NULL ; + } + + if ( fr == NULL ) + { + ast_log( LOG_WARNING, "unable to convert null frame\n" ) ; + return NULL ; + } + + // convert the frame + struct ast_frame* translated_frame = ast_translate( trans, fr, 1 ) ; + + // check for errors + if ( translated_frame == NULL ) + { + ast_log( LOG_ERROR, "unable to translate frame\n" ) ; + return NULL ; + } + + // return the translated frame + return translated_frame ; +} + +conf_frame* delete_conf_frame( conf_frame* cf ) +{ + // check for null frames + if ( cf == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to delete null conf frame\n" ) ; + return NULL ; + } + + // check for frame marked as static + if ( cf->static_frame == 1 ) + return NULL ; + + if ( cf->fr != NULL ) + { + ast_frfree( cf->fr ) ; + cf->fr = NULL ; + } + + // make sure converted frames are set to null + int c; + for ( c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) + { + if ( cf->converted[ c ] != NULL ) + { + ast_frfree( cf->converted[ c ] ) ; + cf->converted[ c ] = NULL ; + } + } + + // get a pointer to the next frame + // in the list so we can return it + conf_frame* nf = cf->next ; + + free( cf ) ; + cf = NULL ; + + return nf ; +} + +conf_frame* create_conf_frame( struct ast_conf_member* member, conf_frame* next, const struct ast_frame* fr ) +{ + // pointer to list of mixed frames + conf_frame* cf = malloc( sizeof( struct conf_frame ) ) ; + + if ( cf == NULL ) + { + ast_log( LOG_ERROR, "unable to allocate memory for conf frame\n" ) ; + return NULL ; + } + + // + // init with some defaults + // + + // make sure converted frames are set to null +// for ( int c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) +// { +// cf->converted[ c ] = NULL ; +// } + + memset( (struct ast_frame*)( cf->converted ), 0x0, ( sizeof( struct ast_frame* ) * AC_SUPPORTED_FORMATS ) ) ; + + cf->member = member ; + // cf->priority = 0 ; + + cf->prev = NULL ; + cf->next = next ; + + cf->static_frame = 0 ; + + // establish relationship to 'next' + if ( next != NULL ) next->prev = cf ; + + // this holds the ast_frame pointer + cf->fr = ( fr == NULL ) ? NULL : ast_frdup( ( struct ast_frame* )( fr ) ) ; + + // this holds the temporu mix buffer + cf->mixed_buffer = NULL ; + + return cf ; +} + +conf_frame* copy_conf_frame( conf_frame* src ) +{ + // + // check inputs + // + + if ( src == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to copy null conf frame\n" ) ; + return NULL ; + } + + // + // copy the frame + // + + struct conf_frame *cfr = NULL ; + + // create a new conf frame + cfr = create_conf_frame( src->member, NULL, src->fr ) ; + + if ( cfr == NULL ) + { + ast_log( AST_CONF_DEBUG, "unable to create new conf frame for copy\n" ) ; + return NULL ; + } + + return cfr ; +} + +// +// slinear frame functions +// + +struct ast_frame* create_slinear_frame( char* data ) +{ + struct ast_frame* f ; + + f = calloc( 1, sizeof( struct ast_frame ) ) ; + if ( f == NULL ) + { + ast_log( LOG_ERROR, "unable to allocate memory for slinear frame\n" ) ; + return NULL ; + } + + f->frametype = AST_FRAME_VOICE ; + f->subclass = AST_FORMAT_SLINEAR ; + f->samples = AST_CONF_BLOCK_SAMPLES ; + f->offset = AST_FRIENDLY_OFFSET ; + f->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_DATA ; + + f->datalen = AST_CONF_FRAME_DATA_SIZE ; + f->data = data ; + + f->src = NULL ; + + return f ; +} + +void mix_slinear_frames( char *dst, const char *src, int samples ) +{ + if ( dst == NULL ) return ; + if ( src == NULL ) return ; + + int i, val ; + + for ( i = 0 ; i < samples ; ++i ) + { + val = ( (short*)dst )[i] + ( (short*)src )[i] ; + + if ( val > 0x7fff ) + { + ( (short*)dst )[i] = 0x7fff - 1 ; + continue ; + } + else if ( val < -0x7fff ) + { + ( (short*)dst )[i] = -0x7fff + 1 ; + continue ; + } + else + { + ( (short*)dst )[i] = val ; + continue ; + } + } + + return ; +} + +// +// silent frame functions +// + +conf_frame* get_silent_frame( void ) +{ + static conf_frame* static_silent_frame = NULL ; + + // we'll let this leak until the application terminates + if ( static_silent_frame == NULL ) + { + // ast_log( AST_CONF_DEBUG, "creating cached silent frame\n" ) ; + struct ast_frame* fr = get_silent_slinear_frame() ; + + static_silent_frame = create_conf_frame( NULL, NULL, fr ) ; + + if ( static_silent_frame == NULL ) + { + ast_log( LOG_WARNING, "unable to create cached silent frame\n" ) ; + return NULL ; + } + + // init the 'converted' slinear silent frame + static_silent_frame->converted[ AC_SLINEAR_INDEX ] = get_silent_slinear_frame() ; + + // mark frame as static so it's not deleted + static_silent_frame->static_frame = 1 ; + } + + return static_silent_frame ; +} + +struct ast_frame* get_silent_slinear_frame( void ) +{ + static struct ast_frame* f = NULL ; + + // we'll let this leak until the application terminates + if ( f == NULL ) + { + char* data = malloc( AST_CONF_BUFFER_SIZE ) ; + memset( data, 0x0, AST_CONF_BUFFER_SIZE ) ; + f = create_slinear_frame( data ) ; + } + + return ast_frdup( f ) ; +} + + diff --git a/agc_2-X/trunk/app_conference/frame.h b/agc_2-X/trunk/app_conference/frame.h new file mode 100644 index 00000000..d5b39613 --- /dev/null +++ b/agc_2-X/trunk/app_conference/frame.h @@ -0,0 +1,60 @@ + +// $Id: frame.h,v 1.6 2005/10/26 21:02:07 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _APP_CONF_FRAME_H +#define _APP_CONF_FRAME_H + +// +// includes +// + +#include "app_conference.h" +#include "common.h" + +// +// function declarations +// + +// mixing +conf_frame* mix_frames( conf_frame* frames_in, int speaker_count, int listener_count ) ; + +conf_frame* mix_multiple_speakers( conf_frame* frames_in, int speakers, int listeners ) ; +conf_frame* mix_single_speaker( conf_frame* frames_in ) ; + +// frame creation and deletion +conf_frame* create_conf_frame( struct ast_conf_member* member, conf_frame* next, const struct ast_frame* fr ) ; +conf_frame* delete_conf_frame( conf_frame* cf ) ; +conf_frame* copy_conf_frame( conf_frame* src ) ; + +// convert frame functions +struct ast_frame* convert_frame_to_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) ; +struct ast_frame* convert_frame_from_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) ; +struct ast_frame* convert_frame( struct ast_trans_pvt* trans, struct ast_frame* fr ) ; + +// slinear frame functions +struct ast_frame* create_slinear_frame( char* data ) ; +void mix_slinear_frames( char* dst, const char* src, int samples ) ; + +// silent frame functions +conf_frame* get_silent_frame( void ) ; +struct ast_frame* get_silent_slinear_frame( void ) ; + +// set delivery timestamp for frames +void set_conf_frame_delivery( conf_frame* frame, struct timeval time ) ; + +#endif diff --git a/agc_2-X/trunk/app_conference/hash.gsm b/agc_2-X/trunk/app_conference/hash.gsm new file mode 100644 index 00000000..0d0a8ecf --- /dev/null +++ b/agc_2-X/trunk/app_conference/hash.gsm @@ -0,0 +1,2 @@ +\}PcȣP tۆD#E)#i(*E3yBF:W2wWԢ6TyuWI+sdWysuk2yct9,,Wk|UTWu#.1c}yQ( dº\2! Q\?;waWnfy.7FW){?YW!Q nSB*qUUy>XWQDm! \ No newline at end of file diff --git a/agc_2-X/trunk/app_conference/hash.wav b/agc_2-X/trunk/app_conference/hash.wav new file mode 100644 index 00000000..a079f449 Binary files /dev/null and b/agc_2-X/trunk/app_conference/hash.wav differ diff --git a/agc_2-X/trunk/app_conference/leave.gsm b/agc_2-X/trunk/app_conference/leave.gsm new file mode 100644 index 00000000..7b3bef01 Binary files /dev/null and b/agc_2-X/trunk/app_conference/leave.gsm differ diff --git a/agc_2-X/trunk/app_conference/libspeex/CVS/Entries b/agc_2-X/trunk/app_conference/libspeex/CVS/Entries new file mode 100644 index 00000000..a6a76f82 --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/CVS/Entries @@ -0,0 +1,7 @@ +/misc.c/1.1/Thu Mar 25 15:10:17 2004// +/misc.h/1.1/Thu Mar 25 15:10:17 2004// +/preprocess.c/1.4/Fri Mar 25 20:26:26 2005// +/smallft.c/1.3/Fri Mar 25 20:26:26 2005// +/smallft.h/1.2/Wed Jul 7 13:39:42 2004// +/speex_preprocess.h/1.1/Thu Mar 25 15:10:17 2004// +D diff --git a/agc_2-X/trunk/app_conference/libspeex/CVS/Repository b/agc_2-X/trunk/app_conference/libspeex/CVS/Repository new file mode 100644 index 00000000..c74f117b --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/CVS/Repository @@ -0,0 +1 @@ +app_conference/libspeex diff --git a/agc_2-X/trunk/app_conference/libspeex/CVS/Root b/agc_2-X/trunk/app_conference/libspeex/CVS/Root new file mode 100644 index 00000000..76ea6939 --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@iaxclient.cvs.sourceforge.net:/cvsroot/iaxclient diff --git a/agc_2-X/trunk/app_conference/libspeex/misc.c b/agc_2-X/trunk/app_conference/libspeex/misc.c new file mode 100644 index 00000000..55728099 --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/misc.c @@ -0,0 +1,145 @@ +/* Copyright (C) 2002 Jean-Marc Valin + File: mics.c + Various utility routines for Speex + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "misc.h" +#include +#include +#include + +#ifndef RELEASE +void print_vec(float *vec, int len, char *name) +{ + int i; + printf ("%s ", name); + for (i=0;i>24; + ret += (i>>8)&0x0000ff00; + ret += (i<<8)&0x00ff0000; + ret += (i<<24); +#endif + return ret; +} + +unsigned int le_int(unsigned int i) +{ + unsigned int ret=i; +#ifdef WORDS_BIGENDIAN + ret = i>>24; + ret += (i>>8)&0x0000ff00; + ret += (i<<8)&0x00ff0000; + ret += (i<<24); +#endif + return ret; +} + +unsigned short be_short(unsigned short s) +{ + unsigned short ret=s; +#ifndef WORDS_BIGENDIAN + ret = s>>8; + ret += s<<8; +#endif + return ret; +} + +unsigned short le_short(unsigned short s) +{ + unsigned short ret=s; +#ifdef WORDS_BIGENDIAN + ret = s>>8; + ret += s<<8; +#endif + return ret; +} + +void *speex_alloc (int size) +{ + return calloc(size,1); +} + +void *speex_realloc (void *ptr, int size) +{ + return realloc(ptr, size); +} + +void speex_free (void *ptr) +{ + free(ptr); +} + +void *speex_move (void *dest, void *src, int n) +{ + return memmove(dest,src,n); +} + +void speex_error(char *str) +{ + fprintf (stderr, "Fatal error: %s\n", str); + exit(1); +} + +void speex_warning(char *str) +{ + fprintf (stderr, "warning: %s\n", str); +} + +void speex_warning_int(char *str, int val) +{ + fprintf (stderr, "warning: %s %d\n", str, val); +} + +void speex_rand_vec(float std, spx_sig_t *data, int len) +{ + int i; + for (i=0;i> (shift)) +#define SHR(a,shift) ((a) >> (shift)) +#define SHL(a,shift) ((a) << (shift)) + +/* result fits in 16 bits */ +#define MULT16_16_16(a,b) (((short)(a))*(b)) + +#define MULT16_16(a,b) (((signed int)(a))*(b)) +#define MULT16_32_Q13(a,b) (((a)*((b)>>13)) + ((a)*((signed int)((b)&0x00001fff))>>13)) +#define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14)) +#define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15)) + +#define MULT16_16_Q13(a,b) (((signed int)(a))*(b)>>13) +#define MULT16_16_Q14(a,b) (((signed int)(a))*(b)>>14) +#define MULT16_16_Q15(a,b) (((signed int)(a))*(b)>>15) + +#define MULT16_16_P14(a,b) ((8192+((signed int)(a))*(b))>>14) + + +#define DIV32_16(a,b) (((signed int)(a))/(b)) + +#else + +typedef float spx_mem_t; +typedef float spx_coef_t; +typedef float spx_lsp_t; +typedef float spx_sig_t; +typedef float spx_word16_t; +typedef float spx_word32_t; + +#define LPC_SCALING 1. +#define SIG_SCALING 1. +#define LSP_SCALING 1. + +#define LPC_SHIFT 0 +#define SIG_SHIFT 0 + +#define PSHR(a,shift) (a) +#define SHR(a,shift) (a) +#define SHL(a,shift) (a) +#define MULT16_16_16(a,b) ((a)*(b)) +#define MULT16_16(a,b) ((a)*(b)) + +#define MULT16_32_Q13(a,b) ((a)*(b)) +#define MULT16_32_Q14(a,b) ((a)*(b)) +#define MULT16_32_Q15(a,b) ((a)*(b)) + +#define MULT16_16_Q13(a,b) ((a)*(b)) +#define MULT16_16_Q14(a,b) ((a)*(b)) +#define MULT16_16_Q15(a,b) ((a)*(b)) + + +#endif + +#ifndef RELEASE +void print_vec(float *vec, int len, char *name); +#endif + +unsigned int be_int(unsigned int i); +unsigned int le_int(unsigned int i); + + +unsigned short be_short(unsigned short s); +unsigned short le_short(unsigned short s); + +/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */ +void *speex_alloc (int size); + +/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ +void *speex_realloc (void *ptr, int size); + +/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ +void speex_free (void *ptr); + +/** Speex wrapper for mem_move */ +void *speex_move (void *dest, void *src, int n); + +void speex_error(char *str); + +void speex_warning(char *str); + +void speex_warning_int(char *str, int val); + +void speex_rand_vec(float std, spx_sig_t *data, int len); + +float speex_rand(float std); + +void _speex_putc(int ch, void *file); + +#endif diff --git a/agc_2-X/trunk/app_conference/libspeex/preprocess.c b/agc_2-X/trunk/app_conference/libspeex/preprocess.c new file mode 100644 index 00000000..4e8a5470 --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/preprocess.c @@ -0,0 +1,1136 @@ +/* Copyright (C) 2003 Epic Games + Written by Jean-Marc Valin + + File: preprocess.c + Preprocessor with denoising based on the algorithm by Ephraim and Malah + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include "speex_preprocess.h" +#include "misc.h" +#include "smallft.h" + +#define max(a,b) ((a) > (b) ? (a) : (b)) +#define min(a,b) ((a) < (b) ? (a) : (b)) + +/* use single-precision math funcs. (1.3% perf improvement). */ +#if 1 +#define exp(a) expf(a) +#define sqrt(a) sqrtf(a) +#define floor(a) floorf(a) +#define log(a) logf(a) +#endif + + + +#ifndef M_PI +#define M_PI 3.14159263 +#endif + +#define SQRT_M_PI_2 0.88623 +#define LOUDNESS_EXP 2.5 + +#define NB_BANDS 8 + +#define ZMIN .1 +#define ZMAX .316 +#define ZMIN_1 10 +#define LOG_MIN_MAX_1 0.86859 + +static void conj_window(float *w, int len) +{ + int i; + for (i=0;i9.5) + return 1+.12/x; + + integer = floor(x); + frac = x-integer; + ind = (int)integer; + + return ((1-frac)*table[ind] + frac*table[ind+1])/sqrt(x+.0001); +} + +SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate) +{ + int i; + int N, N3, N4; + + SpeexPreprocessState *st = (SpeexPreprocessState *)speex_alloc(sizeof(SpeexPreprocessState)); + st->frame_size = frame_size; + + /* Round ps_size down to the nearest power of two */ +#if 0 + i=1; + st->ps_size = st->frame_size; + while(1) + { + if (st->ps_size & ~i) + { + st->ps_size &= ~i; + i<<=1; + } else { + break; + } + } + + + if (st->ps_size < 3*st->frame_size/4) + st->ps_size = st->ps_size * 3 / 2; +#else + st->ps_size = st->frame_size; +#endif + + N = st->ps_size; + N3 = 2*N - st->frame_size; + N4 = st->frame_size - N3; + + st->sampling_rate = sampling_rate; + st->denoise_enabled = 1; + st->agc_enabled = 0; + st->agc_level = 8000; + st->vad_enabled = 0; + + st->speech_prob_start = SPEEX_PROB_START ; + st->speech_prob_continue = SPEEX_PROB_CONTINUE ; + + st->frame = (float*)speex_alloc(2*N*sizeof(float)); + st->ps = (float*)speex_alloc(N*sizeof(float)); + st->gain2 = (float*)speex_alloc(N*sizeof(float)); + st->window = (float*)speex_alloc(2*N*sizeof(float)); + st->noise = (float*)speex_alloc(N*sizeof(float)); + st->old_ps = (float*)speex_alloc(N*sizeof(float)); + st->gain = (float*)speex_alloc(N*sizeof(float)); + st->prior = (float*)speex_alloc(N*sizeof(float)); + st->post = (float*)speex_alloc(N*sizeof(float)); + st->loudness_weight = (float*)speex_alloc(N*sizeof(float)); + st->inbuf = (float*)speex_alloc(N3*sizeof(float)); + st->outbuf = (float*)speex_alloc(N3*sizeof(float)); + st->echo_noise = (float*)speex_alloc(N*sizeof(float)); + + st->S = (float*)speex_alloc(N*sizeof(float)); + st->Smin = (float*)speex_alloc(N*sizeof(float)); + st->Stmp = (float*)speex_alloc(N*sizeof(float)); + st->update_prob = (float*)speex_alloc(N*sizeof(float)); + + st->zeta = (float*)speex_alloc(N*sizeof(float)); + st->Zpeak = 0; + st->Zlast = 0; + + st->noise_bands = (float*)speex_alloc(NB_BANDS*sizeof(float)); + st->noise_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float)); + st->speech_bands = (float*)speex_alloc(NB_BANDS*sizeof(float)); + st->speech_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float)); + st->noise_bandsN = st->speech_bandsN = 1; + + conj_window(st->window, 2*N3); + for (i=2*N3;i<2*st->ps_size;i++) + st->window[i]=1; + + if (N4>0) + { + for (i=N3-1;i>=0;i--) + { + st->window[i+N3+N4]=st->window[i+N3]; + st->window[i+N3]=1; + } + } + for (i=0;inoise[i]=1e4; + st->old_ps[i]=1e4; + st->gain[i]=1; + st->post[i]=1; + st->prior[i]=1; + } + + for (i=0;iinbuf[i]=0; + st->outbuf[i]=0; + } + + for (i=0;iloudness_weight[i] = .35-.35*ff/16000+.73*exp(-.5*(ff-3800)*(ff-3800)/9e5); + if (st->loudness_weight[i]<.01) + st->loudness_weight[i]=.01; + st->loudness_weight[i] *= st->loudness_weight[i]; + } + + st->speech_prob = 0; + st->last_speech = 1000; + st->loudness = pow(6000,LOUDNESS_EXP); + st->loudness2 = 6000; + st->nb_loudness_adapt = 0; + + st->fft_lookup = (struct drft_lookup*)speex_alloc(sizeof(struct drft_lookup)); + drft_init(st->fft_lookup,2*N); + + st->nb_adapt=0; + st->consec_noise=0; + st->nb_preprocess=0; + return st; +} + +void speex_preprocess_state_destroy(SpeexPreprocessState *st) +{ + speex_free(st->frame); + speex_free(st->ps); + speex_free(st->gain2); + speex_free(st->window); + speex_free(st->noise); + speex_free(st->old_ps); + speex_free(st->gain); + speex_free(st->prior); + speex_free(st->post); + speex_free(st->loudness_weight); + speex_free(st->echo_noise); + + speex_free(st->S); + speex_free(st->Smin); + speex_free(st->Stmp); + speex_free(st->update_prob); + + speex_free(st->noise_bands); + speex_free(st->noise_bands2); + speex_free(st->speech_bands); + speex_free(st->speech_bands2); + + speex_free(st->inbuf); + speex_free(st->outbuf); + + drft_clear(st->fft_lookup); + speex_free(st->fft_lookup); + + speex_free(st); +} + +static void update_noise(SpeexPreprocessState *st, float *ps, float *echo) +{ + int i; + float beta; + st->nb_adapt++; + beta=1.0/st->nb_adapt; + if (beta < .05) + beta=.05; + + if (!echo) + { + for (i=0;ips_size;i++) + st->noise[i] = (1-beta)*st->noise[i] + beta*ps[i]; + } else { + for (i=0;ips_size;i++) + st->noise[i] = (1-beta)*st->noise[i] + beta*max(0,ps[i]-echo[i]); +#if 0 + for (i=0;ips_size;i++) + st->noise[i] = 0; +#endif + } +} + +static int speex_compute_vad(SpeexPreprocessState *st, float *ps, float mean_prior, float mean_post) +{ + int i, is_speech=0; + int N = st->ps_size; + float scale=.5/N; + + /* FIXME: Clean this up a bit */ + { + float bands[NB_BANDS]; + int j; + float p0, p1; + float tot_loudness=0; + float x = sqrt(mean_post); + + for (i=5;ips[i] * st->loudness_weight[i]; + } + + for (i=0;ispeech_prob + .01*(1-st->speech_prob); + p1 *= .01*st->speech_prob + .99*(1-st->speech_prob); + + st->speech_prob = p0/(p1+p0); + */ + + if (st->noise_bandsN < 50 || st->speech_bandsN < 50) + { + if (mean_post > 5) + { + float adapt = 1./st->speech_bandsN++; + if (adapt<.005) + adapt = .005; + for (i=0;ispeech_bands[i] = (1-adapt)*st->speech_bands[i] + adapt*bands[i]; + /*st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*bands[i]*bands[i];*/ + st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*(bands[i]-st->speech_bands[i])*(bands[i]-st->speech_bands[i]); + } + } else { + float adapt = 1./st->noise_bandsN++; + if (adapt<.005) + adapt = .005; + for (i=0;inoise_bands[i] = (1-adapt)*st->noise_bands[i] + adapt*bands[i]; + /*st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*bands[i]*bands[i];*/ + st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*(bands[i]-st->noise_bands[i])*(bands[i]-st->noise_bands[i]); + } + } + } + p0=p1=1; + for (i=0;inoise_bands2[i] - st->noise_bands[i]*st->noise_bands[i]; + speech_var = 1.01*st->speech_bands2[i] - st->speech_bands[i]*st->speech_bands[i];*/ + noise_var = st->noise_bands2[i]; + speech_var = st->speech_bands2[i]; + if (noise_var < .1) + noise_var = .1; + if (speech_var < .1) + speech_var = .1; + + /*speech_var = sqrt(speech_var*noise_var); + noise_var = speech_var;*/ + if (speech_var < .05*speech_var) + noise_var = .05*speech_var; + if (speech_var < .05*noise_var) + speech_var = .05*noise_var; + + if (bands[i] < st->noise_bands[i]) + speech_var = noise_var; + if (bands[i] > st->speech_bands[i]) + noise_var = speech_var; + + speech_mean = st->speech_bands[i]; + noise_mean = st->noise_bands[i]; + if (noise_mean < speech_mean - 5) + noise_mean = speech_mean - 5; + + tmp1 = exp(-.5*(bands[i]-speech_mean)*(bands[i]-speech_mean)/speech_var)/sqrt(2*M_PI*speech_var); + tmp2 = exp(-.5*(bands[i]-noise_mean)*(bands[i]-noise_mean)/noise_var)/sqrt(2*M_PI*noise_var); + /*fprintf (stderr, "%f ", (float)(p0/(.01+p0+p1)));*/ + /*fprintf (stderr, "%f ", (float)(bands[i]));*/ + pr = tmp1/(1e-25+tmp1+tmp2); + /*if (bands[i] < st->noise_bands[i]) + pr=.01; + if (bands[i] > st->speech_bands[i] && pr < .995) + pr=.995;*/ + if (pr>.999) + pr=.999; + if (pr<.001) + pr=.001; + /*fprintf (stderr, "%f ", pr);*/ + p0 *= pr; + p1 *= (1-pr); + } + + p0 = pow(p0,.2); + p1 = pow(p1,.2); + +#if 1 + p0 *= 2; + p0=p0/(p1+p0); + if (st->last_speech>20) + { + float tmp = sqrt(tot_loudness)/st->loudness2; + tmp = 1-exp(-10*tmp); + if (p0>tmp) + p0=tmp; + } + p1=1-p0; +#else + if (sqrt(tot_loudness) < .6*st->loudness2 && p0>15*p1) + p0=15*p1; + if (sqrt(tot_loudness) < .45*st->loudness2 && p0>7*p1) + p0=7*p1; + if (sqrt(tot_loudness) < .3*st->loudness2 && p0>3*p1) + p0=3*p1; + if (sqrt(tot_loudness) < .15*st->loudness2 && p0>p1) + p0=p1; + /*fprintf (stderr, "%f %f ", (float)(sqrt(tot_loudness) /( .25*st->loudness2)), p0/(p1+p0));*/ +#endif + + p0 *= .99*st->speech_prob + .01*(1-st->speech_prob); + p1 *= .01*st->speech_prob + .99*(1-st->speech_prob); + + st->speech_prob = p0/(1e-25+p1+p0); + /*fprintf (stderr, "%f %f %f ", tot_loudness, st->loudness2, st->speech_prob);*/ + + /* decide if frame is speech using speech probability settings */ + +/* if (st->speech_prob> .35 || (st->last_speech < 20 && st->speech_prob>.1)) */ + if ( + st->speech_prob > st->speech_prob_start + || ( st->last_speech < 20 && st->speech_prob > st->speech_prob_continue ) + ) + { + is_speech = 1; + st->last_speech = 0; + } + else + { + st->last_speech++; + if ( st->last_speech < 20 ) + is_speech = 1; + } + + if (st->noise_bandsN > 50 && st->speech_bandsN > 50) + { + if (mean_post > 5) + { + float adapt = 1./st->speech_bandsN++; + if (adapt<.005) + adapt = .005; + for (i=0;ispeech_bands[i] = (1-adapt)*st->speech_bands[i] + adapt*bands[i]; + /*st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*bands[i]*bands[i];*/ + st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*(bands[i]-st->speech_bands[i])*(bands[i]-st->speech_bands[i]); + } + } else { + float adapt = 1./st->noise_bandsN++; + if (adapt<.005) + adapt = .005; + for (i=0;inoise_bands[i] = (1-adapt)*st->noise_bands[i] + adapt*bands[i]; + /*st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*bands[i]*bands[i];*/ + st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*(bands[i]-st->noise_bands[i])*(bands[i]-st->noise_bands[i]); + } + } + } + + + } + + return is_speech; +} + +static void speex_compute_agc(SpeexPreprocessState *st, float mean_prior) +{ + int i; + int N = st->ps_size; + float scale=.5/N; + float agc_gain; + int freq_start, freq_end; + float active_bands = 0; + + freq_start = (int)(300.0*2*N/st->sampling_rate); + freq_end = (int)(2000.0*2*N/st->sampling_rate); + for (i=freq_start;iS[i] > 20*st->Smin[i]+1000) + active_bands+=1; + } + active_bands /= (freq_end-freq_start+1); + + if (active_bands > .2) + { + float loudness=0; + float rate, rate2=.2; + st->nb_loudness_adapt++; + rate=2.0/(1+st->nb_loudness_adapt); + if (rate < .05) + rate = .05; + if (rate < .1 && pow(loudness, LOUDNESS_EXP) > st->loudness) + rate = .1; + if (rate < .2 && pow(loudness, LOUDNESS_EXP) > 3*st->loudness) + rate = .2; + if (rate < .4 && pow(loudness, LOUDNESS_EXP) > 10*st->loudness) + rate = .4; + + for (i=2;ips[i] * st->gain2[i] * st->gain2[i] * st->loudness_weight[i]; + } + loudness=sqrt(loudness); + /*if (loudness < 2*pow(st->loudness, 1.0/LOUDNESS_EXP) && + loudness*2 > pow(st->loudness, 1.0/LOUDNESS_EXP))*/ + st->loudness = (1-rate)*st->loudness + (rate)*pow(loudness, LOUDNESS_EXP); + + st->loudness2 = (1-rate2)*st->loudness2 + rate2*pow(st->loudness, 1.0/LOUDNESS_EXP); + + loudness = pow(st->loudness, 1.0/LOUDNESS_EXP); + + /*fprintf (stderr, "%f %f %f\n", loudness, st->loudness2, rate);*/ + } + + agc_gain = st->agc_level/st->loudness2; + /*fprintf (stderr, "%f %f %f %f\n", active_bands, st->loudness, st->loudness2, agc_gain);*/ + if (agc_gain>200) + agc_gain = 200; + + for (i=0;igain2[i] *= agc_gain; + +} + +static void preprocess_analysis(SpeexPreprocessState *st, short *x) +{ + int i; + int N = st->ps_size; + int N3 = 2*N - st->frame_size; + int N4 = st->frame_size - N3; + float *ps=st->ps; + + /* 'Build' input frame */ + for (i=0;iframe[i]=st->inbuf[i]; + for (i=0;iframe_size;i++) + st->frame[N3+i]=x[i]; + + /* Update inbuf */ + for (i=0;iinbuf[i]=x[N4+i]; + + /* Windowing */ + for (i=0;i<2*N;i++) + st->frame[i] *= st->window[i]; + + /* Perform FFT */ + drft_forward(st->fft_lookup, st->frame); + + /* Power spectrum */ + ps[0]=1; + for (i=1;iframe[2*i-1]*st->frame[2*i-1] + st->frame[2*i]*st->frame[2*i]; + +} + +static void update_noise_prob(SpeexPreprocessState *st) +{ + int i; + int N = st->ps_size; + + for (i=1;iS[i] = 100+ .8*st->S[i] + .05*st->ps[i-1]+.1*st->ps[i]+.05*st->ps[i+1]; + + if (st->nb_preprocess<1) + { + for (i=1;iSmin[i] = st->Stmp[i] = st->S[i]+100; + } + + if (st->nb_preprocess%200==0) + { + for (i=1;iSmin[i] = min(st->Stmp[i], st->S[i]); + st->Stmp[i] = st->S[i]; + } + } else { + for (i=1;iSmin[i] = min(st->Smin[i], st->S[i]); + st->Stmp[i] = min(st->Stmp[i], st->S[i]); + } + } + for (i=1;iupdate_prob[i] *= .2; + if (st->S[i] > 5*st->Smin[i]) + st->update_prob[i] += .8; + /*fprintf (stderr, "%f ", st->S[i]/st->Smin[i]);*/ + /*fprintf (stderr, "%f ", st->update_prob[i]);*/ + } + +} + +inline void ephraim_malah(SpeexPreprocessState *st, int N, float Pframe) +{ + int i; + + /* defactor loop for i=1,1 < i < N-1, and i= N-1 cases */ + /* i=1 case */ + { + float MM; + float theta; + float prior_ratio; + float p, q; + float zeta1; + float P1; + + prior_ratio = st->prior[1]/(1.0001+st->prior[1]); + theta = (1+st->post[1])*prior_ratio; + + zeta1 = st->zeta[1]; + + if (zeta1ZMAX) + P1 = 1; + else + P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1); + + /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/ + + /* FIXME: add global prop (P2) */ + q = 1-Pframe*P1; + if (q>.95) + q=.95; + p=1/(1 + (q/(1-q))*(1+st->prior[1])*exp(-theta)); + + /* Optimal estimator for loudness domain */ + MM = hypergeom_gain(theta); + + st->gain[1] = prior_ratio * MM; + /*Put some (very arbitraty) limit on the gain*/ + if (st->gain[1]>2) + { + st->gain[1]=2; + } + + if (st->denoise_enabled) + { + st->gain2[1]=p*p*st->gain[1]; + } else { + st->gain2[1]=1; + } + } + + for (i=2;i<(N-1);i++) + { + float MM; + float theta; + float prior_ratio; + float p, q; + float zeta1; + float P1; + + + zeta1 = .25*st->zeta[i-1] + .5*st->zeta[i] + .25*st->zeta[i+1]; + + prior_ratio = st->prior[i]/(1.0001+st->prior[i]); + theta = (1+st->post[i])*prior_ratio; + + + + if (zeta1ZMAX) + P1 = 1; + else + P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1); + + /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/ + + + /* FIXME: add global prop (P2) */ + q = 1-Pframe*P1; + if (q>.95) + q=.95; + p=1/(1 + (q/(1-q))*(1+st->prior[i])*exp(-theta)); + + /* Optimal estimator for loudness domain */ + MM = hypergeom_gain(theta); + + st->gain[i] = prior_ratio * MM; + /*Put some (very arbitraty) limit on the gain*/ + if (st->gain[i]>2) + { + st->gain[i]=2; + } + + if (st->denoise_enabled) + { + st->gain2[i]=p*p*st->gain[i]; + } else { + st->gain2[i]=1; + } + } + + /* i = N-1 case */ + { + float MM; + float theta; + float prior_ratio; + float p, q; + float zeta1; + float P1; + + prior_ratio = st->prior[N-1]/(1.0001+st->prior[N-1]); + theta = (1+st->post[N-1])*prior_ratio; + + zeta1 = st->zeta[N-1]; + + if (zeta1ZMAX) + P1 = 1; + else + P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1); + + /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/ + + /* FIXME: add global prop (P2) */ + q = 1-Pframe*P1; + if (q>.95) + q=.95; + p=1/(1 + (q/(1-q))*(1+st->prior[N-1])*exp(-theta)); + + /* Optimal estimator for loudness domain */ + MM = hypergeom_gain(theta); + + st->gain[N-1] = prior_ratio * MM; + /*Put some (very arbitraty) limit on the gain*/ + if (st->gain[N-1]>2) + { + st->gain[N-1]=2; + } + + if (st->denoise_enabled) + { + st->gain2[N-1]=p*p*st->gain[N-1]; + } else { + st->gain2[N-1]=1; + } + } + st->gain2[0]=st->gain[0]=0; + st->gain2[N-1]=st->gain[N-1]=0; +} + + +int speex_preprocess(SpeexPreprocessState *st, short *x, float *echo) +{ + int i; + int is_speech=1; + float mean_post=0; + float mean_prior=0; + int N = st->ps_size; + int N3 = 2*N - st->frame_size; + int N4 = st->frame_size - N3; + float scale=.5/N; + float *ps=st->ps; + float Zframe=0, Pframe; + + preprocess_analysis(st, x); + + update_noise_prob(st); + + st->nb_preprocess++; + + /* Noise estimation always updated for the 20 first times */ + if (st->nb_adapt<10) + { + update_noise(st, ps, echo); + } + + /* Deal with residual echo if provided */ + if (echo) + for (i=1;iecho_noise[i] = (.7*st->echo_noise[i] + .3* echo[i]); + + /* Compute a posteriori SNR */ + for (i=1;ipost[i] = ps[i]/(1+st->noise[i]+st->echo_noise[i]) - 1; + if (st->post[i]>100) + st->post[i]=100; + /*if (st->post[i]<0) + st->post[i]=0;*/ + mean_post+=st->post[i]; + } + mean_post /= N; + if (mean_post<0) + mean_post=0; + + /* Special case for first frame */ + if (st->nb_adapt==1) + for (i=1;iold_ps[i] = ps[i]; + + /* Compute a priori SNR */ + { + /* A priori update rate */ + float gamma; + float min_gamma=0.12; + gamma = 1.0/st->nb_preprocess; + + /*Make update rate smaller when there's no speech*/ +#if 0 + if (mean_post<3.5 && mean_prior < 1) + min_gamma *= (mean_post+.5); + else + min_gamma *= 4.; +#else + min_gamma = .1*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post); + if (min_gamma>.15) + min_gamma = .15; + if (min_gamma<.02) + min_gamma = .02; +#endif + /*min_gamma = .08;*/ + + /*if (gammaprior[i] = gamma*max(0.0,st->post[i]) + + (1-gamma)*st->gain[i]*st->gain[i]*st->old_ps[i]/(1+st->noise[i]+st->echo_noise[i]); + + if (st->prior[i]>100) + st->prior[i]=100; + + mean_prior+=st->prior[i]; + } + } + mean_prior /= N; + +#if 0 + for (i=0;iprior[i]); + } + fprintf (stderr, "\n"); +#endif + /*fprintf (stderr, "%f %f\n", mean_prior,mean_post);*/ + + if (st->nb_preprocess>=20) + { + int do_update = 0; + float noise_ener=0, sig_ener=0; + /* If SNR is low (both a priori and a posteriori), update the noise estimate*/ + /*if (mean_prior<.23 && mean_post < .5)*/ + if (mean_prior<.23 && mean_post < .5) + do_update = 1; + for (i=1;inoise[i]; + sig_ener += ps[i]; + } + if (noise_ener > 3*sig_ener) + do_update = 1; + /*do_update = 0;*/ + if (do_update) + { + st->consec_noise++; + } else { + st->consec_noise=0; + } + } + + if (st->vad_enabled) + is_speech = speex_compute_vad(st, ps, mean_prior, mean_post); + + + if (st->consec_noise>=3) + { + update_noise(st, st->old_ps, echo); + } else { + for (i=1;iupdate_prob[i]<.5) + st->noise[i] = .90*st->noise[i] + .1*st->ps[i]; + } + } + + for (i=1;izeta[i] = .7*st->zeta[i] + .3*st->prior[i]; + } + + { + int freq_start = (int)(300.0*2*N/st->sampling_rate); + int freq_end = (int)(2000.0*2*N/st->sampling_rate); + for (i=freq_start;izeta[i]; + } + } + + Zframe /= N; + if (Zframe 1.5*st->Zlast) + { + Pframe = 1; + st->Zpeak = Zframe; + if (st->Zpeak > 10) + st->Zpeak = 10; + if (st->Zpeak < 1) + st->Zpeak = 1; + } else { + if (Zframe < st->Zpeak*ZMIN) + { + Pframe = 0; + } else if (Zframe > st->Zpeak*ZMAX) + { + Pframe = 1; + } else { + Pframe = log(Zframe/(st->Zpeak*ZMIN)) / log(ZMAX/ZMIN); + } + } + } + st->Zlast = Zframe; + + /*fprintf (stderr, "%f\n", Pframe);*/ + /* Compute gain according to the Ephraim-Malah algorithm */ + ephraim_malah(st,N,Pframe); + + if (st->agc_enabled) + speex_compute_agc(st, mean_prior); + +#if 0 + if (!is_speech) + { + for (i=0;igain2[i] = 0; + } +#if 0 + else { + for (i=0;igain2[i] = 1; + } +#endif +#endif + + /* PERF: 14% when only vad is enabled [7.0 vs 8.2 sec] */ + if(st->agc_enabled || st->denoise_enabled) { + /* Apply computed gain */ + for (i=1;iframe[2*i-1] *= st->gain2[i]; + st->frame[2*i] *= st->gain2[i]; + } + + /* Get rid of the DC and very low frequencies */ + st->frame[0]=0; + st->frame[1]=0; + st->frame[2]=0; + /* Nyquist frequency is mostly useless too */ + st->frame[2*N-1]=0; + + /* Inverse FFT with 1/N scaling */ + drft_backward(st->fft_lookup, st->frame); + + for (i=0;i<2*N;i++) + st->frame[i] *= scale; + + { + float max_sample=0; + for (i=0;i<2*N;i++) + if (fabs(st->frame[i])>max_sample) + max_sample = fabs(st->frame[i]); + if (max_sample>28000) + { + float damp = 28000./max_sample; + for (i=0;i<2*N;i++) + st->frame[i] *= damp; + } + } + + for (i=0;i<2*N;i++) + st->frame[i] *= st->window[i]; + + /* Perform overlap and add */ + for (i=0;ioutbuf[i] + st->frame[i]; + for (i=0;iframe[N3+i]; + + /* Update outbuf */ + for (i=0;ioutbuf[i] = st->frame[st->frame_size+i]; + } + + /* Save old power spectrum */ + for (i=1;iold_ps[i] = ps[i]; + + return is_speech; +} + +void speex_preprocess_estimate_update(SpeexPreprocessState *st, short *x, float *noise) +{ + int i; + int N = st->ps_size; + int N3 = 2*N - st->frame_size; + + float *ps=st->ps; + + preprocess_analysis(st, x); + + update_noise_prob(st); + + st->nb_preprocess++; + + for (i=1;iupdate_prob[i]<.5) + st->noise[i] = .90*st->noise[i] + .1*ps[i]; + } + + for (i=0;ioutbuf[i] = x[st->frame_size-N3+i]*st->window[st->frame_size+i]; + + /* Save old power spectrum */ + for (i=1;iold_ps[i] = ps[i]; + +} + + +int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr) +{ + SpeexPreprocessState *st; + st=(SpeexPreprocessState*)state; + switch(request) + { + case SPEEX_PREPROCESS_SET_DENOISE: + st->denoise_enabled = (*(int*)ptr); + break; + case SPEEX_PREPROCESS_GET_DENOISE: + (*(int*)ptr) = st->denoise_enabled; + break; + + case SPEEX_PREPROCESS_SET_AGC: + st->agc_enabled = (*(int*)ptr); + break; + case SPEEX_PREPROCESS_GET_AGC: + (*(int*)ptr) = st->agc_enabled; + break; + + case SPEEX_PREPROCESS_SET_AGC_LEVEL: + st->agc_level = (*(float*)ptr); + if (st->agc_level<1) + st->agc_level=1; + if (st->agc_level>32768) + st->agc_level=32768; + break; + case SPEEX_PREPROCESS_GET_AGC_LEVEL: + (*(float*)ptr) = st->agc_level; + break; + + case SPEEX_PREPROCESS_SET_VAD: + st->vad_enabled = (*(int*)ptr); + break; + case SPEEX_PREPROCESS_GET_VAD: + (*(int*)ptr) = st->vad_enabled; + break; + + case SPEEX_PREPROCESS_SET_PROB_START: + st->speech_prob_start = (*(float*)ptr) ; + if ( st->speech_prob_start > 1 ) + st->speech_prob_start = st->speech_prob_start / 100 ; + if ( st->speech_prob_start > 1 || st->speech_prob_start < 0 ) + st->speech_prob_start = SPEEX_PROB_START ; + break ; + case SPEEX_PREPROCESS_GET_PROB_START: + (*(float*)ptr) = st->speech_prob_start ; + break ; + + case SPEEX_PREPROCESS_SET_PROB_CONTINUE: + st->speech_prob_continue = (*(float*)ptr) ; + if ( st->speech_prob_continue > 1 ) + st->speech_prob_continue = st->speech_prob_continue / 100 ; + if ( st->speech_prob_continue > 1 || st->speech_prob_continue < 0 ) + st->speech_prob_continue = SPEEX_PROB_CONTINUE ; + break ; + break ; + case SPEEX_PREPROCESS_GET_PROB_CONTINUE: + (*(float*)ptr) = st->speech_prob_continue ; + break ; + + default: + speex_warning_int("Unknown speex_preprocess_ctl request: ", request); + return -1; + } + return 0; +} diff --git a/agc_2-X/trunk/app_conference/libspeex/qc_20060323.zip b/agc_2-X/trunk/app_conference/libspeex/qc_20060323.zip new file mode 100644 index 00000000..a2a4d3b3 Binary files /dev/null and b/agc_2-X/trunk/app_conference/libspeex/qc_20060323.zip differ diff --git a/agc_2-X/trunk/app_conference/libspeex/smallft.c b/agc_2-X/trunk/app_conference/libspeex/smallft.c new file mode 100644 index 00000000..2a4fc02a --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/smallft.c @@ -0,0 +1,1256 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: *unnormalized* fft transform + last mod: $Id: smallft.c,v 1.3 2005/03/25 20:26:26 stevek Exp $ + + ********************************************************************/ + +/* FFT implementation from OggSquish, minus cosine transforms, + * minus all but radix 2/4 case. In Vorbis we only need this + * cut-down version. + * + * To do more than just power-of-two sized vectors, see the full + * version I wrote for NetLib. + * + * Note that the packing is a little strange; rather than the FFT r/i + * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, + * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the + * FORTRAN version + */ + +#include +#include "smallft.h" +#include "misc.h" + +static void drfti1(int n, float *wa, int *ifac){ + static int ntryh[4] = { 4,2,3,5 }; + static float tpi = 6.28318530717958648f; + float arg,argh,argld,fi; + int ntry=0,i,j=-1; + int k1, l1, l2, ib; + int ld, ii, ip, is, nq, nr; + int ido, ipm, nfm1; + int nl=n; + int nf=0; + + L101: + j++; + if (j < 4) + ntry=ntryh[j]; + else + ntry+=2; + + L104: + nq=nl/ntry; + nr=nl-ntry*nq; + if (nr!=0) goto L101; + + nf++; + ifac[nf+1]=ntry; + nl=nq; + if(ntry!=2)goto L107; + if(nf==1)goto L107; + + for (i=1;i>1; + ipp2=ip; + idp2=ido; + nbd=(ido-1)>>1; + t0=l1*ido; + t10=ip*ido; + + if(ido==1)goto L119; + for(ik=0;ikl1){ + for(j=1;j>1; + ipp2=ip; + ipph=(ip+1)>>1; + if(idol1)goto L139; + + is= -ido-1; + t1=0; + for(j=1;jn==1)return; + drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); +} + +void drft_backward(struct drft_lookup *l,float *data){ + if (l->n==1)return; + drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); +} + +void drft_init(struct drft_lookup *l,int n) +{ + l->n=n; + l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache)); + l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache)); + fdrffti(n, l->trigcache, l->splitcache); +} + +void drft_clear(struct drft_lookup *l) +{ + if(l) + { + if(l->trigcache) + speex_free(l->trigcache); + if(l->splitcache) + speex_free(l->splitcache); + } +} diff --git a/agc_2-X/trunk/app_conference/libspeex/smallft.h b/agc_2-X/trunk/app_conference/libspeex/smallft.h new file mode 100644 index 00000000..d44c41b1 --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/smallft.h @@ -0,0 +1,42 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the XIPHOPHORUS Company http://www.xiph.org/ * + * * + ******************************************************************** + + function: fft transform + last mod: $Id: smallft.h,v 1.2 2004/07/07 13:39:42 stevek Exp $ + + ********************************************************************/ + +#ifndef _V_SMFT_H_ +#define _V_SMFT_H_ + +/*#include "vorbis/codec.h"*/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct drft_lookup{ + int n; + float *trigcache; + int *splitcache; +}; + +extern void drft_forward(struct drft_lookup *l,float *data); +extern void drft_backward(struct drft_lookup *l,float *data); +extern void drft_init(struct drft_lookup *l,int n); +extern void drft_clear(struct drft_lookup *l); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/agc_2-X/trunk/app_conference/libspeex/speex_preprocess.h b/agc_2-X/trunk/app_conference/libspeex/speex_preprocess.h new file mode 100644 index 00000000..320224ea --- /dev/null +++ b/agc_2-X/trunk/app_conference/libspeex/speex_preprocess.h @@ -0,0 +1,139 @@ +/* Copyright (C) 2003 Epic Games + Written by Jean-Marc Valin + + File: speex_preprocess.h + + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +struct drft_lookup; + +typedef struct SpeexPreprocessState { + int frame_size; /**< Number of samples processed each time */ + int ps_size; /**< Number of points in the power spectrum */ + int sampling_rate; /**< Sampling rate of the input/output */ + + /* parameters */ + int denoise_enabled; + int agc_enabled; + float agc_level; + int vad_enabled; + + // probabilities to check speech_prob against + float speech_prob_start ; + float speech_prob_continue ; + + float *frame; /**< Processing frame (2*ps_size) */ + float *ps; /**< Current power spectrum */ + float *gain2; /**< Adjusted gains */ + float *window; /**< Analysis/Synthesis window */ + float *noise; /**< Noise estimate */ + float *old_ps; /**< Power spectrum for last frame */ + float *gain; /**< Ephraim Malah gain */ + float *prior; /**< A-priori SNR */ + float *post; /**< A-posteriori SNR */ + + float *S; /**< Smoothed power spectrum */ + float *Smin; /**< See Cohen paper */ + float *Stmp; /**< See Cohen paper */ + float *update_prob; /**< Propability of speech presence for noise update */ + + float *zeta; /**< Smoothed a priori SNR */ + float Zpeak; + float Zlast; + + float *loudness_weight; /**< Perceptual loudness curve */ + + float *echo_noise; + + float *noise_bands; + float *noise_bands2; + int noise_bandsN; + float *speech_bands; + float *speech_bands2; + int speech_bandsN; + + float *inbuf; /**< Input buffer (overlapped analysis) */ + float *outbuf; /**< Output buffer (for overlap and add) */ + + float speech_prob; + int last_speech; + float loudness; /**< loudness estimate */ + float loudness2; /**< loudness estimate */ + int nb_adapt; /**< Number of frames used for adaptation so far */ + int nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */ + int consec_noise; /**< Number of consecutive noise frames */ + int nb_preprocess; /**< Number of frames processed so far */ + struct drft_lookup *fft_lookup; /**< Lookup table for the FFT */ + +} SpeexPreprocessState; + +/** Creates a new preprocessing state */ +SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); + +/** Destroys a denoising state */ +void speex_preprocess_state_destroy(SpeexPreprocessState *st); + +/** Preprocess a frame */ +int speex_preprocess(SpeexPreprocessState *st, short *x, float *noise); + +/** Preprocess a frame */ +void speex_preprocess_estimate_update(SpeexPreprocessState *st, short *x, float *noise); + +/** Used like the ioctl function to control the preprocessor parameters */ +int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); + +#define SPEEX_PROB_START 0.35 +#define SPEEX_PROB_CONTINUE 0.1 + +#define SPEEX_PREPROCESS_SET_DENOISE 0 +#define SPEEX_PREPROCESS_GET_DENOISE 1 + +#define SPEEX_PREPROCESS_SET_AGC 2 +#define SPEEX_PREPROCESS_GET_AGC 3 + +#define SPEEX_PREPROCESS_SET_VAD 4 +#define SPEEX_PREPROCESS_GET_VAD 5 + +#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 +#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 + +#define SPEEX_PREPROCESS_SET_PROB_START 8 +#define SPEEX_PREPROCESS_GET_PROB_START 9 + +#define SPEEX_PREPROCESS_SET_PROB_CONTINUE 10 +#define SPEEX_PREPROCESS_GET_PROB_CONTINUE 11 + +#ifdef __cplusplus +} +#endif diff --git a/agc_2-X/trunk/app_conference/member.c b/agc_2-X/trunk/app_conference/member.c new file mode 100644 index 00000000..30f6ccc8 --- /dev/null +++ b/agc_2-X/trunk/app_conference/member.c @@ -0,0 +1,1946 @@ + +// $Id: member.c,v 1.9-1 2006/06/01 16:10:10 mflorell Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003, 2004 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#include "member.h" +#include "regex.h" + + + +// process an incoming frame. Returns 0 normally, 1 if hangup was received. +static int process_incoming(struct ast_conference *conf, struct ast_conf_member *member, struct ast_frame *f) +{ + + int silent_frame = 0; + + if ( + f->frametype == AST_FRAME_DTMF + && member->send_dtmf + ) + { // send the DTMF event to the MGR interface.. + manager_event( + EVENT_FLAG_CALL, + "ConferenceDTMF", + "Channel: %s\r\n" + "Key: %c\r\n", + member->channel_name, + f->subclass + ) ; + + ast_frfree(f); + f = NULL; + } + else if ( member->type == 'L' ) + { + // this is a listen-only user, ignore the frame + ast_frfree( f ) ; + f = NULL ; + } + else if ( ( f->frametype == AST_FRAME_VOICE ) || (f->frametype == AST_FRAME_DTMF) ) +// else if ( f->frametype == AST_FRAME_VOICE ) + { + // accounting: count the incoming frame + member->frames_in++ ; + + if (f->frametype == AST_FRAME_DTMF) + { + if ( (member->inband_dtmf == -1) || (member->rfc_dtmf == -1) ) + { + char *digit = "X" ; + char *dtmfRFC = "X" ; + int conf_count ; + struct ast_conf_member *membertest; + + if (f->subclass == 35) { digit = "hash" ; dtmfRFC = "#" ; } + if (f->subclass == 42) { digit = "star" ; dtmfRFC = "*" ; } + if (f->subclass == 48) { digit = "0" ; dtmfRFC = "0" ; } + if (f->subclass == 49) { digit = "1" ; dtmfRFC = "1" ; } + if (f->subclass == 50) { digit = "2" ; dtmfRFC = "2" ; } + if (f->subclass == 51) { digit = "3" ; dtmfRFC = "3" ; } + if (f->subclass == 52) { digit = "4" ; dtmfRFC = "4" ; } + if (f->subclass == 53) { digit = "5" ; dtmfRFC = "5" ; } + if (f->subclass == 54) { digit = "6" ; dtmfRFC = "6" ; } + if (f->subclass == 55) { digit = "7" ; dtmfRFC = "7" ; } + if (f->subclass == 56) { digit = "8" ; dtmfRFC = "8" ; } + if (f->subclass == 57) { digit = "9" ; dtmfRFC = "9" ; } + + ast_log( LOG_NOTICE, "DTMF debug frame output to voice %d - %s\n", f->subclass, digit ) ; + + int res = 0 ; + int dtmf_invalid = 0 ; + regex_t re; + + if(regcomp(&re, digit, REG_EXTENDED|REG_NOSUB) != 0) { dtmf_invalid = 0; } + dtmf_invalid = regexec(&re, "0123456789*#abcdABCDstarhash", (size_t)0, NULL, 0); + regfree(&re); + ast_log( LOG_NOTICE, "Regex debug %d - %s - %s\n", dtmf_invalid, member->channel_name, digit) ; + + // play DTMF for other members of the conference + membertest = conf->memberlist ; + conf_count = conf->membercount ; + + // ast_log( LOG_NOTICE, "2 DTMF debug frame output to voice, conf count %d\n", conf_count) ; + + while (membertest != NULL) + { + + if( (!strcmp(membertest->channel_name, member->channel_name)) || ( digit == "X" ) ) + { + ast_log( LOG_ERROR, "skipping playing DTMF tone on %s\n", membertest->channel_name ) ; + } + else + { + + if (member->inband_dtmf == -1) + { + if (!basic_play_sound ( membertest->channel_name, digit )) + { + ast_log( LOG_ERROR, "playing DTMF tone FAILED on %s\n", membertest->channel_name ) ; + } + } + + if (member->rfc_dtmf == -1) + { + ast_log( LOG_NOTICE, "START sending DTMF signal on %s\n", membertest->channel_name ) ; + + if(dtmf_invalid > 0) + { + ast_log(LOG_WARNING, "Illegal DTMF character '%s' in string. (0-9*#aAbBcCdD allowed)\n", digit); + } + else + { + + res = ast_dtmf_stream(membertest->chan,NULL,digit,250); + if (res) + { + ast_log( LOG_NOTICE, "DTMF signal %s on %s sent\n", digit, membertest->channel_name ) ; + } + } + } + } + membertest = membertest->next; + } + } + + + } + + +#ifdef DEBUG_OUTPUT_PCM + // !!! TESTING !!! + if ( member->incoming_fh != NULL ) + { + fwrite( f->data, f->datalen, 1, member->incoming_fh ) ; + fflush( member->incoming_fh ) ; + } +#endif + +#if ( SILDET == 2 ) + // + // make sure we have a valid dsp and frame type + // + if ( + member->dsp != NULL + && f->subclass == AST_FORMAT_SLINEAR + && f->datalen == AST_CONF_FRAME_DATA_SIZE + ) + { + // send the frame to the preprocessor +#ifdef DEBUG_USE_TIMELOG + int spx_ret; + TIMELOG(spx_ret = speex_preprocess( member->dsp, f->data, NULL ), 3, "speex_preprocess"); + if ( spx_ret == 0 ) +#else + if ( speex_preprocess( member->dsp, f->data, NULL ) == 0 ) +#endif + { + // + // we ignore the preprocessor's outcome if we've seen voice frames + // in within the last AST_CONF_SKIP_SPEEX_PREPROCESS frames + // + if ( member->ignore_speex_count > 0 ) + { + // ast_log( AST_CONF_DEBUG, "ignore_speex_count => %d\n", member->ignore_speex_count ) ; + + // skip speex_preprocess(), and decrement counter + --member->ignore_speex_count ; + } + else + { + // set silent_frame flag + silent_frame = 1 ; + } + } + else + { + // voice detected, reset skip count + member->ignore_speex_count = AST_CONF_SKIP_SPEEX_PREPROCESS ; + } + } +#endif + + // used to debug drop off in received frames + // struct timeval tv ; + // gettimeofday( &tv, NULL ) ; + + if ( silent_frame == 1 ) + { + // ignore silent frames + // ast_log( AST_CONF_DEBUG, "RECEIVED SILENT FRAME, channel => %s, frames_in => %ld, s => %ld, ms => %ld\n", + // member->channel_name, member->frames_in, tv.tv_sec, tv.tv_usec ) ; + } + else + { + // queue a non-silent frame for mixing + + // ast_log( AST_CONF_DEBUG, "RECEIVED VOICE FRAME, channel => %s, frames_in => %ld, s => %ld, ms => %ld\n", + // member->channel_name, member->frames_in, tv.tv_sec, tv.tv_usec ) ; + + // acquire member lock + ast_mutex_lock( &member->lock ) ; + + // + // queue up the voice frame so the conference + // thread can mix them before sending + // + + // struct ast_frame* af = ast_frdup( f ) ; + + // if ( queue_incoming_frame( member, af ) != 0 ) + if ( queue_incoming_frame( member, f ) != 0 ) + { + // free the duplicated frame, if we can't queue it + // ast_log( LOG_NOTICE, "dropped incoming frame, channel => %s\n", chan->name ) ; + // ast_frfree( af ) ; + // af = NULL ; + } + else + { + // everything is going ok + } + + // release member mutex + ast_mutex_unlock( &member->lock ) ; + } + + // free the original frame + ast_frfree( f ) ; + f = NULL ; + } + else if ( + f->frametype == AST_FRAME_CONTROL + && f->subclass == AST_CONTROL_HANGUP + ) + { + // hangup received + + // free the frame + ast_frfree( f ) ; + f = NULL ; + + // break out of the while ( 42 == 42 ) + return 1 ; + } + else + { + // undesirables + ast_frfree( f ) ; + f = NULL ; + } + return 0; +} + +// get the next frame from the soundq; must be called with member locked. +static struct ast_frame *get_next_soundframe(struct ast_conf_member *member, struct ast_frame + *exampleframe) { + struct ast_frame *f; + +again: + f=ast_readframe(member->soundq->stream); + + if(!f) { // we're done with this sound; remove it from the queue, and try again + struct ast_conf_soundq *toboot = member->soundq; + + ast_closestream(toboot->stream); + member->soundq = toboot->next; + + //ast_log( LOG_WARNING, "finished playing a sound, next = %x\n", member->soundq); + // notify applications via mgr interface that this sound has been played + manager_event( + EVENT_FLAG_CALL, + "ConferenceSoundComplete", + "Channel: %s\r\n" + "Sound: %s\r\n", + member->channel_name, + toboot->name + ); + + free(toboot); + if(member->soundq) goto again; + + // if we get here, we've gotten to the end of the queue; reset write format + if ( ast_set_write_format( member->chan, member->write_format ) < 0 ) + { + ast_log( LOG_ERROR, "unable to set write format to %d\n", + member->write_format ) ; + } + } else { + // copy delivery from exampleframe + f->delivery = exampleframe->delivery; + } + + return f; +} + +// process outgoing frames for the channel, playing either normal conference audio, +// or requested sounds +static int process_outgoing(struct ast_conf_member *member) +{ + conf_frame* cf ; // frame read from the output queue + struct ast_frame *f; + struct ast_frame *realframe = NULL; + + for(;;) + { + // acquire member mutex and grab a frame. + ast_mutex_lock( &member->lock ) ; + cf = get_outgoing_frame( member ) ; + + // if there's no frames exit the loop. + if(!cf){ + ast_mutex_unlock( &member->lock ) ; + break; + } + + f = cf->fr; + + // if we're playing sounds, we can just replace the frame with the + // next sound frame, and send it instead + if(member->soundq) { + realframe = f; + f = get_next_soundframe(member, f); + if(!f) { // if we didn't get anything, just revert to "normal" + f = realframe; + realframe = NULL; + } + } + + ast_mutex_unlock(&member->lock); + +#ifdef DEBUG_FRAME_TIMESTAMPS + // !!! TESTING !!! + int delivery_diff = usecdiff( &f->delivery, &member->lastsent_timeval ) ; + if ( ( delivery_diff != AST_CONF_FRAME_INTERVAL ) && + ( delivery_diff != 2 * AST_CONF_FRAME_INTERVAL ) && + ( delivery_diff != 3 * AST_CONF_FRAME_INTERVAL ) ) + { + ast_log( AST_CONF_DEBUG, "unanticipated delivery time, delivery_diff => %d, delivery.tv_usec => %ld\n", + delivery_diff, f->delivery.tv_usec ) ; + } + + // !!! TESTING !!! + if ( + f->delivery.tv_sec < member->lastsent_timeval.tv_sec + || ( + f->delivery.tv_sec == member->lastsent_timeval.tv_sec + && f->delivery.tv_usec <= member->lastsent_timeval.tv_usec + ) + ) + { + ast_log( LOG_WARNING, "queued frame timestamped in the past, %ld.%ld <= %ld.%ld\n", + f->delivery.tv_sec, f->delivery.tv_usec, + member->lastsent_timeval.tv_sec, member->lastsent_timeval.tv_usec ) ; + } + member->lastsent_timeval = f->delivery ; +#endif + +//#ifdef DEBUG_USE_TIMELOG +// TIMELOG( ast_write( member->chan, f ), 10, "member: ast_write"); +//#else + // send the voice frame + if ( ast_write( member->chan, f ) == 0 ) + { + // struct timeval tv ; + // gettimeofday( &tv, NULL ) ; + // ast_log( AST_CONF_DEBUG, "SENT VOICE FRAME, channel => %s, frames_out => %ld, s => %ld, ms => %ld\n", + // member->channel_name, member->frames_out, tv.tv_sec, tv.tv_usec ) ; + } + else + { + // log 'dropped' outgoing frame + ast_log( LOG_ERROR, "unable to write voice frame to channel, channel => %s\n", member->channel_name ) ; + + // accounting: count dropped outgoing frames + member->frames_out_dropped++ ; + } +//#endif + + // clean up frame + delete_conf_frame( cf ) ; + } + return 0; +} + +// +// main member thread function +// + +int member_exec( struct ast_channel* chan, void* data ) +{ +// struct timeval start, end ; +// gettimeofday( &start, NULL ) ; + + struct ast_conference *conf ; + struct ast_conf_member *member, *membertest; + + struct ast_frame *f ; // frame received from ast_read() + + int left = 0 ; + int res; + + ast_log( AST_CONF_DEBUG, "[ $Revision: 1.9 $ ] begin processing member thread, channel => %s\n", chan->name ) ; + + // + // If the call has not yet been answered, answer the call + // Note: asterisk apps seem to check _state, but it seems like it's safe + // to just call ast_answer. It will just do nothing if it is up. + // it will also return -1 if the channel is a zombie, or has hung up. + // + + res = ast_answer( chan ) ; + if ( res ) + { + ast_log( LOG_ERROR, "unable to answer call\n" ) ; + return -1 ; + } + + // + // create a new member for the conference + // + +// ast_log( AST_CONF_DEBUG, "creating new member, id => %s, flags => %s, p => %s\n", +// id, flags, priority ) ; + + member = create_member( chan, (const char*)( data ) ) ; // flags, atoi( priority ) ) ; + + // unable to create member, return an error + if ( member == NULL ) + { + ast_log( LOG_ERROR, "unable to create member\n" ) ; + return -1 ; + } + + // + // setup asterisk read/write formats + // + + ast_log( AST_CONF_DEBUG, "CHANNEL INFO, CHANNEL => %s, DNID => %s, CALLER_ID => %s, ANI => %s\n", + chan->name, chan->cid.cid_dnid, chan->cid.cid_num, chan->cid.cid_ani ) ; + + ast_log( AST_CONF_DEBUG, "CHANNEL CODECS, CHANNEL => %s, NATIVE => %d, READ => %d, WRITE => %d\n", + chan->name, chan->nativeformats, member->read_format, member->write_format ) ; + + if ( ast_set_read_format( chan, member->read_format ) < 0 ) + { + ast_log( LOG_ERROR, "unable to set read format to signed linear\n" ) ; + delete_member( member ) ; + return -1 ; + } + + // for right now, we'll send everything as slinear + if ( ast_set_write_format( chan, member->write_format ) < 0 ) // AST_FORMAT_SLINEAR, chan->nativeformats + { + ast_log( LOG_ERROR, "unable to set write format to signed linear\n" ) ; + delete_member( member ) ; + return -1 ; + } + + // + // setup a conference for the new member + // + + conf = start_conference( member ) ; + + if ( conf == NULL ) + { + ast_log( LOG_ERROR, "unable to setup member conference\n" ) ; + delete_member( member) ; + return -1 ; + } + +#ifdef DEBUG_OUTPUT_PCM + // !!! TESTING !!! + char* incoming_fn = malloc( 512 ) ; + snprintf( incoming_fn, 512, "/tmp/ac_%s_%ld.gsm", chan->dnid, fr_base.tv_usec ) ; + + // !!! TESTING !!! + member->incoming_fh = ( member->read_format == 2 ) + ? fopen( member->incoming_fn, "wb" ) + : NULL + ; + + // !!! TESTING !!! + if ( member->incoming_fh == NULL ) + { + ast_log( AST_CONF_DEBUG, "incoming_fh is null, incoming_fn => %s\n", incoming_fn ) ; + } + else + { + ast_log( AST_CONF_DEBUG, "incoming_fh is not null, incoming_fn => %s\n", incoming_fn ) ; + } + + // !!! TESTING !!! + free( incoming_fn ) ; +#endif + + // + // process loop for new member ( this runs in it's own thread + // + + ast_log( AST_CONF_DEBUG, "begin member event loop, channel => %s\n", chan->name ) ; + + // timer timestamps + struct timeval base, curr ; + gettimeofday( &base, NULL ) ; + + + + // tell conference_exec we're ready for frames + member->ready_for_outgoing = 1 ; + + int conf_count = 0 ; + int silent_entry = 0 ; + + // entry message for other members of the conference + membertest = conf->memberlist ; + conf_count = conf->membercount ; + + ast_log( LOG_NOTICE, "Conference Members: %d\n", conf_count ) ; + + if (member->quiet_entry_exit == -1) + { + silent_entry = 1 ; + } + ast_log( LOG_NOTICE, "Quiet debug %d - %d\n", member->quiet_entry_exit, silent_entry ) ; + + while (membertest != NULL) + { + if (silent_entry < 1) + { + if( (!strcmp(membertest->channel_name, member->channel_name)) && (conf_count < 2) ) + { + ast_log( LOG_NOTICE, "skipping entry message on %s\n", membertest->channel_name ) ; + + if (!basic_play_sound ( member->channel_name, "conf-onlyperson" )) + { + ast_log( LOG_ERROR, "playing conference welcome message FAILED\n" ) ; + } + } + else + { + if (!basic_play_sound ( membertest->channel_name, "enter" )) + { + ast_log( LOG_ERROR, "playing conference entry message FAILED on %s\n", membertest->channel_name ) ; + } + } + } + else + { + ast_log( LOG_NOTICE, "skipping all entry messages on %s\n", membertest->channel_name ) ; + } + + membertest = membertest->next; + } + + + + while ( 42 == 42 ) + { + // make sure we have a channel to process + if ( chan == NULL ) + { + ast_log( LOG_NOTICE, "member channel has closed\n" ) ; + break ; + } + + //-----------------// + // INCOMING FRAMES // + //-----------------// + + // wait for an event on this channel + left = ast_waitfor( chan, AST_CONF_WAITFOR_LATENCY ) ; + + // ast_log( AST_CONF_DEBUG, "received event on channel, name => %s, rest => %d\n", chan->name, rest ) ; + + if ( left < 0 ) + { + // an error occured + ast_log( + LOG_NOTICE, + "an error occured waiting for a frame, channel => %s, error => %d\n", + chan->name, left + ) ; + } + else if ( left == 0 ) + { + // no frame has arrived yet + // ast_log( LOG_NOTICE, "no frame available from channel, channel => %s\n", chan->name ) ; + } + else if ( left > 0 ) + { + // a frame has come in before the latency timeout + // was reached, so we process the frame + + f = ast_read( chan ) ; + + if ( f == NULL ) + { + ast_log( LOG_NOTICE, "unable to read from channel, channel => %s\n", chan->name ) ; + break ; + } + + // actually process the frame: break if we got hangup. + if(process_incoming(conf, member, f)) break; + + } + + //-----------------// + // OUTGOING FRAMES // + //-----------------// + + // update the current timestamps + gettimeofday( &curr, NULL ) ; + + process_outgoing(member); + + + // back to process incoming frames + continue ; + } + + ast_log( AST_CONF_DEBUG, "end member event loop, time_entered => %ld\n", member->time_entered.tv_sec ) ; + + // + // clean up + // + +#ifdef DEBUG_OUTPUT_PCM + // !!! TESTING !!! + if ( member->incoming_fh != NULL ) + fclose( member->incoming_fh ) ; +#endif + + if ( member != NULL ) member->remove_flag = 1 ; + +// gettimeofday( &end, NULL ) ; +// int expected_frames = ( int )( floor( (double)( usecdiff( &end, &start ) / AST_CONF_FRAME_INTERVAL ) ) ) ; +// ast_log( AST_CONF_DEBUG, "expected_frames => %d\n", expected_frames ) ; + + return -1 ; +} + +// basic sound playing function +int basic_play_sound ( char *channel, char *file ) +{ +// char *channel, *file; + struct ast_conf_member *play_member; + struct ast_conf_soundq *newsound; + struct ast_conf_soundq **q; + + play_member = find_member(channel, 1); + if(!play_member) { + ast_log( LOG_ERROR, "Member %s not found\n", channel) ; + return 0; + } + + newsound = calloc(1,sizeof(struct ast_conf_soundq)); + newsound->stream = ast_openstream(play_member->chan, file, NULL); + if(!newsound->stream) { + free(newsound); + ast_mutex_unlock(&play_member->lock); + ast_log( LOG_ERROR, "sound file not found\n" ) ; + } + play_member->chan->stream = NULL; + + ast_copy_string(newsound->name, file, sizeof(newsound->name)); + + // append sound to the end of the list. + for(q=&play_member->soundq; *q; q = &((*q)->next)) ;; + + *q = newsound; + + ast_mutex_unlock(&play_member->lock); + + ast_log( LOG_NOTICE, "playing conference message %s\n", file ) ; + return 1; +} + +// +// manange member functions +// + +struct ast_conf_member* create_member( struct ast_channel *chan, const char* data ) +{ + // + // check input + // + + if ( chan == NULL ) + { + ast_log( LOG_ERROR, "unable to create member with null channel\n" ) ; + return NULL ; + } + + if ( chan->name == NULL ) + { + ast_log( LOG_ERROR, "unable to create member with null channel name\n" ) ; + return NULL ; + } + + // + // allocate memory for new conference member + // + + struct ast_conf_member *member = calloc( 1, sizeof( struct ast_conf_member ) ) ; + + if ( member == NULL ) + { + ast_log( LOG_ERROR, "unable to malloc ast_conf_member\n" ) ; + return NULL ; + } + + // initialize mutex + ast_mutex_init( &member->lock ) ; + + // + // initialize member with passed data values + // + + char argstr[80] ; + char *stringp, *token ; + + // copy the passed data + strncpy( argstr, data, sizeof(argstr) - 1 ) ; + + // point to the copied data + stringp = argstr ; + + ast_log( AST_CONF_DEBUG, "attempting to parse passed params, stringp => %s\n", stringp ) ; + + // parse the id + if ( ( token = strsep( &stringp, "|" ) ) != NULL ) + { + member->id = malloc( strlen( token ) + 1 ) ; + strcpy( member->id, token ) ; + } + else + { + ast_log( LOG_ERROR, "unable to parse member id\n" ) ; + free( member ) ; + return NULL ; + } + + // parse the flags + if ( ( token = strsep( &stringp, "|" ) ) != NULL ) + { + member->flags = malloc( strlen( token ) + 1 ) ; + strcpy( member->flags, token ) ; + } + else + { + // make member->flags something + member->flags = malloc( sizeof( char ) ) ; + memset( member->flags, 0x0, sizeof( char ) ) ; + } + + // parse the priority + member->priority = ( token = strsep( &stringp, "|" ) ) != NULL + ? atoi( token ) + : 0 + ; + + // parse the vad_prob_start + member->vad_prob_start = ( token = strsep( &stringp, "|" ) ) != NULL + ? atof( token ) + : AST_CONF_PROB_START + ; + + // parse the vad_prob_continue + member->vad_prob_continue = ( token = strsep( &stringp, "|" ) ) != NULL + ? atof( token ) + : AST_CONF_PROB_CONTINUE + ; + + // parse the expected frame size, in samples. ?? + + + // debugging + ast_log( + AST_CONF_DEBUG, + "parsed data params, id => %s, flags => %s, priority => %d, vad_prob_start => %f, vad_prob_continue => %f\n", + member->id, member->flags, member->priority, member->vad_prob_start, member->vad_prob_continue + ) ; + + // + // initialize member with default values + // + + // keep pointer to member's channel + member->chan = chan ; + + // copy the channel name + member->channel_name = malloc( strlen( chan->name ) + 1 ) ; + strcpy( member->channel_name, chan->name ) ; + + // ( default can be overridden by passed flags ) +// member->type = 'L' ; + member->type = 'S' ; + + // ready flag + member->ready_for_outgoing = 0 ; + + // incoming frame queue + member->inFrames = NULL ; + member->inFramesTail = NULL ; + member->inFramesCount = 0 ; + + // last frame caching + member->inFramesRepeatLast = 0 ; + member->inFramesLast = NULL ; + member->okayToCacheLast = 0 ; + + // outgoing frame queue + member->outFrames = NULL ; + member->outFramesTail = NULL ; + member->outFramesCount = 0 ; + + member->outPacker = NULL; + + // ( not currently used ) + // member->samplesperframe = AST_CONF_BLOCK_SAMPLES ; + + // used for determining need to mix frames + // and for management interface notification + member->speaking_state_prev = 0 ; + member->speaking_state_notify = 0 ; + member->speaking_state = 0 ; + + // linked-list pointer + member->next = NULL ; + + // account data + member->frames_in = 0 ; + member->frames_in_dropped = 0 ; + member->frames_out = 0 ; + member->frames_out_dropped = 0 ; + + // for counting sequentially dropped frames + member->sequential_drops = 0 ; + member->since_dropped = 0 ; + + // flags + member->remove_flag = 0 ; + + // record start time + gettimeofday( &member->time_entered, NULL ) ; + + // init dropped frame timestamps + gettimeofday( &member->last_in_dropped, NULL ) ; + gettimeofday( &member->last_out_dropped, NULL ) ; + + // + // parse passed flags + // + + // silence detection flags w/ defaults + int vad_flag = 0 ; + int denoise_flag = 0 ; + int agc_flag = 0 ; + + // is this member using the telephone? + int via_telephone = 0 ; + + // temp pointer to flags string + // char* flags = member->flags ; + char* flags = member->flags ; + int i; + for ( i = 0 ; i < strlen( flags ) ; ++i ) + { + // allowed flags are M, L, S, V, D, A + switch ( flags[i] ) + { + // call via telephone + case 'T': + via_telephone = 1 ; + break ; + + // member types ( last flag wins ) + case 'M': + member->type = 'M' ; + break ; + case 'L': + member->type = 'L' ; + break ; + case 'S': + member->type = 'S' ; + break ; + + // speex preprocessing options + case 'V': + vad_flag = 1 ; + break ; + case 'D': + denoise_flag = 1 ; + break ; + case 'A': + agc_flag = 1 ; + break ; + + // additional features + case 'd': // Send DTMF manager events.. + member->send_dtmf = 1; + break; + case 'q': // Quiet entry and exit from conference + member->quiet_entry_exit = 1; + break; + case 'i': // use Inband DTMF broadcast + member->inband_dtmf = 1; + break; + case 't': // use RFC DTMF broadcast + member->rfc_dtmf = 1; + break; + + default: + ast_log( LOG_WARNING, "received invalid flag, chan => %s, flag => %c\n", + chan->name, flags[i] ) ; + break ; + } + } + + // set the dsp to null so silence detection is disabled by default + member->dsp = NULL ; + +#if ( SILDET == 2 ) + // + // configure silence detection and preprocessing + // if the user is coming in via the telephone, + // and is not listen-only + // + if ( + via_telephone == 1 + && member->type != 'L' + ) + { + // create a speex preprocessor + member->dsp = speex_preprocess_state_init( AST_CONF_BLOCK_SAMPLES, AST_CONF_SAMPLE_RATE ) ; + + if ( member->dsp == NULL ) + { + ast_log( LOG_WARNING, "unable to initialize member dsp, channel => %s\n", chan->name ) ; + } + else + { + ast_log( LOG_NOTICE, "member dsp initialized, channel => %s, v => %d, d => %d, a => %d\n", + chan->name, vad_flag, denoise_flag, agc_flag ) ; + + // set speex preprocessor options + speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_VAD, &vad_flag ) ; + speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_DENOISE, &denoise_flag ) ; + speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_AGC, &agc_flag ) ; + + speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_PROB_START, &member->vad_prob_start ) ; + speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_PROB_CONTINUE, &member->vad_prob_continue ) ; + + ast_log( AST_CONF_DEBUG, "speech_prob_start => %f, speech_prob_continue => %f\n", + member->dsp->speech_prob_start, member->dsp->speech_prob_continue ) ; + } + } +#endif + + // + // set connection type + // + + if ( via_telephone == 1 ) + { + member->connection_type = 'T' ; + } + else if ( strncmp( member->channel_name, "SIP", 3 ) == 0 ) + { + member->connection_type = 'S' ; + } + else // default to iax + { + member->connection_type = 'X' ; + } + + // + // read, write, and translation options + // + + // set member's audio formats, taking dsp preprocessing into account + // ( chan->nativeformats, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, AST_FORMAT_GSM ) + member->read_format = ( member->dsp == NULL ) ? chan->nativeformats : AST_FORMAT_SLINEAR ; + member->write_format = chan->nativeformats ; + + // translation paths ( ast_translator_build_path() returns null if formats match ) + member->to_slinear = ast_translator_build_path( AST_FORMAT_SLINEAR, member->read_format ) ; + member->from_slinear = ast_translator_build_path( member->write_format, AST_FORMAT_SLINEAR ) ; + + //ast_log( AST_CONF_DEBUG, "AST_FORMAT_SLINEAR => %d\n", AST_FORMAT_SLINEAR ) ; + + // index for converted_frames array + { + int format, index; + index=-1; + format = member->write_format; + while( format > 0){ + index++; + format = format >> 1; + } + member->write_format_index= index; + //ast_log( AST_CONF_DEBUG, "converted write_format [%d] to index[%d]\n", member->write_format, index ); + + index=-1; + format = member->read_format; + while( format > 0){ + index++; + format = format >> 1; + } + member->read_format_index=index; + //ast_log( AST_CONF_DEBUG, "converted read_format [%d] to index[%d]\n", member->read_format, index ); + } + + // smoother defaults. + member->smooth_multiple =1; + member->smooth_size_in = -1; + member->smooth_size_out = -1; + member->inSmoother= NULL; + member->outPacker= NULL; + + switch (member->read_format){ + /* these assumptions may be incorrect */ + case AST_FORMAT_ULAW: + case AST_FORMAT_ALAW: + /* + member->smooth_size_in = 160; //bytes + member->smooth_size_out = 160; //samples + */ + break; + case AST_FORMAT_GSM: + /* + member->smooth_size_in = 33; //bytes + member->smooth_size_out = 160;//samples + */ + break; + case AST_FORMAT_SPEEX: + /* this assumptions are wrong + member->smooth_multiple = 2 ; // for testing, force to dual frame + member->smooth_size_in = 39; // bytes + member->smooth_size_out = 160; // samples + */ + break; + case AST_FORMAT_SLINEAR: + /* + member->smooth_size_in = 320; //bytes + member->smooth_size_out = 160; //samples + */ + break; + default: + member->inSmoother = NULL; //don't use smoother for this type. + //ast_log( AST_CONF_DEBUG, "smoother is NULL for member->read_format => %d\n", member->read_format); + } + if (member->smooth_size_in > 0){ + member->inSmoother = ast_smoother_new(member->smooth_size_in); + //ast_log( AST_CONF_DEBUG, "created smoother(%d) for %d\n", member->smooth_size_in , member->read_format); + } + + + // + // finish up + // + + ast_log( AST_CONF_DEBUG, "created member, type => %c, priority => %d, readformat => %d\n", + member->type, member->priority, chan->readformat ) ; + + return member ; +} + +struct ast_conf_member* delete_member( struct ast_conf_member* member ) +{ + // !!! NO RETURN TEST !!! + // do { sleep(1) ; } while (1) ; + + // !!! CRASH TEST !!! + // *((int *)0) = 0; + + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to the delete null member\n" ) ; + return NULL ; + } + + // + // clean up member flags + // + + if ( member->flags != NULL ) + { + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "freeing member flags, name => %s\n", + member->channel_name ) ; + free( member->flags ) ; + } + + // + // delete the members frames + // + + conf_frame* cf ; + + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "deleting member input frames, name => %s\n", + member->channel_name ) ; + + // incoming frames + cf = member->inFrames ; + + while ( cf != NULL ) + { + cf = delete_conf_frame( cf ) ; + } + if (member->inSmoother != NULL) + ast_smoother_free(member->inSmoother); + + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "deleting member output frames, name => %s\n", + member->channel_name ) ; + + // outgoing frames + cf = member->outFrames ; + + while ( cf != NULL ) + { + cf = delete_conf_frame( cf ) ; + } + + if (member->outPacker != NULL) + ast_packer_free(member->outPacker); + + +#if ( SILDET == 2 ) + if ( member->dsp != NULL ) + { + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "destroying member preprocessor, name => %s\n", + member->channel_name ) ; + speex_preprocess_state_destroy( member->dsp ) ; + } +#endif + + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "freeing member translator paths, name => %s\n", + member->channel_name ) ; + + // free the mixing translators + ast_translator_free_path( member->to_slinear ) ; + ast_translator_free_path( member->from_slinear ) ; + + // get a pointer to the next + // member so we can return it + struct ast_conf_member* nm = member->next ; + + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "freeing member channel name, name => %s\n", + member->channel_name ) ; + + // free the member's copy for the channel name + free( member->channel_name ) ; + + // !!! DEBUGING !!! + ast_log( AST_CONF_DEBUG, "freeing member\n" ) ; + + // free the member's memory + free( member ) ; + member = NULL ; + + return nm ; +} + +// +// incoming frame functions +// + +conf_frame* get_incoming_frame( struct ast_conf_member *member ) +{ + // + // sanity checks + // + + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to get frame from null member\n" ) ; + return NULL ; + } + + // + // repeat last frame a couple times to smooth transition + // + +#ifdef AST_CONF_CACHE_LAST_FRAME + if ( member->inFramesCount == 0 ) + { + // nothing to do if there's no cached frame + if ( member->inFramesLast == NULL ) + return NULL ; + + // turn off 'okay to cache' flag + member->okayToCacheLast = 0 ; + + if ( member->inFramesRepeatLast >= AST_CONF_CACHE_LAST_FRAME ) + { + // already used this frame AST_CONF_CACHE_LAST_FRAME times + + // reset repeat count + member->inFramesRepeatLast = 0 ; + + // clear the cached frame + delete_conf_frame( member->inFramesLast ) ; + member->inFramesLast = NULL ; + + // return null + return NULL ; + } + else + { + ast_log( AST_CONF_DEBUG, "repeating cached frame, channel => %s, inFramesRepeatLast => %d\n", + member->channel_name, member->inFramesRepeatLast ) ; + + // increment counter + member->inFramesRepeatLast++ ; + + // return a copy of the cached frame + return copy_conf_frame( member->inFramesLast ) ; + } + } + else if ( member->okayToCacheLast == 0 && member->inFramesCount >= 3 ) + { + ast_log( AST_CONF_DEBUG, "enabling cached frame, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount ) ; + + // turn on 'okay to cache' flag + member->okayToCacheLast = 1 ; + } +#else + if ( member->inFramesCount == 0 ) + return NULL ; +#endif // AST_CONF_CACHE_LAST_FRAME + + // + // return the next frame in the queue + // + + conf_frame* cfr = NULL ; + + // get first frame in line + cfr = member->inFramesTail ; + + // if it's the only frame, reset the queue, + // else, move the second frame to the front + if ( member->inFramesTail == member->inFrames ) + { + member->inFramesTail = NULL ; + member->inFrames = NULL ; + } + else + { + // move the pointer to the next frame + member->inFramesTail = member->inFramesTail->prev ; + + // reset it's 'next' pointer + if ( member->inFramesTail != NULL ) + member->inFramesTail->next = NULL ; + } + + // separate the conf frame from the list + cfr->next = NULL ; + cfr->prev = NULL ; + + // decriment frame count + member->inFramesCount-- ; + +#ifdef AST_CONF_CACHE_LAST_FRAME + // copy frame if queue is now empty + if ( + member->inFramesCount == 0 + && member->okayToCacheLast == 1 + ) + { + // reset repeat count + member->inFramesRepeatLast = 0 ; + + // clear cached frame + if ( member->inFramesLast != NULL ) + { + delete_conf_frame( member->inFramesLast ) ; + member->inFramesLast = NULL ; + } + + // cache new frame + member->inFramesLast = copy_conf_frame( cfr ) ; + } +#endif // AST_CONF_CACHE_LAST_FRAME + + return cfr ; +} + +int queue_incoming_frame( struct ast_conf_member* member, struct ast_frame* fr ) +{ + // + // sanity checks + // + + // check on frame + if ( fr == NULL ) + { + ast_log( LOG_ERROR, "unable to queue null frame\n" ) ; + return -1 ; + } + + // check on member + if ( member == NULL ) + { + ast_log( LOG_ERROR, "unable to queue frame for null member\n" ) ; + return -1 ; + } + + // + // drop a frame if we've filled half the buffer + // ( no more than once per AST_CONF_QUEUE_DROP_TIME_LIMIT ms ) + // + + + /* +ast_log( + AST_CONF_DEBUG, + "queue frame on channel => %s, fr->subclass => %d, fr->datalen => %d, fr->samples => %d\n", + member->channel_name, fr->subclass, fr->datalen, fr->samples +) ; +*/ + + + if ( member->inFramesCount > member->inFramesNeeded ) + { + if ( member->inFramesCount > AST_CONF_QUEUE_DROP_THRESHOLD ) + { + struct timeval curr ; + gettimeofday( &curr, NULL ) ; + + // time since last dropped frame + long diff = usecdiff( &curr, &member->last_in_dropped ) ; + + // number of milliseconds which must pass between frame drops + // ( 15 frames => -100ms, 10 frames => 400ms, 5 frames => 900ms, 0 frames => 1400ms, etc. ) + long time_limit = 1000 - ( ( member->inFramesCount - AST_CONF_QUEUE_DROP_THRESHOLD ) * 100 ) ; + + if ( diff >= time_limit ) + { + // count sequential drops + member->sequential_drops++ ; + + // ast_log( + // AST_CONF_DEBUG, + // "dropping frame from input buffer, channel => %s, incoming => %d, outgoing => %d\n", + // member->channel_name, member->inFramesCount, member->outFramesCount + // ) ; + + // accounting: count dropped incoming frames + member->frames_in_dropped++ ; + + // reset frames since dropped + member->since_dropped = 0 ; + + // delete the frame + delete_conf_frame( get_incoming_frame( member ) ) ; + + gettimeofday( &member->last_in_dropped, NULL ) ; + } + else + { +/* + ast_log( + AST_CONF_DEBUG, + "input buffer larger than drop threshold, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount + ) ; +*/ + } + } + } + + // + // if we have to drop frames, we'll drop new frames + // because it's easier ( and doesn't matter much anyway ). + // + + if ( member->inFramesCount >= AST_CONF_MAX_QUEUE ) + { + // count sequential drops + member->sequential_drops++ ; + + ast_log( + AST_CONF_DEBUG, + "unable to queue incoming frame, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount + ) ; + + // accounting: count dropped incoming frames + member->frames_in_dropped++ ; + + // reset frames since dropped + member->since_dropped = 0 ; + + return -1 ; + } + + // reset sequential drops + member->sequential_drops = 0 ; + + // increment frames since dropped + member->since_dropped++ ; + + // + // create new conf frame from passed data frame + // + + // ( member->inFrames may be null at this point ) + if (member->inSmoother == NULL ){ + conf_frame* cfr = create_conf_frame( member, member->inFrames, fr ) ; + if ( cfr == NULL ) + { + ast_log( LOG_ERROR, "unable to malloc conf_frame\n" ) ; + return -1 ; + } + + // + // add new frame to speaking members incoming frame queue + // ( i.e. save this frame data, so we can distribute it in conference_exec later ) + // + + if ( member->inFrames == NULL ) { + member->inFramesTail = cfr ; + } + member->inFrames = cfr ; + member->inFramesCount++ ; + } else { + //feed frame(fr) into the smoother + + // smoother tmp frame + struct ast_frame *sfr; + int multiple = 1; + int i=0; + + if ( (member->smooth_size_in > 0 ) && (member->smooth_size_in * member->smooth_multiple != fr->datalen) ) + { + //ast_log(AST_CONF_DEBUG,"resetting smooth_size_in. old size=> %d, multiple =>%d, datalen=> %d\n", member->smooth_size_in, member->smooth_multiple, fr->datalen ); + if ( fr->datalen % member->smooth_multiple != 0) { + // if datalen not divisible by smooth_multiple, assume we're just getting normal encoding. + // ast_log(AST_CONF_DEBUG,"smooth_multiple does not divide datalen. changing smooth size from %d to %d, multiple => 1\n", member->smooth_size_in, fr->datalen); + member->smooth_size_in = fr->datalen; + member->smooth_multiple = 1; + } else { + // assume a fixed multiple, so divide into datalen. + int newsmooth = fr->datalen / member->smooth_multiple ; + // ast_log(AST_CONF_DEBUG,"datalen is divisible by smooth_multiple, changing smooth size from %d to %d\n", member->smooth_size_in, newsmooth); + member->smooth_size_in = newsmooth; + } + + //free input smoother. + if (member->inSmoother != NULL) + ast_smoother_free(member->inSmoother); + + //make new input smoother. + member->inSmoother = ast_smoother_new(member->smooth_size_in); + } + + ast_smoother_feed( member->inSmoother, fr ); +//ast_log (AST_CONF_DEBUG, "SMOOTH:Feeding frame into inSmoother, timestamp => %ld.%ld\n", fr->delivery.tv_sec, fr->delivery.tv_usec); + + if ( multiple > 1 ) + fr->samples /= multiple; + + // read smoothed version of frames, add to queue + while( ( sfr = ast_smoother_read( member->inSmoother ) ) ){ + + ++i; +//ast_log( AST_CONF_DEBUG , "\treading new frame [%d] from smoother, inFramesCount[%d], \n\tsfr->frametype -> %d , sfr->subclass -> %d , sfr->datalen => %d sfr->samples => %d\n", i , member->inFramesCount , sfr->frametype, sfr->subclass, sfr->datalen, sfr->samples); +//ast_log (AST_CONF_DEBUG, "SMOOTH:Reading frame from inSmoother, i=>%d, timestamp => %ld.%ld\n",i, sfr->delivery.tv_sec, sfr->delivery.tv_usec); + conf_frame* cfr = create_conf_frame( member, member->inFrames, sfr ) ; + if ( cfr == NULL ) + { + ast_log( LOG_ERROR, "unable to malloc conf_frame\n" ) ; + return -1 ; + } + + // + // add new frame to speaking members incoming frame queue + // ( i.e. save this frame data, so we can distribute it in conference_exec later ) + // + + if ( member->inFrames == NULL ) { + member->inFramesTail = cfr ; + } + member->inFrames = cfr ; + member->inFramesCount++ ; + } + } + + return 0 ; +} + +// +// outgoing frame functions +// + +conf_frame* get_outgoing_frame( struct ast_conf_member *member ) +{ + if ( member == NULL ) + { + ast_log( LOG_WARNING, "unable to get frame from null member\n" ) ; + return NULL ; + } + + conf_frame* cfr ; + + // ast_log( AST_CONF_DEBUG, "getting member frames, count => %d\n", member->outFramesCount ) ; + + if ( member->outFramesCount > AST_CONF_MIN_QUEUE ) + { + cfr = member->outFramesTail ; + + // if it's the only frame, reset the queu, + // else, move the second frame to the front + if ( member->outFramesTail == member->outFrames ) + { + member->outFrames = NULL ; + member->outFramesTail = NULL ; + } + else + { + // move the pointer to the next frame + member->outFramesTail = member->outFramesTail->prev ; + + // reset it's 'next' pointer + if ( member->outFramesTail != NULL ) + member->outFramesTail->next = NULL ; + } + + // separate the conf frame from the list + cfr->next = NULL ; + cfr->prev = NULL ; + + // decriment frame count + member->outFramesCount-- ; + + return cfr ; + } + + return NULL ; +} + +int __queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) +{ + // accounting: count the number of outgoing frames for this member + member->frames_out++ ; + +/* + // + // drop a frame if we've filled half the buffer + // + + if ( member->outFramesCount > AST_CONF_QUEUE_DROP_THRESHOLD ) + { + struct timeval curr ; + gettimeofday( &curr, NULL ) ; + + long diff = usecdiff( &curr, &member->last_out_dropped ) ; + + if ( diff >= AST_CONF_QUEUE_DROP_TIME_LIMIT ) + { + ast_log( + AST_CONF_DEBUG, + "dropping frame from output buffer, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount + ) ; + + // accounting: count dropped outgoing frames + member->frames_out_dropped++ ; + + // delete the frame + delete_conf_frame( get_outgoing_frame( member ) ) ; + + gettimeofday( &member->last_out_dropped, NULL ) ; + } + } +*/ + + // + // we have to drop frames, so we'll drop new frames + // because it's easier ( and doesn't matter much anyway ). + // + if ( member->outFramesCount >= AST_CONF_MAX_QUEUE ) + { + ast_log( + AST_CONF_DEBUG, + "unable to queue outgoing frame, channel => %s, incoming => %d, outgoing => %d\n", + member->channel_name, member->inFramesCount, member->outFramesCount + ) ; + + // accounting: count dropped outgoing frames + member->frames_out_dropped++ ; + + return -1 ; + } + + // + // create new conf frame from passed data frame + // + + conf_frame* cfr = create_conf_frame( member, member->outFrames, fr ) ; + + if ( cfr == NULL ) + { + ast_log( LOG_ERROR, "unable to create new conf frame\n" ) ; + + // accounting: count dropped outgoing frames + member->frames_out_dropped++ ; + + return -1 ; + } + + // set delivery timestamp + cfr->fr->delivery = delivery ; + + // + // add new frame to speaking members incoming frame queue + // ( i.e. save this frame data, so we can distribute it in conference_exec later ) + // + + if ( member->outFrames == NULL ) { + member->outFramesTail = cfr ; + } + member->outFrames = cfr ; + member->outFramesCount++ ; + + // return success + return 0 ; +} + +int queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) +{ + // check on frame + if ( fr == NULL ) + { + ast_log( LOG_ERROR, "unable to queue null frame\n" ) ; + return -1 ; + } + + // check on member + if ( member == NULL ) + { + ast_log( LOG_ERROR, "unable to queue frame for null member\n" ) ; + return -1 ; + } + + + if ( ( member->outPacker == NULL ) && ( member->smooth_multiple > 1 ) && ( member->smooth_size_out > 0 ) ){ + //ast_log (AST_CONF_DEBUG, "creating outPacker with size => %d \n\t( multiple => %d ) * ( size => %d )\n", member->smooth_multiple * member-> smooth_size_out, member->smooth_multiple , member->smooth_size_out); + member->outPacker = ast_packer_new( member->smooth_multiple * member->smooth_size_out); + } + + if (member->outPacker == NULL ){ + return __queue_outgoing_frame( member, fr, delivery ) ; + } + else + { + struct ast_frame *sfr; + int exitval = 0; +//ast_log (AST_CONF_DEBUG, "sending fr into outPacker, datalen=>%d, samples=>%d\n",fr->datalen, fr->samples); + ast_packer_feed( member->outPacker , fr ); + while( (sfr = ast_packer_read( member->outPacker ) ) ) + { +//ast_log (AST_CONF_DEBUG, "read sfr from outPacker, datalen=>%d, samples=>%d\n",sfr->datalen, sfr->samples); + if ( __queue_outgoing_frame( member, sfr, delivery ) == -1 ) { + exitval = -1; + } + } + return exitval; + } +} + +// +// manager functions +// + +void send_state_change_notifications( struct ast_conf_member* member ) +{ + // ast_log( AST_CONF_DEBUG, "sending state change notification\n" ) ; + + // loop through list of members, sending state changes + while ( member != NULL ) + { + // has the state changed since last time through this loop? + if ( member->speaking_state_notify != member->speaking_state_prev ) + { + manager_event( + EVENT_FLAG_CALL, + "ConferenceState", + "Channel: %s\r\n" + "State: %s\r\n", + member->channel_name, + ( ( member->speaking_state_notify == 1 ) ? "speaking" : "silent" ) + ) ; +#if 0 + ast_log( AST_CONF_DEBUG, "member state changed, channel => %s, state => %d, incoming => %d, outgoing => %d\n", + member->channel_name, member->speaking_state_notify, member->inFramesCount, member->outFramesCount ) ; +#endif + + // remember current state + member->speaking_state_prev = member->speaking_state_notify ; + + // we do not reset the speaking_state_notify flag here + } + + // reset notification flag so that + member->speaking_state_notify = 0 ; + + // move the pointer to the next member + member = member->next ; + } + + return ; +} + +// +// meta-info accessors functions +// + +short memberIsPhoneClient( struct ast_conf_member* member ) +{ + if ( member == NULL ) + return 0 ; + + return ( member->connection_type == 'T' ) ? 1 : 0 ; +} + +short memberIsIaxClient( struct ast_conf_member* member ) +{ + if ( member == NULL ) + return 0 ; + + return ( member->connection_type == 'X' ) ? 1 : 0 ; +} + +short memberIsSIPClient( struct ast_conf_member* member ) +{ + if ( member == NULL ) + return 0 ; + + return ( member->connection_type == 'S' ) ? 1 : 0 ; +} + +short memberIsModerator( struct ast_conf_member* member ) +{ + if ( member == NULL ) + return 0 ; + + return ( member->type == 'M' ) ? 1 : 0 ; +} + +short memberIsListener( struct ast_conf_member* member ) +{ + if ( member == NULL ) + return 0 ; + + return ( member->type == 'L' ) ? 1 : 0 ; +} + + +// +// ast_packer, adapted from ast_smoother +// pack multiple frames together into one packet on the wire. +// + +#define PACKER_SIZE 8000 +#define PACKER_QUEUE 10 // store at most 10 complete packets in the queue + +struct ast_packer { + int framesize; // number of frames per packet on the wire. + int size; + int packet_index; + int format; + int readdata; + int optimizablestream; + int flags; + float samplesperbyte; + struct ast_frame f; + struct timeval delivery; + char data[PACKER_SIZE]; + char framedata[PACKER_SIZE + AST_FRIENDLY_OFFSET]; + int samples; + int sample_queue[PACKER_QUEUE]; + int len_queue[PACKER_QUEUE]; + struct ast_frame *opt; + int len; +}; + +void ast_packer_reset(struct ast_packer *s, int framesize) +{ + memset(s, 0, sizeof(struct ast_packer)); + s->framesize = framesize; + s->packet_index=0; + s->len=0; +} + +struct ast_packer *ast_packer_new(int framesize) +{ + struct ast_packer *s; + if (framesize < 1) + return NULL; + s = malloc(sizeof(struct ast_packer)); + if (s) + ast_packer_reset(s, framesize); + return s; +} + +int ast_packer_get_flags(struct ast_packer *s) +{ + return s->flags; +} + +void ast_packer_set_flags(struct ast_packer *s, int flags) +{ + s->flags = flags; +} + +int ast_packer_feed(struct ast_packer *s, const struct ast_frame *f) +{ + if (f->frametype != AST_FRAME_VOICE) { + ast_log(LOG_WARNING, "Huh? Can't pack a non-voice frame!\n"); + return -1; + } + if (!s->format) { + s->format = f->subclass; + s->samples=0; + } else if (s->format != f->subclass) { + ast_log(LOG_WARNING, "Packer was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass); + return -1; + } + if (s->len + f->datalen > PACKER_SIZE) { + ast_log(LOG_WARNING, "Out of packer space\n"); + return -1; + } + if (s->packet_index >= PACKER_QUEUE ){ + ast_log(LOG_WARNING, "Out of packer queue space\n"); + return -1; + } + + memcpy(s->data + s->len, f->data, f->datalen); + /* If either side is empty, reset the delivery time */ + if (!s->len || (!f->delivery.tv_sec && !f->delivery.tv_usec) || + (!s->delivery.tv_sec && !s->delivery.tv_usec)) + s->delivery = f->delivery; + s->len += f->datalen; +//packer stuff + s->len_queue[s->packet_index] += f->datalen; + s->sample_queue[s->packet_index] += f->samples; + s->samples += f->samples; + + if (s->samples > s->framesize ) + ++s->packet_index; + + return 0; +} + +struct ast_frame *ast_packer_read(struct ast_packer *s) +{ + struct ast_frame *opt; + int len; + /* IF we have an optimization frame, send it */ + if (s->opt) { + opt = s->opt; + s->opt = NULL; + return opt; + } + + /* Make sure we have enough data */ + if (s->samples < s->framesize ){ + return NULL; + } + len = s->len_queue[0]; + if (len > s->len) + len = s->len; + /* Make frame */ + s->f.frametype = AST_FRAME_VOICE; + s->f.subclass = s->format; + s->f.data = s->framedata + AST_FRIENDLY_OFFSET; + s->f.offset = AST_FRIENDLY_OFFSET; + s->f.datalen = len; + s->f.samples = s->sample_queue[0]; + s->f.delivery = s->delivery; + /* Fill Data */ + memcpy(s->f.data, s->data, len); + s->len -= len; + /* Move remaining data to the front if applicable */ + if (s->len) { + /* In principle this should all be fine because if we are sending + G.729 VAD, the next timestamp will take over anyawy */ + memmove(s->data, s->data + len, s->len); + if (s->delivery.tv_sec || s->delivery.tv_usec) { + /* If we have delivery time, increment it, otherwise, leave it at 0 */ + s->delivery.tv_sec += s->sample_queue[0] / 8000.0; + s->delivery.tv_usec += (((int)(s->sample_queue[0])) % 8000) * 125; + if (s->delivery.tv_usec > 1000000) { + s->delivery.tv_usec -= 1000000; + s->delivery.tv_sec += 1; + } + } + } + int j; + s->samples -= s->sample_queue[0]; + if( s->packet_index > 0 ){ + for (j=0; jpacket_index -1 ; j++){ + s->len_queue[j]=s->len_queue[j+1]; + s->sample_queue[j]=s->sample_queue[j+1]; + } + s->len_queue[s->packet_index]=0; + s->sample_queue[s->packet_index]=0; + s->packet_index--; + } else { + s->len_queue[0]=0; + s->sample_queue[0]=0; + } + + + /* Return frame */ + return &s->f; +} + +void ast_packer_free(struct ast_packer *s) +{ + free(s); +} diff --git a/agc_2-X/trunk/app_conference/member.h b/agc_2-X/trunk/app_conference/member.h new file mode 100644 index 00000000..3a1fa4bf --- /dev/null +++ b/agc_2-X/trunk/app_conference/member.h @@ -0,0 +1,212 @@ + +// $Id: member.h,v 1.7 2005/11/02 22:42:42 stevek Exp $ + +/* + * app_conference + * + * A channel independent conference application for Asterisk + * + * Copyright (C) 2002, 2003 Junghanns.NET GmbH + * Copyright (C) 2003-2005 HorizonLive.com, Inc. + * + * Klaus-Peter Junghanns + * Steve Kann + * + * This program may be modified and distributed under the + * terms of the GNU Public License. + * + */ + +#ifndef _APP_CONF_MEMBER_H +#define _APP_CONF_MEMBER_H + +// +// includes +// + +#include "app_conference.h" +#include "common.h" +#include "asterisk/app.h" + + +// +// struct declarations +// + +struct ast_conf_soundq +{ + char name[256]; + struct ast_filestream *stream; // the stream + int muted; // should incoming audio be muted while we play? + struct ast_conf_soundq *next; +}; + +struct ast_conf_member +{ + ast_mutex_t lock ; // member data mutex + + struct ast_channel* chan ; // member's channel + char* channel_name ; // member's channel name + + // values passed to create_member () via *data + int priority ; // highest priority gets the channel + char* flags ; // raw member-type flags + char type ; // L = ListenOnly, M = Moderator, S = Standard (Listen/Talk) + char* id ; // member id + + // determine by flags and channel name + char connection_type ; // T = telephone, X = iaxclient, S = sip + + // vad voice probability thresholds + float vad_prob_start ; + float vad_prob_continue ; + + // ready flag + short ready_for_outgoing ; + + // input frame queue + conf_frame* inFrames ; + conf_frame* inFramesTail ; + unsigned int inFramesCount ; + + // input/output smoother + struct ast_smoother *inSmoother; + struct ast_packer *outPacker; + int smooth_size_in; + int smooth_size_out; + int smooth_multiple; + + // frames needed by conference_exec + unsigned int inFramesNeeded ; + + // used when caching last frame + conf_frame* inFramesLast ; + unsigned int inFramesRepeatLast ; + unsigned short okayToCacheLast ; + + // output frame queue + conf_frame* outFrames ; + conf_frame* outFramesTail ; + unsigned int outFramesCount ; + + // time we last dropped a frame + struct timeval last_in_dropped ; + struct timeval last_out_dropped ; + + // ( not currently used ) + // int samplesperframe ; + + // used for determining need to mix frames + // and for management interface notification + short speaking_state_prev ; + short speaking_state_notify ; + short speaking_state ; + + // pointer to next member in single-linked list + struct ast_conf_member* next ; + + // accounting values + unsigned long frames_in ; + unsigned long frames_in_dropped ; + unsigned long frames_out ; + unsigned long frames_out_dropped ; + + // for counting sequentially dropped frames + unsigned int sequential_drops ; + unsigned long since_dropped ; + + // start time + struct timeval time_entered ; + struct timeval lastsent_timeval ; + + // flag indicating we should remove this member + short remove_flag ; + +#if ( SILDET == 2 ) + // pointer to speex preprocessor dsp + SpeexPreprocessState *dsp ; + // number of frames to ignore speex_preprocess() + int ignore_speex_count; +#else + // placeholder when preprocessing is not enabled + void* dsp ; +#endif + + // audio format this member is using + int write_format ; + int read_format ; + + int write_format_index ; + int read_format_index ; + + // member frame translators + struct ast_trans_pvt* to_slinear ; + struct ast_trans_pvt* from_slinear ; + + // For playing sounds + struct ast_conf_soundq *soundq; + +#ifdef DEBUG_OUTPUT_PCM + FILE *incoming_fh; +#endif + + int send_dtmf:1; + int quiet_entry_exit:1; + int inband_dtmf:1; + int rfc_dtmf:1; +} ; + +struct conf_member +{ + struct ast_conf_member* realmember ; + struct conf_member* next ; +} ; + +// +// function declarations +// + +int member_exec( struct ast_channel* chan, void* data ) ; + +int basic_play_sound ( char *channel, char *file ) ; + +struct ast_conf_member* create_member( struct ast_channel* chan, const char* data ) ; +struct ast_conf_member* delete_member( struct ast_conf_member* member ) ; + +// incoming queue +int queue_incoming_frame( struct ast_conf_member* member, struct ast_frame* fr ) ; +conf_frame* get_incoming_frame( struct ast_conf_member* member ) ; + +// outgoing queue +int queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ; +int __queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ; +conf_frame* get_outgoing_frame( struct ast_conf_member* member ) ; + +void send_state_change_notifications( struct ast_conf_member* member ) ; + +// +// meta-info accessors functions +// + +short memberIsPhoneClient( struct ast_conf_member* member ) ; +short memberIsIaxClient( struct ast_conf_member* member ) ; +short memberIsSIPClient( struct ast_conf_member* member ) ; + +short memberIsModerator( struct ast_conf_member* member ) ; +short memberIsListener( struct ast_conf_member* member ) ; + +// +// packer functions +// + +struct ast_packer; + +extern struct ast_packer *ast_packer_new(int bytes); +extern void ast_packer_set_flags(struct ast_packer *packer, int flags); +extern int ast_packer_get_flags(struct ast_packer *packer); +extern void ast_packer_free(struct ast_packer *s); +extern void ast_packer_reset(struct ast_packer *s, int bytes); +extern int ast_packer_feed(struct ast_packer *s, const struct ast_frame *f); +extern struct ast_frame *ast_packer_read(struct ast_packer *s); + +#endif diff --git a/agc_2-X/trunk/app_conference/star.gsm b/agc_2-X/trunk/app_conference/star.gsm new file mode 100644 index 00000000..5ec8908e --- /dev/null +++ b/agc_2-X/trunk/app_conference/star.gsm @@ -0,0 +1,2 @@ +:nPSat֪j*PR6۞D IDCtb LICENSE: GPLv2 +# + +$DB = 1; # set to 1 for debug mode + +use lib ".\\",".\\libs", './', './libs', '../libs', '/usr/local/perl_TK/libs', 'C:\\AST_VICI\\libs'; +use English; +use Tk; +use POSIX; +use Tk::BrowseEntry; +use Time::Local; +use Time::HiRes ('gettimeofday','usleep','sleep'); # needed to have perl sleep in increments of less than one second +use Net::MySQL; + + +sub SetDelimiter; +sub SetFieldValue; +sub SetFields; +sub ErrorCheckOptions; +sub CheckUserDefinedData; +sub ProcessFile; +sub CheckTitle; +sub CheckFirstName; +sub CheckLastName; +sub CheckPhone; +sub CheckAreaCode; +sub CheckAddress; +sub CheckZip; +sub CheckState; +sub CheckDateofBirth; +sub FormatRecord; + +### Make sure this file is in a libs path or put the absolute path to it +require("AST_VICI_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +sub idcheck_connect; + +&idcheck_connect; ### connect and define custom variables + + +if ($DB) {print STDERR "DEBUG MODE\n";} + +my $MW = new MainWindow( + -background => '#CCCCCC', + -title => 'astLEADLOADER.pl 0.1' +); + +$|=1; + + $dbh = Net::MySQL->new(hostname => "$DBX_server", database => "$DBX_database", user => "$DBX_user", password => "$DBX_pass", port => "$DBX_port") + or die "Couldn't connect to database: $DBX_server - $DBX_database\n"; + +############################ +# GLOBAL VARIABLES # +############################ +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +$yr18=$year-18; +if ($sec < 10) {$sec = "0$sec";} +if ($min < 10) {$min = "0$min";} +if ($hour < 10) {$hour = "0$hour";} +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} + +$timestamp=time(); + +$under18=$yr18.$mon.$mday; # Comes into play MUCH further down. + +undef $wday; undef $yday; undef $isdst; +# Use date_entered if/when list is going to be inserted into vicidial_lists table +#$date_entered="$year-$mon-$mday"; +$error_message=""; + +# $quantity="1"; +$good_records=0; +$bad_records=0; +$total_records=0; +$no_fields=0; + +$fields{"vendor_lead_code"}=99; +$fields{"source_id"}=99; +#$fields{"list_id"}=99; +#$fields{"campaign_id"}=99; +$fields{"phone_number"}=99; +$fields{"title"}=99; +$fields{"first_name"}=99; +$fields{"middle_initial"}=99; +$fields{"last_name"}=99; +$fields{"address1"}=99; +$fields{"address2"}=99; +$fields{"address3"}=99; +$fields{"city"}=99; +$fields{"state"}=99; +$fields{"province"}=99; +$fields{"postal_code"}=99; +$fields{"gender"}=99; +$fields{"date_of_birth"}=99; +$fields{"alt_phone"}=99; +$fields{"email"}=99; +$fields{"security_phrase"}=99; +$fields{"comments"}=99; + +$dobmask="yyyy-mm-dd"; + +open(ZIPCODE_INFO, "< US_zipcode_ranges.txt"); +$i=0; +while ($buffer=) { + @state_ary=split(/\|/, $buffer); + $us_zc_ary[$i][0]=$state_ary[0]; + $us_zc_ary[$i][1]=$state_ary[1]; + $us_zc_ary[$i][2]=$state_ary[2]; + $i++; +} +close(ZIPCODE_INFO); + +open(ZIPCODE_INFO2, "< AUS_zipcode_ranges.txt"); +$i=0; +while ($buffer=) { + @aus_state_ary=split(/\|/, $buffer); + $aus_zc_ary[$i][0]=$aus_state_ary[0]; + $aus_zc_ary[$i][1]=$aus_state_ary[1]; + $aus_zc_ary[$i][2]=$aus_state_ary[2]; + $i++; +} +close(ZIPCODE_INFO2); + +$provinces{"A"}="NL"; +$provinces{"B"}="NS"; +$provinces{"C"}="PE"; +$provinces{"E"}="NB"; +$provinces{"G"}="QC"; +$provinces{"H"}="QC"; +$provinces{"J"}="QC"; +$provinces{"K"}="ON"; +$provinces{"L"}="ON"; +$provinces{"M"}="ON"; +$provinces{"N"}="ON"; +$provinces{"P"}="ON"; +$provinces{"R"}="MB"; +$provinces{"S"}="SK"; +$provinces{"T"}="AB"; +$provinces{"V"}="BC"; +$provinces{"X"}="NT"; +$provinces{"X"}="YT"; + +$delim_name="tab"; + +$checkfirstname="N"; +$checkaddress="N"; +$checkpostal_code="N"; +$checkstate="N"; +$checkprovince="N"; +$checkarea_code="N"; +$checkdate_of_birth="N"; +################## + + + + + +$MW->geometry("650x500+0+0"); + +############################ +# TEXT ELEMENTS # +############################ + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "File Name:" +)->place( + -x => '90', + -y => '20', + -anchor => 'e' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Delimiter:" +)->place( + -x => '90', + -y => '55', + -anchor => 'e' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "List ID:" +)->place( + -x => '90', + -y => '90', + -anchor => 'e' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Country:" +)->place( + -x => '250', + -y => '90', + -anchor => 'e' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Errata:" +)->place( + -x => '95', + -y => '125', + -anchor => 'e' +); + +$errata=$MW->Scrolled("Text", + -font => "{Arial} 9 {bold}", + -wrap => "word", + -height => 10, + -width => 65, + -scrollbars => 'e', + -spacing1 => 0 +)->place( + -x => '95', + -y => '270', + -anchor => 'sw' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Good records: " +)->place( + -x => '475', + -y => '300', + -anchor => 'e' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Bad records: " +)->place( + -x => '475', + -y => '340', + -anchor => 'e' +); + +$MW->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Total records: " +)->place( + -x => '475', + -y => '380', + -anchor => 'e' +); + +$MW->Label( + -background => '#CCCCCC', + -text => "Version 1.yo-mama - Written by Joseph Johnson\n" + )->place( + -x => '300', + -y => '480', + -anchor => 'center' + ); + +############################ +# BUTTONS # +############################ +# $BrowseButton= +$MW->Button( + -font => "{Arial} 8 {bold}", + -text => "BROWSE", + -width => "10", + -borderwidth => "3", + -relief => 'groove', + -background => '#FF0000', + -activebackground => '#FFCCCC', + -foreground => '#FFFFFF', + -command => sub{$file_name=$MW->getOpenFile(); $SetFieldsButton->configure(-state => 'normal');} +)->place( + -x => "500", + -y => "20", + -anchor => 'center' +); + +$SetFieldsButton=$MW->Button( + -font => "{Arial} 8 {bold}", + -text => "SET FIELDS", + -width => "10", + -borderwidth => "3", + -relief => 'groove', + -background => '#FF0000', + -activebackground => '#FFCCCC', + -foreground => '#FFFFFF', + -state => 'disabled', + -command => sub{&SetDelimiter; &SetFields;} +)->place( + -x => "500", + -y => "55", + -anchor => 'center' +); + +# $ErrorChecksButton= +$MW->Button( + -font => "{Arial} 8 {bold}", + -text => "ERROR CHECKS", + -width => "12", + -borderwidth => "3", + -relief => 'groove', + -background => '#FF0000', + -activebackground => '#FFCCCC', + -foreground => '#FFFFFF', + # -state => 'disabled', + -command => sub{&ErrorCheckOptions;} +)->place( + -x => "400", + -y => "90", + -anchor => 'center' +); + +$StartButton=$MW->Button( + -font => "{Arial} 8 {bold}", + -text => "START PROCESSING", + -width => "18", + -background => '#009900', + -activebackground => '#99FF99', + -foreground => '#FFFFFF', + -state => 'disabled', + -command => sub {&CheckUserDefinedData;} +)->place( + -x => "95", + -y => "300", + -anchor => 'w' +); + +$StopButton=$MW->Button( + -font => "{Arial} 8 {bold}", + -text => "CANCEL PROCESSING", + -width => "18", + -background => '#FF3333', + -activebackground => '#FF9999', + -foreground => '#FFFFFF', + -state => 'disabled', + -command => sub{$stop_records=1;} +)->place( + -x => "95", + -y => "340", + -anchor => 'w' +); + + +$MW->Button( + -font => "{Arial} 8 {bold}", + -text => "EXIT", + -width => "18", + -background => '#0000FF', + -activebackground => '#CCCCFF', + -foreground => '#FFFFFF', + -command => sub{exit} +)->place( + -x => "95", + -y => "380", + -anchor => 'w' +); + +$x=90; +foreach(qw/tab comma qc pipe(|) other/) { + $MW->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => $_, + -variable => \$delim_name, + -value => $_, + -command => sub{&SetDelimiter;} + )->place( + -x => $x, + -y => "55", + -anchor => 'w' + ); + $x+=70; +} + +############################ +# ENTRY FIELDS # +############################ + +## Login +$MW->Entry( + -font => "{Arial} 9 {bold}", + -background => "#FFFFFF", + -textvariable => \$file_name, + -width => 50 +)->place( + -x => "95", + -y => "20", + -anchor => 'w' +); + +$MW->Entry( + -font => "{Arial} 9 {bold}", + -background => "#FFFFFF", + -textvariable => \$other_delim, + -width => 2 +)->place( + -x => "450", + -y => "55", + -anchor => 'e' +); + +$MW->Entry( + -font => "{Arial} 9 {bold}", + -background => "#FFFFFF", + -textvariable => \$list_id, + -width => 10 +)->place( + -x => "95", + -y => "90", + -anchor => 'w' +); + +$GoodRecords=$MW->Entry( + -font => "{Arial} 9 {bold}", + -background => "#FFFFFF", +# -textvariable => \$good_records, + -width => 10 +)->place( + -x => "550", + -y => "300", + -anchor => 'e' +); + +$BadRecords=$MW->Entry( + -font => "{Arial} 9 {bold}", + -background => "#FFFFFF", +# -textvariable => \$bad_records, + -width => 10 +)->place( + -x => "550", + -y => "340", + -anchor => 'e' +); + +$TotalRecords=$MW->Entry( + -font => "{Arial} 9 {bold}", + -background => "#FFFFFF", +# -textvariable => \$total_records, + -width => 10 +)->place( + -x => "550", + -y => "380", + -anchor => 'e' +); +############################# +# BROWSEENTRY FIELDS # +############################# + +$CountryListbox=$MW->BrowseEntry( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -variable => \$list_country, + -width => 5 +)->place( + -x => "250", + -y => "80", +); +$CountryListbox->insert('end', "USA"); +$CountryListbox->insert('end', "CAN"); +$CountryListbox->insert('end', "UK"); +$CountryListbox->insert('end', "AUS"); + +sub SetDelimiter { + if ($delim_name eq "tab") { + $delimiter="\\t"; + } elsif ($delim_name eq "comma") { + $delimiter="\,"; + } elsif ($delim_name=~/pipe/i) { + $delimiter="\\|"; + } elsif ($delim_name eq "qc") { + $delimiter="\\|"; + } else { + $delimiter=$other_delim; + } +} + +sub SetFieldValue() { + open(CALLBUFFER, "> ./input.log"); + # $instructions=""; + for ($j=0; $j<$no_fields; $j++) { + $fieldvar="field".$j."_value"; + if (length($$fieldvar)>0 && $$fieldvar!~/\s/i) { + $fields{"$$fieldvar"}=$j; + } else { + $fields{"$$fieldvar"}=99; + } + } + + foreach $item (keys %fields) { + print CALLBUFFER sprintf("%-20s", $item).": ".$fields{$item}."\t\t\n"; + } + close(CALLBUFFER); +} + +# sub CountRecords() { +# `copy $file_name count.txt`; +# $total_records=`wc -l < count.txt`; +# print "wc -l < $file_name"; +# chomp($total_records); +# $TotalRecords->delete(0, 'end'); +# $TotalRecords->insert(0, "$total_records"); +# } + +sub SetFields{ + if (length($delim_name)>0) { + open(SOURCE_FILE, "< $file_name"); + if (!Exists($tL)){ + + $buffer=; + $pattern='","'; + $pt2='",,"'; + $pt3='",,,"'; + $pt4='",,,,"'; + $buffer=~s/$pattern/|/g; + $buffer=~s/$pt2/||/g; + $buffer=~s/$pt3/|||/g; + $buffer=~s/$pt4/||||/g; + $buffer=~s/[\*\"\'\\\\]//g; + + @row=split(/$delimiter/, $buffer); + $no_fields=scalar(@row); + $rows=ceil($no_fields/2); + $winheight=20+(40*$rows)+40; + + $tL = $MW->Toplevel(); + $tL->title("SET FIELDS TO POINT TO THE PROPER DATA"); + $tL->geometry("600x$winheight+20+80"); + + $canvas=$tL->Canvas( + -background => '#CCCCCC', + -width => "600", + -height => "$winheight" + )->place( + -x => "0", + -y => "0" + ); + + for ($i=0; $icreateRectangle($xcoord-2,$ycoord-15,$xcoord+285,$ycoord+15, -fill => '#999999'); + + $tL->Label( + -font => "{Courier} 9 {bold}", + -background => '#999999', + -text => "$row[$i]" + )->place( + -x => $xcoord, + -y => $ycoord, + -anchor => 'w' + ); + + $xcoord+=175; + $boxname="field".$i; + $boxvar="field".$i."_value"; + $$boxname=$tL->BrowseEntry( + -font => "{Arial} 9 {bold}", + -background => '#999999', + -variable => \$$boxvar, + -command => sub{&SetFieldValue;}, + -width => 10 + )->place( + -x => $xcoord, + -y => ($ycoord-10), + ); + $$boxname->insert('end', " "); + $$boxname->insert('end', "vendor_lead_code"); + $$boxname->insert('end', "source_id"); +# $$boxname->insert('end', "list_id"); +# $$boxname->insert('end', "campaign_id"); + $$boxname->insert('end', "phone_number"); + $$boxname->insert('end', "title"); + $$boxname->insert('end', "first_name"); + $$boxname->insert('end', "middle_initial"); + $$boxname->insert('end', "last_name"); + $$boxname->insert('end', "address1"); + $$boxname->insert('end', "address2"); + $$boxname->insert('end', "address3"); + $$boxname->insert('end', "city"); + $$boxname->insert('end', "state"); + $$boxname->insert('end', "province"); + $$boxname->insert('end', "postal_code"); + $$boxname->insert('end', "gender"); + $$boxname->insert('end', "date_of_birth"); + $$boxname->insert('end', "alt_phone"); + $$boxname->insert('end', "email"); + $$boxname->insert('end', "security_phrase"); + $$boxname->insert('end', "comments"); + $$boxvar=" "; + } + $ycoord=30+(40*($rows)); + $xcoord=300; + $tL->Button( + -font => "{Arial} 8 {bold}", + -text => "ACCEPT THESE VALUES", + -width => "24", + -background => '#009900', + -activebackground => '#99FF99', + -foreground => '#FFFFFF', + -command => sub { + $StartButton->configure(-state => 'normal'); + $MW->configure(-takefocus => 1); # doesn't make it modal + $tL->destroy; + } + )->place( + -x => "$xcoord", + -y => "$ycoord", + -anchor => 'c' + ); + + } else { + $tL->deiconify(); + $tL->raise(); + } + $MW->configure(-takefocus => 0); # doesn't make it modal + $tL->transient($MW); # doesn't make it modal + $tL->group($MW); # doesn't make it modal + $tL->grab # makes modal! + ; + } +} + +sub ErrorCheckOptions{ + if (length($delim_name)>0) { + if (!Exists($tL)){ + + + $tL = $MW->Toplevel(); + $tL->title("SELECT ERROR CHECKS"); + $tL->geometry("440x400+100+80"); + + $canvas=$tL->Canvas( + -background => '#CCCCCC', + -width => "440", + -height => "400" + )->place( + -x => "0", + -y => "0" + ); + + $canvas->createRectangle(20,2,420,28, -fill => '#999999'); + + $tL->Label( + -font => "{Arial} 10 {bold}", + -foreground => '#FFFFFF', + -background => '#999999', + -text => "SELECT ERROR CHECKS TO PERFORM" + )->place( + -x => '220', + -y => '15', + -anchor => 'center' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "First name must exist: " + )->place( + -x => '340', + -y => '50', + -anchor => 'e' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkfirstname, + -value => "Y" + )->place( + -x => "350", + -y => "50", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkfirstname, + -value => "N" + )->place( + -x => "390", + -y => "50", + -anchor => 'w' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Minimal address required: " + )->place( + -x => '340', + -y => '70', + -anchor => 'e' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkaddress, + -value => "Y" + )->place( + -x => "350", + -y => "70", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkaddress, + -value => "N" + )->place( + -x => "390", + -y => "70", + -anchor => 'w' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Valid postal code required: " + )->place( + -x => '340', + -y => '90', + -anchor => 'e' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkpostal_code, + -value => "Y" + )->place( + -x => "350", + -y => "90", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkpostal_code, + -value => "N" + )->place( + -x => "390", + -y => "90", + -anchor => 'w' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "State required (US & Australia): " + )->place( + -x => '340', + -y => '110', + -anchor => 'e' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkstate, + -value => "Y" + )->place( + -x => "350", + -y => "110", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkstate, + -value => "N" + )->place( + -x => "390", + -y => "110", + -anchor => 'w' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Province required (Canada): " + )->place( + -x => '340', + -y => '130', + -anchor => 'e' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkprovince, + -value => "Y" + )->place( + -x => "350", + -y => "130", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkprovince, + -value => "N" + )->place( + -x => "390", + -y => "130", + -anchor => 'w' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Valid date of birth required (mask: ): " + )->place( + -x => '340', + -y => '150', + -anchor => 'e' + ); + + $DOBListBox=$tL->BrowseEntry( + -font => "{Arial} 8 {bold}", + -background => '#CCCCCC', + -variable => \$dobmask, + -width => 12 + )->place( + -x => "325", + -y => "150", + -anchor => 'e' + ); + $DOBListBox->insert('end', "mm/dd/yyyy"); + $DOBListBox->insert('end', "dd/mm/yyyy"); + $DOBListBox->insert('end', "yyyy/mm/dd"); + $DOBListBox->insert('end', "yyyy/dd/mm"); + $DOBListBox->insert('end', "mm/dd/yy"); + $DOBListBox->insert('end', "dd/mm/yy"); + $DOBListBox->insert('end', "yy/mm/dd"); + $DOBListBox->insert('end', "yy/dd/mm"); + $DOBListBox->insert('end', "mm-dd-yyyy"); + $DOBListBox->insert('end', "dd-mm-yyyy"); + $DOBListBox->insert('end', "yyyy-mm-dd"); + $DOBListBox->insert('end', "yyyy-dd-mm"); + $DOBListBox->insert('end', "mm-dd-yy"); + $DOBListBox->insert('end', "dd-mm-yy"); + $DOBListBox->insert('end', "yy-mm-dd"); + $DOBListBox->insert('end', "yy-dd-mm"); + $DOBListBox->insert('end', "mmddyyyy"); + $DOBListBox->insert('end', "ddmmyyyy"); + $DOBListBox->insert('end', "yyyymmdd"); + $DOBListBox->insert('end', "yyyyddmm"); + $DOBListBox->insert('end', "mmddyy"); + $DOBListBox->insert('end', "ddmmyy"); + $DOBListBox->insert('end', "yymmdd"); + $DOBListBox->insert('end', "yyddmm"); + + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkdate_of_birth, + -value => "Y" + )->place( + -x => "350", + -y => "150", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkdate_of_birth, + -value => "N" + )->place( + -x => "390", + -y => "150", + -anchor => 'w' + ); + + $tL->Label( + -font => "{Arial} 9 {bold}", + -background => '#CCCCCC', + -text => "Area code must match state/prov (US/CAN): " + )->place( + -x => '340', + -y => '170', + -anchor => 'e' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "Y", + -variable => \$checkarea_code, + -value => "Y" + )->place( + -x => "350", + -y => "170", + -anchor => 'w' + ); + $tL->Radiobutton( + -background => '#CCCCCC', + -activebackground => '#CCCCCC', + -text => "N", + -variable => \$checkarea_code, + -value => "N" + )->place( + -x => "390", + -y => "170", + -anchor => 'w' + ); + + $tL->Button( + -font => "{Arial} 8 {bold}", + -text => "ACCEPT THESE VALUES", + -width => "24", + -background => '#009900', + -activebackground => '#99FF99', + -foreground => '#FFFFFF', + -command => sub { + $MW->configure(-takefocus => 1); # doesn't make it modal + $tL->destroy; + } + )->place( + -x => "220", + -y => "220", + -anchor => 'c' + ); + + } else { + $tL->deiconify(); + $tL->raise(); + } + $MW->configure(-takefocus => 0); # doesn't make it modal + $tL->transient($MW); # doesn't make it modal + $tL->group($MW); # doesn't make it modal + $tL->grab # makes modal! + ; + } +} + +sub CheckUserDefinedData { + if ($DB) {print STDERR "Checking data\n";} + + $baduserdata=" "; + if ($fields{"phone_number"}==99) { + $baduserdata.="You must define a phone_number field\n"; + } + if ($fields{"last_name"}==99) { + $baduserdata.="You must define a last_name field\n"; + } + if ($list_country eq "") { + $baduserdata.="You must choose what country this list will be dialing to\n"; + } + $list_id=~s/[^0-9]//g; + if ($list_id eq "") { + $baduserdata.="You must enter a list ID# for the dialer\n"; + } + if (length($baduserdata)>1) { + $baduserdata.="\n\nFix the above problems before the list can be processed."; + if (!Exists($tError)){ + + + $tError = $MW->Toplevel(); + $tError->title("ERROR"); + $tError->geometry("400x200+150+125"); + + $canvas=$tError->Canvas( + -background => '#CCCCCC', + -width => "400", + -height => "200" + )->place( + -x => "0", + -y => "0" + ); + + $tError->Label( + -font => "{Arial} 10 {bold}", + -background => '#CCCCCC', + -text => "$baduserdata" + )->place( + -x => 200, + -y => 0, + -anchor => 'n' + ); + + $tError->Button( + -font => "{Arial} 8 {bold}", + -text => "OK", + -width => "24", + -background => '#009900', + -activebackground => '#99FF99', + -foreground => '#FFFFFF', + -command => sub { + $MW->configure(-takefocus => 1); # doesn't make it modal + $tError->destroy; + } + )->place( + -x => "200", + -y => "150", + -anchor => 'c' + ); + } + + } else { + &ProcessFile; + } +} + +sub ProcessFile { + + if ($DB) {print STDERR "Processing File\n";} + + $stop_records=0; + $StopButton->configure(-state => 'normal'); + # $errata->delete(0, 'end'); + + $i=0; + $bad_records=0; $good_records=0; $total_records=0; + + $error_log="error_log_listid_".$list_id."_".$timestamp.".txt"; + open(ERROR_LOG, "> $error_log"); + + + $mktbl="create table vicidial_temporary_phone_list(phone varchar(20) primary key)"; + $dbh->query($mktbl); + + $timestamp1=time(); + + &SetDelimiter; + + open(RECORDS, "< $file_name"); + while ($buffer=uc()) { + $total_records++; + if ($total_records%10==0) { + } + + $pattern='","'; + $pt2='",,"'; + $pt3='",,,"'; + $pt4='",,,,"'; + $buffer=~s/$pattern/|/g; + $buffer=~s/$pt2/||/g; + $buffer=~s/$pt3/|||/g; + $buffer=~s/$pt4/||||/g; + $i++; + # if ($i%5000==0) {print "\n######## ".sprintf("%-6s", $i)." RECORDS PARSED ########\n\n";} + + #### SPLIT THE ROW BASED ON YOUR ENTRIES #### + $buffer=~s/[\*\"\'\\\\]//g; + @row=split(/$delimiter/, $buffer); + $row[99]=" "; + $vendor_lead_code=$row[$fields{"vendor_lead_code"}]; + $source_id=$row[$fields{"source_id"}]; +# $campaign_id=$row[$fields{"campaign_id"}]; + $phone_number=$row[$fields{"phone_number"}]; + $title=$row[$fields{"title"}]; + $first_name=$row[$fields{"first_name"}]; + $middle_initial=$row[$fields{"middle_initial"}]; + $last_name=$row[$fields{"last_name"}]; + $address1=$row[$fields{"address1"}]; + $address2=$row[$fields{"address2"}]; + $address3=$row[$fields{"address3"}]; + $city=$row[$fields{"city"}]; + $state=$row[$fields{"state"}]; + $province=$row[$fields{"province"}]; + $postal_code=$row[$fields{"postal_code"}]; + $gender=$row[$fields{"gender"}]; + $date_of_birth=$row[$fields{"date_of_birth"}]; + $alt_phone=$row[$fields{"alt_phone"}]; + $email=$row[$fields{"email"}]; + $security_phrase=$row[$fields{"security_phrase"}]; + $comments=$row[$fields{"comments"}]; + + + ####################################### + # TIDY UP THE DATA # + ####################################### + + $vendor_lead_code=~s/^\s*(.*?)\s*$/$1/; + $vendor_lead_code=substr($vendor_lead_code, 0, 20); + $source_id=~s/^\s*(.*?)\s*$/$1/; + $source_id=substr($source_id, 0, 6); + $list_id=~s/^\s*(.*?)\s*$/$1/; + $list_id=~s/[^0-9]//g; + $list_id=substr($list_id, 0, 8); +# $campaign_id=~s/^\s*(.*?)\s*$/$1/; +# $campaign_id=substr($campaign_id, 0, 8); + $phone_number=~s/^\s*(.*?)\s*$/$1/; + $phone_number=~s/[^0-9]//g; + $title=~s/^\s*(.*?)\s*$/$1/; + $title=~s/[^A-Z]//g; + $title=substr($title, 0, 4); + $first_name=~s/^\s*(.*?)\s*$/$1/; + $first_name=~s/[^A-Z\-\s\.\,]//g; + $first_name=substr($first_name, 0, 30); + $middle_initial=~s/^\s*(.*?)\s*$/$1/; + $middle_initial=~s/[^A-Z]//g; + $middle_initial=substr($middle_initial, 0, 1); + $last_name=~s/^\s*(.*?)\s*$/$1/; + $last_name=~s/[^A-Z\-\s\.\,]//g; + $last_name=substr($last_name, 0, 30); + $address1=~s/^\s*(.*?)\s*$/$1/; + $address1=substr($address1, 0, 100); + $address2=~s/^\s*(.*?)\s*$/$1/; + $address2=substr($address2, 0, 100); + $address3=~s/^\s*(.*?)\s*$/$1/; + $address3=substr($address3, 0, 100); + $city=~s/^\s*(.*?)\s*$/$1/; + $city=substr($city, 0, 50); + $state=~s/^\s*(.*?)\s*$/$1/; + $state=~s/[^A-Z]//g; + $state=substr($state, 0, 2); + $province=~s/^\s*(.*?)\s*$/$1/; + $province=~s/[^A-Z\s\-]//g; + $province=substr($province, 0, 50); + $postal_code=~s/^\s*(.*?)\s*$/$1/; + $gender=~s/^\s*(.*?)\s*$/$1/; + $gender=~s/[^MF]//g; + $gender=substr($gender, 0, 1); + $date_of_birth=~s/^\s*(.*?)\s*$/$1/; + $date_of_birth=~s/[^0-9\-\/]//g; + $date_of_birth=substr($date_of_birth, 0, 10); + $alt_phone=~s/^\s*(.*?)\s*$/$1/; + $alt_phone=~s/[^0-9]//g; + $email=~s/^\s*(.*?)\s*$/$1/; + $email=substr($email, 0, 70); + $security_phrase=~s/^\s*(.*?)\s*$/$1/; + $security_phrase=substr($security_phrase, 0, 100); + $comments=~s/^\s*(.*?)\s*$/$1/; + $comments=substr($comments, 0, 255); + + if ($list_country eq "CAN") { + if (length($state)==0) { + $state=$province; + } elsif (length($state)==2 && length($province)==0) { + $province=$state; + } + } + + CheckTitle(); + } + + $GoodRecords->delete(0, 'end'); + $GoodRecords->insert('end', "$good_records"); + $BadRecords->delete(0, 'end'); + $BadRecords->insert('end', "$bad_records"); + $TotalRecords->delete(0, 'end'); + $TotalRecords->insert('end', "$total_records"); + $droptbl="drop table vicidial_temporary_phone_list"; + $dbh->query($droptbl); + $StopButton->configure(-state => 'disabled'); + $timestamp2=time(); + $total_time=$timestamp2-$timestamp1; + print ERROR_LOG "Total time: $total_time\n"; + close(ERROR_LOG); + close(RECORDS); +} + +sub CheckTitle() { + if ($DB) {print STDERR "Checking title\n";} + if ($fields{"title"}!=99 && $fields{"gender"}==99) { + if ($title=~/^mrs|^miss|^ms|^lady|^madam/i) { + $gender="F"; + } elsif ($title=~/^mr|^sir|^baron|^rev|^rabbi|^past/i) { + $gender="M"; + } else { + $gender=""; + } + } + CheckFirstName(); +} + +sub CheckFirstName() { + if ($DB) {print STDERR "Checking firstname\n";} + if ($fields{"first_name"}!=99 && $checkfirstname eq "Y") { + if (length($first_name)==0) { + $errata->insert('end', "FIRST NAME MISSING IN RECORD ".$i."\n"); + print ERROR_LOG "FIRST NAME MISSING IN RECORD ".$i."\n"; + $bad_records++; + } else { + CheckLastName(); + } + + } else { + CheckLastName(); + } +} + +sub CheckLastName() { + if ($DB) {print STDERR "Checking lastname\n";} + if ($fields{"last_name"}!=99) { + if (length($last_name)==0) { + $errata->insert('end', "LAST NAME MISSING IN RECORD ".$i."\n"); + print ERROR_LOG "LAST NAME MISSING IN RECORD ".$i."\n"; + $bad_records++; + } else { + CheckPhone(); + } + + } else { + CheckPhone(); + } +} + +sub CheckPhone() { + if ($DB) {print STDERR "Checking phone\n";} + $q=0; + while (substr($phone_number, $q, 1) eq "0") { + $q++; + } + $phone_number=substr($phone_number, $q); + $phone_number=substr($phone_number, -10); + if (($list_country eq "USA" && length($phone_number)==10 && $phone_number>2010000000 && $phone_number<9900000000 && $phone_number!~/0{7}/ && $phone_number!~/1{7}/ && $phone_number!~/2{7}/ && $phone_number!~/3{7}/ && $phone_number!~/4{7}/ && $phone_number!~/5{7}/ && $phone_number!~/6{7}/ && $phone_number!~/7{7}/ && $phone_number!~/8{7}/ && $phone_number!~/9{7}/) || ($list_country eq "AUS" && length($phone_number)==9 && $phone_number=~/^[23478]/) || ($list_country eq "UK" && length($phone_number)==10 && $phone_number=~/^[1237]/ && $phone_number!~/0{7}/ && $phone_number!~/1{7}/ && $phone_number!~/2{7}/ && $phone_number!~/3{7}/ && $phone_number!~/4{7}/ && $phone_number!~/5{7}/ && $phone_number!~/6{7}/ && $phone_number!~/7{7}/ && $phone_number!~/8{7}/ && $phone_number!~/9{7}/) || ($list_country eq "CAN" && length($phone_number)==10 && $phone_number>2040000000 && $phone_number<9060000000 && $phone_number!~/0{7}/ && $phone_number!~/1{7}/ && $phone_number!~/2{7}/ && $phone_number!~/3{7}/ && $phone_number!~/4{7}/ && $phone_number!~/5{7}/ && $phone_number!~/6{7}/ && $phone_number!~/7{7}/ && $phone_number!~/8{7}/ && $phone_number!~/9{7}/)) { + $stmt="select count(*) from vicidial_temporary_phone_list where phone='$phone_number'"; + $dbh->query("$stmt") or die "ERROR: $!\n"; + if ($dbh->has_selected_record) { +# print "Has selected record.\n"; + $rslt = $dbh->create_record_iterator(); + while (my $row = $rslt->each) { + if ($row->[0]>0) { + $bad_records++; + $errata->insert('end', "DUPLICATE PHONE IN RECORD ".$i.": ".$phone_number."\n"); + print ERROR_LOG "DUPLICATE PHONE IN RECORD ".$i."\n"; + } else { +# print "Record is fine.\n"; + $area_code=substr($phone_number, 0, 3); + $prefix=substr($phone_number, 3, 3); + if ($list_country=~/^USA|CAN/i) { + CheckAreaCode(); + } else { + CheckAddress(); + } + } + } + } else { +# print "No selected record.\n"; + $area_code=substr($phone_number, 0, 3); + $prefix=substr($phone_number, 3, 3); + if ($list_country=~/^USA|CAN/i) { + CheckAreaCode(); + } else { + CheckAddress(); + } + } + } elsif (length($phone_number)==0) { + $bad_records++; + $errata->insert('end', "NO PHONE IN RECORD ".$i.": ".$phone_number."\n"); + print ERROR_LOG "NO PHONE IN RECORD ".$i."\n"; + } else { + $bad_records++; + $errata->insert('end', "BAD PHONE IN RECORD ".$i.": ".$phone_number."\n"); + print ERROR_LOG "BAD PHONE IN RECORD ".$i."\n"; + } +} + +sub CheckAreaCode() { + if ($DB) {print STDERR "Checking areacode\n";} + $stmt="select areacode, state from vicidial_phone_codes where areacode='$area_code' and country='$list_country' limit 1"; + $dbh->query("$stmt") or die "ERROR: $!\n"; + if ($dbh->has_selected_record) { + # print "Has selected record.\n"; + $rslt = $dbh->create_record_iterator(); + my $row = $rslt->each; + $row->[0]+=0; + if ($row->[0]>0) { + if ($checkarea_code eq "Y") { + $alt_state=$row->[1]; + # print "$i)\t$area_code - $state - $alt_state\t"; + if ($list_country eq "CAN") { + if ($province==$alt_state) { + CheckAddress(); + } else { + $errata->insert('end', "PROVINCE/AREA CODE MISMATCHED IN RECORD $i\n"); + print ERROR_LOG "PROVINCE/AREA CODE MISMATCHED IN RECORD ".$i."\n"; + $bad_records++; + } + } elsif ($list_country eq "USA") { + if ($state eq $alt_state) { + CheckAddress(); + } else { + $errata->insert('end', "STATE/AREA CODE MISMATCHED IN RECORD $i\n"); + print ERROR_LOG "STATE/AREA CODE MISMATCHED IN RECORD ".$i."\n"; + $bad_records++; + } + } else { + die "The script should not have reached this point, since the country should have been CANADA or USA to do this check, and should have been skipped otherwise.\n"; + } + } else { + CheckAddress(); + } + } else { + $errata->insert('end', "BAD AREA CODE IN RECORD $i: $area_code\n"); + print ERROR_LOG "BAD AREA CODE IN RECORD $i: $area_code\n"; + $bad_records++; + } +# } + } else { + die "This should have returned something.\n"; + } +} + +sub CheckAddress() { + if ($DB) {print STDERR "Checking address\n";} + if ($fields{"address1"}!=99 && $checkaddress eq "Y") { + $fulladdress=$address1.$address2.$address3; + if (length($fulladdress)<5) { + $errata->insert('end', "INSUFFICIENT ADDRESS INFO IN RECORD $i\n"); + print ERROR_LOG "INSUFFICIENT ADDRESS INFO IN RECORD $i\n"; + $bad_records++; + } else { + CheckZip(); + } + } else { + CheckZip(); + } +} + +sub CheckZip() { + if ($DB) {print STDERR "Checking postal\n";} + if ($fields{"postal_code"}!=99 && $checkpostal_code eq "Y") { + if ($list_country eq "USA") { + $pccheck=$postal_code; + $pccheck=~s/[^0-9]//g; + if ((length($pccheck)!=5 && length($pccheck)!=9) || $pccheck<1001) { + $errata->insert('end', "BAD POSTAL CODE IN RECORD $i: $postal_code\n"); + print ERROR_LOG "BAD POSTAL CODE IN RECORD $i: $postal_code\n"; + $bad_records++; + } else { + CheckState(); + } + } elsif ($list_country eq "AUS") { + $postal_code=~s/[^0-9]//g; + if (length($postal_code)!=4 || $postal_code<101) { + $errata->insert('end', "BAD POSTAL CODE IN RECORD $i: $postal_code\n"); + print ERROR_LOG "BAD POSTAL CODE IN RECORD $i: $postal_code\n"; + $bad_records++; + } else { + CheckState(); + } + } elsif ($list_country eq "UK") { + $pccheck=$postal_code; + $pccheck=~s/[^0-9A-Z]//g; + if ($postal_code=~/\s{2,3}/i) { + $postal_code=~s/\s{2,3}/ /g; + } + if (length($pccheck)>7 || length($pccheck)<5 || $postal_code!~/[A-Z]{1,2}\d{1,2}[A-Z]{0,1}\s\d[A-Z]{2}/i) { + $errata->insert('end', "BAD POSTAL CODE IN RECORD $i: $postal_code\n"); + print ERROR_LOG "BAD POSTAL CODE IN RECORD $i: $postal_code\n"; + $bad_records++; + } else { + CheckState(); + } + } else { + $pccheck=$postal_code; + $pccheck=~s/[^0-9A-Z]//g; + if ($postal_code=~/\s{2,3}/i) { + $postal_code=~s/\s{2,3}/ /g; + } + if (length($pccheck)!=6 || $pccheck!~/[A-Z]\d[A-Z]\d[A-Z]\d/i) { + $errata->insert('end', "BAD POSTAL CODE IN RECORD $i: $postal_code\n"); + print ERROR_LOG "BAD POSTAL CODE IN RECORD $i: $postal_code\n"; + $bad_records++; + } else { + if ($fields{"province"}==99 || length($province)==0) { + $province=$provinces{substr($postal_code, 0, 1)}; + if (length($state)==0) { + $state=$province; + } + } + CheckState(); + print "\n"; + } + } + + } else { + CheckState(); + } +} + +sub CheckState() { + if ($DB) {print STDERR "Checking state\n";} + if (($fields{"state"}!=99 && $checkstate eq "Y")) { + if ($list_country eq "USA") { + $_="CT,DE,DC,FL,GA,IN,KY,ME,MD,MA,MI,NH,NJ,NY,NC,OH,PA,RI,SC,TN,VT,VA,WV,AL,AR,IL,IA,KS,LA,MN,MS,MO,NE,ND,OK,SD,TX,WI,AZ,CO,ID,MT,NM,OR,UT,WY,CA,NV,WA,AK,HI"; + $pccheck=$postal_code; + $pccheck=~s/[^0-9]//g; + if(/$state/ && length($state)==2) { + CheckDateofBirth(); + } elsif ((length($pccheck)==5 || length($pccheck)==9) && $pccheck>1000) { + $pccheck=substr($pccheck, 0, 5); + for ($q=0; $q=$us_zc_ary[$q][1] && $pccheck<=$us_zc_ary[$q][2]) { + $state=$us_zc_ary[$q][0]; + } + } + CheckDateofBirth(); + } else { + $errata->insert('end', "MISSING STATE INFO IN RECORD $i\n"); + print ERROR_LOG "MISSING STATE INFO IN RECORD $i\n"; + $bad_records++; + } + } elsif ($list_country eq "AUS") { + $state=~s/[^A-Z]//g; + $_="ACT,NT,NSW,VIC,QLD,SA,WA,TAS"; + + $pccheck=$postal_code; + $pccheck=~s/[^0-9]//g; + if(/$state/ && (length($state)==2 || length($state)==3)) { + CheckDateofBirth(); + } elsif (length($pccheck)==4 && $pccheck>=200) { + $pccheck=substr($pccheck, 0, 4); + for ($q=0; $q=$aus_zc_ary[$q][1] && $pccheck<=$aus_zc_ary[$q][2]) { + $state=$aus_zc_ary[$q][0]; + } + } + CheckDateofBirth(); + } else { + $errata->insert('end', "MISSING STATE INFO IN RECORD $i\n"); + print ERROR_LOG "MISSING STATE INFO IN RECORD $i\n"; + $bad_records++; + } + } + } else { + CheckDateofBirth(); + } +} + +sub CheckDateofBirth() { + if ($DB) {print STDERR "Checking dob\n";} + if ($fields{"date_of_birth"}!=99 && $checkdate_of_birth eq "Y") { + %pos=(); + if (length($date_of_birth)>=6 && length($date_of_birth)<=10) { + if ($dobmask=~/\-/) { + $pos{index($dobmask, "y")}="doby"; + $pos{index($dobmask, "m")}="dobm"; + $pos{index($dobmask, "d")}="dobd"; + $x=0; + @dob_ary=split(/\-/, $date_of_birth); + foreach $position (sort(keys(%pos))) { + $varname=$pos{$position}; + $$varname=$dob_ary[$x]; + $x++; + } + } elsif ($dobmask=~/\//) { + $pos{index($dobmask, "y")}="doby"; + $pos{index($dobmask, "m")}="dobm"; + $pos{index($dobmask, "d")}="dobd"; + $x=0; + @dob_ary=split(/\//, $date_of_birth); + foreach $position (sort(keys(%pos))) { + $varname=$pos{$position}; + $$varname=$dob_ary[$x]; + $x++; + } + } else { + $ypos=index($dobmask, "y"); + $mpos=index($dobmask, "m"); + $dpos=index($dobmask, "d"); + $yend=rindex($dobmask, "y"); + $mend=rindex($dobmask, "m"); + $dend=rindex($dobmask, "d"); + $doby=substr($date_of_birth, $ypos, (($yend+1)-$ypos)); + $dobm=substr($date_of_birth, $mpos, (($mend+1)-$mpos)); + $dobd=substr($date_of_birth, $dpos, (($dend+1)-$dpos)); + } + $dobd=substr("0".$dobd, -2); + $dobm=substr("0".$dobm, -2); + if ($dobmask!~/yyyy/i) { + $doby=substr("19".$doby, -4); + } + $date_of_birth="$doby-$dobm-$dobd"; + + if ($date_of_birth!~/^(\d){4}\-(\d){2}\-(\d){2}$/i || $dobm>12 || $dobm<1 || $dobd<1 || $dobd>31) { + $errata->insert('end', "INVALID DATE OF BIRTH IN RECORD ".$i.": ".$date_of_birth."\n"); + print ERROR_LOG "INVALID DATE OF BIRTH IN RECORD ".$i.": ".$date_of_birth."\n"; + $bad_records++; + } elsif ($under18<$doby.$dobm.$dobd) { + $errata->insert('end', "CUSTOMER UNDER 18 - RECORD ".$i.": ".$date_of_birth."\n"); + print ERROR_LOG "CUSTOMER UNDER 18 - RECORD ".$i.": ".$date_of_birth."\n"; + $bad_records++; + } else { + FormatRecord(); + } + } else { + $errata->insert('end', "INVALID DATE OF BIRTH IN RECORD ".$i.": ".$date_of_birth."\n"); + print ERROR_LOG "INVALID DATE OF BIRTH IN RECORD ".$i.": ".$date_of_birth."\n"; + $bad_records++; + } + } else { + FormatRecord(); + } +} + +sub FormatRecord() { + if ($DB) {print STDERR "Formatting record\n";} + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year = ($year + 1900); + $mon++; + if ($sec < 10) {$sec = "0$sec";} + if ($min < 10) {$min = "0$min";} + if ($hour < 10) {$hour = "0$hour";} + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + undef $wday; undef $yday; undef $isdst; + $entry_date="$year-$mon-$mday $hour:$min:$sec"; + $phone_code=1; + if ($list_country eq "AUS") { + $phone_code="01161"; + } elsif ($list_country eq "UK") { + $phone_code="01144"; + } + + if ($i%50==0) { + $GoodRecords->delete(0, 'end'); + $GoodRecords->insert(0, "$good_records"); + $BadRecords->delete(0, 'end'); + $BadRecords->insert(0, "$bad_records"); + $TotalRecords->delete(0, 'end'); + $TotalRecords->insert(0, "$total_records"); + print STDERR "$total_records\n"; + usleep(1*900*1000); + } + + $error_message=""; + $good_records++; + $stmt="insert into vicidial_temporary_phone_list VALUES ('$phone_number')"; + $dbh->query($stmt) or die "Temporary table error: $!\n"; + $stmt="insert into vicidial_list(entry_date, status, vendor_lead_code, source_id, list_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments) VALUES('$entry_date', 'NEW', '$vendor_lead_code', '$source_id', '$list_id', '$phone_code', '$phone_number', '$title', '$first_name', '$middle_initial', '$last_name', '$address1', '$address2', '$address3', '$city', '$state', '$province', '$postal_code', '$list_country', '$gender', '$date_of_birth', '$alt_phone', '$email', '$security_phrase', '$comments')"; + $dbh->query($stmt) or die "Vicidial_list table error: $!"; +} +# $errata->insert('end', "#######################################"); + + + +########################################## +########################################## +### connect to idcheck database and fill in variables +########################################## +########################################## +sub idcheck_connect { + + $SIP_abb = $SIP_user; + $SIP_abb =~ s/SIP\/|IAX2\/|Zap\///gi; + + +$dbhA = Net::MySQL->new(hostname => "$DB_server", database => "$DB_database", user => "$DB_user", password => "$DB_pass", port => "$DB_port") + or die "Couldn't connect to database: $DB_server - $DB_database\n"; + +if ($DB) {print STDERR "connecting to DB: $DB_server - $DB_database\n";} + + $dbhA->query("SELECT * FROM phones where server_ip = '$server_ip' and extension = '$SIP_abb';"); + if ($dbhA->has_selected_record) + { + $iterA=$dbhA->create_record_iterator; + $rec_countA=0; + while ($recordA = $iterA->each) + { + if($DB){print STDERR $recordA->[0],"|", $recordA->[1],"\n";} + + $LOCAL_GMT = "$recordA->[17]"; + $ASTmgrUSERNAME = "$recordA->[18]"; + $ASTmgrSECRET = "$recordA->[19]"; + $login_user = "$recordA->[20]"; + $login_pass = "$recordA->[21]"; + $login_campaign = "$recordA->[22]"; + $park_on_extension = "$recordA->[23]"; + $conf_on_extension = "$recordA->[24]"; + $VICIDIAL_park_on_extension = "$recordA->[25]"; + $VICIDIAL_park_on_filename = "$recordA->[26]"; + $monitor_prefix = "$recordA->[27]"; + $recording_exten = "$recordA->[28]"; + $voicemail_exten = "$recordA->[29]"; + $voicemail_dump_exten = "$recordA->[30]"; + $ext_context = "$recordA->[31]"; + $dtmf_send_extension = "$recordA->[32]"; + $call_out_number_group = "$recordA->[33]"; + $client_browser = "$recordA->[34]"; + $install_directory = "$recordA->[35]"; + $local_web_callerID_URL = "$recordA->[36]"; + $VICIDIAL_web_URL = "$recordA->[37]"; + $AGI_call_logging_enabled = "$recordA->[38]"; + $user_switching_enabled = "$recordA->[39]"; + $conferencing_enabled = "$recordA->[40]"; + $admin_hangup_enabled = "$recordA->[41]"; + $admin_hijack_enabled = "$recordA->[42]"; + $admin_monitor_enabled = "$recordA->[43]"; + $call_parking_enabled = "$recordA->[44]"; + $updater_check_enabled = "$recordA->[45]"; + $AFLogging_enabled = "$recordA->[46]"; + $QUEUE_ACTION_enabled = "$recordA->[47]"; + $CallerID_popup_enabled = "$recordA->[48]"; + $voicemail_button_enabled = "$recordA->[49]"; + $enable_fast_refresh = "$recordA->[50]"; + $fast_refresh_rate = "$recordA->[51]"; + $enable_persistant_mysql = "$recordA->[52]"; + $auto_dial_next_number = "$recordA->[53]"; + $VDstop_rec_after_each_call = "$recordA->[54]"; + $DBX_server = "$recordA->[55]"; + $DBX_database = "$recordA->[56]"; + $DBX_user = "$recordA->[57]"; + $DBX_pass = "$recordA->[58]"; + $DBX_port = "$recordA->[59]"; + $DBY_server = "$recordA->[60]"; + $DBY_database = "$recordA->[61]"; + $DBY_user = "$recordA->[62]"; + $DBY_pass = "$recordA->[63]"; + $DBY_port = "$recordA->[64]"; + + if (length($DBX_server)<4) {$DBX_server = $DB_server;} + if (length($DBX_database)<2) {$DBX_database = $DB_database;} + $rec_countA++; + } + } + + $dbhA->close; + +} + + + + + +MainLoop; \ No newline at end of file diff --git a/agc_2-X/trunk/astguiclient_web/AST_inboundEXTstats.php b/agc_2-X/trunk/astguiclient_web/AST_inboundEXTstats.php new file mode 100644 index 00000000..28c5b20d --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/AST_inboundEXTstats.php @@ -0,0 +1,400 @@ + LICENSE: GPLv2 +# +# CHANGES +# 60421-1450 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60620-1322 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.11.20';} + +$stmt="select extension,full_number,inbound_name from inbound_numbers where server_ip='" . mysql_real_escape_string($server_ip) . "';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$inbound_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $inbound_to_print) + { + $row=mysql_fetch_row($rslt); + $inbound[$i] =$row[0]; + $fullnum[$i] =$row[1]; + $inbname[$i] =$row[2]; + $i++; + } +?> + + + + + +\n"; +#echo"\n"; +echo "ASTERISK: Inbound Calls Stats\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n\n"; + +echo "
\n\n";
+
+
+if (!$group)
+{
+echo "\n\n";
+echo "PLEASE SELECT A NUMBER AND DATE ABOVE AND CLICK SUBMIT\n";
+}
+
+else
+{
+
+
+echo "ASTERISK: Inbound Calls Stats                      $NOW_TIME\n";
+
+echo "\n";
+echo "---------- TOTALS\n";
+
+$extenSQL = "and extension='" . mysql_real_escape_string($group) . "'";
+if (eregi("\*",$group))
+	{$extenSQL = "and extension LIKE \"%$group\"";}
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$TOTALcalls =	sprintf("%10s", $row[0]);
+$average_hold_seconds = ($row[1] / $row[0]);
+$average_hold_seconds = round($average_hold_seconds, 0);
+$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+
+echo "Total Calls That came into this number:       $TOTALcalls\n";
+echo "Average Call Length(seconds) for all Calls:   $average_hold_seconds\n";
+
+echo "\n";
+echo "---------- DROPS\n";
+
+$stmt="select count(*),sum(length_in_sec) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+
+$DROPcalls =	sprintf("%10s", $row[0]);
+$DROPpercent = (($DROPcalls / $TOTALcalls) * 100);
+$DROPpercent = round($DROPpercent, 0);
+
+if ($row[0])
+	{
+	$average_hold_seconds = ($row[1] / $row[0]);
+	$average_hold_seconds = round($average_hold_seconds, 0);
+	$average_hold_seconds =	sprintf("%10s", $average_hold_seconds);
+	}
+else {$DROPpercent=0;   $average_hold_seconds=0;}
+echo "Total DROP Calls:   (less than 10 seconds)    $DROPcalls  $DROPpercent%\n";
+echo "Average Call Length(seconds) for DROP Calls:  $average_hold_seconds\n";
+
+
+##############################
+#########  CALLS STATS
+
+echo "\n";
+echo "---------- CALL LISTINGS\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+echo "| CALLERID             | CALLERIDNAME         | LENGTH | DATE TIME           |\n";
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+$stmt="select number_dialed,caller_code,length_in_sec,start_time from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " 00:00:01' and start_time <= '" . mysql_real_escape_string($query_date) . " 23:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$users_to_print = mysql_num_rows($rslt);
+$i=0;
+while ($i < $users_to_print)
+	{
+	$row=mysql_fetch_row($rslt);
+
+	$CID =			sprintf("%-20s", $row[0]);
+	$CIDname =		sprintf("%-20s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);}
+	$datetime =		sprintf("%-19s", $row[3]);
+	$USERavgTALK =	$row[2];
+
+	$USERavgTALK_M = ($USERavgTALK / 60);
+	$USERavgTALK_M = round($USERavgTALK_M, 2);
+	$USERavgTALK_M_int = intval("$USERavgTALK_M");
+	$USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int);
+	$USERavgTALK_S = ($USERavgTALK_S * 60);
+	$USERavgTALK_S = round($USERavgTALK_S, 0);
+	if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";}
+	$USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S";
+	$USERavgTALK_MS =		sprintf("%6s", $USERavgTALK_MS);
+
+	echo "| $CID | $CIDname | $USERavgTALK_MS | $datetime |\n";
+
+	$i++;
+	}
+
+echo "+----------------------+----------------------+--------+---------------------+\n";
+
+##############################
+#########  TIME STATS
+
+if ($output == 'FULL')
+	{
+
+	echo "\n";
+	echo "---------- TIME STATS\n";
+
+	echo "\n";
+
+	$hi_hour_count=0;
+	$last_full_record=0;
+	$i=0;
+	$h=0;
+	while ($i <= 96)
+		{
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:00:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:14:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:15:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:29:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:30:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:44:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL ;";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$hour_count[$i] = $row[0];
+		if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];}
+		if ($hour_count[$i] > 0) {$last_full_record = $i;}
+		$stmt="select count(*) from call_log where start_time >= '" . mysql_real_escape_string($query_date) . " $h:45:00' and start_time <= '" . mysql_real_escape_string($query_date) . " $h:59:59' and server_ip='" . mysql_real_escape_string($server_ip) . "' $extenSQL and (length_in_sec <= 10 or length_in_sec is null);";
+		$rslt=mysql_query($stmt, $link);
+		if ($DB) {echo "$stmt\n";}
+		$row=mysql_fetch_row($rslt);
+		$drop_count[$i] = $row[0];
+		$i++;
+		$h++;
+		}
+
+	$hour_multiplier = (100 / $hi_hour_count);
+	#$hour_multiplier = round($hour_multiplier, 0);
+
+	echo "\n";
+	echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS\n";
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 102) 
+		{
+		if ($Mk >= 5) 
+			{
+			$Mk=0;
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+	#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP                                  | DROPS | TOTAL |\n";
+	echo "| HOUR |$call_scale| DROPS | TOTAL |\n";
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+	$ZZ = '00';
+	$i=0;
+	$h=4;
+	$hour= -1;
+	$no_lines_yet=1;
+
+	while ($i <= 96)
+		{
+		$char_counter=0;
+		$time = '      ';
+		if ($h >= 4) 
+			{
+			$hour++;
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$time = "+$hour$ZZ+";
+			}
+		if ($h == 1) {$time = "   15 ";}
+		if ($h == 2) {$time = "   30 ";}
+		if ($h == 3) {$time = "   45 ";}
+		$Ghour_count = $hour_count[$i];
+		if ($Ghour_count < 1) 
+			{
+			if ( ($no_lines_yet) or ($i > $last_full_record) )
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				echo "|$time|";
+				$k=0;   while ($k <= 102) {echo " ";   $k++;}
+				echo "| $hour_count[$i] |\n";
+				}
+			}
+		else
+			{
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (99 - $Xhour_count);
+
+			$Gdrop_count = $drop_count[$i];
+			if ($Gdrop_count < 1) 
+				{
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "*X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 101) {echo " ";   $char_counter++;}
+				echo "| 0     | $hour_count[$i] |\n";
+
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				$hour_count[$i] =	sprintf("%-5s", $hour_count[$i]);
+				$drop_count[$i] =	sprintf("%-5s", $drop_count[$i]);
+
+				echo "|$time|";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "X";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 102) {echo " ";   $char_counter++;}
+				echo "| $drop_count[$i] | $hour_count[$i] |\n";
+				}
+			}
+		
+		
+		$i++;
+		$h++;
+		}
+
+
+	echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n";
+
+
+	}
+
+
+
+
+}
+
+
+
+?>
+
+ + \ No newline at end of file diff --git a/agc_2-X/trunk/astguiclient_web/admin.php b/agc_2-X/trunk/astguiclient_web/admin.php new file mode 100644 index 00000000..75f407c7 --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/admin.php @@ -0,0 +1,1824 @@ + LICENSE: GPLv2 +# +# AST GUI database administration +# +# CHANGES +# 50913-1118 - Added outbound_cid for web-client calls +# 50926-1356 - Modified to allow for language translation +# 50926-1613 - Added WeBRooTWritablE write controls +# 51128-1254 - Modified to allow PHP global vars off +# 51208-2120 - Added option to login with vicidial_user login if allowed +# 51213-1650 - Added option to delete phones if allowed by vicidial_users +# 60421-1430 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1137 - Fixed phone search bug +# 60620-1243 - Added variable filtering to eliminate SQL injection attack threat +# + +$version = '1.1.12'; +$build = '60620-1243'; + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["server_id"])) {$server_id=$_GET["server_id"];} + elseif (isset($_POST["server_id"])) {$server_id=$_POST["server_id"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} + elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} +if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} + elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["computer_ip"])) {$computer_ip=$_GET["computer_ip"];} + elseif (isset($_POST["computer_ip"])) {$computer_ip=$_POST["computer_ip"];} +if (isset($_GET["login"])) {$login=$_GET["login"];} + elseif (isset($_POST["login"])) {$login=$_POST["login"];} +if (isset($_GET["active"])) {$active=$_GET["active"];} + elseif (isset($_POST["active"])) {$active=$_POST["active"];} +if (isset($_GET["phone_type"])) {$phone_type=$_GET["phone_type"];} + elseif (isset($_POST["phone_type"])) {$phone_type=$_POST["phone_type"];} +if (isset($_GET["fullname"])) {$fullname=$_GET["fullname"];} + elseif (isset($_POST["fullname"])) {$fullname=$_POST["fullname"];} +if (isset($_GET["company"])) {$company=$_GET["company"];} + elseif (isset($_POST["company"])) {$company=$_POST["company"];} +if (isset($_GET["picture"])) {$picture=$_GET["picture"];} + elseif (isset($_POST["picture"])) {$picture=$_POST["picture"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} + elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} +if (isset($_GET["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_GET["ASTmgrUSERNAME"];} + elseif (isset($_POST["ASTmgrUSERNAME"])) {$ASTmgrUSERNAME=$_POST["ASTmgrUSERNAME"];} +if (isset($_GET["ASTmgrSECRET"])) {$ASTmgrSECRET=$_GET["ASTmgrSECRET"];} + elseif (isset($_POST["ASTmgrSECRET"])) {$ASTmgrSECRET=$_POST["ASTmgrSECRET"];} +if (isset($_GET["login_user"])) {$login_user=$_GET["login_user"];} + elseif (isset($_POST["login_user"])) {$login_user=$_POST["login_user"];} +if (isset($_GET["login_pass"])) {$login_pass=$_GET["login_pass"];} + elseif (isset($_POST["login_pass"])) {$login_pass=$_POST["login_pass"];} +if (isset($_GET["login_campaign"])) {$login_campaign=$_GET["login_campaign"];} + elseif (isset($_POST["login_campaign"])) {$login_campaign=$_POST["login_campaign"];} +if (isset($_GET["park_on_extension"])) {$park_on_extension=$_GET["park_on_extension"];} + elseif (isset($_POST["park_on_extension"])) {$park_on_extension=$_POST["park_on_extension"];} +if (isset($_GET["conf_on_extension"])) {$conf_on_extension=$_GET["conf_on_extension"];} + elseif (isset($_POST["conf_on_extension"])) {$conf_on_extension=$_POST["conf_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_GET["VICIDIAL_park_on_extension"];} + elseif (isset($_POST["VICIDIAL_park_on_extension"])) {$VICIDIAL_park_on_extension=$_POST["VICIDIAL_park_on_extension"];} +if (isset($_GET["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_GET["VICIDIAL_park_on_filename"];} + elseif (isset($_POST["VICIDIAL_park_on_filename"])) {$VICIDIAL_park_on_filename=$_POST["VICIDIAL_park_on_filename"];} +if (isset($_GET["monitor_prefix"])) {$monitor_prefix=$_GET["monitor_prefix"];} + elseif (isset($_POST["monitor_prefix"])) {$monitor_prefix=$_POST["monitor_prefix"];} +if (isset($_GET["recording_exten"])) {$recording_exten=$_GET["recording_exten"];} + elseif (isset($_POST["recording_exten"])) {$recording_exten=$_POST["recording_exten"];} +if (isset($_GET["voicemail_exten"])) {$voicemail_exten=$_GET["voicemail_exten"];} + elseif (isset($_POST["voicemail_exten"])) {$voicemail_exten=$_POST["voicemail_exten"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["dtmf_send_extension"])) {$dtmf_send_extension=$_GET["dtmf_send_extension"];} + elseif (isset($_POST["dtmf_send_extension"])) {$dtmf_send_extension=$_POST["dtmf_send_extension"];} +if (isset($_GET["call_out_number_group"])) {$call_out_number_group=$_GET["call_out_number_group"];} + elseif (isset($_POST["call_out_number_group"])) {$call_out_number_group=$_POST["call_out_number_group"];} +if (isset($_GET["client_browser"])) {$client_browser=$_GET["client_browser"];} + elseif (isset($_POST["client_browser"])) {$client_browser=$_POST["client_browser"];} +if (isset($_GET["install_directory"])) {$install_directory=$_GET["install_directory"];} + elseif (isset($_POST["install_directory"])) {$install_directory=$_POST["install_directory"];} +if (isset($_GET["local_web_callerID_URL"])) {$local_web_callerID_URL=$_GET["local_web_callerID_URL"];} + elseif (isset($_POST["local_web_callerID_URL"])) {$local_web_callerID_URL=$_POST["local_web_callerID_URL"];} +if (isset($_GET["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_GET["VICIDIAL_web_URL"];} + elseif (isset($_POST["VICIDIAL_web_URL"])) {$VICIDIAL_web_URL=$_POST["VICIDIAL_web_URL"];} +if (isset($_GET["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_GET["AGI_call_logging_enabled"];} + elseif (isset($_POST["AGI_call_logging_enabled"])) {$AGI_call_logging_enabled=$_POST["AGI_call_logging_enabled"];} +if (isset($_GET["user_switching_enabled"])) {$user_switching_enabled=$_GET["user_switching_enabled"];} + elseif (isset($_POST["user_switching_enabled"])) {$user_switching_enabled=$_POST["user_switching_enabled"];} +if (isset($_GET["conferencing_enabled"])) {$conferencing_enabled=$_GET["conferencing_enabled"];} + elseif (isset($_POST["conferencing_enabled"])) {$conferencing_enabled=$_POST["conferencing_enabled"];} +if (isset($_GET["admin_hangup_enabled"])) {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];} + elseif (isset($_POST["admin_hangup_enabled"])) {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];} +if (isset($_GET["admin_hijack_enabled"])) {$admin_hijack_enabled=$_GET["admin_hijack_enabled"];} + elseif (isset($_POST["admin_hijack_enabled"])) {$admin_hijack_enabled=$_POST["admin_hijack_enabled"];} +if (isset($_GET["admin_monitor_enabled"])) {$admin_monitor_enabled=$_GET["admin_monitor_enabled"];} + elseif (isset($_POST["admin_monitor_enabled"])) {$admin_monitor_enabled=$_POST["admin_monitor_enabled"];} +if (isset($_GET["call_parking_enabled"])) {$call_parking_enabled=$_GET["call_parking_enabled"];} + elseif (isset($_POST["call_parking_enabled"])) {$call_parking_enabled=$_POST["call_parking_enabled"];} +if (isset($_GET["updater_check_enabled"])) {$updater_check_enabled=$_GET["updater_check_enabled"];} + elseif (isset($_POST["updater_check_enabled"])) {$updater_check_enabled=$_POST["updater_check_enabled"];} +if (isset($_GET["AFLogging_enabled"])) {$AFLogging_enabled=$_GET["AFLogging_enabled"];} + elseif (isset($_POST["AFLogging_enabled"])) {$AFLogging_enabled=$_POST["AFLogging_enabled"];} +if (isset($_GET["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_GET["QUEUE_ACTION_enabled"];} + elseif (isset($_POST["QUEUE_ACTION_enabled"])) {$QUEUE_ACTION_enabled=$_POST["QUEUE_ACTION_enabled"];} +if (isset($_GET["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_GET["CallerID_popup_enabled"];} + elseif (isset($_POST["CallerID_popup_enabled"])) {$CallerID_popup_enabled=$_POST["CallerID_popup_enabled"];} +if (isset($_GET["voicemail_button_enabled"])) {$voicemail_button_enabled=$_GET["voicemail_button_enabled"];} + elseif (isset($_POST["voicemail_button_enabled"])) {$voicemail_button_enabled=$_POST["voicemail_button_enabled"];} +if (isset($_GET["enable_fast_refresh"])) {$enable_fast_refresh=$_GET["enable_fast_refresh"];} + elseif (isset($_POST["enable_fast_refresh"])) {$enable_fast_refresh=$_POST["enable_fast_refresh"];} +if (isset($_GET["fast_refresh_rate"])) {$fast_refresh_rate=$_GET["fast_refresh_rate"];} + elseif (isset($_POST["fast_refresh_rate"])) {$fast_refresh_rate=$_POST["fast_refresh_rate"];} +if (isset($_GET["enable_persistant_mysql"])) {$enable_persistant_mysql=$_GET["enable_persistant_mysql"];} + elseif (isset($_POST["enable_persistant_mysql"])) {$enable_persistant_mysql=$_POST["enable_persistant_mysql"];} +if (isset($_GET["auto_dial_next_number"])) {$auto_dial_next_number=$_GET["auto_dial_next_number"];} + elseif (isset($_POST["auto_dial_next_number"])) {$auto_dial_next_number=$_POST["auto_dial_next_number"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["DBX_server"])) {$DBX_server=$_GET["DBX_server"];} + elseif (isset($_POST["DBX_server"])) {$DBX_server=$_POST["DBX_server"];} +if (isset($_GET["DBX_database"])) {$DBX_database=$_GET["DBX_database"];} + elseif (isset($_POST["DBX_database"])) {$DBX_database=$_POST["DBX_database"];} +if (isset($_GET["DBX_user"])) {$DBX_user=$_GET["DBX_user"];} + elseif (isset($_POST["DBX_user"])) {$DBX_user=$_POST["DBX_user"];} +if (isset($_GET["DBX_pass"])) {$DBX_pass=$_GET["DBX_pass"];} + elseif (isset($_POST["DBX_pass"])) {$DBX_pass=$_POST["DBX_pass"];} +if (isset($_GET["DBX_port"])) {$DBX_port=$_GET["DBX_port"];} + elseif (isset($_POST["DBX_port"])) {$DBX_port=$_POST["DBX_port"];} +if (isset($_GET["DBY_server"])) {$DBY_server=$_GET["DBY_server"];} + elseif (isset($_POST["DBY_server"])) {$DBY_server=$_POST["DBY_server"];} +if (isset($_GET["DBY_database"])) {$DBY_database=$_GET["DBY_database"];} + elseif (isset($_POST["DBY_database"])) {$DBY_database=$_POST["DBY_database"];} +if (isset($_GET["DBY_user"])) {$DBY_user=$_GET["DBY_user"];} + elseif (isset($_POST["DBY_user"])) {$DBY_user=$_POST["DBY_user"];} +if (isset($_GET["DBY_pass"])) {$DBY_pass=$_GET["DBY_pass"];} + elseif (isset($_POST["DBY_pass"])) {$DBY_pass=$_POST["DBY_pass"];} +if (isset($_GET["DBY_port"])) {$DBY_port=$_GET["DBY_port"];} + elseif (isset($_POST["DBY_port"])) {$DBY_port=$_POST["DBY_port"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["old_extension"])) {$old_extension=$_GET["old_extension"];} + elseif (isset($_POST["old_extension"])) {$old_extension=$_POST["old_extension"];} +if (isset($_GET["old_server_ip"])) {$old_server_ip=$_GET["old_server_ip"];} + elseif (isset($_POST["old_server_ip"])) {$old_server_ip=$_POST["old_server_ip"];} +if (isset($_GET["old_server_id"])) {$old_server_id=$_GET["old_server_id"];} + elseif (isset($_POST["old_server_id"])) {$old_server_id=$_POST["old_server_id"];} +if (isset($_GET["server_description"])) {$server_description=$_GET["server_description"];} + elseif (isset($_POST["server_description"])) {$server_description=$_POST["server_description"];} +if (isset($_GET["asterisk_version"])) {$asterisk_version=$_GET["asterisk_version"];} + elseif (isset($_POST["asterisk_version"])) {$asterisk_version=$_POST["asterisk_version"];} +if (isset($_GET["max_vicidial_trunks"])) {$max_vicidial_trunks=$_GET["max_vicidial_trunks"];} + elseif (isset($_POST["max_vicidial_trunks"])) {$max_vicidial_trunks=$_POST["max_vicidial_trunks"];} +if (isset($_GET["telnet_host"])) {$telnet_host=$_GET["telnet_host"];} + elseif (isset($_POST["telnet_host"])) {$telnet_host=$_POST["telnet_host"];} +if (isset($_GET["telnet_port"])) {$telnet_port=$_GET["telnet_port"];} + elseif (isset($_POST["telnet_port"])) {$telnet_port=$_POST["telnet_port"];} +if (isset($_GET["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_GET["ASTmgrUSERNAMEupdate"];} + elseif (isset($_POST["ASTmgrUSERNAMEupdate"])) {$ASTmgrUSERNAMEupdate=$_POST["ASTmgrUSERNAMEupdate"];} +if (isset($_GET["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_GET["ASTmgrUSERNAMElisten"];} + elseif (isset($_POST["ASTmgrUSERNAMElisten"])) {$ASTmgrUSERNAMElisten=$_POST["ASTmgrUSERNAMElisten"];} +if (isset($_GET["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_GET["ASTmgrUSERNAMEsend"];} + elseif (isset($_POST["ASTmgrUSERNAMEsend"])) {$ASTmgrUSERNAMEsend=$_POST["ASTmgrUSERNAMEsend"];} +if (isset($_GET["answer_transfer_agent"])) {$answer_transfer_agent=$_GET["answer_transfer_agent"];} + elseif (isset($_POST["answer_transfer_agent"])) {$answer_transfer_agent=$_POST["answer_transfer_agent"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["old_conf_exten"])) {$old_conf_exten=$_GET["old_conf_exten"];} + elseif (isset($_POST["old_conf_exten"])) {$old_conf_exten=$_POST["old_conf_exten"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["CoNfIrM"])) {$CoNfIrM=$_GET["CoNfIrM"];} + elseif (isset($_POST["CoNfIrM"])) {$CoNfIrM=$_POST["CoNfIrM"];} + +##### BEGIN VARIABLE FILTERING FOR SECURITY ##### + +### DIGITS and Dots +$phone_ip = ereg_replace("[^\.0-9]","",$phone_ip); +$server_ip = ereg_replace("[^\.0-9]","",$server_ip); +$old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); +$computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); + +### Y or N ONLY ### +$active = ereg_replace("[^NY]","",$active); + +### DIGITS ONLY ### +$dialplan_number = ereg_replace("[^0-9]","",$dialplan_number); +$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id); +$outbound_cid = ereg_replace("[^0-9]","",$outbound_cid); +$VICIDIAL_park_on_extension = ereg_replace("[^0-9]","",$VICIDIAL_park_on_extension); +$park_on_extension = ereg_replace("[^0-9]","",$park_on_extension); +$conf_on_extension = ereg_replace("[^0-9]","",$conf_on_extension); +$conf_exten = ereg_replace("[^0-9]","",$conf_exten); +$old_conf_exten = ereg_replace("[^0-9]","",$old_conf_exten); +$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten); +$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten); +$recording_exten = ereg_replace("[^0-9]","",$recording_exten); +$monitor_prefix = ereg_replace("[^0-9]","",$monitor_prefix); +$answer_transfer_agent = ereg_replace("[^0-9]","",$answer_transfer_agent); +$DBX_port = ereg_replace("[^0-9]","",$DBX_port); +$DBY_port = ereg_replace("[^0-9]","",$DBY_port); +$telnet_port = ereg_replace("[^0-9]","",$telnet_port); +$max_vicidial_trunks = ereg_replace("[^0-9]","",$max_vicidial_trunks); +$auto_dial_next_number = ereg_replace("[^0-9]","",$auto_dial_next_number); +$VDstop_rec_after_each_call = ereg_replace("[^0-9]","",$VDstop_rec_after_each_call); +$enable_persistant_mysql = ereg_replace("[^0-9]","",$enable_persistant_mysql); +$enable_fast_refresh = ereg_replace("[^0-9]","",$enable_fast_refresh); +$user_switching_enabled = ereg_replace("[^0-9]","",$user_switching_enabled); +$updater_check_enabled = ereg_replace("[^0-9]","",$updater_check_enabled); +$QUEUE_ACTION_enabled = ereg_replace("[^0-9]","",$QUEUE_ACTION_enabled); +$conferencing_enabled = ereg_replace("[^0-9]","",$conferencing_enabled); +$voicemail_button_enabled = ereg_replace("[^0-9]","",$voicemail_button_enabled); +$CallerID_popup_enabled = ereg_replace("[^0-9]","",$CallerID_popup_enabled); +$call_parking_enabled = ereg_replace("[^0-9]","",$call_parking_enabled); +$AGI_call_logging_enabled = ereg_replace("[^0-9]","",$AGI_call_logging_enabled); +$AFLogging_enabled = ereg_replace("[^0-9]","",$AFLogging_enabled); +$admin_monitor_enabled = ereg_replace("[^0-9]","",$admin_monitor_enabled); +$admin_hijack_enabled = ereg_replace("[^0-9]","",$admin_hijack_enabled); +$admin_hangup_enabled = ereg_replace("[^0-9]","",$admin_hangup_enabled); +$fast_refresh_rate = ereg_replace("[^0-9]","",$fast_refresh_rate); +$ADD = ereg_replace("[^0-9]","",$ADD); + +### ALPHA-NUMERIC and underscore and dash and slash and at and dot +$extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$extension); +$old_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$old_extension); +$install_directory = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$install_directory); +$client_browser = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$client_browser); +$dtmf_send_extension = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$dtmf_send_extension); +$call_out_number_group = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$call_out_number_group); +$telnet_host = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$telnet_host); +$DBX_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBX_server); +$DBY_server = ereg_replace("[^-\.\:\/\@\_0-9a-zA-Z]","",$DBY_server); + +### ALPHA-NUMERIC (and underscore and dash) +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$login = ereg_replace("[^-\_0-9a-zA-Z]","",$login); +$user = ereg_replace("[^-\_0-9a-zA-Z]","",$user); +$pass = ereg_replace("[^-\_0-9a-zA-Z]","",$pass); +$status = ereg_replace("[^-\_0-9a-zA-Z]","",$status); +$protocol = ereg_replace("[^-\_0-9a-zA-Z]","",$protocol); +$ASTmgrUSERNAMEupdate = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEupdate); +$ASTmgrUSERNAMEsend = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMEsend); +$ASTmgrUSERNAMElisten = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAMElisten); +$ASTmgrUSERNAME = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrUSERNAME); +$ASTmgrSECRET = ereg_replace("[^-\_0-9a-zA-Z]","",$ASTmgrSECRET); +$login_user = ereg_replace("[^-\_0-9a-zA-Z]","",$login_user); +$login_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$login_pass); +$login_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$login_campaign); +$DBX_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_user); +$DBY_user = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_user); +$DBX_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_pass); +$DBY_pass = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_pass); +$DBX_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBX_database); +$DBY_database = ereg_replace("[^-\_0-9a-zA-Z]","",$DBY_database); +$VICIDIAL_park_on_filename = ereg_replace("[^-\_0-9a-zA-Z]","",$VICIDIAL_park_on_filename); +$server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$server_id); +$old_server_id = ereg_replace("[^-\_0-9a-zA-Z]","",$old_server_id); +$ext_context = ereg_replace("[^-\_0-9a-zA-Z]","",$ext_context); +$CoNfIrM = ereg_replace("[^-\_0-9a-zA-Z]","",$CoNfIrM); + +### ALPHA-NUMERIC and spaces dots, commas, dashes, underscores +$phone_type = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$phone_type); +$full_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$full_name); +$fullname = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$fullname); +$company = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$company); +$picture = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$picture); +$local_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$local_gmt); +$server_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$server_description); +$asterisk_version = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$asterisk_version); + +### VARIABLES TO BE mysql_real_escape_string ### +# $VICIDIAL_web_URL = +# $local_web_callerID_URL = + +##### END VARIABLE FILTERING FOR SECURITY ##### + +if ($force_logout) +{ + if( (strlen($PHP_AUTH_USER)>0) or (strlen($PHP_AUTH_PW)>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "You have now logged out. Thank you\n"; + exit; +} + +if (!isset($ADD)) {$ADD=0;} + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + +if ($ADD==1) {$process = 'ADD NEW PHONE';} +if ($ADD==11) {$process = 'ADD NEW SERVER';} +if ($ADD==111) {$process = 'ADD NEW CONFERENCE';} +if ($ADD==2) {$process = 'ADDING NEW PHONE';} +if ($ADD==21) {$process = 'ADDING NEW SERVER';} +if ($ADD==211) {$process = 'ADDING NEW CONFERENCE';} +if ($ADD==3) {$process = 'MODIFY PHONE';} +if ($ADD==31) {$process = 'MODIFY SERVER';} +if ($ADD==311) {$process = 'MODIFY CONFERENCE';} +if ($ADD==4) {$process = 'MODIFYING PHONE';} +if ($ADD==41) {$process = 'MODIFYING SERVER';} +if ($ADD==411) {$process = 'MODIFYING CONFERENCE';} +if ($ADD==5) {$process = 'DELETE PHONE';} +if ($ADD==6) {$process = 'DELETE PHONE';} +if ($ADD==55) {$process = 'SEARCH PHONES';} +if ($ADD==66) {$process = 'SEARCH PHONES RESULTS';} +if ($ADD==0) {$process = 'PHONE LIST';} +if ($ADD==10) {$process = 'SERVER LIST';} +if ($ADD==100) {$process = 'CONFERENCE LIST';} +if ($ADD==99999) {$process = 'HELP';} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if ($auth<1) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > '6' and ast_admin_access='1';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $stmt="SELECT * from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname =$row[3]; + $LOGdelete_phones =$row[17]; + } + } + +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./project_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + echo "|$stmt|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + if (strlen($LOGfullname) < 1) + { + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + } + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + + ##### get server listing for dynamic pulldown + $stmt="SELECT server_ip,server_description from servers order by server_ip"; + $rsltx=mysql_query($stmt, $link); + $servers_to_print = mysql_num_rows($rsltx); + $servers_list=''; + + $o=0; + while ($servers_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $servers_list .= "\n"; + $o++; + } + + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); + +$NWB = "   \"HELP\""; +###################### +# ADD=99999 display the HELP SCREENS +###################### + +if ($ADD==99999) +{ +echo "\n"; +echo "\n"; +echo "ASTERISK ADMIN: Administration - $process \n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
ASTERISK ADMIN: HELP


\n"; + +?> +PHONES TABLE

+ +
+Phone extension - This field is where you put the phones name as it appears to Asterisk not including the protocol or slash at the beginning. For Example: for the SIP phone SIP/test101 the Phone extension would be test101. Also, for IAX2 phones make sure you use the full phones name: IAX2/IAXphone1@IAXphone1 would be IAXphone1@IAXphone1. For Zap phones make sure you put the full channel: Zap/25-1 would be 25-1. Another note, make sure you set the Protocol below correctly for your type of phone. + +
+
+
+Dialplan number - This field is for the number you dial to have the phone ring. This number is defined in the extensions.conf file of your Asterisk server + +
+
+
+Voicemail Box - This field is for the voicemail box that the messages go to for the user of this phone. We use this to check for voicemail messages and for the user to be able to use the VOICEMAIL button on astGUIclient app. + +
+
+
+Outbound CallerID - This field is where you would enter the callerID number that you would like to appear on outbound calls placed form the astguiclient web-client. This does not work on RBS, non-PRI, T1/E1s. + +
+
+
+Phone IP address - This field is for the phone's IP address if it is a VOIP phone. This is an optional field + +
+
+
+Computer IP address - This field is for the user's computer IP address. This is an optional field + +
+
+
+Server IP - This menu is where you select which server the phone is active on. + +
+
+
+Login - The login used for the phone user to login to the client applications. + +
+
+
+Password - The password used for the phone user to login to the client applications. + +
+
+
+Status - The status of the phone in the system, ACTIVE and ADMIN allow for GUI clients to work. ADMIN allows access to this administrative web site. All other statuses do not allow GUI or Admin web access. + +
+
+
+Active Account - Whether the phone is active to put it in the list in the GUI client. + +
+
+
+Phone Type - Purely for administrative notes. + +
+
+
+Full Name - Used by the GUIclient in the list of active phones. + +
+
+
+Company - Purely for administrative notes. + +
+
+
+Picture - Not yet Implemented. + +
+
+
+New Messages - Number of new voicemail messages for this phone on the Asterisk server. + +
+
+
+Old Messages - Number of old voicemail messages for this phone on the Asterisk server. + +
+
+
+Client Protocol - The protocol that the phone uses to connect to the Asterisk server: SIP, IAX2, Zap . Also, there is EXTERNAL for remote dial numbers or speed dial numbers that you want to list as phones. + +
+
+
+Local GMT - The difference from Greenwich Mean time, or ZULU time where the phone is located. DO NOT ADJUST FOR DAYLIGHT SAVINGS TIME. This is used by the VICIDIAL campaign to accurately display the time and customer time. + +
+
+
+Manager Login - This is the login that the GUI clients for this phone will use to access the Database where the server data resides. + +
+
+
+Manager Secret - This is the password that the GUI clients for this phone will use to access the Database where the server data resides. + +
+
+
+VICIDIAL Default User - This is to place a default value in the VICIDIAL user field whenever this phone user opens the astVICIDIAL client app. Leave blank for no user. + +
+
+
+VICIDIAL Default Pass - This is to place a default value in the VICIDIAL password field whenever this phone user opens the astVICIDIAL client app. Leave blank for no pass. + +
+
+
+VICIDIAL Default Campaign - This is to place a default value in the VICIDIAL campaign field whenever this phone user opens the astVICIDIAL client app. Leave blank for no campaign. + +
+
+
+Park Exten - This is the default Parking extension for the client apps. Verify that a different one works before you change this. + +
+
+
+Conf Exten - This is the default Conference park extension for the client apps. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park Exten - This is the default Parking extension for VICIDIAL client app. Verify that a different one works before you change this. + +
+
+
+VICIDIAL Park File - This is the default VICIDIAL park extension file name for the client apps. Verify that a different one works before you change this. limited to 10 characters. + +
+
+
+Monitor Prefix - This is the dialplan prefix for monitoring of Zap channels automatically within the astGUIclient app. Only change according to the extensions.conf ZapBarge extensions records. + +
+
+
+Recording Exten - This is the dialplan extension for the recording extension that is used to drop into meetme conferences to record them. It usually lasts upto one hour if not stopped. verify with extensions.conf file before changing. + +
+
+
+VMAIL Main Exten - This is the dialplan extension going to check your voicemail. verify with extensions.conf file before changing. + +
+
+
+VMAIL Dump Exten - This is the dialplan prefix used to send calls directly to a user's voicemail from a live call in the astGUIclient app. verify with extensions.conf file before changing. + +
+
+
+Exten Context - This is the dialplan context that this phone primarily uses. It is assumed that all numbers dialed by the client apps are using this context so it is a good idea to make sure this is the most wide context possible. verify with extensions.conf file before changing. + +
+
+
+DTMF send Channel - This is the channel string used to send DTMF sounds into meetme conferences from the client apps. Verify the exten and context with the extensions.conf file. + +
+
+
+Outbound Call Group - This is the channel group that outbound calls from this phone are placed out of. There are a couple routines in the client apps that use this. For Zap channels you want to use something like Zap/g2 , for IAX2 trunks you would want to use the full IAX prefix like IAX2/VICItest1:secret@10.10.10.15:4569. Verify the trunks with the extensions.conf file, it is usually what you have defined as the TRUNK global variable at the top of the file. + +
+
+
+Browser Location - This is applicable to only UNIX/LINUX clients, the absolute path to Mozilla or Firefox browser on the machine. verify this by launching it manually. + +
+
+
+Install Directory - This is the place where the astGUIclient and astVICIDIAL scripts are located on your machine. For Win32 it should be something like C:\AST_VICI and for UNIX it should be something like /usr/local/perl_TK. verify this manually. + +
+
+
+CallerID URL - This is the web address of the page used to do custom callerID lookups. default testing address is: http://astguiclient.sf.net/test_callerid_output.php + +
+
+
+VICIDIAL Default URL - This is the web address of the page used to do custom VICIDIAL Web Form queries. default testing address is: http://astguiclient.sf.net/test_VICIDIAL_output.php + +
+
+
+Call Logging - This is set to true if the call_log.agi file is in place in the extensions.conf file for all outbound and hangup 'h' extensions to log all calls. This should always be 1 because it is manditory for many astGUIclient and VICIDIAL features to work properly. + +
+
+
+User Switching - Set to true to allow user to switch to another user account. NOTE: If user switches they can initiate recording on the new user's phone conversation + +
+
+
+Conferencing - Set to true to allow user to start conference calls with upto six external lines. + +
+
+
+Admin Hangup - Set to true to allow user to be able to hangup any line at will through astGUIclient. Good idea only to enable this for Admin users. + +
+
+
+Admin Hijack - Set to true to allow user to be able to grab and redirect to their extension any line at will through astGUIclient. Good idea only to enable this for Admin users. But is very useful for Managers. + +
+
+
+Admin Monitor - Set to true to allow user to be able to grab and redirect to their extension any line at will through astGUIclient. Good idea only to enable this for Admin users. But is very useful for Managers and as a training tool. + +
+
+
+Call Park - Set to true to allow user to be able to park calls on astGUIclient hold to be picked up by any other astGUIclient user on the system. Calls stay on hold for upto a half hour then hangup. Usually enabled for all. + +
+
+
+Updater Check - Set to true to display a popup warning that the updater time has not changed in 20 seconds. Useful for Admin users. + +
+
+
+AF Logging - Set to true to log many actions of astGUIclient usage to a text file on the user's computer. + +
+
+
+Queue Enabled - Set to true to have client apps use the Asterisk Central Queue system. Required for VICIDIAL and recommended for all users. + +
+
+
+CallerID Popup - Set to true to allow for numbers defined in the extensions.conf file to send CallerID popup screens to astGUIclient users. + +
+
+
+VMail Button - Set to true to display the VOICEMAIL button and the messages count display on astGUIclient. + +
+
+
+Fast Refresh - Set to true to enable a new rate of refresh of call information for the astGUIclient. Default disabled rate is 1000 ms ,1 second. Can increase system load if you lower this number. + +
+
+
+Fast Refresh Rate - in milliseconds. Only used if Fast Refresh is enabled. Default disabled rate is 1000 ms ,1 second. Can increase system load if you lower this number. + +
+
+
+Persistant MySQL - If enabled the astGUIclient connection will remain connected instead of connecting every second. Useful if you have a fast refresh rate set. It will increase the number of connections on your MySQL machine. + +
+
+
+Auto Dial Next Number - If enabled the VICIDIAL client will dial the next number on the list automatically upon disposition of a call unless they selected to "Stop Dialing" on the disposition screen. + +
+
+
+Stop Rec after each call - If enabled the VICIDIAL client will stop whatever recording is going on after each call has been dispositioned. Useful if you are doing a lot of recording or you are using a web form to trigger recording. + +
+
+
+DBX Server - The MySQL database server that this user should be connecting to. + +
+
+
+DBX Database - The MySQL database that this user should be connecting to. Default is asterisk. + +
+
+
+DBX User - The MySQL user login that this user should be using when connecting. Default is cron. + +
+
+
+DBX Pass - The MySQL user password that this user should be using when connecting. Default is 1234. + +
+
+
+DBX Port - The MySQL TCP port that this user should be using when connecting. Default is 3306. + +
+
+
+DBY Server - The MySQL database server that this user should be connecting to. Secondary server, not used currently. + +
+
+
+DBY Database - The MySQL database that this user should be connecting to. Default is asterisk. Secondary server, not used currently. + +
+
+
+DBY User - The MySQL user login that this user should be using when connecting. Default is cron. Secondary server, not used currently. + +
+
+
+DBY Pass - The MySQL user password that this user should be using when connecting. Default is 1234. Secondary server, not used currently. + +
+
+
+DBY Port - The MySQL TCP port that this user should be using when connecting. Default is 3306. Secondary server, not used currently. + + +



+ +SERVERS TABLE

+
+
+Server ID - This field is where you put the Asterisk servers name, doesnt have to be an official domain sub, just a nickname to identify the server to Admin users. + +
+
+
+Server Description - The field where you use a small phrase to describe the Asterisk server. + +
+
+
+Server IP Address - The field where you put the Network IP address of the Asterisk server. + +
+
+
+Active - Set whether the Asterisk server is active or inactive. + +
+
+
+Asterisk Version - Set the version of Asterisk that you have installed on this server. Examples: '1.2', '1.0.8', '1.0.7', 'CVS_HEAD', 'REALLY OLD', etc... This is used because versions 1.0.8 and 1.0.9 have a different method of dealing with Local/ channels, a bug that has been fixed in CVS v1.0, and need to be treated differently when handling their Local/ channels. Also, current CVS_HEAD and the 1.2 release tree uses different manager and command output so it must be treated differently as well. + +
+
+
+Max VICIDIAL Trunks - This field will determine the maximum number of lines that the VICIDIAL auto-dialer will attempt to call on this server. If you want to dedicate two full PRI T1s to VICIDIALing on a server then you would set this to 46. Default is 96. + +
+
+
+Telnet Host - This is the address or name of the Asterisk server and is how the manager applications connect to it from where they are running. If they are running on the Asterisk server, then the default of 'localhost' is fine. + +
+
+
+Telnet Port - This is the port of the Asterisk server Manager connection and is how the manager applications connect to it from where they are running. The default of '5038' is fine for a standard install. + +
+
+
+Manager User - The username or login used to connect genericly to the Asterisk server manager. Default is 'cron' + +
+
+
+Manager Secret - The secret or password used to connect genericly to the Asterisk server manager. Default is '1234' + +
+
+
+Manager Update User - The username or login used to connect to the Asterisk server manager optimized for the Update scripts. Default is 'updatecron' and assumes the same secret as the generic user. + +
+
+
+Manager Listen User - The username or login used to connect to the Asterisk server manager optimized for scripts that only listen for output. Default is 'listencron' and assumes the same secret as the generic user. + +
+
+
+Manager Send User - The username or login used to connect to the Asterisk server manager optimized for scripts that only send Actions to the manager. Default is 'sendcron' and assumes the same secret as the generic user. + +
+
+
+Server GMT offset - The difference in hours from GMT time not adjusted for Daylight-Savings-Time of the server. Default is '-5' + +
+
+
+VMail Dump Exten - The extension prefix used on this server to send calls directly through agc to a specific voicemail box. Default is '85026666666666' + +
+
+
+VICIDIAL AD extension - The default extension if none is present in the campaign to send calls to for VICIDIAL auto dialing. Default is '8365' + +
+
+
+Default Context - The default dialplan context used for scripts that operate for this server. Default is 'default' + + +



+ +CONFERENCES TABLE

+
+
+Conference Number - This field is where you put the meetme conference dialpna number. It is also recommended that the meetme number in meetme.conf matches this number for each entry. This is for the conferences in astGUIclient and is used for leave-3way-call functionality in VICIDIAL. + +
+
+
+Server IP - The menu where you select the Asterisk server that this conference will be on. + + + + + + +







+







+THE END +
+ + + +ASTERISK ADMIN: Administration - <? echo $process ?> + + + +
+ + + + + + +
  ASTERISK ADMIN - Logout  
  LIST ALL PHONES | ADD A NEW PHONE | SEARCH FOR A PHONE | ADD A SERVER | LIST ALL SERVERS
  SHOW ALL CONFERENCES | ADD A NEW CONFERENCE
+"; + +echo "
ADD A NEW PHONE
\n"; +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
\n"; + +} + + +###################### +# ADD=11 display the ADD NEW SERVERS FORM SCREEN +###################### + +if ($ADD==11) +{ +echo ""; + +echo "
ADD A NEW SERVER\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
\n"; + +} + + +###################### +# ADD=111 display the ADD NEW CONFERENCES FORM SCREEN +###################### + +if ($ADD==111) +{ +echo ""; + +echo "
ADD A NEW CONFERENCE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference Number: (digits only)$NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
\n"; + +} + + +###################### +# ADD=2 adds the new phone to the system +###################### + +if ($ADD==2) +{ + echo ""; + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
PHONE NOT ADDED - there is already a Phone in the system with this extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
PHONE NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
PHONE ADDED\n"; + + $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=3; +} + +###################### +# ADD=21 adds the new server to the system +###################### + +if ($ADD==21) +{ + echo ""; + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
SERVER NOT ADDED - there is already a server in the system with this ID\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVER NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
SERVER ADDED\n"; + + $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=31; +} + + +###################### +# ADD=211 adds the new conference to the system +###################### + +if ($ADD==211) +{ + echo ""; + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + {echo "
CONFERENCE NOT ADDED - there is already a conference in the system with this ID and server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCE NOT ADDED - Please go back and look at the data you entered\n";} + else + { + echo "
CONFERENCE ADDED\n"; + + $stmt="INSERT INTO conferences (conf_exten,server_ip) values('$conf_exten','$server_ip');"; + $rslt=mysql_query($stmt, $link); + } + } +$ADD=100; +} + + +###################################################################################################### +###################################################################################################### +####### 5 series, delete records confirmation +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=5 confirmation before deletion of phone +###################### + +if ($ADD==5) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($LOGdelete_phones < 1) ) + { + echo "
PHONE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Server IP be at least 7 characters in length\n"; + } + else + { + echo "
PHONE DELETION CONFIRMATION: $extension - $server_ip\n"; + echo "

Click here to delete phone $extension - $server_ip


\n"; + } + +$ADD='3'; # go to phone modification below +} + + + + +###################################################################################################### +###################################################################################################### +####### 6 series, delete records +###################################################################################################### +###################################################################################################### + + +###################### +# ADD=6 delete phone record +###################### + +if ($ADD==6) +{ + echo ""; + + if ( (strlen($extension) < 2) or (strlen($server_ip) < 7) or ($CoNfIrM != 'YES') or ($LOGdelete_phones < 1) ) + { + echo "
PHONE NOT DELETED - Please go back and look at the data you entered\n"; + echo "
Extension be at least 2 characters in length\n"; + echo "
Server IP be at least 7 characters in length\n"; + } + else + { + $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; + $rslt=mysql_query($stmt, $link); + + ### LOG CHANGES TO LOG FILE ### + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./admin_changes_log.txt", "a"); + fwrite ($fp, "$date|!!!DELETING PHONE!!!|$PHP_AUTH_USER|$ip|extension='$extension'|server_ip='$server_ip'|\n"); + fclose($fp); + } + echo "
PHONE DELETION COMPLETED: $extension - $server_ip\n"; + echo "

\n"; + } + +$ADD='0'; # go to phone list +} + + + + + + +###################### +# ADD=3 modify phone info in the system +###################### + +if ($ADD==3) +{ + echo ""; + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A PHONE RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
New Messages: $row[14]$NWB#phones-messages$NWE
Old Messages: $row[15]$NWB#phones-old_messages$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
VICIDIAL Default Pass: $NWB#phones-login_pass$NWE
VICIDIAL Default Campaign: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park File: $NWB#phones-VICIDIAL_park_on_filename$NWE
Monitor Prefix: $NWB#phones-monitor_prefix$NWE
Recording Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Context: $NWB#phones-ext_context$NWE
DTMFSend Channel: $NWB#phones-dtmf_send_extension$NWE
Outbound Call Group: $NWB#phones-call_out_number_group$NWE
Browser Location: $NWB#phones-client_browser$NWE
Install Directory: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Default URL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
User Switching: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hangup: $NWB#phones-admin_hangup_enabled$NWE
Admin Hijack: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Call Park: $NWB#phones-call_parking_enabled$NWE
Updater Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Queue Enabled: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Button: $NWB#phones-voicemail_button_enabled$NWE
Fast Refresh: $NWB#phones-enable_fast_refresh$NWE
Fast Refresh Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Dial Next Number: $NWB#phones-auto_dial_next_number$NWE
Stop Rec after each call: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Server: (Primary DB Server)$NWB#phones-DBX_server$NWE
DBX Database: (Primary Server Database)$NWB#phones-DBX_database$NWE
DBX User: (Primary DB Login)$NWB#phones-DBX_user$NWE
DBX Pass: (Primary DB Secret)$NWB#phones-DBX_pass$NWE
DBX Port: (Primary DB Port)$NWB#phones-DBX_port$NWE
DBY Server: (Secondary DB Server)$NWB#phones-DBY_server$NWE
DBY Database: (Secondary Server Database)$NWB#phones-DBY_database$NWE
DBY User: (Secondary DB Login)$NWB#phones-DBY_user$NWE
DBY Pass: (Secondary DB Secret)$NWB#phones-DBY_pass$NWE
DBY Port: (Secondary DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Click here for phone stats\n"; + +if ($LOGdelete_phones > 0) + { + echo "

DELETE THIS PHONE\n"; + } + +} + + +###################### +# ADD=31 modify server info in the system +###################### + +if ($ADD==31) +{ + echo ""; + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A SERVER RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
PHONES WITHIN THIS SERVER:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIONNAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This server has $active_lists active phones and $inactive_lists inactive phones

\n"; +echo "
\n"; +} + + +###################### +# ADD=311 modify conference info in the system +###################### + +if ($ADD==311) +{ + echo ""; + + $stmt="SELECT * from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A CONFERENCE RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference: $NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
Current Extension:
\n"; + +echo "
\n"; + +} + + + +###################### +# ADD=4 submit phone modifications to the system +###################### + +if ($ADD==4) +{ + echo ""; + + $stmt="SELECT count(*) from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($extension != $old_extension) or ($server_ip != $old_server_ip) ) ) + {echo "
PHONE NOT MODIFIED - there is already a Phone in the system with this extension/server\n";} + else + { + if ( (strlen($extension) < 1) or (strlen($server_ip) < 7) or (strlen($dialplan_number) < 1) or (strlen($voicemail_id) < 1) or (strlen($login) < 1) or (strlen($pass) < 1)) + {echo "
PHONE NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
PHONE MODIFIED: $extension\n"; + + $stmt="UPDATE phones set extension='$extension', dialplan_number='$dialplan_number', voicemail_id='$voicemail_id', phone_ip='$phone_ip', computer_ip='$computer_ip', server_ip='$server_ip', login='$login', pass='$pass', status='$status', active='$active', phone_type='$phone_type', fullname='$fullname', company='$company', picture='$picture', protocol='$protocol', local_gmt='$local_gmt', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', login_user='$login_user', login_pass='$login_pass', login_campaign='$login_campaign', park_on_extension='$park_on_extension', conf_on_extension='$conf_on_extension', VICIDIAL_park_on_extension='$VICIDIAL_park_on_extension', VICIDIAL_park_on_filename='$VICIDIAL_park_on_filename', monitor_prefix='$monitor_prefix', recording_exten='$recording_exten', voicemail_exten='$voicemail_exten', voicemail_dump_exten='$voicemail_dump_exten', ext_context='$ext_context', dtmf_send_extension='$dtmf_send_extension', call_out_number_group='$call_out_number_group', client_browser='$client_browser', install_directory='$install_directory', local_web_callerID_URL='" . mysql_real_escape_string($local_web_callerID_URL) . "', VICIDIAL_web_URL='" . mysql_real_escape_string($VICIDIAL_web_URL) . "', AGI_call_logging_enabled='$AGI_call_logging_enabled', user_switching_enabled='$user_switching_enabled', conferencing_enabled='$conferencing_enabled', admin_hangup_enabled='$admin_hangup_enabled', admin_hijack_enabled='$admin_hijack_enabled', admin_monitor_enabled='$admin_monitor_enabled', call_parking_enabled='$call_parking_enabled', updater_check_enabled='$updater_check_enabled', AFLogging_enabled='$AFLogging_enabled', QUEUE_ACTION_enabled='$QUEUE_ACTION_enabled', CallerID_popup_enabled='$CallerID_popup_enabled', voicemail_button_enabled='$voicemail_button_enabled', enable_fast_refresh='$enable_fast_refresh', fast_refresh_rate='$fast_refresh_rate', enable_persistant_mysql='$enable_persistant_mysql', auto_dial_next_number='$auto_dial_next_number', VDstop_rec_after_each_call='$VDstop_rec_after_each_call', DBX_server='$DBX_server', DBX_database='$DBX_database', DBX_user='$DBX_user', DBX_pass='$DBX_pass', DBX_port='$DBX_port', DBY_server='$DBY_server', DBY_database='$DBY_database', DBY_user='$DBY_user', DBY_pass='$DBY_pass', DBY_port='$DBY_port', outbound_cid='$outbound_cid' where extension='$old_extension' and server_ip='$old_server_ip';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from phones where extension='$extension' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A PHONE RECORD: $row[1]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Phone extension: $NWB#phones-extension$NWE
Dialplan Number: (digits only)$NWB#phones-dialplan_number$NWE
Voicemail Box: (digits only)$NWB#phones-voicemail_id$NWE
Outbound CallerID: (digits only)$NWB#phones-outbound_cid$NWE
Phone IP address: (optional)$NWB#phones-phone_ip$NWE
Computer IP address: (optional)$NWB#phones-computer_ip$NWE
Server IP: $NWB#phones-server_ip$NWE
Login: $NWB#phones-login$NWE
Password: $NWB#phones-pass$NWE
Status: $NWB#phones-status$NWE
Active Account: $NWB#phones-active$NWE
Phone Type: $NWB#phones-phone_type$NWE
Full Name: $NWB#phones-fullname$NWE
Company: $NWB#phones-company$NWE
Picture: $NWB#phones-picture$NWE
New Messages: $row[14]$NWB#phones-messages$NWE
Old Messages: $row[15]$NWB#phones-old_messages$NWE
Client Protocol: $NWB#phones-protocol$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#phones-local_gmt$NWE
Manager Login: $NWB#phones-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#phones-ASTmgrSECRET$NWE
VICIDIAL Default User: $NWB#phones-login_user$NWE
VICIDIAL Default Pass: $NWB#phones-login_pass$NWE
VICIDIAL Default Campaign: $NWB#phones-login_campaign$NWE
Park Exten: $NWB#phones-park_on_extension$NWE
Conf Exten: $NWB#phones-conf_on_extension$NWE
VICIDIAL Park Exten: $NWB#phones-VICIDIAL_park_on_extension$NWE
VICIDIAL Park File: $NWB#phones-VICIDIAL_park_on_filename$NWE
Monitor Prefix: $NWB#phones-monitor_prefix$NWE
Recording Exten: $NWB#phones-recording_exten$NWE
VMailMain Exten: $NWB#phones-voicemail_exten$NWE
VMailDump Exten: $NWB#phones-voicemail_dump_exten$NWE
Exten Context: $NWB#phones-ext_context$NWE
DTMFSend Channel: $NWB#phones-dtmf_send_extension$NWE
Outbound Call Group: $NWB#phones-call_out_number_group$NWE
Browser Location: $NWB#phones-client_browser$NWE
Install Directory: $NWB#phones-install_directory$NWE
CallerID URL: $NWB#phones-local_web_callerID_URL$NWE
VICIDIAL Default URL: $NWB#phones-VICIDIAL_web_URL$NWE
Call Logging: $NWB#phones-AGI_call_logging_enabled$NWE
User Switching: $NWB#phones-user_switching_enabled$NWE
Conferencing: $NWB#phones-conferencing_enabled$NWE
Admin Hangup: $NWB#phones-admin_hangup_enabled$NWE
Admin Hijack: $NWB#phones-admin_hijack_enabled$NWE
Admin Monitor: $NWB#phones-admin_monitor_enabled$NWE
Call Park: $NWB#phones-call_parking_enabled$NWE
Updater Check: $NWB#phones-updater_check_enabled$NWE
AF Logging: $NWB#phones-AFLogging_enabled$NWE
Queue Enabled: $NWB#phones-QUEUE_ACTION_enabled$NWE
CallerID Popup: $NWB#phones-CallerID_popup_enabled$NWE
VMail Button: $NWB#phones-voicemail_button_enabled$NWE
Fast Refresh: $NWB#phones-enable_fast_refresh$NWE
Fast Refresh Rate: (in ms)$NWB#phones-fast_refresh_rate$NWE
Persistant MySQL: $NWB#phones-enable_persistant_mysql$NWE
Auto Dial Next Number: $NWB#phones-auto_dial_next_number$NWE
Stop Rec after each call: $NWB#phones-VDstop_rec_after_each_call$NWE
DBX Server: (Primary DB Server)$NWB#phones-DBX_server$NWE
DBX Database: (Primary Server Database)$NWB#phones-DBX_database$NWE
DBX User: (Primary DB Login)$NWB#phones-DBX_user$NWE
DBX Pass: (Primary DB Secret)$NWB#phones-DBX_pass$NWE
DBX Port: (Primary DB Port)$NWB#phones-DBX_port$NWE
DBY Server: (Secondary DB Server)$NWB#phones-DBY_server$NWE
DBY Database: (Secondary Server Database)$NWB#phones-DBY_database$NWE
DBY User: (Secondary DB Login)$NWB#phones-DBY_user$NWE
DBY Pass: (Secondary DB Secret)$NWB#phones-DBY_pass$NWE
DBY Port: (Secondary DB Port)$NWB#phones-DBY_port$NWE
\n"; + +echo "

Click here for phone stats\n"; + +if ($LOGdelete_phones > 0) + { + echo "

DELETE THIS PHONE\n"; + } + +} + +###################### +# ADD=41 submit server modifications to the system +###################### + +if ($ADD==41) +{ + echo ""; + + $stmt="SELECT count(*) from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_id != $old_server_id) ) + {echo "
SERVER NOT MODIFIED - there is already a server in the system with this server_id\n";} + else + { + $stmt="SELECT count(*) from servers where server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ($server_ip != $old_server_ip) ) + {echo "
SERVER NOT MODIFIED - there is already a server in the system with this server_ip\n";} + else + { + if ( (strlen($server_id) < 1) or (strlen($server_ip) < 7) ) + {echo "
SERVER NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
SERVER MODIFIED: $server_ip\n"; + + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context' where server_id='$old_server_id';"; + $rslt=mysql_query($stmt, $link); + } + } + } + + $stmt="SELECT * from servers where server_id='$server_id';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A SERVER RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
\n"; + +echo "
\n"; +echo "
PHONES WITHIN THIS SERVER:
\n"; +echo "\n"; +echo "\n"; + + $active_lists = 0; + $inactive_lists = 0; + $stmt="SELECT extension,active,fullname from phones where server_ip='$row[2]'"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $camp_lists=''; + + $o=0; + while ($lists_to_print > $o) { + $rowx=mysql_fetch_row($rsltx); + $o++; + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + + } + +echo "
EXTENSIONNAMEACTIVE
$rowx[0]$rowx[2]$rowx[1]

\n"; +echo "
\n"; + + $camp_lists = eregi_replace(".$","",$camp_lists); +echo "This server has $active_lists active phones and $inactive_lists inactive phones

\n"; +echo "
\n"; + +} + +###################### +# ADD=411 submit conference modifications to the system +###################### + +if ($ADD==411) +{ + echo ""; + + $stmt="SELECT count(*) from conferences where conf_exten='$conf_exten' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0] > 0) && ( ($conf_exten != $old_conf_exten) or ($server_ip != $old_server_ip) ) ) + {echo "
CONFERENCE NOT MODIFIED - there is already a Conference in the system with this extension-server\n";} + else + { + if ( (strlen($conf_exten) < 1) or (strlen($server_ip) < 7) ) + {echo "
CONFERENCE NOT MODIFIED - Please go back and look at the data you entered\n";} + else + { + echo "
CONFERENCE MODIFIED: $conf_exten\n"; + + $stmt="UPDATE conferences set conf_exten='$conf_exten',server_ip='$server_ip',extension='$extension' where conf_exten='$old_conf_exten';"; + $rslt=mysql_query($stmt, $link); + } + } + + $stmt="SELECT * from conferences where conf_exten='$conf_exten';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + +echo "
MODIFY A CONFERENCE RECORD: $row[0]\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Conference: $NWB#conferences-conf_exten$NWE
Server IP: $NWB#conferences-server_ip$NWE
Current Extension:
\n"; + +echo "
\n"; + +} + + + + + + + +###################### +# ADD=55 search form +###################### + +if ($ADD==55) +{ +echo ""; + +echo "
SEARCH FOR A PHONE\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
extension:
Full Name:
Phone type:
\n"; + +} + +###################### +# ADD=66 phone search results +###################### + +if ($ADD==66) +{ + echo ""; + + $SQL = ''; + if ($extension) {$SQL .= "extension LIKE \"%$extension%\" and";} + if ($fullname) {$SQL .= "fullname LIKE \"%$fullname%\" and";} + if ($phone_type) {$SQL .= "phone_type LIKE \"%$phone_type%\" and";} + $SQL = eregi_replace(" and$", "", $SQL); + if (strlen($SQL)>5) {$SQL = "where $SQL";} + + $stmt="SELECT * from phones $SQL order by extension,server_ip;"; +# echo "\n|$stmt|\n"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SEARCH RESULTS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFY | STATS
\n"; + +} + + + +###################### +# ADD=0 display all active phones +###################### +if ($ADD==0) +{ + echo ""; + + $stmt="SELECT * from phones order by extension,server_ip"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
PHONE LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[16]$row[5]$row[1]$row[2]$row[8]$row[11]$row[14]$row[15]MODIFY | STATS
\n"; +} + +###################### +# ADD=10 display all servers +###################### +if ($ADD==10) +{ + echo ""; + + $stmt="SELECT * from servers order by server_id"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
SERVER LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0]$row[1] $row[2] $row[4] $row[3]  MODIFY
\n"; +} + + +###################### +# ADD=100 display all conferences +###################### +if ($ADD==100) +{ + echo ""; + + $stmt="SELECT * from conferences order by conf_exten"; + $rslt=mysql_query($stmt, $link); + $phones_to_print = mysql_num_rows($rslt); + +echo "
CONFERENCE LISTINGS:\n"; +echo "
\n"; + + $o=0; + while ($phones_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + +echo "
$row[0] $row[1] $row[2]$row[4]  MODIFY
\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds"; +echo "             VERSION: $version"; +echo "             BUILD: $build
\n"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/astguiclient_web/dbconnect.php b/agc_2-X/trunk/astguiclient_web/dbconnect.php new file mode 100644 index 00000000..f1998407 --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/dbconnect.php @@ -0,0 +1,14 @@ + LICENSE: GPLv2 +# + +$link=mysql_connect("localhost", "cron", "1234"); +mysql_select_db("asterisk"); + +#$WeBServeRRooT = '/home/www/htdocs'; +$WeBServeRRooT = '/usr/local/apache2/htdocs'; +$WeBRooTWritablE = '1'; + +?> \ No newline at end of file diff --git a/agc_2-X/trunk/astguiclient_web/help.gif b/agc_2-X/trunk/astguiclient_web/help.gif new file mode 100644 index 00000000..5575d7c8 Binary files /dev/null and b/agc_2-X/trunk/astguiclient_web/help.gif differ diff --git a/agc_2-X/trunk/astguiclient_web/inbound_popup.php b/agc_2-X/trunk/astguiclient_web/inbound_popup.php new file mode 100644 index 00000000..6f451656 --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/inbound_popup.php @@ -0,0 +1,228 @@ + LICENSE: GPLv2 +### +# this is the inbound popup of a specific call that grabs the call and allows you to go and fetch info on that caller in the local CRM system. +# +# changes: +# 60620-1329 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} + elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; +$FILE_datetime = $STARTtime; + +$ext_context = 'demo'; +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK REMOTE INBOUND: Popup + + +
+ + 0) +{ + + $stmt="DELETE from parked_channels where server_ip='$user_server_ip' and parked_time='" . mysql_real_escape_string($parked_time) . "' and channel='" . mysql_real_escape_string($channel) . "' LIMIT 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $DTqueryCID = "RR$FILE_datetime$PHP_AUTH_USER"; + + ### insert a NEW record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$user_server_ip','','Redirect','$DTqueryCID','Exten: $dialplan_number','Channel: " . mysql_real_escape_string($channel) . "','Context: $ext_context','Priority: 1','Callerid: $DTqueryCID','','','','','')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + echo "Redirect command sent for channel $channel       $NOW_TIME\n

\n"; + + + $url = 'https://10.10.10.15/internal/back_end_systems/cust_serv/index.php?Search=SEARCH&'; + $Suser = 'username='; + $Spass = '&passwd='; + $Sphone = '&phone='; + + $newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW$Sphone$phone"; + if ( ($phone == 'unknown') or (strlen($phone)<9) ) + {$newurl = "$url$Suser$PHP_AUTH_USER$Spass$PHP_AUTH_PW";} + + echo "Look up this customer in Customer Service System\n

\n"; + + echo "Close this window\n

\n"; +} +else +{ + echo "Redirect command FAILED for channel $channel       $NOW_TIME\n

\n"; + echo "Close this window\n

\n"; +} + + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/astguiclient_web/phone_stats.php b/agc_2-X/trunk/astguiclient_web/phone_stats.php new file mode 100644 index 00000000..e1ff62d0 --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/phone_stats.php @@ -0,0 +1,244 @@ + LICENSE: GPLv2 +# +# +# changes: +# 60620-1333 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["begin_date"])) {$begin_date=$_GET["begin_date"];} + elseif (isset($_POST["begin_date"])) {$begin_date=$_POST["begin_date"];} +if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} + elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["full_name"])) {$full_name=$_GET["full_name"];} + elseif (isset($_POST["full_name"])) {$full_name=$_POST["full_name"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$admin_page = './admin.php'; + +if (!isset($begin_date)) {$begin_date = $TODAY;} +if (!isset($end_date)) {$end_date = $TODAY;} + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status='ADMIN';"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname from phones where server_ip='$server_ip' and extension='$extension'"; + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $row[0]; + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + +?> + + +ASTERISK ADMIN: Phone Stats + + +
+
+ + + + + + +\n"; +echo "
  ASTERISK ADMIN: Administration  
  LIST ALL PHONES | ADD A NEW PHONE | SEARCH FOR A PHONE | ADD A SERVER | LIST ALL SERVERS
  SHOW ALL CONFERENCES | ADD A NEW CONFERENCE
  \n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " to \n"; +echo "  \n"; +echo "\n"; + + +echo "           $user - $full_name\n"; + +echo "
\n"; + + + $stmt="SELECT count(*),channel_group, sum(length_in_sec) from call_log where extension='" . mysql_real_escape_string($extension) . "' and server_ip='" . mysql_real_escape_string($server_ip) . "' and start_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and start_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59' group by channel_group order by channel_group"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + +echo "
\n"; + +echo "CALL TIME AND CHANNELS:\n"; + +echo "
\n"; +echo "\n"; + + $total_calls=0; + $o=0; + while ($statuses_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $call_seconds = $row[2]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} + + echo ""; + echo "\n"; + echo "\n"; + $total_calls = ($total_calls + $row[0]); + + $call_seconds=0; + $o++; + } + + $stmt="SELECT sum(length_in_sec) from call_log where extension='" . mysql_real_escape_string($extension) . "' and server_ip='" . mysql_real_escape_string($server_ip) . "' and start_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and start_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59'"; + $rslt=mysql_query($stmt, $link); + $counts_to_print = mysql_num_rows($rslt); + $row=mysql_fetch_row($rslt); + $call_seconds = $row[0]; + $call_hours = ($call_seconds / 3600); + $call_hours = round($call_hours, 2); + $call_hours_int = intval("$call_hours"); + $call_minutes = ($call_hours - $call_hours_int); + $call_minutes = ($call_minutes * 60); + $call_minutes_int = round($call_minutes, 0); + if ($call_minutes_int < 10) {$call_minutes_int = "0$call_minutes_int";} +# echo "|$stmt|\n"; + +echo "\n"; +echo "
CHANNEL GROUP COUNT HOURS:MINUTES
$row[1] $row[0] $call_hours_int:$call_minutes_int
TOTAL CALLS $total_calls $call_hours_int:$call_minutes_int
\n"; +echo "

\n"; + +echo "
\n"; + +echo "LAST 1000 CALLS FOR DATE RANGE:\n"; +echo "\n"; +echo "\n"; + + $stmt="SELECT number_dialed,channel_group,start_time,length_in_min from call_log where extension='" . mysql_real_escape_string($extension) . "' and server_ip='" . mysql_real_escape_string($server_ip) . "' and start_time >= '" . mysql_real_escape_string($begin_date) . " 0:00:01' and start_time <= '" . mysql_real_escape_string($end_date) . " 23:59:59' LIMIT 1000"; + $rslt=mysql_query($stmt, $link); + $events_to_print = mysql_num_rows($rslt); +# echo "|$stmt|\n"; + + $total_calls=0; + $o=0; + $event_start_seconds=''; + $event_stop_seconds=''; + while ($events_to_print > $o) { + $row=mysql_fetch_row($rslt); + if (eregi("1$|3$|5$|7$|9$", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + + $call_seconds=0; + $o++; + } + + +echo "
NUMBER CHANNEL GROUP DATE LENGTH(MIN.)
$row[0] $row[1] $row[2] $row[3]
\n"; + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + +
+ + + + + + + + + diff --git a/agc_2-X/trunk/astguiclient_web/remote_inbound.php b/agc_2-X/trunk/astguiclient_web/remote_inbound.php new file mode 100644 index 00000000..605fe83a --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/remote_inbound.php @@ -0,0 +1,169 @@ + LICENSE: GPLv2 +### +# the purpose of this script and webpage is to allow for remote or local users of the system to log in and grab phone calls that are coming inbound into the Asterisk server and being put in the parked_channels table while they hear a soundfile for a limited amount of time before being forwarded on to either a set extension or a voicemail box. This gives remote or local agents a way to grab calls without tying up their phone lines all day. The agent sees the refreshing screen of calls on park and when they want to take one they just click on it, and a small window opens that will allow them to grab the call and/or look up more information on the caller through the callerID that is given(if available) +# +# changes: +# 60620-1343 - Added variable filtering to eliminate SQL injection attack threat +# - Added required user/pass to gain access to this page +# + +require("dbconnect.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +$submit=$_GET["submit"]; if (!$submit) {$submit=$_POST["submit"];} +$SUBMIT=$_GET["SUBMIT"]; if (!$SUBMIT) {$SUBMIT=$_POST["SUBMIT"];} + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$popup_page = './inbound_popup.php'; + + $stmt="SELECT count(*) from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active = 'Y' and status IN('ACTIVE','ADMIN');"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$fp = fopen ("./project_auth_entries.txt", "a"); +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + + if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-ASTERISK\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($PHP_AUTH_USER); + $password=strtoupper($PHP_AUTH_PW); + $stmt="SELECT fullname,dialplan_number from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + fwrite ($fp, "ASTERISK|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + + ##### get server listing for dynamic pulldown + $stmt="SELECT fullname,dialplan_number,server_ip from phones where login='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + if ($DB) {echo "$stmt\n";} + $rsltx=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rsltx); + $fullname = $rowx[0]; + $dialplan_number = $rowx[1]; + $user_server_ip = $rowx[2]; + if ($DB) {echo "|$rowx[0]|$rowx[1]|$rowx[2]|\n";} + } + else + { + fwrite ($fp, "ASTERISK|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } + } + + echo"\n"; + echo"ASTERISK REMOTE INBOUND: Main\n"; + echo"\n"; + echo"\n"; + echo"\n"; + +?> + + +
+ +
\n"; + +echo "Click on the channel below that you would like to have directed to your phone

\n"; + +echo "
\n";
+echo "CHANNEL    SERVER        CHANNEL_GROUP   EXTENSION    PARKED_BY            PARKED_TIME        \n";
+echo "----------------------------------------------------------------------------------------------\n";
+
+
+
+
+
+$stmt="SELECT count(*) from parked_channels where server_ip='$user_server_ip' order by parked_time";
+$rslt=mysql_query($stmt, $link);
+if ($DB) {echo "$stmt\n";}
+$row=mysql_fetch_row($rslt);
+$parked_count = $row[0];
+	if ($parked_count > 0)
+	{
+	$stmt="SELECT * from parked_channels where server_ip='$user_server_ip' and channel_group LIKE \"IN_%\" order by parked_time";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$parked_to_print = mysql_num_rows($rslt);
+	$i=0;
+	while ($i < $parked_to_print)
+		{
+		$row=mysql_fetch_row($rslt);
+		$channel =			sprintf("%-11s", $row[0]);
+		$server =			sprintf("%-14s", $row[1]);
+		$channel_group =	sprintf("%-16s", $row[2]);
+		$extension =		sprintf("%-13s", $row[3]);
+		$parked_by =		sprintf("%-21s", $row[4]);
+		$parked_time =		sprintf("%-19s", $row[5]);
+
+		echo "$channel$server$channel_group$extension$parked_by$parked_time\n";
+
+		$i++;
+		}
+
+	}
+	else
+	{
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "*************************************** NO PARKED CALLS **************************************\n";
+	echo "**********************************************************************************************\n";
+	echo "**********************************************************************************************\n";
+	}
+
+
+$ENDtime = date("U");
+
+$RUNtime = ($ENDtime - $STARTtime);
+
+echo "
\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + + + + + + + diff --git a/agc_2-X/trunk/astguiclient_web/test.php b/agc_2-X/trunk/astguiclient_web/test.php new file mode 100644 index 00000000..62f8277b --- /dev/null +++ b/agc_2-X/trunk/astguiclient_web/test.php @@ -0,0 +1,30 @@ + LICENSE: GPLv2 +### + +$STARTtime = date("U"); +$STARTdate = date("Y-m-d H:i:s"); + + +$link=mysql_connect("localhost", "cron", "1234"); +mysql_select_db("asterisk"); + + $stmt="SELECT * from phones;"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + print "|$auth|\n"; + +exit; + + + +?> + + + + + diff --git a/agc_2-X/trunk/call_inbound.agi b/agc_2-X/trunk/call_inbound.agi new file mode 100644 index 00000000..540fbd2b --- /dev/null +++ b/agc_2-X/trunk/call_inbound.agi @@ -0,0 +1,235 @@ +#!/usr/bin/perl +# +# call_inbound.agi +# +# runs at the beginning and ending of every inbound call received +# +# You need to put lines similar to those below in your extensions.conf file: +# +# parameters for call_inbound.agi (7 fields separated by five dashes "-----"): +# 1. the extension of the phone to ring as defined in the asterisk.phones table +# 2. the phone number that was called, for the live_inbound/_log entry +# 3. a text description of the number that was called in +# 4-7. optional fields, they are also passed as fields in the GUI to web browser +# +# ;inbound calls: +#exten => _*NXXNXXXXXX*3429,3,AGI(call_inbound.agi,spa2000-----8005553429-----Inbound 800-----x-----y-----z-----w) +# +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +$US='_'; +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$Y = substr($year, 0, 1); +$mon++; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$Fhour = "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"; +$filedate = "$US$Y$mon$mday$hour$min$sec$US"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $phone_ext = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $comment_a = $ARGV_vars[2]; + $comment_b = $ARGV_vars[3]; + $comment_c = $ARGV_vars[4]; + $comment_d = $ARGV_vars[5]; + $comment_e = $ARGV_vars[6]; + + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( $calleridname =~ /\"/) {$calleridname =~ s/\"//gi;} + if ( (length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d\*$//gi; + $callerid =~ s/\*\d\d\d\d$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + + ### set the callerid if sent with DNIS + print "SET CALLERID $callerid\n"; + checkresult($result); + } +} + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + + $callerid = "\"$calleridname\" <$callerid>"; + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ($extension =~ /h/i) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($stage =~ /START/) + { + + if ($V) {print STDERR "\nCALL INBOUND STARTED\n";} + if ($M) {print STDERR "+++++ CALL INBOUND START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";} + +# if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $mysql = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + $stmtA = "INSERT INTO live_inbound (uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e) values('$unique_id','$channel','$server_ip','$callerid','$extension','$phone_ext','$now_date','$inbound_number','$comment_a','$comment_b','$comment_c','$comment_d','$comment_e')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,inbound_number,comment_a,comment_b,comment_c,comment_d,comment_e) values('$unique_id','$channel','$server_ip','$callerid','$extension','$phone_ext','$now_date','$inbound_number','$comment_a','$comment_b','$comment_c','$comment_d','$comment_e')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + $mysql->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + if ($V) {print STDERR "\nCONNECTED: deleting live_inbound record for $unique_id on $server_ip\n";} + + $stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + $dbh->close; + + + if ($M) {print STDERR "+++++ CALL INBOUND HUNGUP: |$unique_id|\n";} + } +if ($V) {print STDERR "\nAll Done Call Inbound Exiting:\n";} + +exit; + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/call_log.agi b/agc_2-X/trunk/call_log.agi new file mode 100644 index 00000000..3c1ff55c --- /dev/null +++ b/agc_2-X/trunk/call_log.agi @@ -0,0 +1,326 @@ +#!/usr/bin/perl +# +# call_log.agi version 0.8 +# +# runs at the beginning and ending of every external call made and received +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;outbound dialing: +# exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN}) +# +# ;inbound calls: +# exten => 101,1,AGI(call_log.agi,${EXTEN}) +# +# ;all hangups: +# exten => h,1,AGI(call_log.agi,${EXTEN}) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes +# +# 60311-1309 - Fixed CallerID/name for VICIDIAL calls +# 60315-1020 - Added MySQL query fail debug print output +# 60622-0956 - Altered log for Zap client phones for consistent output +# + +$V = 0; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +# Customized Variables +#$server_ip = '10.10.11.14'; # Asterisk server IP +#$DB_server = '10.10.11.10'; # MySQL server IP +#$DB_database = 'asterisk'; # MySQL database name +#$DB_user = 'astcron'; # MySQL user +#$DB_pass = 'astcron'; # MySQL pass + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + ## Seb Auriol added from here (04-May-05): + ## From http://home.cogeco.ca/~camstuff/agi.html: + ## """AGI scripts *always* receive two arguments. + ## The first argument is the full path to the script itself. + ## The second argument is the stuff passed in from the "exten" line.""" + ## $ARGV[1] is the second argument. + ## Actually http://home.cogeco.ca/~camstuff/agi.html is INCORRECT!!! + ## The FIRST and ONLY argument (in perl) is the stuff passed in from the "exten" line. + ## I think this is do with the perl interpreter vs the python interpreter, which inserts the + ## full path to the script as the 1st argument. + if (length($ARGV[0])>0) + { + $extensionarg = $ARGV[0]; # This is a fudge that assumes you only pass in one parameter. This argument should really be parsed. /Seb + } + ## until here. + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( $callerid =~ /\"/) {$callerid =~ s/\"//gi;} + +# if ( (length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) ) + if ( ( + (length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) + ) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + } + ## Seb Auriol added from here (04-May-05): + ## $extensionarg was supplied to the script and should override $extension. + ## This is to enable us to call this script from a macro. + if ($extensionarg) {$extension = $extensionarg;} + ## until here. +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ( ($extension =~ /h/i) && (length($extension) < 3)) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($stage =~ /START/) + { + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + if ($V) {print STDERR "\nCALL STARTED\n";} + if ($M) {print STDERR "+++++ CALL LOG START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";} + + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} + if ($channel =~ /^IAX2/) {$channel =~ s/\/\d+$//gi;} + if ($channel =~ /^Zap\//) + { + $channel_line = $channel; + $channel_line =~ s/^Zap\///gi; + + $dbh->query("SELECT count(*) FROM phones where server_ip='$server_ip' and extension='$channel_line' and protocol='Zap';"); + if ($dbh->has_selected_record) { + $iter=$dbh->create_record_iterator; + while ( $record = $iter->each) { + $is_client_phone = "$record->[0]"; + if ($V) {print STDERR "$is_client_phone|$channel_line|\n";} + } + } + if ($is_client_phone < 1) + { + $channel_group = 'Zap Trunk Line'; + $number_dialed = $callerid; + } + } + ### This section breaks the outbound dialed number down(or builds it up) to a 10 digit number and gives it a description + if ( ($channel =~ /^SIP|^IAX2/) or ($is_client_phone > 0) ) + { + if ( ($extension =~ /^901144/) && (length($extension)==16) ) #test 207 608 6400 + {$extension =~ s/^9//gi; $channel_group = 'Outbound Intl UK';} + if ( ($extension =~ /^901161/) && (length($extension)==15) ) #test 39 417 2011 + {$extension =~ s/^9//gi; $channel_group = 'Outbound Intl AUS';} + if ( ($extension =~ /^91800|^91888|^91877|^91866/) && (length($extension)==12) ) + {$extension =~ s/^91//gi; $channel_group = 'Outbound Local 800';} + if ( ($extension =~ /^9/) && (length($extension)==8) ) + {$extension =~ s/^9/727/gi; $channel_group = 'Outbound Local';} + if ( ($extension =~ /^9/) && (length($extension)==11) ) + {$extension =~ s/^9//gi; $channel_group = 'Outbound Local';} + if ( ($extension =~ /^91/) && (length($extension)==12) ) + {$extension =~ s/^91//gi; $channel_group = 'Outbound Long Distance';} + if ($is_client_phone > 0) + {$channel_group = 'Zap Client Phone';} + + $SIP_ext = $channel; $SIP_ext =~ s/SIP\/|IAX2\/|Zap\///gi; + + $number_dialed = $extension; + $extension = $SIP_ext; + } + + $stmtA = "INSERT INTO call_log (uniqueid,channel,channel_group,type,server_ip,extension,number_dialed,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,caller_code) values('$unique_id','$channel','$channel_group','$type','$server_ip','$extension','$number_dialed','$now_date','$now_date_epoch','','','','','$callerid')"; + + if ($V) {print STDERR "\n|$stmtA|\n";} + $dbh->query($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + + $dbh->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + if ($V) {print STDERR "\nCONNECTED\n";} + + + + $dbh->query("SELECT uniqueid,start_epoch FROM call_log where uniqueid='$unique_id'"); + if ($dbh->has_selected_record) { + $iter=$dbh->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) { + if ($V) {print STDERR $record->[0],"|", $record->[1],"\n";} + $start_time = "$record->[1]"; + $rec_count++; + } + } + + if ($rec_count) + { + $length_in_sec = ($now_date_epoch - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + if ($V) {print STDERR "\nQUERY done: start time = $start_time | sec: $length_in_sec | min: $length_in_min |\n";} + + $stmtA = "UPDATE call_log set end_time='$now_date',end_epoch='$now_date_epoch',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where uniqueid='$unique_id'"; + + if ($V) {print STDERR "\n|$stmtA|\n";} + $dbh->query($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } + + $stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$server_ip'"; + $dbh->query($stmtA); +# $dbh->query($stmtA) or die "NO LIVE_INBOUND_ENTRY: |$stmtA|\n"; + + + $dbh->query("SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$server_ip' LIMIT 1"); + $rec_count=0; + if ($dbh->has_selected_record) { + $iter=$dbh->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) { + if ($V) {print STDERR $record->[0],"|", $record->[1],"\n";} + $parked_time = "$record->[0]"; + $grab_time = "$record->[1]"; + $rec_count++; + } + } + + if ($rec_count) + { + print STDERR "*****Entry found for $unique_id-$server_ip in park_log: $parked_time|$grab_time\n"; + if ($parked_time > $grab_time) + { + $parked_sec=($now_date_epoch - $parked_time); + $talked_sec=0; + } + else + { + $talked_sec=($now_date_epoch - $parked_time); + $parked_sec=($grab_time - $parked_time); + } + + $stmtA = "UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "NO PARK_LOG_ENTRY: |$stmtA|\n"; + } +# else {print STDERR "*****No entry found for $unique_id-$server_ip in park_log\n";} + + $dbh->close; + + if ($M) {print STDERR "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|\n";} + } +if ($V) {print STDERR "\nAll Done Exiting:\n";} + +exit; diff --git a/agc_2-X/trunk/call_logCID.agi b/agc_2-X/trunk/call_logCID.agi new file mode 100644 index 00000000..409828e0 --- /dev/null +++ b/agc_2-X/trunk/call_logCID.agi @@ -0,0 +1,309 @@ +#!/usr/bin/perl +# +# call_log.agi version 0.6 +# +# runs at the beginning and ending of every external call made and received +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;outbound dialing: +# exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN}) +# +# ;inbound calls: +# exten => 101,1,AGI(call_log.agi,${EXTEN}) +# +# ;all hangups: +# exten => h,1,DeadAGI(call_log.agi,${EXTEN}) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# changes +# +# 60622-0957 - Altered log for Zap client phones for consistent output +# + +$V = 0; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + if ($args =~ />| |\"/i) + { + @CID = split(/-----/, $args); + $fullCID=1; + $callerid = $CID[2]; + $calleridname = $CID[3]; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (!$fullCID) # if no fullCID sent + { + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( $calleridname =~ /\"/) {$calleridname =~ s/\"//gi;} +# if ( (length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) ) + if ( ( + (length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) ) + ) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d\*$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + } + $calleridname = $callerid; + } +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ( ($extension =~ /h/i) && (length($extension) < 3)) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($stage =~ /START/) + { + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + if ($V) {print STDERR "\nCALL STARTED\n";} + if ($M) {print STDERR "+++++ CALL LOG START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";} + + $is_client_phone = 0; + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} + if ($channel =~ /^IAX2/) {$channel =~ s/\/\d+$//gi;} + if ($channel =~ /^Zap\//) + { + $channel_line = $channel; + $channel_line =~ s/^Zap\///gi; + + $dbh->query("SELECT count(*) FROM phones where server_ip='$server_ip' and extension='$channel_line' and protocol='Zap';"); + if ($dbh->has_selected_record) { + $iter=$dbh->create_record_iterator; + while ( $record = $iter->each) { + $is_client_phone = "$record->[0]"; + if ($V) {print STDERR "$is_client_phone|$channel_line|\n";} + } + } + if ($is_client_phone < 1) + { + $channel_group = 'Zap Trunk Line'; + $number_dialed = $callerid; + } + } + ### This section breaks the outbound dialed number down(or builds it up) to a 10 digit number and gives it a description + if ( ($channel =~ /^SIP|^IAX2/) or ($is_client_phone > 0) ) + { + if ( ($extension =~ /^901144/) && (length($extension)==16) ) #test 207 608 6400 + {$extension =~ s/^9//gi; $channel_group = 'Outbound Intl UK';} + if ( ($extension =~ /^901161/) && (length($extension)==15) ) #test 39 417 2011 + {$extension =~ s/^9//gi; $channel_group = 'Outbound Intl AUS';} + if ( ($extension =~ /^91800|^91888|^91877|^91866/) && (length($extension)==12) ) + {$extension =~ s/^91//gi; $channel_group = 'Outbound Local 800';} + if ( ($extension =~ /^9/) && (length($extension)==8) ) + {$extension =~ s/^9/727/gi; $channel_group = 'Outbound Local';} + if ( ($extension =~ /^9/) && (length($extension)==11) ) + {$extension =~ s/^9//gi; $channel_group = 'Outbound Local';} + if ( ($extension =~ /^91/) && (length($extension)==12) ) + {$extension =~ s/^91//gi; $channel_group = 'Outbound Long Distance';} + if ($is_client_phone > 0) + {$channel_group = 'Zap Client Phone';} + + $SIP_ext = $channel; $SIP_ext =~ s/SIP\/|IAX2\/|Zap\///gi; + + $number_dialed = $extension; + $extension = $SIP_ext; + } + + $stmtA = "INSERT INTO call_log (uniqueid,channel,channel_group,type,server_ip,extension,number_dialed,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,caller_code) values('$unique_id','$channel','$channel_group','$type','$server_ip','$extension','$number_dialed','$now_date','$now_date_epoch','','','','','$calleridname')"; + + if ($V) {print STDERR "\n|$stmtA|\n";} + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + + $dbh->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + if ($V) {print STDERR "\nCONNECTED\n";} + + + + $dbh->query("SELECT uniqueid,start_epoch FROM call_log where uniqueid='$unique_id'"); + if ($dbh->has_selected_record) { + $iter=$dbh->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) { + if ($V) {print STDERR $record->[0],"|", $record->[1],"\n";} + $start_time = "$record->[1]"; + $rec_count++; + } + } + + if ($rec_count) + { + $length_in_sec = ($now_date_epoch - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + if ($V) {print STDERR "\nQUERY done: start time = $start_time | sec: $length_in_sec | min: $length_in_min |\n";} + + $stmtA = "UPDATE call_log set end_time='$now_date',end_epoch='$now_date_epoch',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where uniqueid='$unique_id'"; + + if ($V) {print STDERR "\n|$stmtA|\n";} + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + } + + $stmtA = "DELETE from live_inbound where uniqueid='$unique_id' and server_ip='$server_ip'"; + $dbh->query($stmtA); +# $dbh->query($stmtA) or die "NO LIVE_INBOUND_ENTRY:\n"; + +##### BEGIN Park Log entry check and update ##### + $dbh->query("SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$server_ip' LIMIT 1"); + $rec_count=0; + if ($dbh->has_selected_record) { + $iter=$dbh->create_record_iterator; + $rec_count=0; + while ( $record = $iter->each) { + if ($V) {print STDERR $record->[0],"|", $record->[1],"\n";} + $parked_time = "$record->[0]"; + $grab_time = "$record->[1]"; + $rec_count++; + } + } + + if ($rec_count) + { + print STDERR "*****Entry found for $unique_id-$server_ip in park_log: $parked_time|$grab_time\n"; + if ($parked_time > $grab_time) + { + $parked_sec=($now_date_epoch - $parked_time); + $talked_sec=0; + } + else + { + $talked_sec=($now_date_epoch - $parked_time); + $parked_sec=($grab_time - $parked_time); + } + + $stmtA = "UPDATE park_log set status='HUNGUP',hangup_time='$now_date',parked_sec='$parked_sec',talked_sec='$talked_sec' where uniqueid='$unique_id' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "NO PARK_LOG_ENTRY:\n"; + } +# else {print STDERR "*****No entry found for $unique_id-$server_ip in park_log\n";} +##### END Park Log entry check and update ##### + + $dbh->close; + + if ($M) {print STDERR "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|\n";} + } +if ($V) {print STDERR "\nAll Done Exiting:\n";} + +exit; diff --git a/agc_2-X/trunk/call_park.agi b/agc_2-X/trunk/call_park.agi new file mode 100644 index 00000000..98b2c9fb --- /dev/null +++ b/agc_2-X/trunk/call_park.agi @@ -0,0 +1,224 @@ +#!/usr/bin/perl +# +# call_park.agi +# +# runs when a call is to be parked for pickup of customer service +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound calls: +# exten => 101,1,AGI(call_park.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $comment_d = $ARGV_vars[5]; + $comment_e = $ARGV_vars[6]; + + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d\*$//gi; + $callerid =~ s/\*\d\d\d\d$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + + ### set the callerid if sent with DNIS + print "SET CALLERID $callerid\n"; + checkresult($result); + } +} + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ($extension =~ /h/i) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($status !~ /HANGUP/) + { + + if ($V) {print STDERR "\nCALL PARK STARTED\n";} + if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";} + + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $mysql = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + $stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + $mysql->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + + if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";} + + $stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + $dbh->close; + + + if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";} + } +if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";} + +exit; + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/call_park_EXT.agi b/agc_2-X/trunk/call_park_EXT.agi new file mode 100644 index 00000000..3cab013f --- /dev/null +++ b/agc_2-X/trunk/call_park_EXT.agi @@ -0,0 +1,223 @@ +#!/usr/bin/perl +# +# call_park.agi +# +# runs when a call is to be parked for pickup of customer service +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound calls: +# exten => 101,1,AGI(call_park.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $comment_d = $ARGV_vars[5]; + $comment_e = $ARGV_vars[6]; + + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d\*$//gi; + $callerid =~ s/\*\d\d\d\d$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + + ### set the callerid if sent with DNIS + print "SET CALLERID $callerid\n"; + checkresult($result); + } +} + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ($extension =~ /h/i) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($status !~ /HANGUP/) + { + + if ($V) {print STDERR "\nCALL PARK STARTED\n";} + if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid|$now_date\n";} + + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $mysql = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + $stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + $mysql->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";} + + $stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + $dbh->close; + + + if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";} + } +if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";} + +exit; + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/call_park_I.agi b/agc_2-X/trunk/call_park_I.agi new file mode 100644 index 00000000..4d6f52e0 --- /dev/null +++ b/agc_2-X/trunk/call_park_I.agi @@ -0,0 +1,230 @@ +#!/usr/bin/perl +# +# call_park_I.agi +# +# runs when a call is to be parked for pickup of customer service +# This version is for calls send from one server to another over Crossover PRI T +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound calls: +#exten => _90009.,1,AGI(call_park_I.agi,${EXTEN}) +#exten => _90009.,2,Answer ; Answer the line +#exten => _90009.,3,Playback(park) ; Play a welcome message & music +#exten => _90009.,4,AGI(call_park_I.agi,HANGUP-----${EXTEN}) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + $status = $ARGV_vars[1]; + + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for internal PRI transfer data string "90009*CL_uk3survy_*8301*10000123*universal***" + if ($extension =~ /^900\d\d\*/) + { + @EXT_vars = split(/\*/, $extension); + + $referring_extension = $EXT_vars[0]; # initial extension sent + $channel_group = $EXT_vars[1]; # name of the parked group + $inbound_number = $EXT_vars[2]; # extension to send call to after parsing + $parked_by = $EXT_vars[3]; # leadID + $park_extension = $EXT_vars[4]; # filename of the on-hold music file + $comment_d = $EXT_vars[5]; # N/A + $comment_e = $EXT_vars[6]; # N/A + + ### set the callerid to the filename of the audio for on-hold + print "SET CALLERID $park_extension\n"; + checkresult($result); + print STDERR "callerID changed: $park_extension\n"; + } +} + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$AGI->stream_file('beep'); + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ( ($extension =~ /h/i) && (length($extension) < 4)) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($status !~ /HANGUP/) + { + + if ($V) {print STDERR "\nCALL PARK STARTED\n";} + if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $mysql = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + $stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$parked_by','$now_date')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $mysql->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";} + + $stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + $dbh->close; + + + if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";} + } +if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";} + +exit; + + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/call_park_L.agi b/agc_2-X/trunk/call_park_L.agi new file mode 100644 index 00000000..d59e6946 --- /dev/null +++ b/agc_2-X/trunk/call_park_L.agi @@ -0,0 +1,307 @@ +#!/usr/bin/perl +# +# call_park_L.agi +# +# runs when a call is to be parked for pickup of customer service +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound calls: +# exten => 101,1,AGI(call_park_L.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $comment_d = $ARGV_vars[5]; + $comment_e = $ARGV_vars[6]; + + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d\*$//gi; + $callerid =~ s/\*\d\d\d\d$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + + ### set the callerid if sent with DNIS + print "SET CALLERID $callerid\n"; + checkresult($result); + } +} + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$AGI->stream_file('beep'); + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ($extension =~ /h/i) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($status !~ /HANGUP/) + { + + if ($V) {print STDERR "\nCALL PARK STARTED\n";} + + &enter_pin_number; + + if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = ($pin + 0);} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $mysql = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + $stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $mysql->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";} + + $stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + $dbh->close; + + + if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";} + } +if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";} + +exit; + + + + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 9) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=9; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/call_park_W.agi b/agc_2-X/trunk/call_park_W.agi new file mode 100644 index 00000000..4bd97e27 --- /dev/null +++ b/agc_2-X/trunk/call_park_W.agi @@ -0,0 +1,307 @@ +#!/usr/bin/perl +# +# call_park.agi +# +# runs when a call is to be parked for pickup of customer service +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound calls: +# exten => 101,1,AGI(call_park.agi,IN_800_TPP_CS-----8775154104-----Inbound TPP 800 CS-----park-----HANGUP----------) +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$M = 1; # set to 1 for 2 line messages mode + +### Make sure this file is in a path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + + +($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) {$Fhour = "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"; + + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + ### list of command-line array arguments: + @ARGV_vars = split(/-----/, $ARGV[0]); + + $channel_group = $ARGV_vars[0]; + $inbound_number = $ARGV_vars[1]; + $parked_by = $ARGV_vars[2]; + $park_extension = $ARGV_vars[3]; + $status = $ARGV_vars[4]; + $comment_d = $ARGV_vars[5]; + $comment_e = $ARGV_vars[6]; + + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} + if ( (!$callerid) or ($callerid =~ /unknown/) ) + {$callerid = $calleridname;} + + ### allow for ANI being sent with the DNIS "*3125551212*9999*" + if ($extension =~ /^\*\d\d\d\d\d\d\d\d\d\d\*/) + { + $callerid = $extension; + $callerid =~ s/\*\d\d\d\d\*$//gi; + $callerid =~ s/\*\d\d\d\d$//gi; + $callerid =~ s/^\*//gi; + $extension =~ s/^\*\d\d\d\d\d\d\d\d\d\d\*//gi; + $extension =~ s/\*$//gi; + + ### set the callerid if sent with DNIS + print "SET CALLERID $callerid\n"; + checkresult($result); + } +} + +if ($V) +{ + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } +} + +$AGI->stream_file('beep'); + +if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ($extension =~ /h/i) {$stage = 'END';} +else {$stage = 'START';} + +### call start stage +if ($status !~ /HANGUP/) + { + + if ($V) {print STDERR "\nCALL PARK STARTED\n";} + + &enter_pin_number; + + if ($M) {print STDERR "+++++ CALL PARK START : |$unique_id|$channel|$extension|$type|$callerid-$pin|$now_date\n";} + + if ($channel =~ /^SIP/) {$channel =~ s/-.*//gi;} +# if ($channel =~ /^Zap\//) {$channel =~ s/-\d$//gi;} + if (length($callerid)<10) {$callerid = $parked_by;} + if (length($pin)>0) {$callerid = $pin;} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $mysql = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + $stmtA = "INSERT INTO parked_channels (channel,server_ip,channel_group,extension,parked_by,parked_time) values('$channel','$server_ip','$channel_group','$park_extension','$callerid','$now_date')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $stmtA = "INSERT INTO park_log (uniqueid,status,channel,server_ip,parked_time,channel_group) values('$unique_id','PARKED','$channel','$server_ip','$now_date','$channel_group')"; + if ($V) {print STDERR "\n|$stmtA|\n";} + $mysql->query($stmtA) or die "Couldn't execute query:\n"; + + + $mysql->close; + } + + +### call end stage +else + { + + if ($V) {print STDERR "\nCALL INBOUND HUNG UP\n";} + + use Net::MySQL; + + if (!$DB_port) {$DB_port='3306';} + + my $dbh = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n"; + + if ($V) {print STDERR "\nCONNECTED: deleting parked_channels record for $unique_id on $server_ip\n";} + + $stmtA = "DELETE from parked_channels where channel='$channel' and server_ip='$server_ip'"; + $dbh->query($stmtA) or die "Couldn't execute query:\n"; + $dbh->close; + + + if ($M) {print STDERR "+++++ CALL PARK HUNGUP: |$unique_id|\n";} + } +if ($V) {print STDERR "\nAll Done Call Park Exiting:\n";} + +exit; + + + + +sub enter_pin_number +{ +# please enter the pin number followed by the pound key + +$interrupt_digit=''; +undef $interrupt_digit; + +$interrupt_digit = $AGI->stream_file('four_digit_id','123456789'); + + print STDERR "interrupt_digit |$interrupt_digit|\n"; + +$digits_being_entered=1; +$totalDTMF=''; +if ($interrupt_digit > 1) + { + if ($interrupt_digit == 48) {$interrupt_digit=0;} + if ($interrupt_digit == 49) {$interrupt_digit=1;} + if ($interrupt_digit == 50) {$interrupt_digit=2;} + if ($interrupt_digit == 51) {$interrupt_digit=3;} + if ($interrupt_digit == 52) {$interrupt_digit=4;} + if ($interrupt_digit == 53) {$interrupt_digit=5;} + if ($interrupt_digit == 54) {$interrupt_digit=6;} + if ($interrupt_digit == 55) {$interrupt_digit=7;} + if ($interrupt_digit == 56) {$interrupt_digit=8;} + if ($interrupt_digit == 57) {$interrupt_digit=9;} + + $totalDTMF=$interrupt_digit; + } + +$digit_loop_counter=0; +#while ( ($digits_being_entered) && ($digit_loop_counter < 20) ) +# { +# $digit = chr($AGI->wait_for_digit('30000')); # wait 30 seconds for input or until the pound key is pressed +# if ($digit =~ /\d/) +# { +# $totalDTMF = "$totalDTMF$digit"; +# print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); +# undef $digit; +# } +# else +# { +# $digits_being_entered=0; +# } +# +# $digit_loop_counter++; +# } + +while ( ($digit_loop_counter < 4) ) + { + $digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed + if ($digit =~ /\d/) + { + $totalDTMF = "$totalDTMF$digit"; + print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n"; +# $AGI->say_digits("$digit"); + undef $digit; + } + else + { + $digit_loop_counter=4; + } + + $digit_loop_counter++; + } + +$totalDTMF =~ s/\D//gi; +$pin = $totalDTMF; +if ($totalDTMF) {print STDERR "digit |$digit| TotalDTMF |$totalDTMF|\n";} +} + + + + +sub checkresult { + my ($res) = @_; + my $retval; + $tests++; + chomp $res; + if ($res =~ /^200/) { + $res =~ /result=(-?\d+)/; + if (!length($1)) { + print STDERR "FAIL ($res)\n"; + $fail++; + } else { + print STDERR "PASS ($1)\n"; + $pass++; + } + } else { + print STDERR "FAIL (unexpected result '$res')\n"; + $fail++; + } +} diff --git a/agc_2-X/trunk/debug_speak.agi b/agc_2-X/trunk/debug_speak.agi new file mode 100644 index 00000000..ceeca504 --- /dev/null +++ b/agc_2-X/trunk/debug_speak.agi @@ -0,0 +1,123 @@ +#!/usr/bin/perl +# +# debug_speak.agi version 0.1 +# +# runs during any extension and speaks the extension sent to it while +# printing the extension as well as lots of info about the call to STDERR +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound errors with speaking of extension: +#exten => _XXXX,1,AGI(debug_speak.agi,${EXTEN}) +#exten => _XXXX,3,Hangup +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 1; # set to 1 for verbose mode +$CLIOUT = 1; # set to 1 for printing 1 line to STDERR +$SPEAK = 1; # set to 1 for saying invalid digits + +($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) {$Fhour = "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"; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($CLIOUT) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($CLIOUT) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} + if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;} +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +if ($CLIOUT) {print STDERR "****** DEBUG: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|\n";} + +if ($SPEAK) + { + $AGI->stream_file('beep'); + sleep(1); + $AGI->say_digits("$extension"); + } + + +exit; diff --git a/agc_2-X/trunk/docs/ACQS.txt b/agc_2-X/trunk/docs/ACQS.txt new file mode 100644 index 00000000..3881de11 --- /dev/null +++ b/agc_2-X/trunk/docs/ACQS.txt @@ -0,0 +1,94 @@ ++------------------------------------------------------------------------------+ +| Asterisk GUI client - astguiclient - fourth public release 0.9.2 | +| Description of the Asterisk Central Queue System | +| created by Matt Florell | +| project started 2003-10-06 http://sourceforge.net/projects/astguiclient/ | ++------------------------------------------------------------------------------+ + +This suite of programs is designed to work with the Asterisk Open-source PBX +(http://www.asterisk.org) as a cross-platform GUI client and the supporting +server side applications necessary for the features of the GUI application to +work with Asterisk. + +Scripts that are involved with the ACQS backend are: + + - AST_SERVER_conf.pl - file where you define your variables for the server apps + + Must be present in the /home/cron/ directory + + - AST_manager_listen.pl - listener for the Asterisk Central Queue System (ACQS) + + Must be present in the /home/cron/ directory + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + - AST_manager_send.pl - send-spawn for the ACQS + + Must be present in the /home/cron/ directory + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + - AST_send_action_child.pl - blind-send for the ACQS + + Must be present in the /home/cron/ directory + + Requires Net::Telnet, Net::MySQL perl Modules + + - ADMIN_keepalive_AST_send_listen.pl - checks to see that ACQS is running + + Must put entry for this script in the cron as "* * * * * /path/script" + + - ADMIN_restart_roll_logs.pl - rolls logs over datestamp upon restart + + put this script in your machine's startup routine + + +DESCRIPTION: +This set of programs was created to reduce the risk of deadlocks that occur when +the manager interface connection from a remote machine to the Asterisk server +becomes severed or backlogged in some way resulting in a buffer-overflow of the +manager interface on the Asterisk box and a deadlock of the Asterisk PBX. The +probability of this happening is rare on a system where you may have 100 or less +action commans being executed a day, but when the action commands rise to the +level of 3000+ per server across 30 machines you will have at least 1 deadlock +per day if not one per hour. That's why we needed to find a way to still issue +manager Actions but not have to maintain a connection with the Asterisk Manager +interface. Here is a rundown of how the ACQS works: + +There is a simple database table where the action information with unique IDs is +stored and where each action's information is updated by the listener. The table +I use is called vicidial_manager and is detailed in the CONF_MySQL.txt file in +this distribution. + +1. First, the GUI client application inserts a record into the table as a NEW +action and includes a unique callerID for REDIRECT and ORIGINATE commands(the +callerID field is how the listener will update the record in the DB) +INSERT INTO vicidial_manager values('','','2004-01-30 +17:22:53','NEW','N','10.10.11.12','','Originate','DL40130172253cc160','Channel: +local/8600011@demo','Context: default','Exten: 917274515135','Priority: +1','Callerid: DL40130172253cc160','','','','',''); + +2. Second, there is a constantly running application on the Asterisk box that +selects queues from the database to be processed, and launches a new child +script to send the action to the database, then marks the action as SENT. + +3. Third, each child process logs into the manager interface and sends the +action immediately, then stays open for 10 seconds to not cause any problems, +clears it's buffer and then logs out and exits. + +4. Fourth, the listener app is constantly connected on the Asterisk box to the +manager interface and parses all output from the manager interface. Every time a +"Newstate Ringing" event is seen an update statement is sent to the DB based +upon the callerid of the call filling in the channel that the call is on and the +uniqueID of the call and sets the record to "UPDATED" + +5. Fifth, the listener also listens for "Hangup" events and sends an update to +the DB with a "DEAD" status keyed by the call's uniqueID. + +The above process is executed extremely fast and actually has suprisingly little +effect on the load of the Asterisk box. Because each action is sent through it's +own child process there is no risk of the system deadlocking because of a single +bad action thread. + + + +NOTES: +This started out as a desperate quick fix that evolved into a system that has +been up and running reliably on two separate Asterisk servers. Since we +implemented ACQS we haven't had a single deadlock on either of these servers. +If anyone has suggestions/praises/criticisms I would love to hear them. + +To use, install the scripts listed above and set the $QUEUE_ACTION_enabled +variable in the client's libs/AST_VICI_conf.pl configuration file to 1 + diff --git a/agc_2-X/trunk/docs/APP_CONFERENCE.txt b/agc_2-X/trunk/docs/APP_CONFERENCE.txt new file mode 100644 index 00000000..92011ec2 --- /dev/null +++ b/agc_2-X/trunk/docs/APP_CONFERENCE.txt @@ -0,0 +1,86 @@ +VICIDIAL and app_conference +(1.2 tree) EXPERIMENTAL!!! + +app_conference offers the plusses of being able to do conferencing +without any zaptel hardware or timers as well as doing native codec +streaming, meaning no manditory downsampling to slin like meetme. +These two features alone mean a rather significant performance boost +to companies who only use VOIP for agents and trunks as well as not +requiring the cost of zaptel hardware or the nightmare of getting +ztdummy to work on some systems. + +As of right now, I have a test system fully up and running using +app_conference with VICIDIAL on Asterisk 1.2.8. I have made several +modifications to the app_conference code to make it more of a drop-in +replacement for meetme so that it does not require any changes to the +VICIDIAL codebase. I have added entry and exit sounds(slightly +different from meetme's) as well as "only one in this conference" +message in addition to changing the default member type to speaker(S). +So far I have tested with IAX and SIP channels only and everything +works just like on meetme but I have not done any capacity testing or +tested it in production yet. + +If you want to use app_conference instead of meetme for VICIDIAL then follow these instructions: + +cd /usr/src/asterisk +wget http://www.eflo.net/files/VD_app_conference_0.6.zip +unzip VD_app_conference_0.6.zip +cd app_conference +make clean +make +make install + + +In your extensions.conf file you would replace these lines: +exten => 8600051,1,Meetme,8600051 +exten => 8600052,1,Meetme,8600052 +...continue through 8600100... +exten => 78600051,1,Meetme,8600051|q +exten => 78600052,1,Meetme,8600052|q +...continue through 78600100... +exten => 68600051,1,Meetme,8600051|mq +exten => 68600052,1,Meetme,8600052|mq +...continue through 68600100... + + +with these lines: +exten => 8600051,1,Conference(8600051) +exten => 8600052,1,Conference(8600052) +...continue through 8600100... +exten => 78600051,1,Conference(8600051|q) +exten => 78600052,1,Conference(8600052|q) +...continue through 78600100... +exten => 68600051,1,Conference(8600051|Lq) +exten => 68600052,1,Conference(8600052|Lq) +...continue through 68600100... + +NOTES: +Here are the possible feature flags for this version of app_conference: + o M: Moderator (presently same as speaker) [default] + o S: Speaker + o L: Listener + o T: "Telephone caller" (just for stats?). + o V: Do VAD on this caller + o D: Use Denoise filter on this caller. + o d: Send manager events when DTMF is received. + o q: Do not play enter or exit sounds. + o i: use inband dtmf broadcast. + o t: use rfc dtmf signal broadcast. + +COMPILE NOTES: + +Some Makefile alterations may be necessary for your system: + +From Alek Barkley: +I am running FC4 with latest updates ( 2.6.16 kernel ) +My CPU is AMD K6 and GCC 4.0.2. + +I edited Makefile in app_conference distribution. +To enter CPU architecture in my case -march=k6 +======================================================== +PROC = k6 +# this is fun for x86 +#CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 +CFLAGS += -march=k6 +=========================================================== + diff --git a/agc_2-X/trunk/docs/CALLBACKS_PROCESS.txt b/agc_2-X/trunk/docs/CALLBACKS_PROCESS.txt new file mode 100644 index 00000000..2077cdb7 --- /dev/null +++ b/agc_2-X/trunk/docs/CALLBACKS_PROCESS.txt @@ -0,0 +1,98 @@ +CALLBACK proces flow 2006-01-05 + +***** FULL CALLBACKS FUNCTIONALITY WAS ADDED IN THE 1.1.11 RELEASE ***** + +This will outline the process I have thought through in my head for a call-back +process in VICIDIAL. I have received suggestions for methodologies of how many +people think that call-backs should work and I think I've finally come to a +conclusion of how I may build it into VICIDIAL that incorporates most of these +suggestions. + + + +The Agent Side: +When an Agent dispositions a call as CALLBK, a popup frame will appear that will +allow selecting a date from a calendar window(with option to go forward by month +up to 1 year) and a pull-down list that will show hours(in 30 minute increments +defaulting to current half hour). After the agent selects a day and time, they +must check a box to denote that only they should be able to get this Callback. +If the box is unchecked, anyone will be able to call this lead after it's +callback_time elapses. The lead will be entered as vicidial_list.status CBHOLD +in the system and will not be able to be dialed or selected as a dial status in +the admin screen. + +If the agent checks the box that they will be the only one that can callback the +lead and it is time to call that lead again(vicidial.php will check at login and +every 30 minutes to see if there are any agent-specific leads that need to be +called back by that agent) then when the agent is paused they will be able to +click on the "CALLBACK" button on the bottom of the screen and select which lead +that they want to callback. The call will proceed as a normal call and will be +dispositioned as normal. The callback button will probably be able to flash or +gently strobe like the astguiclient.php voicemail button does when callbacks are +available to be called for that logged-in agent. + +If the agent does not check that they are the only ones to be able to call that +specific lead back, then it will be updated by the AST_VDhopper.pl script once +it's callback date/time has been reached the status will be changed to CALLBK +and will be available for calling if that status is selected in the dial +statuses for the campaign and if the list is active. + +If the managr has given the agent permission to set USERONLY callbacks, then +the agent will be able to call those customers back by clicking on the CALLBACK +count link below the comments field of vicidial.php once they are logged in. +From here they can see the listing of their callbacks and their settings, and +can call the customer back by clicking on the callback record. + + + +The Admin Side: +In the admin.php web page will be a callback viewer. Admin users will be able to +search and sort by campaign, list, user, status and time-range to see summary +lists of the Callbacks in the vicidial_callbacks table. Callbacks will be +alterable through the modify lead screen. + + + +The Server Side: +The vicidial_callbacks table will look like this: + CREATE TABLE vicidial_callbacks ( +callback_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +lead_id INT(9) UNSIGNED, +list_id INT(8) UNSIGNED, +campaign_id VARCHAR(8), +status VARCHAR(10), +entry_time DATETIME, +callback_time DATETIME, +modify_date TIMESTAMP, +user VARCHAR(20), +recipient ENUM('USERONLY','ANYONE'), +comments VARCHAR(255), +index (lead_id), +index (status), +index (callback_time) +); + +The status field will probably have the following possible values: ACTIVE, LIVE, +ARCHIVE and all old callback entries will be kept for archival purposes, +anthough not viewable by the agent. + +The AST_VDhopper.pl script will do a select every minute(before it does it's +hopper filling run) for callbacks that need to be placed back in CALLBK status. +Something like this query: + SELECT lead_id from vicidial_callbacks where callback_time < '2006-01-06 +10:02:03' and status='ACTIVE'; + +AST_VDhopper.pl will then: +- set these leads to vicidial_list.status of CALLBK +- set the called_since_last_reset to N +- insert the lead into the vicidial_hopper under the campaign it was originally + set if it is an ANYONE callback +- change the vicidial_callbacks.status to LIVE. + +At the time of a hangup of a callback call, the vicidial.php script will set the +vicidial_callbacks.status to ARCHIVE. The leads that designate the recipient as +USERONLY will not be altered in any way by AST_VDhopper.pl. + + + + diff --git a/agc_2-X/trunk/docs/CONF_Asterisk.txt b/agc_2-X/trunk/docs/CONF_Asterisk.txt new file mode 100644 index 00000000..eeb61f7c --- /dev/null +++ b/agc_2-X/trunk/docs/CONF_Asterisk.txt @@ -0,0 +1,9 @@ +Here is what you need to add to your Asterisk configuration by configuration filename: + +Notes: +- You do NOT have to have MusicOnHold enabled or mpg123 installed to use this +- it is assumed in the client app code that you need to dial a "9" to get an outside line +- Parking is really just sending a call to a a Playback file then doing a redirect to an extension + +***************************** DEPRICATED *************************************** +Look at the SCRATCH_INSTALL document for instructions on how to modify Asterisk conf files for astGUIclient operation \ No newline at end of file diff --git a/agc_2-X/trunk/docs/CONF_MySQL.txt b/agc_2-X/trunk/docs/CONF_MySQL.txt new file mode 100644 index 00000000..760fd990 --- /dev/null +++ b/agc_2-X/trunk/docs/CONF_MySQL.txt @@ -0,0 +1,17 @@ +### Create the following tables in your "asterisk" MySQL database + + +################################################################################ +################################################################################ +#### #### +#### THIS FILE IS DEPRICATED, LOOK AT THE MySQL_AST_CREATE_tables.sql #### +#### FILE FOR MORE INFO ON MYSQL DATABASE SETUP #### +#### #### +################################################################################ +################################################################################ + +### remember to prepopulate the conferencing table with meetme conferences defined +### remember to prepopulate the phones table with proper values +### remember to prepopulate the servers table with the asterisk servers' IP addresses +### remember to prepopulate the server_updater table with the asterisk servers' IP addresses + diff --git a/agc_2-X/trunk/docs/CONF_VICIDIAL_MySQL.txt b/agc_2-X/trunk/docs/CONF_VICIDIAL_MySQL.txt new file mode 100644 index 00000000..51a02a11 --- /dev/null +++ b/agc_2-X/trunk/docs/CONF_VICIDIAL_MySQL.txt @@ -0,0 +1,12 @@ +### to use VICIDIAL create these tables in your "asterisk" MySQL database + +################################################################################ +################################################################################ +#### #### +#### THIS FILE IS DEPRICATED, LOOK AT THE MySQL_AST_CREATE_tables.sql #### +#### FILE and the SCRATCH_INSTALL FILEFOR MORE INFO ON #### +#### MYSQL DATABASE SETUP #### +#### #### +################################################################################ +################################################################################ + diff --git a/agc_2-X/trunk/docs/LICENSE.txt b/agc_2-X/trunk/docs/LICENSE.txt new file mode 100644 index 00000000..d3ca3645 --- /dev/null +++ b/agc_2-X/trunk/docs/LICENSE.txt @@ -0,0 +1,278 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. diff --git a/agc_2-X/trunk/docs/LOAD_BALANCING.txt b/agc_2-X/trunk/docs/LOAD_BALANCING.txt new file mode 100644 index 00000000..8a2ef30a --- /dev/null +++ b/agc_2-X/trunk/docs/LOAD_BALANCING.txt @@ -0,0 +1,123 @@ +VICIDIAL - LOAD BALANCING setup. + +This document is meant to summarize the capabilities and setup of VICIDIAL in a multi-server environment. + +Why Load Balance? + +The primary reason to do load balancing, or clustering of multiple VICIDIAL servers, is to spread the calls taken in or the answered calls on an outbound campaign across all of the agents that are logged into a campaign no matter what server they are on. For instance, on an outbound campaign, you have 2 servers, server one has 20 agents logged in on a campaign and the other server(two) has 5 agents logged in on the same campaign. Lets say that the campaign is set to a dial_level of 3.0 so there are 60 active calls being placed on server one and 15 active calls being placed on server two. Then 23 of the calls on server one answer meaning that there are three calls too many for the agents available on that server. Under a load-balancing-overflow setup those three calls can travel over an IAX2 trunk directly to the agents on that server that are still available. This increased efficiency in both inbound and outbound environments as well as reducing on-hold times for customers and equalizing wait times for agents across all servers for a campaign. + +Another reason for load balancing is the ability to use cheaper hardware on the server side. It is much cheaper and more fault-tolerant to buy four P4 2.0GHz 1U servers for $800 a piece than it is to buy a single 4U quad Xeon 3.2GHz server. The four 1U servers will have more total capacity, can be easily scaled and if one fails you've only lost 25% of capacity instead of everything. This philosophy has serverd our call center very well over the last two years. + + +How do I set up load balancing on my two server VICIDIAL setup? + +These steps are taken directly from the SCRATCH_INSTALL document, but they are all put together here to give a better idea of what is needed all in one place. It is assumed that you already have VICIDIAL up and running on both servers. + +NOTE: In a multi-server setup you may want to have your database and web server on a separate machine from your Asterisk/VICIDIAL servers. Simply copy the web page directories to your new database/web server and set the AST_SERVER_conf.pl files on your VICIDIAL servers to point to that new database server. You can also have several web servers(or even load-balancing web servers) if you have more than 70 seats in one installation you may want to do that. For the web pages you just need to make sure the dbconnect.php files are configured for your database server. We have had 9 VICIDIAL servers and 2 web servers using a single database server with no problems. + + +1. The VICIDIAL/Asterisk servers need to have all of the perl scripts and cron jobs installed on them, except these which only need to be on one of the servers: + - AST_VDhopper.pl + - AST_cleanup_agent_log.pl + - ADMIN_adjust_GMTnow_on_leads.pl + - AST_DB_optimize.pl + + +2. The two servers need to be registered to each other as IAX2 friends: + SERVER ONE(ASTtest1-10.10.10.15) + iax.conf: + register => ASTtest1:test@10.10.10.16 + + [ASTtest2] + type=friend + accountcode=IAXtrunk2 + context=default + auth=plaintext + host=dynamic + permit=0.0.0.0/0.0.0.0 + secret=test + qualify=yes + + SERVER TWO(ASTtest2-10.10.10.16) + iax.conf: + register => ASTtest2:test@10.10.10.15 + + [ASTtest1] + type=friend + accountcode=IAXtrunk1 + context=default + auth=plaintext + host=dynamic + permit=0.0.0.0/0.0.0.0 + secret=test + qualify=yes + + +3. The two servers need to have wildcard extensions assigned to the other server in the dialplan: + SERVER ONE(ASTtest1-10.10.10.15) + extensions.conf: + [globals] + TRUNKIAX2=IAX2/ASTtest1:test@10.10.10.16 + + [default] + exten => _010*010*010*016*8600XXX,1,Dial(${TRUNKIAX2}/${EXTEN:16},55,o) + exten => _010*010*010*016*8600XXX,2,Hangup + + SERVER TWO(ASTtest2-10.10.10.16) + extensions.conf: + [globals] + TRUNKIAX1=IAX2/ASTtest2:test@10.10.10.15 + + [default] + exten => _010*010*010*015*8600XXX,1,Dial(${TRUNKIAX1}/${EXTEN:16},55,o) + exten => _010*010*010*015*8600XXX,2,Hangup + + +4. For BOTH servers the VDAD extens need to be setup there as well for the Load-Balance and Load-Balance-Overflow AGI scripts, as well as setting up the closer and inbound extens if needed: + + ; VICIDIAL_auto_dialer transfer script Load Balance Overflow: + exten => 8367,1,AGI(call_log.agi,${EXTEN}) + exten => 8367,2,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) + exten => 8367,3,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) + exten => 8367,4,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) + exten => 8367,5,Hangup + + ; VICIDIAL_auto_dialer transfer script Load Balanced: + exten => 8368,1,AGI(call_log.agi,${EXTEN}) + exten => 8368,2,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) + exten => 8368,3,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) + exten => 8368,4,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) + exten => 8368,5,Hangup + + ; parameters for agi-VDAD_LB_closer.agi (2 fields separated by five dashes "-----"): + ; 1. the full extension formatted by VICIDIAL for internal transfers * separated + ; 2. the word START to denote the beginning of the acceptance of the transfer + ; inbound VICIDIAL transfer calls [INTERNAL TRANSFER] + exten => _90009.,1,Answer ; Answer the line + exten => _90009.,2,AGI(agi-VDAD_LB_closer.agi,${EXTEN}-----START) + exten => _90009.,3,Hangup + + ; parameters for agi-VDAD_LO_closer.agi (2 fields separated by five dashes "-----"): + ; 1. the full extension formatted by VICIDIAL for internal transfers * separated + ; 2. the word START to denote the beginning of the acceptance of the transfer + ; inbound VICIDIAL transfer calls [LOCAL TRANSFER] + exten => _990009.,1,Answer ; Answer the line + exten => _990009.,2,AGI(agi-VDAD_LO_closer.agi,${EXTEN}-----START) + exten => _990009.,3,Hangup + + ; inbound VICIDIAL call with prompt for 4-digit fronter code + exten => 1234,1,Answer ; Answer the line + exten => 1234,2,AGI(agi-VDAD_LO_closer_inbound.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) + exten => 1234,3,Hangup + + +5. Reload both Asterisk servers and for outbound change the VDAD exten to 8367 or 8368 and kill the AST_VDauto_dial.pl scripts on both servers so they can restart and you can now look at the AST_timeonVDADall.php page(per campaign time-on-VDAD available from the STATS and REPORTS link on the vicidial admin screen) that will allo you to see the server_ip of the agent and the server_ip of the call per campaign across all campaigns. + +If you have any questions or problems please post to the astguiclient-users list(link available on the project website) + +6. For multi-server VICIDIAL/astGUIclient installations these cron scripts only need to be set up and run on one of the servers: +- AST_VDhopper.pl +- AST_cleanup_agent_log.pl +- ADMIN_adjust_GMTnow_on_leads.pl +- AST_DB_optimize.pl + diff --git a/agc_2-X/trunk/docs/README.txt b/agc_2-X/trunk/docs/README.txt new file mode 100644 index 00000000..6b80a7f8 --- /dev/null +++ b/agc_2-X/trunk/docs/README.txt @@ -0,0 +1,713 @@ ++------------------------------------------------------------------------------+ +| Asterisk GUI client - astguiclient - twenty-fifth public release 1.1.12 | +| created by astGUIclient group | +| project started 2003-10-06 http://sourceforge.net/projects/astguiclient/ | ++------------------------------------------------------------------------------+ + +This suite of programs is designed to work with the Asterisk Open-source PBX +(http://www.asterisk.org) as a cross-platform GUI client and the supporting +server side applications necessary for the features of the GUI application to +work with Asterisk. The client-side GUI apps are available now as web pages +running AJAX scripted web pages(Firefox recommended) + + ***** Description, Notes and Changelog below ***** + +Included in this distribution of the Asterisk GUI client are: + + - README.txt - this file + + - SCRATCH_INSTALL.txt - detailed instructions of how to fully install Asterisk +with astguiclient from scratch. Also you could use this doc to install from +PHASE 6 of the document if you have an existing Asterisk installation you want +to put astguiclient onto. + + - ACQS.txt - Readme file describing the Asterisk Central Queue System + + - VICIDIAL.txt - Readme file describing the VICIDIAL auto-dialing system + + - REQUIREMENTS.txt - Basic requirements for running astGUIclient/VICIDIAL + + - LOAD_BALANCING.txt - Instructions for multi-server installations + + - TODO.txt - List of what has changed since last release including changes for future releases + + - LICENSE.txt - The license for this release GPLv2 + + - install_server_files.pl - perl script to put files in the right place on the +server. Run as "perl install_server_files.pl" + + - languages.txt - translations file for web-client scripts + - languages_admin.txt - translations fiel for admin pages + + - start_asterisk_boot.pl - starts asterisk through a screen, good for system +boot time startups of asterisk. + +- MySQL_AST_CREATE_tables.sql - used to create tables for astguiclient and +vicidial in your MySQL database + + - astLEADLOADER.pl - client perl/Tk GUI for loading leads into the vicidial_list + + same application run specs as the AST_WINphoneAPP above + ### SOON TO BE DEPRICATED AND UNSUPPORTED ### see the web lead loader + + - ADMIN_area_code_populate.pl - run once to update phone codes to database + + - AST_VICI_conf.pl - file where you define your variables for the client app + + Must be present in one of the libs_path folders + + - AST_update.pl - command line DB updater + + Ideally is run on the Asterisk server locally + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + - AST_vm_update.pl - command line DB voicemail count updater + + Ideally is run on the Asterisk server locally + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + place in the cron as "* * * * * /path/to/script" + +- AST_conf_update.pl - command line DB conference room reg validator + + Ideally is run on the Asterisk server locally + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + place in the cron as "* * * * * /path/to/script" + + - ADMIN_keepalive_AST_update.pl - checks to see that updater is running + + Must put entry for this script in the cron as "* * * * * /path/to/script" + + - AST_CRON_mix_recordings.pl - command line recording mixer to be put in cron + + Runs under UNIX CLI in the cron of the Asterisk Server + + Requires perl (Net::FTP and Net::Ping optional if FTPing to archive server) + + - AST_SERVER_conf.pl - file where you define your variables for the server apps + + Must be present in the /home/cron/ directory + + - AST_manager_listen.pl - listener for the Asterisk Central Queue System (ACQS) + + Must be present in the /home/cron/ directory + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + - AST_manager_send.pl - send-spawn for the ACQS + + Must be present in the /home/cron/ directory + + Requires Net::Telnet, Net::MySQL and Time::HiRes perl Modules + + - AST_send_action_child.pl - blind-send for the ACQS + + Must be present in the /home/cron/ directory + + Requires Net::Telnet, Net::MySQL perl Modules + + - ADMIN_keepalive_AST_send_listen.pl - checks to see that ACQS is running + + Must put entry for this script in the cron as "* * * * * /path/to/script" + + - ADMIN_keepalive_send_listen.at - used for batch restarts of ACQS in seconds + + - AST_manager_kill_hung_congested.pl - kills CONGEST Local/ channels + + To be used with VICIDIAL + + Must put entry for this script in the cron as "* * * * * /path/to/script" + + - ADMIN_listener_restart.pl - automatically restart ACQS + + Assumes installation in /home/cron/ + + - ADMIN_restart_roll_logs.pl - rolls logs over datestamp upon restart + + put this script in your machine's startup routine + + - AST_reset_mysql_vars.pl - resets MySQL tables + + To be used with VICIDIAL + + put this script in your machine's startup routine + + - AST_flush_DBqueue.pl - streamlines DB on heavy volume VICIDIAL systems + + To be used with VICIDIAL + + put this script in the cron at a regular interval(once an hour or so) + + - AST_cleanup_agent_log.pl - cleans up agent log times in VICIDIAL systems + + To be used with VICIDIAL + + put this script in the cron at a regular interval(once an hour or so) + +- The following AGI scripts: + + Run on the Asterisk Server + + Must be present in the /var/lib/asterisk/agi-bin/ directory + + Require perl and Net::MySQL to run + - call_log.agi - AGI/perl program for call logging + - call_logCID.agi - AGI/perl program for call logging receiving CallerID + - call_inbound.agi - AGI/perl program for CallerID popup info (OPTIONAL) + - agi-dtmf.agi - AGI/perl program that plays DTMF tines for conferences + + Requires DTMF sounds to be copied to /var/lib/asterisk/sounds/ + - agi-VDADtransfer.agi - AGI/perl program that transfers calls to VICIDIAL reps + - agi-VDAD_LO_transfer.agi - transfers calls to VICIDIAL reps Load Balance Overflow + - agi-VDAD_LB_transfer.agi - transfers calls to VICIDIAL reps Load Balanced + - agi-VDADcloser.agi - AGI/perl program that takes calls from VICIDIAL reps + + Allows calls from internal or over Zap crossover or IAX from another server + - agi-VDAD_LO_closer.agi - calls from VICIDIAL front to CLOSERS Balance Overflow + - agi-VDAD_LB_closer.agi - calls from VICIDIAL front to CLOSERS Load Balanced + - agi-VDADcloser_inboundANI.agi - AGI/perl that takes calls from outside lines + + like agi-VDADcloser.agi except grabs ANI from robbed-bit T1 channel inbound + - agi-VDADcloser_inboundCID.agi - AGI/perl that takes calls from outside lines + + like agi-VDADcloser.agi except grabs CID from T1-PRI channel inbound + - agi-VDADcloser_inboundCIDlookup.agi - AGI/perl that takes calls from outside lines + + like agi-VDADcloser.agi except looks up CID in DB to display info + - agi-VDADcloser_inbound.agi - AGI/perl that takes calls from outside lines + + like agi-VDADcloser.agi except grabs 4-digit entered code as fronter # + - agi-VDAD_LO_closer_inbound.agi - Load-balance-overflow version + - agi-VDAD_LB_closer_inbound.agi - Load-balance version + - agi-VDADcloser_PHONE.agi - AGI/perl that takes calls from outside lines + + like agi-VDADcloser.agi except attempts to lookup the info from PHONE provided + - park_CID.agi - AGI/perl program to place the callID in the park entry + - call_park_I.agi and call_park_L.agi - AGI/perl script for handling inbound + + Used in conjunction with VICIDIAL closers + + - AST_VDauto_dial.pl - script to automatically call leads for VICIDIAL + + To be used with VICIDIAL + + kept running with the associated keepalive script in the cron + + - AST_VDremote_agents.pl - script to keep remote agents logged in + + To be used with VICIDIAL + + kept running with the associated keepalive script in the cron + + - AST_VDhopper.pl - script to keep leads in the VICIDIAL hopper + + To be used with VICIDIAL + + recommended to put into cron as "* * * * * /path/to/script" + + - ADMIN_keepalive_AST_VDautodial.pl - checks to see that VDAD is running + + Must put entry for this script in the cron as "* * * * * /path/to/script" + + - ADMIN_keepalive_AST_VDremote_agents.pl - keeps remote agents logged in + + Must put entry for this script in the cron as "* * * * * /path/to/script" + + - VICIDIAL_IN_new_leads_file.pl - script to load lead files into VICIDIAL + + To be used with VICIDIAL + + - AST_DB_optimize.pl - optimizes many heavily-used tables in the asterisk DB + + recommended to put into cron as "2 1 * * * /path/to/script" + + - ADMIN_adjust_GMTnow_on_leads.pl - adjusts the current GMT offset for leads + + recommended to put into cron as "3 1 * * * /path/to/script" + + should be run immediately after loading in new leads + + follows daylight saving rules for several countries including: + USA, Canada, Mexico, UK, Ireland, Australia, New Zealand, etc... + + - phone_codes_GMT.txt - file that contains all GMT offsets + + used by ADMIN_adjust_GMTnow_on_leads.pl script + + has over 1,000 entries for various areacode/country/GMT combinations + + - ASTGUICLIENT Web admin pages - administration for ASTGUICLIENT + + must be installed on machine with PHP and MySQL enabled + + must be able to read/write/update to asterisk MySQL database + + welcome.php - just a welcome page + + admin.php - all admin functions for ASTGUICLIENT database + + user_stats.php - look at live user stats + + remote_inbound.php - custom script to grab parked inbound calls remotely + + inbound_popup.php - from remote_inbound page + + - astGUIclient web-client pages - web-only client app in agc folder + + must be installed on machine with PHP and MySQL enabled + + must be able to read/write/update to asterisk MySQL database + + astguiclient.php - the client app + + vicidial.php - the VICIDIAL web-client app + + dbconnect.php - must set to database + + all other scripts are for use by the astguiclient.php script internally + + - VICIDIAL Web admin pages - administration for VICIDIAL campaigns + + must be installed on machine with PHP and MySQL enabled + + must be able to read/write/update to asterisk MySQL database + + welcome.php - just a welcome page + + admin.php - all admin functions for VICIDIAL + + user_stats.php - look at live user stats + + record_conf_1_hour.php - record a VICIDIAL conference for 1 hour + + closer.php - where closers log in to grab calls sent from fronters + + closer_popup.php - from closer page, sends call to closers phone + + closer_dispo.php - from closer_popup, allows dispositioning of call + + +DESCRIPTION: +This program was designed as a GUI client for the Asterisk PBX with Zaptel +trunks or IAX or SIP VOIP trunks and SIP/IAX/Zap hard or softphones or devices +as extensions, it could be adapted to other functions, but it was designed for +Zap/IAX/SIP users. The client programs are web-based and will run on most +modern web browsers + + +TO BE ADDED: +See the TODO.txt file for more info on what has been finished in this version as +well as what we're thinking of working on. The items marked HIGH priority in the +TODO file are the ones we expect to have finished for the next release. If you +have suggestions please send them. + + +NOTES: +There are several features/processes that could have been done many different +ways in this suite, one for example is call parking. After tinkering with +Asterisk/AGI-only call parking where all of the call parking would be achieved +with no need for a GUI client, I discovered that my implementation did not +function well on all single line phones or the Grandstream phones. I settled on +the current method of call-parking by creating a record in a table for a call +parked and Redirecting the call to a constant music extension to take any phone +button pressing out of the loop. We haven't had any problems since we switched +to this method of call parking. Many of the other decisions of how to program +features in this suite we arrived at through similar trial-and-error methods. If +anyone has suggestions/praises/criticisms I would love to hear them. + + +KNOWN BUGS: +- the astGUIclient web client exposes a nasty memory leak in Internet Explorer, + Firefox does not have the same problem so we recommend it instead. +- on astGUIclient you cannot record a native bridge VOIP-only conversation + unless you go into a conference, you also cannot monitor a native-bridge + VOIP-only conversation +- Depending on what version of perl you are running(for the Perl scripts only), + you may have a conflicting version of the Time::HiRes perl module installed. + To fix this, jut go to http://search.cpan.org/~jhi/Time-HiRes-1.82/ and + download the version that your error message says it's looking for(HiRes.pm). + + +VERSION HISTORY: + +0.7 - First public release - 2003-11-18 +This is the first release of the Asterisk GUI Client code, it is entirely +written in Perl with portability and rapid development/testing in mind. The perl +code is NOT strict, it was written loose and fast and has been functioning +rather well in a production environment of 60 clients for one month now. + +0.8 - Second public release - 2003-12-09 +- Several bug fixes +- New button for monitoring live extensions on Zap channels +- Changed the method that the live channels/phone were populated on the +listboxes of the client app. +- Changed the Asterisk/Manager commands to work correctly with new Asterisk CVS +versions requirements. +- A new routine was enabled to allow for making sure that the updater is +running and bringing up a popup alert window on the client if the updater has +not updated in the last 6 seconds. (this also added a new MySQL table) +- Changed the updater to run every 450 milliseconds instead of every 333 +milliseconds. +- Updater changed to allow for ringing channels to appear in the live_channels +table. + +0.9 - Third public release - 2004-02-05 +The majority of the work in this release it to make it more stable and fix some +pretty bad bugs. We created the Asterisk Central Queue System to address the +problem with buffer-overflows in the manager interface of Asterisk causing total +system deadlocks. We also completed and touched-up many other features that we +didn't finish in previous releases. Here is the list of changes: +- Several bug fixes +- Inclusion of listing for active SIP/Local channels and ability to hang them up +- Completely changed the method of conferencing to be more fluid +- Added HELP popup screen +- Added intrasystem calling funtionality +- Updater changed to allow for SIP/Local channels +- Recording for conferences is now able to record all audio in and out +- Added ability to send DTMF tones within a conference +- Changed alert window for updater being down timeout to 20 seconds +- Added an option for using the new Asterisk Central Queue System(ACQS) that +reduces the risk of deadlocks that occur with buffer-overflows on remote manager +interface connections +- Included new script to run at boot time and rotate the logs as well as a +keepalive script for the new ACQS +- Changed non-AGI server-side scripts to allow for a single config file +- Detailed activity logging to text file option added +- Activity logging added to all non-AGI server applications + +0.9.2 - Fourth public release - 2004-03-08 +- several bug fixes for the GUI client and ACQS applications +- addition of the new VICIDIAL auto-dialer application and admin web pages +- added new script to reset MySQL tables +- added new script to kill CONGEST Local/ channels + +0.9.4 - Fifth public release - 2004-03-12 +- a few bug fixes for the GUI and server apps +- addition of callerID popup for the GUI +- callerID buttons to launch web pages from callerID popup +- addition of voicemail count display to GUI +- addition of button to directly connect to voicemail +- addition of voicemail counter updater +- MySQL table "phones" modified and "inbound" table added(see CONF_MySQL.txt) +- new extensions.conf entries need to be added to use callerid and vmail GUI + +1.0.0 - Sixth public release - 2004-03-26 +- a few bug fixes for the GUI and server apps +- Major documentation changes with the addition of the SCRATCH_INSTALL.txt file +that goes step-by-step through the entire install process of an asterisk server +from blank hardware to astguiclient installation and configuration. +- added pretty buttons to the WINphoneAPP +- added blind transfer to voicemail, blind transfer to another extension and +blind external transfer +- new install script created to put server files in default positions and set +permissions to execute +- new sql file to create all tables by running a script execute command in MySQL + +1.0.1 - Seventh public release - 2004-04-27 +- a few bug fixes for the GUI and server apps +- minor changes to WINphoneAPP +- major changes to VICIDIAL client code: + + rearranged VICIDIAL buttons and added some color to DIAL and HANGUP buttons + + allowed for call parking with different park music per-campaign + + allowed for webpage forms launched from GUI with call info + + allowed for different web form web page per-campaign + + allowed agents using VICIDIAL client to send calls with data to a closer + + new call-closer functionality is web-based for flexibility + + added new DTMF dialpad for sending tones quickly +- fixed bugs in VICIDIAL web admin pages +- fixed bugs in ASTGUICLIENT web admin pages +- added code from Paul Concepcion to allow admin pages to work with globals off +- added common database connection file for each set of PHP admin pages +- made small changes to the MySQL database Schema + (NOTE: if upgrading from 1.0.0 run the upgrade_1.0.1.sql script in MySQL) + +1.0.2 - Eighth public release - 2004-06-03 +- a few bug fixes for the GUI apps +- corrected documentation errors in SCRATCH_INSTALL instructions +- updated SCRATCH_INSTALL instructions for some newer software +- corrected errors in SQL install queries +- corrected errors in server installation scripts +- WINphoneAPP config option to allow one persistant mysql DB connection +- WINphoneAPP config option to allow modification of info refresh interval +- VICIDIAL modified to allow for auto-dial of next number + (NOTE: if upgrading from 1.0.1 you do not need to update any web pages or + server apps, this update is only a client GUI and docs update. Note that the + AST_VICI_conf.pl has been updated, so you may need to modify your client + configs to enable new features.) + +1.0.3 - Ninth public release - 2004-07-21 +- a few bug fixes for the GUI apps +- changed the recording to show recording ID when recording is started +- VICIDIAL overhauled: + + added Time::HiRes module requirement to better control time increments + + changed to dial from a small hopper of pre-ordered leads per campaign + + added cron script to always keep leads in the hopper every minute + + added a counter to see how many times a lead is called + + added ability to dial campaign by how many times lead called + + added some new stats to the admin web pages + + created a limited predictive-dialer that will dial a certain amount of leads + per logged in agent and direct the calls that are picked up to the next agent + + ability to transfer the called line and the 3rd party call into a separate + meetme room and continue on dialing + UPGRADE NOTES: + * if upgrading from 1.0.2 you need to update the web pages and all + server apps. + * if upgrading from 1.0.2 run the upgrade_1.0.3.sql script in MySQL + * if upgrading from 1.0.2 you may want to run AST_upgrade_1.0.3.pl to update + your called counts of your leads in vicidial_list. + * AST_SERVER_conf.pl has been updated, so you may need to modify your server + configs to enable new features. + * client app names have been changed to astVICIDIAL and astGUIclient + +1.0.4 - Tenth public release - 2004-09-21 +- several minor bug fixes for GUI apps and server apps +- fixed recording bug in astGUIclient that would rarely stop recording +- added timezone dialing in VICIDIAL +- added new client GUI app for inserting leads into the VICIDIAL leads table +- adjusted timings in the VICIDIAL autodialer for better performance +- added streamlined manager interface logins to help scripts run more smoothly + UPGRADE NOTES: + * if upgrading from 1.0.3 you need to update the web pages and all + server apps. + * if upgrading from 1.0.3 run the upgrade_1.0.4.sql script in MySQL + * if upgrading from 1.0.3 you may want to run ADMIN_adjust_GMTnow_on_leads.pl + to update the timezone in the vicidial_list table + * AST_SERVER_conf.pl on the server has been updated, so you may need to modify + your server configs to enable new features(like timezone dialing). + * AST_VICI_conf.pl for clients has been updated, so you may need to modify + your client configs to enable new features(like timezone dialing). + * run this script if you plan on doing timezone restrictions on VICIDIAL: + ADMIN_area_code_populate.pl + +1.0.5 - Eleventh public release - 2004-10-28 +- many minor bug fixes in most of the server and client scripts +- fixed multiple login bug on VICIDIAL +- fixed the manual-dial/auto-dial switching bug on VICIDIAL +- fixed a few time zone calling bugs on VICIDIAL server apps +- all apps now allow for IAX trunks to be used in addition to the usual Zap +- added more options to install script +- changed CLI lead loader to use Net::MySQL instead of DBI +- modified several scripts that handle CallerID because of the early October + change in the CVS of outputting CID info as two separate fields(CallerID and + CallerIDname) instead of everything being sent in CallerID. +UPGRADE NOTES: + * if upgrading from 1.0.4 you need to update the web pages and all + server and client apps. + * if upgrading from 1.0.4 run the upgrade_1.0.5.sql script in MySQL + * if using a CVS version 2004-10-07 or newer or release 1.0.3 or newer + change the line in extensions.conf + exten => 8309,2,Monitor(wav,${CALLERIDNUM}) + change to + exten => 8309,2,Monitor(wav,${CALLERIDNAME}) + +1.0.6 - Twelfth public release - 2004-12-23 +- many minor bug fixes in most of the server and client scripts +- optimized the ACQS and restructured its keepalive scripts +- added hijack line feature to astGUIclient +- added inbound call handling for VICIDIAL +- added blended in-outbound calling within VICIDIAL +- added new closer stats report +- updated the SCRATCH_INSTALL instructions and corrected errors +- see the TODO.txt file for other items DONE in this release +UPGRADE NOTES: + * if upgrading from 1.0.5 you need to update the web pages and all + server and client apps. + * if upgrading from 1.0.5 run the upgrade_1.0.6.sql script in MySQL + * if upgrading from 1.0.5 add a campaign "CLOSER" to enable closers and + inbound call taking through the VICIDIAL application + (see the SCRATCH_INSTALL document SUBPHASE 6.2 for more information) + +1.1.0 - Thirteenth public release - 2005-03-09 +- several small bug fixes in most of the server and client scripts +- added IAX and Zap client/agent compatibility +- implemented some major database optimizations +- ability to specify MySQL port across all apps +- moved almost all client config variables from client files to the Database +- created a meetme room validator that will allow faster reassignment of conferences +- created a new remote_agent login system for VICIDIAL in/outbound calls +- restructuring of AST_update script to cope better with manager output hiccups +- added dial timeout field to VICIDIAL to specify the timeout per campaign +- added help popups to every page of the admin web pages to explain fields +- see the TODO.txt file for other items DONE in this release +UPGRADE NOTES: + * if upgrading from 1.0.6 you need to update the web pages and all + server and client apps. + * if upgrading from 1.0.6 run the upgrade_1.1.0.sql script in MySQL + * if upgrading from 1.0.6 you will need to configure your client parameters on + the admin web page and remove them from the client computers (except for the + fields that are in the sample AST_VICI_conf.pl file) + * older client apps are not compatible with this version, you must upgrade + +1.1.1 - Fourteenth public release - 2005-06-03 +- several small bug fixes in most of the server and client scripts +- added astGUIclient web-only client +- added campaign-custom disposition statuses to VICIDIAL +- added campaign-custom CallerID to VICIDIAL +- added fronter-display-disable option to VICIDIAL Inbound Groups +- added ability to separate vicidial users by groups +- added performance stats gathering ability to AST_update script +- fixed the send-to-vmail portion of inbound AGI scripts +- added simple web-based lead file loader for VICIDIAL +UPGRADE NOTES: + * if upgrading from 1.1.0 you need to update the web pages and all + server apps. + * if upgrading from 1.1.0 run the upgrade_1.1.1.sql script in MySQL + +1.1.2 - Fifteenth public release - 2005-06-06 +- fixed fatal bug in AST_update.pl script +- added instructions for ploticus install to SCRATCH_INSTALL +UPGRADE NOTES: + * if upgrading from 1.1.0 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + * if upgrading from 1.1.0 run the upgrade_1.1.1.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.1.sql) + +1.1.3 - Sixteenth public release - 2005-06-10 +- fixed config bug in AST_VDauto_dial.pl script +- added null query result checks to scripts in the agc web-only client +- added documentation for the inbound and transfer AGI script variables +- added documentation and tested install with MySQL 4.1 tree (4.1.12) +UPGRADE NOTES: + * if upgrading from 1.1.0 - 1.1.2 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + * if upgrading from 1.1.0 run the upgrade_1.1.1.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.1.sql) + +1.1.4 - Seventeenth public release - 2005-06-24 +- fixed new Local channel bugs caused by changes in Asterisk 1.0.8 and CVS +- added beta support for SIP trunks +- added ability to send VICIDIAL outbound calls to custom AGI script per + campaign and included new survey sample AGI script +- added better Asterisk shutdown detection to AST_manager_listen script +UPGRADE NOTES: + * if upgrading from 1.1.3 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + - if using VICIDIAL download the new client script to all client stations + - make sure you populate the new $AST_ver variable in AST_SERVER_conf.pl + * if upgrading from 1.1.3 run the upgrade_1.1.4.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.4.sql) + +1.1.5 - Eighteenth public release - 2005-08-12 +- fixed new Local channel bugs caused by changes in Asterisk 1.0.8 and 1.0.9 +- moved many server variables to the database, editable through admin.php +- added ability to limit number of outbound trunks used by VICIDIAL auto dialer +- many small changes and bug fixes to the astguiclient web client +- added alpha vicidial web-client (click-to-dial only) +UPGRADE NOTES: + * if upgrading from 1.1.4 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + - VICIDIAL perl/TK client is unchanged from 1.1.4 + - make sure you check the astguiclient admin.php server parameters + * if upgrading from 1.1.4 run the upgrade_1.1.5.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.5.sql) + +1.1.6 - Nineteenth public release - 2005-08-29 +- streamlined many of the server apps and added command-line debug capability +- finished the vicidial web-client and tested in prduction +- modified server-side scripts to function with Asterisk CVS_HEAD(soon to be 1.2) +- modified server performance logging and graphing, added user/system proc % +UPGRADE NOTES: + * if upgrading from 1.1.5 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - perl/TK clients are unchanged from 1.1.5 + - make sure you check the astguiclient admin.php server parameters + - make the agi-VDADtransfer.agi changes in extensions.conf (mentioned in SCRATCH_INSTALL doc) + * if upgrading from 1.1.5 run the upgrade_1.1.6.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.6.sql) + +1.1.7 - Twentieth public release - 2005-10-05 +- Added HotKeys key binding for VICIDIAL web-client fast dispositioning +- Internationalization(multi-language) of web-clients and admin pages +- Added ability in manual VICIDIAL to call alternate lead phone numbers +- Added option of pull-down of active campaigns to VICIDIAL web login +- Fixed some issues with scripts interacting with Asterisk 1.2 +- other small changes listed in the TODO.txt file +UPGRADE NOTES: + * if upgrading from 1.1.6 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - perl/TK clients have been slightly updated(will be unsupported soon) + - multi-language versions of web-clients and admin pages are available in the + LANG_agc.zip and LANG_admin.zip files and can be unzipped into your webroot + directory. Make sure you check the dbconnect.php file in each directory. + * if upgrading from 1.1.6 run the upgrade_1.1.7.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.7.sql) + +1.1.8 - Twenty-First public release - 2005-11-10 +- Added per-campaign call recording options to VICIDIAL +- Added detailed logging for VICIDIAL agent time +- Fixed some issues with scripts interacting with Asterisk 1.2 +- other small changes listed in the TODO.txt file +UPGRADE NOTES: + * if upgrading from 1.1.7 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - multi-language versions of web-clients and admin pages are available in the + LANG_agc.zip and LANG_admin.zip files and can be unzipped into your webroot + directory. Make sure you check the dbconnect.php file in each directory. + * if upgrading from 1.1.7 run the upgrade_1.1.8.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.8.sql) + +1.1.9 - Twenty-Second public release - 2006-01-19 +- Added Load Balancing of Inbound and Outbound calls across multiple Asterisk + servers in the same setup +- Removed all PHP globals requirements, can now use register_globals=Off in PHP +- Add fully translated Greek admin and agc scripts(agc images to come) +- Added security elements to admin pages and added record deletion functions +- Added a script tab to VICIDIAL to have a variable-populated agent script +- Added new Super lead loader with field chooser and CVS/XLS-format capability +- Added favorites panel to astguiclient.php that shows off/on hook +- Many other small changes listed in the TODO.txt file +UPGRADE NOTES: + * if upgrading from 1.1.8 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - multi-language versions of web-clients and admin pages are available in the + LANG_agc.zip and LANG_admin.zip files and can be unzipped into your webroot + directory. Make sure you check the dbconnect.php file in each directory. + * if upgrading from 1.1.8 run the upgrade_1.1.9.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.9.sql) + +1.1.10 - Twenty-Third public release - 2006-03-17 +- Added capability to work with app_amd(answering machine detection) +- Added transfer-conference number and DTMF presets per campaign +- Added sphinx ring-time analysis disposition package(beta) +- Added scheduled callbacks to VICIDIAL +- Added more user-permission options/restrictions +- Several small bug fixes for better Asterisk 1.2.4 compatibility +- Many other small changes listed in the TODO.txt file +UPGRADE NOTES: + * if upgrading from 1.1.9 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - add "exten => h,2,DeadAGI(VD_hangup.agi,${EXTEN})" to extensions.conf + - multi-language versions of web-clients and admin pages are available in the + LANG_agc.zip and LANG_admin.zip files and can be unzipped into your webroot + directory. Make sure you check the dbconnect.php file in each directory. + * if upgrading from 1.1.9 run the upgrade_1.1.10.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.10.sql) + +1.1.11 - Twenty-Fourth public release - 2006-04-28 +- Added Agent-only Scheduled Callbacks +- Added Lead Filters for campaigns to use custom SQL to narrow calling scope +- Added Agent manual-lead-insertion capability +- Fixed PHP variable checking in all PHP scripts to be more compliant +- Added more user-permission options/restrictions for both agents and admins +- Several small bug fixes for better Asterisk 1.2.6 and SVN compatibility +- Many other small changes listed in the TODO.txt file +UPGRADE NOTES: + * if upgrading from 1.1.10 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - multi-language versions of web-clients and admin pages are available in the + LANG_agc.zip and LANG_admin.zip files and can be unzipped into your webroot + directory. Make sure you check the dbconnect.php file in each directory. + * if upgrading from 1.1.10 run the upgrade_1.1.11.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.11.sql) + +1.1.12 - Twenty-Fifth public release - 2006-06-22 +- Security enhancements of PHP scripts to reduce SQL-injection and other threats +- Completely redesigned local call time system in VICIDIAL for more flexibility +- Added Drop-call and safe-harbor options to campaigns and inbound groups +- Added option for allowing wrapup time between calls in vicidial.php +- Multi-language translation rewritten for more flexibility and easy of use +- Added more user-permission options/restrictions for both agents and admins +- Added option of using app_conference instead of meetme engine +- Added internal DNC list for Do-Not-Call entries across the system +- Added automatic lead recycling to call back Busy calls at definable intervals +- Added listID override and timezone lookup to all lead importing scripts +- Added easy-prompt-recording AGI and playback: agi-record_prompts.agi +- Many other changes and bug fixes listed in the TODO.txt file +UPGRADE NOTES: + * if upgrading from 1.1.11 you need to: + - download the new version from the project website + - unzip the zip file into the /home/cron/astguiclient directory + - and either: + + copy the web pages and all server apps to their proper locations manually + + or run the install_server_files.pl script to put all items in their + default places + (make sure AST_SERVER_conf.pl and dbconnect.php files are config'd properly) + - multi-language versions of web-clients and admin pages are available in the + LANG_agc.zip and LANG_admin.zip files and can be unzipped into your webroot + directory. Make sure you check the dbconnect.php file in each directory. + * if upgrading from 1.1.11 run the upgrade_1.1.12.sql script in MySQL + (\. /home/cron/astguiclient/upgrade_1.1.12.sql) + * if upgrading from older version you will need to run this query for each + campaign in VICIDIAL in MySQL: + (INSERT INTO vicidial_campaign_stats (campaign_id) values('campaignname');) diff --git a/agc_2-X/trunk/docs/REQUIREMENTS.txt b/agc_2-X/trunk/docs/REQUIREMENTS.txt new file mode 100644 index 00000000..29921a6d --- /dev/null +++ b/agc_2-X/trunk/docs/REQUIREMENTS.txt @@ -0,0 +1,32 @@ +This is the basic list of requirements for using astGUIclient. It is highly +recommended that you read the SCRATCH_INSTALL doc for more information on +installing the package properly. + +Requirements for installing astGUIclient/VICIDIAL on an Asterisk server: +- Asterisk 1.0.10 and 1.2.6 recommended but will work with older versions +- Zap trunks(T1/E1 or PSTN lines), IAX2 trunks or SIP trunks required +- If using VOIP trunks and VICIDIAL auto-dial, you must have trunks registered +- You must have a zaptel timer like a PSTN/T1/E1 card or ztdummy + or you can use the experimental app_conference module +- Client phones can be SIP/IAX/Zap +- In extensions.conf you must use the 'o' Dial flag on your outbound extensions +- In extensions.conf you must have thee following line in your default context: + exten => h,1,DeadAGI(call_log.agi,${EXTEN}) +- No modification of outgoing callerID (you can set callerID through admin) +- In php.ini you must have uploads turned on to use the web lead loader +- SoX 12.17.5 or greater must be installed +- GNU screen 3.9.15 or greater must be installed +- ntp must be installed and syncd to same time source as any other servers +- Perl5 with several CPAN modules(Time::HiRes, Net::MySQL, Net::Telnet, etc) +- Access to MySQL server, must be version 4.0.X or higher +- Access to Apache/PHP webserver +- Several entries in the cron for interval-running scripts and keepalives + +Requirements for using the astGUIclient/VICIDIAL web-client versions +- Recommended 500MHz speed or faster and 64MB RAM or more +- Any Unix with Xwindows, Mac OS9/X or Win98/2k/XP operating system +- Recommended use Firefox for all OSs (will run under IE5.0 or greater as well) + NOTE: (Internet Explorer has memory leaks that will cause it to freeze +3hrs) + Will also run on Opera 8.5+, Mozilla 1.7+ and Netscape 8+ +- ntp or sntp time syncing to same source as server recommended +- Proper configuration settings for each phone/computer in the phones DB table diff --git a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt new file mode 100644 index 00000000..e2ef2cd0 --- /dev/null +++ b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt @@ -0,0 +1,2609 @@ +Asterisk/astguiclient install from scratch. v.1.1.12 2006-06-22 + By the astGUIclient group astguiclient@eflo.net + +**** IMPORTANT - In order for vicidial/astguiclient to function correctly please +read the REQUIREMENTS.txt for a minimum requirements list. *** + + +This document is meant to be a very in-depth step-by-step explanation of +installing the Asterisk open-source PBX on a Linux system and also installing +the astGUIclient suite. The instructions will assume starting from nothing and +will try to give several side step instructions to account for some differences +in choices of hardware and software. + +The actual installation that I am doing as I write these instructions will be on +the following hardware: + + - Pentium 3 500MHz + - Intel motherboard D815BN + - 256MB PC133 RAM + - 80GB IBM deskstar 7200RPM Hard Drive + - Digium Wildcard Single Span T1 Card T100P + - 2U rackmount case with 250W power supply + - Phone hardware will be a Grandstream BT102 and a Sipura SPA-2000 because they +are so cheap and readily available + +All of these parts, aside from the Digium card and the two SIP VOIP devices, +were purchased from ebay and the entire package(with the two VOIP devices and +all server hardware included) cost me about $1100 to put together including the +phones and Digium adapter. + +We have many other Asterisk servers at our main office, but this one can be +experimented with easily because it was so cheap to make and has a relatively +small capacity when compared with a multi-processor server with a quad span T1 +card. + +This is our test Asterisk server and functions well for a dozen or so extensions +in use if it were to be used in production. A size that is optimal for many +small offices operating with a fractional data/voice T1 for instance. + +For hardware you can use almost any Pentium-class processor(PII, PIII, Athlon, +Xeon, etc), and you can use any digium telco interface card. Both of these +choices will determine what the capacity of your Asterisk server will be. If you +want to do simple IVR or conference calling and a few extensions, then a PIII +with a single Digium T1 card will work just fine for you. If you want to use the +VICIDIAL application, you will want to get as high-powered of a machine as you +can afford and get a digium quad-span T1 card. + +The following is assumed for these installation procedures: +- You have access to a CD burner and 3 blank CDs +- You have some sort of broadband internet connection +- You understand basic linux commands and can use a file editor like vi +- You have all of the necessary hardware: + - a pentium-class computer + - a digium telco interface card with appropriate telco lines + - at least 1 SIP VOIP device + - a Local Area Network(LAN) with extra ports enough for the new server +and the number of phones you want + + + + + +PHASE 1: INSTALLING AN OPERATING SYSTEM + + +This installation will be using Slackware 10.2 for the linux distribution, +Slackware 10.0will also work with these instructions. There are several easier +linux distributions and there are others that are more popular, but Slackware is +a nice non-commercial distro that has been around for a long time and proven +itself to be a very uncluttered and stable platform for development. + +1. Go to http://www.ultimatebootcd.com/ , download the latest bootcd and +burn it to a CD. This will be needed to partition the hard drive prior to +installation of Slackware linux. The latest version as of this writing is 3.3 +(If you have problems with your hardware booting some of the utilities with 3.3 +I suggest trying 1.7, that version has older utilities, but still gets the job +done and works on every machine I've tried it on). + +2. Insert the ultimatebootcd you just burned into your CDROM drive and boot +to it. You will select "filesystem utilities" and then "XFDISK" + +3. Select any old partitions and delete them and then create 2 new +partitions: + - 70000 MB, select yes to validate, change partition type to "Linux Native" + - 3332 MB, select yes to validate, change partition type to "Linux Swap" + - press F3 to exit and let it do it's thing, this will take an hour or so. + +4. Go to http://www.slackware.com/getslack/ to download Slackware linux. +The most recent release as of this writing is 10.2. This release fits on 2 CDs. +Download both installation disks from any close server listed on the download +page and burn them both to CDs. + +5. Insert Disk 1 of the Slackware installation CD and boot your computer. +If you have a simple computer with just an IDE drive just hit enter at the boot: +prompt. If you have other hard drive adapters(SCSI/RAID/SATA/etc..) you will +need to look at the Slackware installation help page to determine what boot +image you will need to use to install Slackware correctly. + +6. Login as root and type "setup" at the prompt to go to the setup menu. +7. Go to ADDSWAP and hit Enter +8. Select the swap partition you just created and hit Yes, The swap +partition will then be formatted +9. Select the root partiton you just created as Linux Native and hit +Select, then select "ext3" for the file system, then select 4096 for the inodes +and the root partition will then be formatted +10. Select "Install Slackware from a CD" and hit OK +11. Select "auto" installation and hit OK +12. Select every package except for "KDEI" and hit OK +13. Select "full" installation and hit OK +14. Insert the next Slackware installation disk (disk 2) when it prompts +you, and hit OK to continue +15. Now you will select the boot kernel that you will use from now on. If +you have a simple system with IDE drives you can probably just select "skip" and +go to the next step. If not then you should probably select "cdrom" and select +the kernel from the list that you selected to boot into the installation. +16. You can make a bootdisk if you like, but you don't have to. +17. For Modem you can select "no modem" and hit OK to continue +18. Enable hotplug, hit Yes to continue +19. Install lilo "simple" and hit OK to continue +20. lilo frame buffer console 640x480 is safe choice if you're not sure +21. Optional Lilo append, leave blank and hit OK to continue +22. Lilo destination, I usually choose MBR but root works most of the time +23. Mouse, select the mouse type that you have hooked up, or select ps/2 +24. Load GPM at boot time, Hit Yes to continue +25. select Yes to configure your network +26. Hostname, we are typing "phone" +27. network, we are typing our local domain name +28. IP address, we are selecting Static IP, here's what we enter for +network, you should enter a network setup that will work with your local LAN: + - IP address: 10.10.10.15 + - subnet: 255.255.0.0 + - gateway: 10.10.10.1 + - name server: 10.10.10.1 +29. Accept your network settings +30. Startup services to run, change nothing and select OK to continue +31. select NO for custom screen fonts +32. Hardware clock to UTC, select NO +33. Select your time zone and hit OK +34. I usually select gnome as the window manager, even though you won't be +using it on this machine +35. Select Yes to enter a root password. type something that you will +remember. +36. Setup of Slackware Linux is complete, hit OK and EXIT then press +CTRL-ALT-DELETE to reboot your computer + + + + + +PHASE 2: COMPILING A CUSTOM LINUX KERNEL + + +From this step on you should be able to continue the installation remotely +although it is wise to at least have quick access to the machine if something +goes wrong. + +To connect remotely through SSH on linux type "slogin serveripaddress" or to use +Windows to connect you can use a piece of free software called putty available +here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html +Also, for windows you can use SSH file transferring(SFTP) with a program called +filezilla: http://filezilla.sourceforge.net/ + +This is an optional step if your linux system is running, but compiling your own +custom kernel is always a way to optimize your system for the hardware you have +installed or a way to remove the unnecesary modules that are in the default +kernel. You will definately want to build your own kernel if you have a multi +processor machine. + +If you want to load a 2.6 kernel then start with step -5, otherwise to use the +2.4 kernel that comes with Slackware(2.4.31) just start at step 1 below: + +-5. cd /usr/src +-4. wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.15.6.tar.gz +-3. gunzip linux-2.6.15.6.tar.gz +-2. tar xvf linux-2.6.15.6.tar +-1. mv -f /usr/src/linux /usr/src/linux-old +-0. ln -s /usr/src/linux-2.6.15.6 /usr/src/linux +1. cd /usr/src/linux # move to your linux source directory +2. cp .config config.save # copy old config to a save file +3. make mrproper # prep for kernel assembly +4. make menuconfig # launch configuration menu app + (this part is very dependant upon your own hardware) + enable processor version # select the processor that you have + enable SMP # if more than 1 processor or Intel HT + enable high memory () # if more than 1GB of RAM + enable SCSI Multiple # if SCSI drives + enable SCSI devices AMI Megaraid # if SCSI Megaraid adapter + enable 3com network devices # if 3com network card + enable ext3 file system # for ext3 to work + enable all ACPI options # for SMP to work + enable Enhanced Real Time Clock Support in Character devices section + # for SMP to work + enable any other hardware specific options + exit and save configuration +5. make dep # build the kernel dependancies +6. make clean # clean up the kernel build areas +7. make bzImage # create a kernel bzImage +8. make modules # build the modules into the image +9. make modules_install # install kernel modules +10. # nothing# mkinitrd /boot/initrd-XXXXXX.img XXXXXX *not needed on Slackware* +11. cp arch/i386/boot/bzImage /boot/bzImage-XXXXXX # copy image + (put whatever you want in XXXXXX, that is your new kernel name) +12. cp System.map /boot/System.map-XXXXXXN # copy system map +13. mv -f /boot/System.map /boot/System.map-orig +14. ln -s /boot/System.map-XXXXXX /boot/System.map # symlink map +15. vi /etc/lilo.conf # edit the lilo boot config file + image=/boot/bzImage-XXXXXX # add the new image in above- + label=test-XXXXXX # the previous one + root=/dev/hda1 # device of root partition + read-only +16. /sbin/lilo # run the lilo reload script +17. shutdown -r 0 # reboot machine and hope it worked + + + + + +PHASE 3: INSTALLING SOFTWARE BEFORE ASTERISK + +In this step we will be installing software that Asterisk and/or astGUIclient +needs to be able to function to its fullest ability. Not all of these software +packages are manditory to successfully install Asterisk and some of them can be +installed on other machines on your network like MySQL or Apache. But, in this +installation we are assuming that there are no other machines on our network to +help the Asterisk server, so it must have everything it needs installed locally. + + +It's nice to have a non-root account to put applications and have things run on +when you don't want to use root. We use cron user account for this purpose. + + + +SUBPHASE 3.0: creating an underpriveledged user account + +1. type "adduser cron" at the command prompt +2. follow the prompts and assign a password that you will remember to the new +user. The home directory should be /home/cron/ for this new user. + + + +SUBPHASE 3.1: Installing Perl Modules + +NOTE - you can install ActiveState http://www.activestate.com perl for faster +executing code that uses less processor time, but it is not required. Here's +the source for ActiveState Perl 5.6: (it's free) + http://downloads.activestate.com/ActivePerl/src/5.6/AP638_source.tgz +I hope to add the lengthy steps for installing it as your default perl on your +server but I need some time and a free machine to do that. + +cpan is the "Comprehensive Perl Archive Network". It's a mirrored archive of +most of the perl modules out there complete with a installation and management +command-line interface. Here's what you do to start it: +*REQUIRED* (needed for perl AGIs) + +1. perl -MCPAN -e shell # type in the command line +2. You will then go through CPAN setup, just hit ENTER for most prompts except +for the mirrors list, you will want to select at least 4 mirrors + - yes for manual configuration + - enter for the next 18 prompts + - for the "make install options" it's a good idea to add UNINST=1 + - enter for the next 4 prompts + - select your continent and country + - select a few cpan mirrors + - enter for the next 2 prompts +3. Once you see the cpan> prompt you can begin installing modules +4. If you've never installed cpan before you should probably install the +following modules first: (say YES if asked to install prerequisites) + - install MD5 + - install Digest::MD5 + - install Digest::SHA1 + - install readline (just hit Enter when it asks for operator) + - install Bundle::CPAN + - reload cpan +- then you can install other modules: + - install DBI + - install O/OY/OYAMA/Net-MySQL-0.08.tar.gz + - install Net::Telnet + - install Time::HiRes + - install OLE::Storage_Lite (needed for super list loader Excel) + - install Spreadsheet::ParseExcel (needed for super list loader Excel) +- then quit cpan, you are done +5. Go to http://asterisk.gnuinter.net/ and download the asterisk-perl module +(backup link: http://www.freedomphones.net/files/asterisk-perl-0.08.tar.gz) + - to install this directly on the command line type: + - cd /usr/local + - wget http://asterisk.gnuinter.net/files/asterisk-perl-0.08.tar.gz + - gunzip asterisk-perl-0.08.tar.gz + - tar xvf asterisk-perl-0.08.tar + - cd asterisk-perl-0.08 + - perl Makefile.PL + - make all + - make install + - you are done + + + +SUBPHASE 3.2: Installing other utilities + +Sox is an audio utility that allows you to mix audio files together at their +start point into one file. it is necessary for Asterisk recordings that record +in and out as separate files +*REQUIRED* (needed for recording mixing) + +1. Go to http://sourceforge.net/projects/sox/ and download the sox package + - to install this directly on the command line type: + - cd /usr/local + - wget http://easynews.dl.sourceforge.net/sourceforge/sox/sox-12.17.9.tar.gz + - gunzip sox-12.17.9.tar.gz + - tar xvf sox-12.17.9.tar + - cd sox-12.17.9 + - ./configure + - make (if alsa.o errors add --disable-alsa-dsp to configure and redo) + - make install + - you are done + + +LAME is an MP3 encoder used to convert audio files from WAV to MP3. We prefer GSM +usually, but some users have standardized on MP3 so they would need this utility +to be loaded to use that option. +*OPTIONAL* + +2. Go to http://lame.sourceforge.net/ and download the lame package + - to install this directly on the command line type: + - cd /usr/local + -wget http://umn.dl.sourceforge.net/sourceforge/lame/lame-3.96.1.tar.gz + -gunzip lame-3.96.1.tar.gz + -tar xvf lame-3.96.1.tar + -cd lame-3.96.1 + -./configure + -make + -make install + - you are done + + +mpg123 is the mp3 player for asterisk and is used for music-on-hold +applications. We do not usually use it on our system, but to be more +comprehensive we will give the directions to install it. +*OPTIONAL* (only if you want to use Astrisk's music-on-hold) + +3. Go to http://www.mpg123.de/ and download the mpg123 package + - to install this directly on the command line type: + - cd /usr/local + - wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz + - gunzip mpg123-0.59r.tar.gz + - tar xvf mpg123-0.59r.tar + - cd mpg123-0.59r + - ./configure + - make linux + - make install + - you are done + + +Screen is a terminal emulator that allows you to run a process as command line +and be able to detach from them('Ctrl+a' then 'd') and log all output of the +terminal to a screenlog file if desired(add a '-L' to the launching command). +In our installations this is how we launch Asterisk upon startup and still have +the ability to log output and still attach to the screen that executed asterisk +originally. +*REQUIRED* + +4. Go to http://www.gnu.org/software/screen/ and download the screen package + - to install this directly on the command line type: + - cd /usr/local + - wget http://ftp.gnu.org/gnu/screen/screen-4.0.2.tar.gz + or for older version: + - wget http://mirrors.kernel.org/gnu/screen/screen-3.9.15.tar.gz + - gunzip screen-4.0.2.tar.gz + - tar xvf screen-4.0.2.tar + - cd screen-4.0.2 + - ./configure + - make + - make install + - you are done + + +ttyload is a simple terminal application that shows the processor load in a +graphical time-based scrolling graph. We use it to view how loaded the system is +and it visualizes load spikes very well +*OPTIONAL* (only for obsessive admins like me) + +5. Go to http://www.daveltd.com/src/util/ttyload/ and download the ttyload +package + - to install this directly on the command line type: + - cd /usr/local + - wget http://www.daveltd.com/src/util/ttyload/ttyload-0.4.4.tar.gz + - gunzip ttyload-0.4.4.tar.gz + - tar xvf ttyload-0.4.4.tar + - cd ttyload-0.4.4 + - make + - ln -s /usr/local/ttyload-0.4.4/ttyload /usr/bin/ttyload + - you are done + + +ntpd is the network time protocol daemon that matches the time on your machine +with the time of a master server somewhere in the world. We use it to make sure +the time is the same on our client computers and our servers. +*MANDITORY FOR VICIDIAL USERS* (install on server and all clients) + +6. Go to http://www.ntp.org/ and download the ntpd package + - to install this directly on the command line type: + - cd /usr/local + - wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.2.tar.gz + If you get compilation errors here try 4.1.2: + - wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.1.2.tar.gz + - gunzip ntp-stable-4.2.0a-20060224.tar.gz + - tar xvf ntp-stable-4.2.0a-20060224.tar + - cd ntp-4.2.0 + - ./configure + - make + - make install + - vi /etc/ntp.conf (change to just 1 line: "server 18.145.0.30") + - cp /etc/ntp.conf /etc/ntpd.conf # just to be sure + - /usr/local/bin/ntpdate -u 18.145.0.30 # initial sync + - /usr/sbin/ntpd # run it + - you are done + + +aftpd is a tftp server which is a file transfer method used by many VOIP phones +to get their firmware and/or configuration files. This is optional. +*OPTIONAL* (only if you want it for a VOIP phone you are going to use) + +7. Go to ftp://ftp.mamalinux.com/pub/atftp and download the aftpd package + - to install this directly on the command line type: + - cd /usr/local + - ncftpget ftp://ftp.mamalinux.com/pub/atftp/atftp-0.7.tar.gz + - gunzip atftp-0.7.tar.gz + - tar xvf atftp-0.7.tar + - cd atftp-0.7 + - ./configure + - make + - make install + - mkdir /usr/local/tftp # create the directory to put files in + - chmod 0777 /usr/local/tftp # set permissions for new directory + - "/usr/local/sbin/in.tftpd --verbose=6 --daemon --port=69 --user cron /usr/local/tftp" # command to start tftpd server + - you are done + + +iftop is a good console bandwidth visualization tool that shows you active +connections, where they are going to/from and how much of your precious bandwidth +they are using. *OPTIONAL* + +8. Go to http://www.ex-parrot.com/~pdw/iftop/ and download the package + - to install this directly on the command line type: + - cd /usr/local + - wget http://www.tcpdump.org/release/libpcap-0.8.3.tar.gz + - gunzip libpcap-0.8.3.tar.gz + - tar xvf libpcap-0.8.3.tar + - cd libpcap-0.8.3 + - ./configure + - make + - make install + - cd /usr/local + - wget http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz + - gunzip iftop-0.17.tar.gz + - tar xvf iftop-0.17.tar + - cd iftop-0.17 + - ./configure + - make + - make install + - iftop + - you are done + + +ploticus is a free graph creation package that allows you to create line graphs +within PNG files simply by creating a config file and a data file. We use this +package along with the included PHP script to generate server performance graphs +that can be displayed real-time on a web page. *OPTIONAL* + +9. Go to http://ploticus.sourceforge.net/ and download the package + - to install this directly on the command line type: + NOTE: you may have to edit the Makefile to remove X11 if you don't have it + - cd /usr/local + - wget http://ploticus.sourceforge.net/download/pl232src.tar.gz + - gunzip pl232src.tar.gz + - tar xvf pl232src.tar + - cd pl232src/src/ + - make clean + - make + - make install + - you are done + NOTE: for the graphics to work on the AST_server_performance page you will + need the 'pl' script to be linked or copied into your htdocs/vicidial/ploticus directory + NOTE: you may need to edit the Makefile for ploticus if you do not have X11 + +MySQL is a fast database system that is very easy to integrate with any +application. You can either install it on the local Asterisk system or have one +somewhere on your network. For our purposes, we are creating an Asterisk +installation that is self contained and needs no other local servers to operate, +so we will need to install mysql on this machine. +*OPTIONAL* (only install MySQL locally if you don't want to use an installation +on another machine) +NOTE: a minimum of MySQL 4.0.X is required + +10. Go to http://www.mysql.com/ and download the mysql package + - to install this directly on the command line type: + - cd /usr/local + - wget http://mirror.trouble-free.net/mysql_mirror/Downloads/MySQL-4.0/mysql-4.0.27.tar.gz + - gunzip mysql-4.0.27.tar.gz + - tar xvf mysql-4.0.27.tar + - cd mysql-4.0.27 + - groupadd mysql + - useradd -g mysql mysql + - "./configure --prefix=/usr/local/mysql --enable-large-files --enable-shared=yes --with-readline" + If only MySQL client is needed for DBD::mysql then use this: + - "./configure --prefix=/usr/local/mysql --without-server --enable-shared=yes --with-readline" + - make + - make install + - scripts/mysql_install_db + - chown -R root /usr/local/mysql + - chown -R mysql /usr/local/mysql/var + - chgrp -R mysql /usr/local/mysql + - cp support-files/my-medium.cnf /etc/my.cnf + - /usr/local/mysql/bin/mysqld_safe --user=mysql & + - you are done + + ***** NOTE: if you use MySQL version 4.0.X: ***** + (http://mirror.trouble-free.net/mysql_mirror/Downloads/MySQL-4.0/mysql-4.0.27.tar.gz) + Then you need to make sure that you use the 0.08 version of the Net::MySQL + perl module. This can be found in the astguiclient release zip file in the + libs/Net folder(MySQL.pm). Here are instructions on how to replace the + 0.09 version of MySQL.pm with the 0.08 version which is MySQL 4.0.X compatible: + - cpan + - install O/OY/OYAMA/Net-MySQL-0.08.tar.gz + or you can use the version included with the astguiclient release: + - locate -u + - locate MySQL.pm (replace the path below with the path you find) + - mv /usr/lib/perl5/site_perl/5.8.6/Net/MySQL.pm MySQL.pm-old + - cp /home/cron/astguiclient_1.1.12-3/libs/Net/MySQL.pm /usr/lib/perl5/site_perl/5.8.6/Net/MySQL.pm + If you do not do this, then you will see MySQL authentication errors on your + Asterisk server. + + ***** NOTE: if you use MySQL version 4.1.12 or greater: ***** + (http://mirror.services.wisc.edu/mysql/Downloads/MySQL-4.1/mysql-4.1.18.tar.gz) + If you are using the 0.08 version of the Net::MySQL perl module with 4.1.X + Then you need to make sure that you use the SET PASSWORD ... OLD_PASSWORD to + allow the older client libraries to connect to the MySQL server, or you can + start your mysqld server with the "-old-passwords" option. If you do not do + this, then you will see MySQL authentication errors on your Asterisk server. + + ***** NOTE: if you will be using any of the DBI perl scripts: ***** + Every machine that you will be using the newer BDI perl scripts on will need + to have the perl modules DBI and DBD::mysql installed on them. To do this + you will also need to at least have the MySQL client installed on the server + (see above) then you will need to go to 'cpan' and "install DBI" and + "install DBD::mysql". You may need to "force install DBD::mysql" if the DBD + tests fail on your first try, but that is OK since the tests are not needed + + +openssh is a remote login protocol server that is always a good idea to have +updated on your system, so we're going to install a new version now. +*OPTIONAL* (only updated as a precaution, not manditory) + [NOTE: newer zlib is needed before installing] + +11. Go to http://www.openssh.org/ and download the linux source for openssh + - to install this directly on the command line type: + - cd /usr/local + - wget http://www.zlib.net/zlib-1.2.3.tar.gz + - gunzip zlib-1.2.3.tar.gz + - tar xvf zlib-1.2.3.tar + - cd zlib-1.2.3 + - ./configure + - make + - make install + - cd /usr/local + - wget http://gulus.usherbrooke.ca/pub/appl/ssh/OpenSSH/portable/openssh-4.3p2.tar.gz + - gunzip openssh-4.3p2.tar.gz + - tar xvf openssh-4.3p2.tar + - cd openssh-4.3p2 + - ./configure + - make + - make install + - you are done + + +openssl is the open-source SSL libraries package, and to install a fake SSL cert +locally and have it work with apache, you need it installed on your machine +*OPTIONAL* (only install openssl if you want to use SSL secured web pages on +your locally installed copy of Apache web server) + +12. Go to http://www.openssl.org/ and download the linux source for openssl + - to install this directly on the command line type: + - cd /usr/local + - wget http://www.openssl.org/source/openssl-0.9.8b.tar.gz + - gunzip openssl-0.9.8b.tar.gz + - tar xvf openssl-0.9.8b.tar + - cd openssl-0.9.8b + - ./config + - make + - make install + - you are done + + +apache is a web server that allows you to use many different modules with it to +extend it's functionality. In order to use some of the astguiclient +functionalities we need to have Apache and PHP installed on this machine. +*OPTIONAL* (only install Apache and PHP locally if you don't want to use an +installation on another machine) + +13. Go to http://www.apache.org/ and download the apache unix source + Go to http://www.php.net/ and download the php unix source code + - to install this directly on the command line type: + - cd /usr/local + - wget http://apache.secsup.org/dist/httpd/httpd-2.0.58.tar.gz + - gunzip httpd-2.0.58.tar.gz + - tar xvf httpd-2.0.58.tar + - wget http://us2.php.net/distributions/php-4.4.2.tar.gz + NOTE: PHP 5.1.1 has also been tested with this release + - gunzip php-4.4.2.tar.gz + - tar xvf php-4.4.2.tar + - cd httpd-2.0.58 + - ./configure --enable-so --with-apxs2 + - make + - make install + - cd ../php-4.4.2 + - ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql + - make + - make install + - cp php.ini-dist /usr/local/lib/php.ini + NOTE: you will want to make sure notice logging is turned off: + error_reporting = E_ALL & ~E_NOTICE ; (this is default) + - vi /usr/local/apache2/conf/httpd.conf + add the following lines: + "AddType application/x-httpd-php .php .phtml" + "LoadModule php4_module libexec/libphp4.so" + modify the index.html line and add index.php to the list + - /usr/local/apache2/bin/apachectl start + - go to http://your-new-asterisk-server-ipaddress/ to see if it worked + - you are done + + +balance is a load-balancing application for Linux that will allow you to spread +the load of your web traffic across many servers. If you are running more than +70 agents on a single server you may want to install this application and build +another cheap web server to handle the extra load. +*OPTIONAL* + +14. Go to http://balance.sourceforge.net to download the most recent source version + - to install this directly on the command line type: + - cd /usr/local + - wget http://voxel.dl.sourceforge.net/sourceforge/balance/balance-3.34.tgz + - gunzip balance-3.34.tgz + - tar xvf balance-3.34.tar + - cd balance-3.34 + - make + - make install + - /usr/sbin/balance -f 81 localhost:80 10.10.10.16:80 + That command will take port 81 traffic and send it evenly to the local + server and the 10.10.10.16 server reducing the load and speeding up + the applications. More info on balance: http://www.inlab.de/balance.pdf + + +subversion is the new code control framework use by the Asterisk community. If +you want to use the latest development code of Asterisk you will need to have +this loaded on your system. +*OPTIONAL* + +15. Go to http://subversion.tigris.org to download the most recent source version + - to install this directly on the command line type: + - cd /usr/local + - wget http://subversion.tigris.org/downloads/subversion-1.3.0.tar.gz + - gunzip subversion-1.3.0.tar.gz + - tar xvf subversion-1.3.0.tar + - cd subversion-1.3.0 + - ./configure --enable-ssl --with-neon + - make + - make install + + + +PHASE 4: INSTALLING ASTERISK + +OK, all the prep work is done, now it's time to start having fun with Asterisk. +There are four basic ways to install Asterisk, an official release(at the time of +this writing the official release is 1.2.9.1), the CVS_v1-0 branch(1.0 +with bug fixes not yet packaged and released) and the SVN_DEV version(development +branch). Because there are bugs that affect astGUIclient in releases 1.0.8 and +1.0.9, we recommend using Asterisk 1.2.9.1 or 1.0.11.1. These instructions are how we +get our Asterisk system with it's T1 line installed with our 2 SIP VOIP devices +and one IAX2 softphone. + +NOTE: If you want to use release 1.0.8 or 9 we would recommend either using the +CVS_v1-0_Stable branch where the issues are fixed, or patching your 1.0.8/1.0.9 code +with the following patch: +(http://astguiclient.sourceforge.net/experimental_code/localmasq.patch) +- If you do patch your system make sure you put the asterisk version + field for the server on the admin pages as '1.0.11.1' + +1. follow these command line steps: + - mkdir /usr/src/asterisk + - cd /usr/src/asterisk + A. if you want 1.2 release (reliable with new features): + - wget http://ftp.digium.com/pub/asterisk/releases/asterisk-1.2.9.1.tar.gz + - wget http://ftp.digium.com/pub/zaptel/releases/zaptel-1.2.6.tar.gz + - wget http://ftp.digium.com/pub/libpri/releases/libpri-1.2.3.tar.gz + - gunzip asterisk-1.2.9.1.tar.gz + - tar xvf asterisk-1.2.9.1.tar + - gunzip zaptel-1.2.6.tar.gz + - tar xvf zaptel-1.2.6.tar + - gunzip libpri-1.2.3.tar.gz + - tar xvf libpri-1.2.3.tar + B. If you want latest 1.0 tree stable release: + - wget http://ftp.digium.com/pub/asterisk/old-releases/asterisk-1.0.11.1.tar.gz + - wget http://ftp.digium.com/pub/zaptel/releases/zaptel-1.0.10.tar.gz + - wget http://ftp.digium.com/pub/libpri/releases/libpri-1.0.9.tar.gz + - gunzip asterisk-1.0.11.1.tar.gz + - tar xvf asterisk-1.0.11.1.tar + - gunzip zaptel-1.0.10.tar.gz + - tar xvf zaptel-1.0.10.tar + - gunzip libpri-1.0.9.tar.gz + - tar xvf libpri-1.0.9.tar + C. if you want latest SVN_DEV version (sometimes unstable) [1.3 tree] + - svn checkout http://svn.digium.com/svn/asterisk/trunk asterisk + - svn checkout http://svn.digium.com/svn/zaptel/trunk zaptel + - svn checkout http://svn.digium.com/svn/libpri/trunk libpri + D. if you want latest STABLE 1.2 tree version (stable) + - svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2 + - svn checkout http://svn.digium.com/svn/zaptel/branches/1.2 zaptel-1.2 + - svn checkout http://svn.digium.com/svn/libpri/branches/1.2 libpri-1.2 + - ALL -> + - (1.0 tree)if you want to allow for more than 100 voicemail messages in a + mailbox(warning this will slightly increase memory usage when a call + is in voicemail) edit the voicemail source code file: + - vi /usr/src/asterisk/asterisk/apps/app_voicemail.c + edit this line and change 100 to 999: + #define MAXMSG 100 + - (1.0 tree)if you have no X server installed on your Asterisk machine, then you + will need to comment out the gtk console lib(only affects stable tree + and 1.0 releases) edit the voicemail source code file: + - vi /usr/src/asterisk/asterisk/pbx/Makefile + edit this line at the top and just add a hash # in front of it as shown: + #PBX_LIBS+=$(shell $(CROSS_COMPILE_BIN)gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so") + + - cd ./zaptel-1.2.6 + - make clean + - make + - make install + - cd ../libpri-1.2.3 + - make clean + - make + - make install + - cd ../asterisk-1.2.9.1 + - (1.2 tree) If you want to include Answering Machine Detection ability + you will need to download app_amd.c and amd.conf and alter the + apps/Makefile to compile it properly + - cd apps + - wget http://www.eflo.net/files/app_amd2.c + - mv app_amd2.c app_amd.c + - vi Makefile + replace this line(line 32): + app_mixmonitor.so app_stack.so + with this line: + app_mixmonitor.so app_stack.so app_amd.so + - wget http://www.eflo.net/files/amd2.conf + - mkdir /etc/asterisk + - mv amd2.conf /etc/asterisk/amd.conf + - cd ../ + + -(1.2 tree) apply the cli delimiter patch + - wget http://www.eflo.net/files/cli_chan_concise_delimiter.patch + - patch -p1 < ./cli_chan_concise_delimiter.patch + - File to patch: cli.c + - make clean + - make + - make install + - make samples # this makes sample conf files + - (1.2 tree) EXPERIMENTAL!!! If you want to use app_conference + instead of meetme for VICIDIAL then follow these instructions + - cd /usr/src/asterisk + - wget http://www.eflo.net/files/VD_app_conference_0.6.zip + - unzip VD_app_conference_0.6.zip + - cd app_conference + - make clean + - make + - make install + + - modprobe zaptel # this loads the zaptel module + - install the module for the digium device that you are using, we are +using the T100P single span T1 card so we use: + - modprobe wct1xxp + Here's the list of all digium cards and the modules you use with +them: + Card Module + ----------------- + TDM400P wctdm + X100P wcfxo + TDM* wcfxs + S100U wcusb + T100P wct1xxp + E100P wct1xxp + T400P tor2 + E400P tor2 + TE110P wcte11xp + TE410P wct4xxp + TE405P wct4xxp + TE411P wct4xxp + TE406P wct4xxp + TE210P wct2xxp + TE205P wct2xxp + TDM2400P wctdm24xxp + - If you have chosen a Sangoma T1/E1 or analog card, you will need to + follow their instructions for installation of their driver software + LATEST Sangoma Wanpipe drivers: + ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-beta4-2.3.4.tgz + - now your asterisk installation is built and loaded and it's time to +configure it. + +NOTES: If you want to install zttool diagnostics you may need the newt package installed: +http://www.freedomphones.net/files/newt-0.51.6.tar.gz +ln -s /usr/lib/libnewt.so.0.51.6 /usr/lib/libnewt.so.0.51 +then go to your zaptel folder and do 'make zttool' + +Digium/Clone X100P EXAMPLE: +Here is an example of a configuration where an X100P single FXO card is used for +zaptel timing and not used for calling: + +NOTE: you can get an X100P through ebay for $10-$30 that will work with Asterisk + + /etc/zaptel.conf: + loadzone=us + defaultzone=us + fxsks=1 + + /etc/asterisk/zapata.conf: + [trunkgroups] + [channels] + context=unused + signalling=fxs_ks + channel => 1 + + Added this to the rc.local file: + # Load zaptel drivers for x100p + modprobe zaptel + modprobe wcfxo + + + +PHASE 5: CONFIGURING ASTERISK AND YOUR SIP PHONES + +In this phase we will configure the telco lines, the SIP phones, the extensions, +meetme(conference calling) rooms, dialplan extensions and the voicemail boxes. +After this phase your Asterisk system should be able to place and receive calls +to and from the SIP phones you have installed over the telco lines you've hooked +up. There are several things that we will not be showing how to do because +Asterisk is extremely flexible and has so many different ways of being +configured, that if we were to try to explain them all in this document it would +be 99% asterisk configuration and be 20,000 lines long, and that would +just be a barrier for those who just want to get it set up. The "Wiki" and the +mailing list are two very good resources for finding answers if you run into +problems configuring your system, here are links to them: +The Wiki: http://www.voip-info.org/tiki-index.php +The Lists: http://www.asterisk.org/index.php?menu=support + +I need to note that it is possible to install Asterisk and use astGUIclient +applications with no Zaptel(Digium) cards installed, but it is not recommended +even if you are not going to use Zap trunks for your inbound-outbound calls +with no real Zap devices, you would need to use a dummy timer(zt_dummy) based +on you USB ports to get meetme conference rooms working properly and you may +have other issues along the way. We would at least recommend getting a X100 or +X101 board from Digium or a clone manufacturer so there is a dedicated hardware +timer in place on your system. + + + +SUBPHASE 5.0: setting up your Asterisk configuration files + +1. edit zaptel.conf + - vi /etc/zaptel.conf + There are many examples inside of the zaptel.conf file that is +generated with the "make samples" command that we issued at the end +of the last phase. There are many different parameters for the +different telco line possibilities, because we are installing a T1 +that is NON-PRI-isdn B8ZS ExtendedSuperframe(ESF) E&M Wink start and 24 +channels, we will use the following settings for zaptel.conf: + span=1,1,0,esf,b8zs + e&m=1-24 + loadzone = us + defaultzone=us + FOR A PRI YOU WOULD USE SOMETHING LIKE THIS: + span=2,2,0,esf,b8zs + bchan=25-47 + dchan=48 + +2. edit zapata.conf + - vi /etc/asterisk/zapata.conf + There are also many examples of how to configure zapata.conf online. +we decided to separate our T1 into two line groups to keep some +incoming calls from being busy if we filled up all of our lines. +Here's what we used(you can set echocancel=no if you are using PRIs): + [channels] + group=1 + language=en + signalling=em_w + usecallerid=yes + callerid=asreceived + context=default + echocancel=64 + echocancelwhenbridged=yes + rxgain=1.0 + txgain=1.0 + channel => 1-2 + group=2 + language=en + signalling=em_w + usecallerid=yes + callerid=asreceived + context=default + echocancel=64 + echocancelwhenbridged=yes + rxgain=1.0 + txgain=1.0 + channel => 3-24 + FOR A PRI YOU WOULD USE SOMETHING LIKE THIS: + group=3 + language=en + signalling=pri_net + usecallerid=yes + callerid=asreceived + callprogress=no + busydetect=no + context=default + echocancel=64 + echocancelwhenbridged=yes + rxgain=1.0 + txgain=1.0 + channel => 25-47 + +3. edit sip.conf + - vi /etc/asterisk/sip.conf + here is where we will edit the configuration of our SIP compatible +phone devices. As stated at the beginning, we will be setting up a +Grandstream Budgetone 102 phone and a Sipura SPA-2000 adapter with +two analog phones connected(each with it's own extension). Here are +the settings we used to set each of them up: + [general] + port = 5060 + bindaddr = 0.0.0.0 + context = default + ; register SIP account on remote machine if using SIP trunks + ; register => testSIPtrunk:test@10.10.10.16:5060 + ; + ; setup account for SIP trunking: + ; [SIPtrunk] + ; disallow=all + ; allow=ulaw + ; allow=alaw + ; type=friend + ; username=testSIPtrunk + ; secret=test + ; host=10.10.10.16 + ; dtmfmode=inband + ; qualify=1000 + + [gs102] + disallow=all + allow=ulaw + allow=alaw + type=friend + username=gs102 + secret=test + host=dynamic + dtmfmode=inband + defaultip=10.10.10.16 + qualify=1000 + mailbox=102 + [spa2000] + disallow=all + allow=ulaw + allow=alaw + type=friend + username=spa2000 + secret=test + host=dynamic + dtmfmode=inband + defaultip=10.10.10.17 + qualify=1000 + mailbox=2000 + [spa2001] + disallow=all + allow=ulaw + allow=alaw + type=friend + username=spa2001 + secret=test + host=dynamic + dtmfmode=inband + defaultip=10.10.10.17 + qualify=1000 + mailbox=2001 +4. edit meetme.conf + - vi /etc/asterisk/meetme.conf + This is known as the conference calling configuration file. We are +just going to add two conferences(one without a pin number and one +with a pin number required for entry): + [rooms] + conf => 8600 + conf => 8601,1234 +5. edit iax.conf (only to do IAX trunks, not required) + - vi /etc/asterisk/iax.conf + This is the IAX configuration file, below is a very simple config for + having two Asterisk servers connect natively to each other, if you + will be using this, make sure to add the optional lines included + after the extensions.conf section. Also, there is an account setup + here for a firefly IAX softphone to use.(details on that later) + * IMPORTANT NOTE * if you plan to use IAX2 trunks for VICIDIAL + outbound dialing you must register with the remote IAX2 server + through the iax.conf file, not just in the Dial or TRUNK line + of the extensions.conf dialplan. + [general] + bindport=4569 + iaxcompat=yes + bandwidth=high + allow=all + allow=gsm ; Always allow GSM, it's cool :) + jitterbuffer=no + tos=lowdelay + register => ASTtest1:test@10.10.10.16:4569 + + [ASTtest2] + type=friend + accountcode=IAXtrunk2 + context=default + auth=plaintext + host=dynamic + permit=0.0.0.0/0.0.0.0 + secret=test + disallow=all + allow=ulaw + qualify=yes + + [firefly01] + type=friend + accountcode=firefly01 + context=default + auth=plaintext + host=dynamic + permit=0.0.0.0/0.0.0.0 + secret=test + disallow=all + allow=gsm + qualify=yes + +##### EXAMPLE - This is a config example for setting up Binfone service(http://www.binfone.com) + +NOTE: The "1112223333" is your iax username. When you signup, Binfone creates +a default IAX username for you, (a 5 digit number, usually, starting with a 1). +This works for most customers. Folks that want inbound then also sign up for +DIDs, each of which has its own IAX username. (Which is the 10 digit DID). +Each username has its own password which is managed through their web interface. + + iax.conf: + [general] + register => 1112223333:PASSWORD@iax.binfone.com + + [1112223333] + auth=md5 + type=friend + username=1112223333 + secret=PASSWORD + host=iax.binfone.com + context=incoming-IAX-context-in-extensions.conf + + + extensions.conf: + [global] + TRUNKBINFONE=IAX2/1112223333:PASSWORD@iax.binfone.com ; IAX trunk interface + + [default] + exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN}) + exten => _91NXXNXXXXXX,2,Dial(${TRUNKIAX}/${EXTEN},55,o) + exten => _91NXXNXXXXXX,3,Hangup + + [incoming] + exten => 1112223333,1,AGI(call_log.agi,${EXTEN}) + exten => 1112223333,2,Dial(sip/gs102,55,o) + exten => 1112223333,3,Hangup + +##### END EXAMPLE + + +6. edit voicemail.conf + - vi /etc/asterisk/voicemail.conf + This is where we set up the voicemail boxes for the extensions that +we have set up: + [general] + format=wav49|gsm|wav + serveremail=asterisk + attach=yes + skipms=3000 + maxsilence=10 + silencethreshold=128 + maxlogins=3 + [zonemessages] + eastern=America/New_York|'vm-received' Q 'digits/at' IMp + central=America/Chicago|'vm-received' Q 'digits/at' IMp + central24=America/Chicago|'vm-received' q 'digits/at' H 'digits/hundred' +M 'hours' + [default] + 102 => 102,Grandstream Mailbox,root@localhost + 2000 => 2000,Sipura Mailbox 1 + 2001 => 2001,Sipura Mailbox 2 + 3001 => 3001,Firefly Mailbox 1 +7. edit manager.conf + - vi /etc/asterisk/manager.conf + This is where we set up remote logins to the asterisk manager +interface, to allow sending of Action commands from remote +connections to the Asterisk server, this will be important for the +astguiclient applications so let's set that up now: + [general] + enabled = yes + port = 5038 + bindaddr = 0.0.0.0 + [cron] + secret = 1234 + read = system,call,log,verbose,command,agent,user + write = system,call,log,verbose,command,agent,user + [updatecron] + secret = 1234 + read = command + write = command + [listencron] + secret = 1234 + read = system,call,log,verbose,command,agent,user + write = command + [sendcron] + secret = 1234 + read = command + write = system,call,log,verbose,command,agent,user + +8. edit logger.conf + - vi /etc/asterisk/logger.conf + This file determines the messages that are logged to the console and +the /var/log/asterisk/messages file. We usually turn on full logging +to the messages file to more easily diagnose any problems that we may +run into, the problem with this is that is does produce very large +files, so be warned: + [logfiles] + console => notice,warning,error + messages => notice,warning,error,debug,verbose +9. edit extensions.conf + - vi /etc/asterisk/extensions.conf + This is known as the dialplan. Since we are installing a +Long-Distance T1 with one 800 number on it, we will need to put that +800 number in the plan, as well as how to dial out through the T1 +lines and we will need to add an entry for each of the phones that we +have just set up in the sip.conf file. There are many examples both +in the sample file and online for what to put in your dialplan, here +is the simplified dialplan that we are using: +######------ START extensions.conf example ------###### +[general] +static=yes +writeprotect=no + +[globals] +CONSOLE=Console/dsp ; Console interface for demo +TRUNK=Zap/g1 ; Trunk interface +TRUNKX=Zap/g2 ; 2nd trunk interface +TRUNKIAX=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface + +[default] +; Extension 8600 + 8601 conference rooms +exten => 8600,1,Meetme,8600 +exten => 8601,1,Meetme,8601 + +; Extension 102 - Grandstream hardphone +exten => 102,1,Playback,transfer|skip ; "Please hold while..." +exten => 102,2,Dial,sip/gs102|20|to ; Ring, 20 secs max +exten => 102,3,Voicemail,u102 ; Send to voicemail... +; Extension 2000 Sipura line 1 +exten => 2000,1,Dial,sip/spa2000|30|to ; Ring, 30 secs max +exten => 2000,2,Voicemail,u2000 ; Send to voicemail... +; Extension 2001 Sipura line 2 +exten => 2001,1,Dial,sip/spa2001|30|to ; Ring, 30 secs max +exten => 2001,2,Voicemail,u2001 ; Send to voicemail... +; Extension 2020 rings both sipura lines +exten => 2001,1,Dial,sip/spa2000&sip/spa2001|30|to ; Ring, 30 secs max +exten => 2001,2,Voicemail,u2000 ; Send to voicemail... +; Extension 301 rings the firefly softphone +exten => 301,1,Dial,(IAX2/firefly01@firefly01/s) +exten => 301,2,Hangup + +; Extension 3429 - Inbound 800 number (1-800-555-3429) +exten => _**3429,1,Ringing +exten => _**3429,2,Answer +exten => _**3429,3,Dial,sip/spa2000&sip/spa2001|30|to ; Ring, 30 secs max +exten => _**3429,4,Voicemail,u2000 ; Send to voicemail... +; Extension 3429 - with ANI [callerID] +exten => _*NXXNXXXXXX*3429,1,Ringing +exten => _*NXXNXXXXXX*3429,2,Answer +exten => _*NXXNXXXXXX*3429,3,Dial,sip/spa2000&sip/spa2001|30|to ; Ring, 30 +secs max +exten => _*NXXNXXXXXX*3429,4,Voicemail,u2000 ; Send to voicemail... + +; dial a long distance outbound number to the UK +exten => _901144XXXXXXXXXX,1,Dial(${TRUNKX}/${EXTEN:1},55,tTo) +exten => _901144XXXXXXXXXX,2,Hangup + +; dial a long distance outbound number to Australia +exten => _901161XXXXXXXXX,1,Dial(${TRUNKX}/${EXTEN:1},,tTo) +exten => _901161XXXXXXXXX,2,Hangup + +; dial an 800 outbound number +exten => _91800NXXXXXX,1,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91800NXXXXXX,2,Hangup +exten => _91888NXXXXXX,1,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91888NXXXXXX,2,Hangup +exten => _91877NXXXXXX,1,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91877NXXXXXX,2,Hangup +exten => _91866NXXXXXX,1,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91866NXXXXXX,2,Hangup + +; dial a local 727 outbound number with area code +exten => _9727NXXXXXX,1,Dial(${TRUNK}/1${EXTEN:1},,tTo) +exten => _9727NXXXXXX,2,Hangup + +; dial a local 813 outbound number with area code +exten => _9813NXXXXXX,1,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _9813NXXXXXX,2,Hangup + +; dial a long distance outbound number +exten => _91NXXNXXXXXX,1,Dial(${TRUNKX}/${EXTEN:1},,tTo) +exten => _91NXXNXXXXXX,2,Hangup + +; dial a local outbound number (modified because of only LD T1) +exten => _9NXXXXXX,1,Dial(${TRUNK}/1727${EXTEN:1},,tTo) +exten => _9NXXXXXX,2,Hangup + +; barge monitoring extension +exten => 8159,1,ZapBarge +exten => 8159,2,Hangup + +; # timeout invalid rules +exten => #,1,Playback(invalid) ; "Thanks for trying the demo" +exten => #,2,Hangup ; Hang them up. +exten => t,1,Goto(#,1) ; If they take too long, give up +exten => i,1,Playback(invalid) ; "That's not valid, try again" + +; Give voicemail at extension 8500 +exten => 8500,1,VoicemailMain +exten => 8500,2,Goto(s,6) + +; ASTERISK AGENTS LOGINS FOR QUEUES (NOT part of VICIDIAL) +; the following assumes phone agent login and exten are 3 digits and the same +; also assumes that 3-digit login is present in agents.conf and queueus.conf +;Agent Logout then stay onhook, DIAL 54 + 3-digit ID +exten => _54XXX,1,AgentCallbackLogin(||) +; the following are used to login and logout of Asterisk Queues from phone +;Agent Login then stay offhook on the phone, DIAL 55 + 3-digit ID +exten => _55XXX,1,AgentLogin(${EXTEN:1}) +;Agent Login then stay onhook, phones will ring, DIAL 56 + 3-digit ID +exten => _56XXX,1,AgentCallbackLogin(||${EXTEN:1}@default) + +######------ END extensions.conf example ------###### + +### OPTIONAL IAX trunk extensions entries for long distance dialing over IAX + exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN}) + exten => _91NXXNXXXXXX,2,Dial(${TRUNKIAX}/${EXTEN},55,o) + exten => _91NXXNXXXXXX,3,Hangup + +### OPTIONAL SIP trunk extensions entries for long distance dialing over SIP + exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN}) + exten => _91NXXNXXXXXX,2,Dial(sip/${EXTEN}@SIPtrunk,55,o) + exten => _91NXXNXXXXXX,3,Hangup + +### OPTIONAL IAX Load Balance extens to allow for Overflow and Balanced VDAD +### In this setup, the serverIP is the prefix followed by agent conf_exten +### server 1 extens: + exten => _010*010*010*016*8600XXX,1,Dial(${TRUNKIAX2}/${EXTEN:16},55,o) + exten => _010*010*010*016*8600XXX,2,Hangup +### server 2 extens: + exten => _010*010*010*015*8600XXX,1,Dial(${TRUNKIAX1}/${EXTEN:16},55,o) + exten => _010*010*010*015*8600XXX,2,Hangup + + +10. Now that you have configured Asterisk, it is time to try to start it for the +first time. + - First make sure that your T1 line(or other telco line) is connected to the +digium card. + - next type the following at the command prompt: "ztcfg -vvvvvv" + - you should see a confirmation that the Zaptel device has loaded + - now you can launch asteris with the following command: + "asterisk -vvvvvvvvvvvvgc" + - you should see a lot of messages scroll by and at the end you should +be given a CLI> prompt if everything loaded OK. + + + +SUBPHASE 5.1: setting up your SIP phones + +You will need to follow the instructions for the phones that you are using with +your system, but here's the way to set up a Grandstream 102 and a Sipura +SPA-2000 + +1. Here are basic instructions for setting up a Grandstream BT 102: + - On the phone plug it in to power only at first and follow these +instructions: + - wait for the phone to boot up and press the MENU button + - go through the menu screens with the menu key and the up/down arrow +keys to move from setting to setting. We are setting the following +values: + - DHCP OFF + - IP Addr: 010.010.010.016 + - Subnet: 255.255.000.000 + - router: 010.010.010.001 + - dnS: 010.010.010.001 + - tftp: we leave this blank for now + - menu 7 we change the codec to G-711u + - now wait 10 seconds and unplug the power and plug it back in + - you can also plug the network cable into the LAN port on the phone + - at this time you can go to your workstation and open a new web browser + - go to http://10.10.10.16/ the password is "admin" + - here is where you will enter in the configuration details for the +phone to register with the Asterisk server + - SIP server: 10.10.10.15 + - SIP user ID: gs102 + - Authenticate ID: gs102 + - Password: test + - Name: gs102 + - Voice Mail UserID: 102 + - Send DTMF: in-audio + - NTP Server: tick.mit.edu + - then click update, click review changes, and click reboot + - your phone should now be able to register with the Asterisk server. If you +still have your console screen up you should see a registration message +appear telling you that gs102 has registered. + +2. Here are the basic instructions for setting up a Sipura SPA-2000 analog +adapter with 2 lines. + - Plug power and two analog phones into the adapter. + - pick up the phone plugged into line1 and press **** to enter admin menu + - press 101# then 0# to disable DHCP + - press 111# then 10*10*10*17# to change the IP address + - press 121# then 255*255*0*0# to change the subnet mask + - press 131# then 10*10*10*1# to change the default gateway + - hang up the phone, unplug the power, plug in the network cable and plug in +the power cable + - now you can go the the admin website: http://10.10.10.17/admin/advanced + - you will need to make these setting changes: + - click on the "Line 1" tab at the top and change the following values: + - Proxy: 10.10.10.15 + - Display Name: spa2000 + - userID: spa2000 + - password: test + - authID: spa2000 + - change the dialplan to the following: +(*xx|xxx|xxxx|xxxxx|xxxxxx|xxxxxxx|xxxxxxxx|xxxxxxxxxxx|xxxxxxxxxxxx|xxxxxxxxxxxxxxx|xxxxxxxxxxxxxxxx.) + - then click the "submit all changes" button at the bottom of the page +and your first phone line should work now + - to register the second line, simply click on the "Line 2" tab and go +through the above steps except use spa2001 instead of spa2000 for the use IDs + +3. Now both of your phone devices are set up and you can try making phone calls +between the three phones + + + +SUBPHASE 5.2: setting up an IAX2 phone + +This is optinal and we won't go into too much detail about this, but currently +there are several IAX hard and softphones on the market and more are coming +every month. Follow the instructions with the IAX phone you have chosen and +follow the steps below: + +1. Add an entry into your iax.conf file like below if you have not already + [firefly01] + type=friend + accountcode=firefly01 + context=default + auth=plaintext + host=dynamic + permit=0.0.0.0/0.0.0.0 + secret=test + qualify=yes + +2. Add an entry into your extensions.conf file like below if it is not in there + ; Extension 3001 rings IAX phone + exten => 301,1,Dial(IAX2/firefly01@firefly01/s) + exten => 301,2,Voicemail,u301 ; Send to voicemail... + +3. Download Firefly 3rd party application for windows: + - http://www.virbiage.com/firefly/download/firefly-thirdparty.exe + MIRRORS: + - http://mirror.isp.net.au/ftp/pub/firefly/firefly-thirdparty.exe + - http://www.freedomphones.net/files/firefly-thirdparty.exe + - Install the application + - Launch Firefly Softphone + - click the "I wish to connect to a 3rd party network" button + - Enter in network name: Asterisk + - Select IAX2 as the protocol + - enter in your server address: "10.10.10.15" in our case + - enter login and pass: "firefly01" and "test" for in our case + - click OK and you should be logged in and can place calls + + +SUBPHASE 5.3: setting up a Zap phone + +This is optinal and we won't go into too much detail about this either, there +are a few ways to use Zap devices as phones on your Asterisk system: Zaptel +phone cards, Channel Banks going through Zaptel T1 card, outside line call +coming in going through Zaptel line card. There isn't much to do but set your +Zaptel config files up and put entries into your extensions.conf file: + +1. Add an entry into your extensions.conf file like below + ; Extension 4001 rings IAX phone + exten => 4001,1,Dial,Zap/1|30| ; ring Zap device 1 + exten => 4001,2,Voicemail,u4001 ; Send to voicemail... + + + + +PHASE 6: INSTALLING ASTGUICLIENT AND VICIDIAL + +Now that Asterisk is installed and running we can add the astGUIclient and +VICIDIAL components to the system. (NOTE: make sure you have added the user "cron") + + + +SUBPHASE 6.0: putting the files in place + +1. Go to http://astguiclient.sf.net/ and download the latest astguiclient +package(as of this writing it is 1.1.12) + - to install this directly on the command line type: + - cd /home/cron + - mkdir astguiclient + - cd astguiclient + - wget http://internap.dl.sourceforge.net/sourceforge/astguiclient/astguiclient_1.1.12-3.zip + - unzip astguiclient_1.1.12-3.zip + - chmod 0755 install_server_files.pl + - perl install_server_files.pl + - cd ../ + - vi AST_SERVER_conf.pl + - edit the values of this file(here's what we used): + $server_ip = '10.10.10.15'; + $DB_server = 'localhost'; + $DB_database = 'asterisk'; + $DB_user = 'cron'; + $DB_pass = '1234'; + - there is one more file you need that's not included with the download +package, it's the conf.gsm file(this is the half-hour music file that we use +to put people on hold). I have a free classical music file that is available +free for download at the following two sites: + http://www.freedomphones.net/conf.gsm + http://astguiclient.sf.net/conf.gsm + Once you have downloaded it, you will need to copy it to this folder: + /var/lib/asterisk/sounds/ + Then you will need to execute this command to copy it as the park file + 'cp /var/lib/asterisk/sounds/conf.gsm /var/lib/asterisk/sounds/park.gsm' + - you are done + + + +SUBPHASE 6.1: creating the MySQL "asterisk" database + +we will create the database and add a few initial records so that we can +use the administrative web interface. Since this is a new install it is easier +to use our new mysql script file to add the tables to the database: + +1. at the command prompt type go to the mysql client: +/usr/local/mysql/bin/mysql +2. type the following into the mysql client prompt: + (make sure you put your IP address in place of "10.10.10.15" in the queries below) +######------ BEGIN Mysql data entry(you can copy and paste this into terminal) # +create database asterisk; + +GRANT SELECT,INSERT,UPDATE,DELETE on asterisk.* TO cron@'%' IDENTIFIED BY '1234'; +GRANT SELECT,INSERT,UPDATE,DELETE on asterisk.* TO cron@localhost IDENTIFIED BY '1234'; + +# NOTE: if using MySQL 4.1.12 or higher you may need to run this query too: +UPDATE mysql.user set password=OLD_PASSWORD('1234') where user='cron'; + +use asterisk; + +\. /home/cron/astguiclient/MySQL_AST_CREATE_tables.sql + +GRANT SELECT on asterisk.phones TO idcheck@'%' IDENTIFIED BY '1234'; +GRANT SELECT on asterisk.phones TO idcheck@localhost IDENTIFIED BY '1234'; + +insert into servers (server_id,server_description,server_ip,active,asterisk_version)values('TESTasterisk','Test install of Asterisk server', '10.10.10.15','Y','1.2.6'); + +insert into server_updater values('10.10.10.15',''); + +insert into phones (extension, dialplan_number, voicemail_id, phone_ip, computer_ip, server_ip, login, pass, status, active, phone_type, fullname, company, picture, messages, old_messages, protocol) values('gs102','102','102','10.10.10.16','10.10.9.16','10.10.10.15','gs102','test', 'ADMIN','Y','Grandstream BT 102','Test Admin Phone','TEST','','0','0','SIP'); + +quit + + run this command from command line: + - /home/cron/ADMIN_area_code_populate.pl + +######------ END Mysql data entry ------###### + +NOTE: if you are not installing using default user/pass or have MySQL on another +server, you will need to edit the dbconnect.php files in the astguiclient, vicidial +and agc directories of your webroot. + +3. Enter the astguiclient administration page: +http://10.10.10.15/astguiclient/admin.php +NOTE: if you click on the Logout button you must leave the user/pass empty and click OK + - Here you will enter the login and password that you inserted into the mysql +database in the phones table and gave a status of ADMIN (subphase 6.1 [gs102/test]) + - Now that you are logged into the astGUIclient administration system we can +add a new phone entry for each of the sipura lines we created. + - click on the "ADD A NEW PHONE" link at the top and enter in the proper +information for each of the new phone lines. Here's what we entered for +spa2000: + - Phone extension: spa2000 + - Dialplan Number: 2000 + - Voicemail Box: 2000 + - Phone IP address: 10.10.10.17 + - Computer IP address: 10.10.9.17 + - Server IP: 10.10.10.15 + - Login: spa2000 + - Password: test + - Status: ACTIVE + - Active Account: Y + - Phone Type: Sipura SPA-2000 line 1 + - Full Name: Sipura line 1 test + - Company: TEST + - Picture: + - for the next phone simply replace 2000 with 2001 in the above example + - now your phones are all all set up in the astguiclient system and you can +use this website to add new phones to be used with astguiclient and monitor +the number of calls people are making. + - click on the "ADD A NEW CONFERENCE" link at the top and enter in the +proper information for each of the new conference lines we will be +adding in a future step. Here's what we entered for out server: + - Phone extension: + - Conference Number: 8600011 + - Server IP: 10.10.10.15 + - for the rest of the conference entries simply increment the conference +number up to 8600029 in the above example + - now your database is set up for the astguiclient conferences which will +allow you to have up to 6 remote parties that you called from your GUI client +application in one conference. + - click on the "LIST ALL SERVERS" link at the top then click on the + server to modify. Verify that the GMT time zone and all other fields + are what you want them to be. There is a setting(Max VICIDIAL Trunks) + that can be modified to limit the number of VICIDIAL outbound trunks + that will be allowed to use on this server. + +4. **OPTIONAL** For IAX clients you will need to use full phone name as the +extension on the admin page entry: "firefly01@firefly01" for our IAX phone example +previously. And do not forget to set the protocol on this page to IAX2 + +5. **OPTIONAL** For Zap clients you will need to use full Zap Channel name as the +extension on the admin page entry: "1-1" for our Zap phone example +previously. And do not forget to set the protocol on this page to Zap + + + + +SUBPHASE 6.2: making additions to your Asterisk conf files + +Now that the database is set up and our phones have entries in the system we can +make the additions to the running Asterisk system that will allow astguiclient +to work with it. + +1. Add the call_log entries to all incoming/outgoing extensions entries: + - here is how our sample dialplan changes for adding call_log entries(only +effected extension groups are show): +######------ START extensions.conf changes for call_log ------###### + +##### This 'h' exten is VERY important for VICIDIAL usage, +##### you will have problems if it is not in your dialplan! +;exten => h,1,AGI(call_log.agi,${EXTEN}) ; use regular AGI for older versions +exten => h,1,DeadAGI(call_log.agi,${EXTEN}) ; DeadAGI is new +exten => h,2,DeadAGI(VD_hangup.agi,PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}) + +; Extension 3429 - Inbound 800 number (1-800-555-3429) +exten => _**3429,1,Ringing +exten => _**3429,2,AGI(call_log.agi,${EXTEN}) +exten => _**3429,3,Answer +exten => _**3429,4,Dial,sip/spa2000&sip/spa2001|30|to +exten => _**3429,5,Voicemail,u2000 +; Extension 3429 - with ANI [callerID] +exten => _*NXXNXXXXXX*3429,1,Ringing +exten => _*NXXNXXXXXX*3429,2,AGI(call_log.agi,${EXTEN}) +exten => _*NXXNXXXXXX*3429,3,Answer +exten => _*NXXNXXXXXX*3429,4,Dial,sip/spa2000&sip/spa2001|30|to +exten => _*NXXNXXXXXX*3429,5,Voicemail,u2000 + +; Extension 7275551212 - Inbound local number from PRI with 10 digit delivery +exten => 7275551212,1,Ringing +exten => 7275551212,2,Wait(1) +exten => 7275551212,3,AGI(call_logCID.agi,${EXTEN}-----${CALLERID}-----${CALLERIDNUM}-----${CALLERIDNAME}) +exten => 7275551212,4,Answer +exten => 7275551212,5,Dial,sip/spa2000&sip/spa2001|30|to +exten => 7275551212,6,Voicemail,u2000 + +; dial a long distance outbound number to the UK +exten => _901144XXXXXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _901144XXXXXXXXXX,2,Dial(${TRUNKX}/${EXTEN:1},55,tTo) +exten => _901144XXXXXXXXXX,3,Hangup + +; dial a long distance outbound number to Australia +exten => _901161XXXXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _901161XXXXXXXXX,2,Dial(${TRUNKX}/${EXTEN:1},,tTo) +exten => _901161XXXXXXXXX,3,Hangup + +; dial an 800 outbound number +exten => _91800NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _91800NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91800NXXXXXX,3,Hangup +exten => _91888NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _91888NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91888NXXXXXX,3,Hangup +exten => _91877NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _91877NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91877NXXXXXX,3,Hangup +exten => _91866NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _91866NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _91866NXXXXXX,3,Hangup + +; dial a local 727 outbound number with area code +exten => _9727NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _9727NXXXXXX,2,Dial(${TRUNK}/1${EXTEN:1},,tTo) +exten => _9727NXXXXXX,3,Hangup + +; dial a local 813 outbound number with area code +exten => _9813NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _9813NXXXXXX,2,Dial(${TRUNK}/${EXTEN:1},,tTo) +exten => _9813NXXXXXX,3,Hangup + +; dial a long distance outbound number +exten => _91NXXNXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _91NXXNXXXXXX,2,Dial(${TRUNKX}/${EXTEN:1},,tTo) +exten => _91NXXNXXXXXX,3,Hangup + +; dial a local outbound number (modified because of only LD T1) +exten => _9NXXXXXX,1,AGI(call_log.agi,${EXTEN}) +exten => _9NXXXXXX,2,Dial(${TRUNK}/1727${EXTEN:1},,tTo) +exten => _9NXXXXXX,3,Hangup + +######------ END extensions.conf changes ------###### + + +2. Add the call_inbound entries to all incoming extensions entries that you want +CallerID popups on: + - here is how our sample dialplan changes for adding call_inbound +entries(only effected extension groups are show): +######------ START extensions.conf changes for call_inbound ------###### +; parameters for call_inbound.agi (7 fields separated by five dashes "-----"): +; 1. the extension of the phone to ring as defined in the asterisk.phones table +; 2. the phone number that was called, for the live_inbound/_log entry +; 3. a text description of the number that was called in +; 4-7. optional fields, they are also passed as fields in the GUI to web browser + +; Extension 3429 - Inbound 800 number (1-800-555-3429) +exten => _**3429,1,Ringing +exten => _**3429,2,AGI(call_log.agi,${EXTEN}) +exten => _**3429,3,AGI(call_inbound.agi,spa2000-----8005553429-----Inbound 800-----x-----y-----z-----w) +exten => _**3429,4,Answer +exten => _**3429,5,Dial,sip/spa2000&sip/spa2001|30|to +exten => _**3429,6,Voicemail,u2000 +; Extension 3429 - with ANI [callerID] +exten => _*NXXNXXXXXX*3429,1,Ringing +exten => _*NXXNXXXXXX*3429,2,AGI(call_log.agi,${EXTEN}) +exten => _*NXXNXXXXXX*3429,3,AGI(call_inbound.agi,spa2000-----8005553429-----Inbound 800-----x-----y-----z-----w) +exten => _*NXXNXXXXXX*3429,3,Answer +exten => _*NXXNXXXXXX*3429,4,Dial,sip/spa2000&sip/spa2001|30|to +exten => _*NXXNXXXXXX*3429,5,Voicemail,u2000 + + +; parameters for agi-VDADcloser.agi (2 fields separated by five dashes "-----"): +; 1. the full extension formatted by VICIDIAL for internal transfers * separated +; 2. the word START to denote the beginning of the acceptance of the transfer +; inbound VICIDIAL transfer calls [can arrive through PRI T1 crossover or IAX channel] +exten => _90009.,1,Answer ; Answer the line +exten => _90009.,2,AGI(agi-VDADcloser.agi,${EXTEN}-----START) +exten => _90009.,3,Hangup + +; parameters for agi-VDADcloser_inbound....agi (7 fields separated by five dashes "-----"): +; 1. the full name of the IN GROUP to be used in vicidial for the inbound call +; 2. the phone number that was called, for the log entry +; 3. the callerID or lead_id of the person that called(usually overridden) +; 4. the park extension audio file name if used +; 5. the status of the call initially(usually not used) +; 6. the list_id to insert the new lead under if it is new (and callerID available) +; 7. the phone dialing code to insert with the new lead if new (and callerID available) + +; inbound VICIDIAL call with CID delivery through T1 PRI +exten => 1234,1,Ringing ; call ringing +exten => 1234,2,Wait(1) ; Wait 1 second for CID delivery from PRI +exten => 1234,3,Answer ; Answer the line +exten => 1234,4,AGI(agi-VDADcloser_inboundCID.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +exten => 1234,5,Hangup + +; inbound VICIDIAL call with ANI delivery through robbed-bit T1 (*NXXNXXXXXX*DNIS) +exten => 1234,1,Answer ; Answer the line +exten => 1234,2,AGI(agi-VDADcloser_inboundANI.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +exten => 1234,3,Hangup + +; inbound VICIDIAL call with prompt for 4-digit fronter code +exten => 1234,1,Answer ; Answer the line +exten => 1234,2,AGI(agi-VDADcloser_inbound.agi,CL_GALLERIA-----7275555134-----Closer-----park----------999-----1) +exten => 1234,3,Hangup + +### follow these instructions if you plan to have VICIDIAL agents take inbound or closer calls: + 1. create a new campaign in VICIDIAL called "CLOSER" + 2. in VICIDIAL web admin "add a new in-group" (the above examples would be "CL_GALLERIA") + - group IDs cannot contain spaces ' ' or dashes '-' or plusses '+' + - if you are using a HEX color value make sure to include the hash '#' at the beginning + 3. have agents log in to the CLOSER campaign and select the CL_GALLERIA button + 4. they will now start receiving inbound calls + 5. as calls come in, each call is inserted into the vicidial_list table under the + list specified int the AGI string, In the above example that would be list 999 + 6. if you want to take closer calls from the campaign "TEST" you will need to create + an in-group called "CL_TEST_" for internal closing(on the same system) or "CL_TEST_L" + for local closing(closer on different system from fronter) and then the fronter will + click on the "internal closer" button to send the call to a closer + +* NOTE, you need to set the dial_level of the CLOSER campaign to 1 or higher for inbound/closers to work + +######------ END extensions.conf changes for call_inbound ------###### + + +3. Add the ZapBarge entries for all zap lines: + - here is how our sample dialplan changes for adding zapbarge line-specific +entries(this is a pure addition, nothing is being modified): +######------ START extensions.conf additions for direct zapbarges ------###### +; ZapBarge direct channel extensions +exten => 8612001,1,ZapBarge(1) +exten => 8612002,1,ZapBarge(2) +exten => 8612003,1,ZapBarge(3) +exten => 8612004,1,ZapBarge(4) +exten => 8612005,1,ZapBarge(5) +exten => 8612006,1,ZapBarge(6) +exten => 8612007,1,ZapBarge(7) +exten => 8612008,1,ZapBarge(8) +exten => 8612009,1,ZapBarge(9) +exten => 8612010,1,ZapBarge(10) +exten => 8612011,1,ZapBarge(11) +exten => 8612012,1,ZapBarge(12) +exten => 8612013,1,ZapBarge(13) +exten => 8612014,1,ZapBarge(14) +exten => 8612015,1,ZapBarge(15) +exten => 8612016,1,ZapBarge(16) +exten => 8612017,1,ZapBarge(17) +exten => 8612018,1,ZapBarge(18) +exten => 8612019,1,ZapBarge(19) +exten => 8612020,1,ZapBarge(20) +exten => 8612021,1,ZapBarge(21) +exten => 8612022,1,ZapBarge(22) +exten => 8612023,1,ZapBarge(23) +exten => 8612024,1,ZapBarge(24) +######------ END extensions.conf additions for direct zapbarges ------###### + + +4. Add the meetme entries for astguiclient and VICIDIAL conferences to +meetme.conf: + - here is how our sample meetme.conf file changes for adding conference +entries (this is a pure addition, nothing is being modified): +######------ START meetme.conf additions for conferences ------###### +conf => 8600011 +conf => 8600012 +conf => 8600013 +conf => 8600014 +conf => 8600015 +conf => 8600016 +conf => 8600017 +conf => 8600018 +conf => 8600019 +conf => 8600020 +conf => 8600021 +conf => 8600022 +conf => 8600023 +conf => 8600024 +conf => 8600025 +conf => 8600026 +conf => 8600027 +conf => 8600028 +conf => 8600029 +conf => 8600051 +conf => 8600052 +conf => 8600053 +conf => 8600054 +conf => 8600055 +conf => 8600056 +conf => 8600057 +conf => 8600058 +conf => 8600059 +conf => 8600060 +conf => 8600061 +conf => 8600062 +conf => 8600063 +conf => 8600064 +conf => 8600065 +conf => 8600066 +conf => 8600067 +conf => 8600068 +conf => 8600069 +conf => 8600070 +conf => 8600071 +conf => 8600072 +conf => 8600073 +conf => 8600074 +conf => 8600075 +conf => 8600076 +conf => 8600077 +conf => 8600078 +conf => 8600079 +conf => 8600080 +conf => 8600081 +conf => 8600082 +conf => 8600083 +conf => 8600084 +conf => 8600085 +conf => 8600086 +conf => 8600087 +conf => 8600088 +conf => 8600089 +conf => 8600090 +conf => 8600091 +conf => 8600092 +conf => 8600093 +conf => 8600094 +conf => 8600095 +conf => 8600096 +conf => 8600097 +conf => 8600098 +conf => 8600099 +conf => 8600100 +######------ END meetme.conf additions for conferences ------###### + + +5. Add the conference entries for astguiclient conferences: + - here is how our sample dialplan changes for adding conference entries (this +is a pure addition, nothing is being modified): +######------ START extensions.conf additions for agc conferences ------###### +exten => 8600011,1,Meetme,8600011|q +exten => 8600012,1,Meetme,8600012|q +exten => 8600013,1,Meetme,8600013|q +exten => 8600014,1,Meetme,8600014|q +exten => 8600015,1,Meetme,8600015|q +exten => 8600016,1,Meetme,8600016|q +exten => 8600017,1,Meetme,8600017|q +exten => 8600018,1,Meetme,8600018|q +exten => 8600019,1,Meetme,8600019|q +exten => 8600020,1,Meetme,8600020|q +exten => 8600021,1,Meetme,8600021|q +exten => 8600022,1,Meetme,8600022|q +exten => 8600023,1,Meetme,8600023|q +exten => 8600024,1,Meetme,8600024|q +exten => 8600025,1,Meetme,8600025|q +exten => 8600026,1,Meetme,8600026|q +exten => 8600027,1,Meetme,8600027|q +exten => 8600028,1,Meetme,8600028|q +exten => 8600029,1,Meetme,8600029|q +######------ END extensions.conf additions for agc conferences ------###### + + +6. Add the conference entries for VICIDIAL conferences: + - here is how our sample dialplan changes for adding VICIDIAL conference +entries(this is a pure addition, nothing is being modified): +NOTE: see below these entries for app_conference instructions is used +######------ START extensions.conf changes for VD conf ------###### +exten => 8600051,1,Meetme,8600051 +exten => 8600052,1,Meetme,8600052 +exten => 8600053,1,Meetme,8600053 +exten => 8600054,1,Meetme,8600054 +exten => 8600055,1,Meetme,8600055 +exten => 8600056,1,Meetme,8600056 +exten => 8600057,1,Meetme,8600057 +exten => 8600058,1,Meetme,8600058 +exten => 8600059,1,Meetme,8600059 +exten => 8600060,1,Meetme,8600060 +exten => 8600061,1,Meetme,8600061 +exten => 8600062,1,Meetme,8600062 +exten => 8600063,1,Meetme,8600063 +exten => 8600064,1,Meetme,8600064 +exten => 8600065,1,Meetme,8600065 +exten => 8600066,1,Meetme,8600066 +exten => 8600067,1,Meetme,8600067 +exten => 8600068,1,Meetme,8600068 +exten => 8600069,1,Meetme,8600069 +exten => 8600070,1,Meetme,8600070 +exten => 8600071,1,Meetme,8600071 +exten => 8600072,1,Meetme,8600072 +exten => 8600073,1,Meetme,8600073 +exten => 8600074,1,Meetme,8600074 +exten => 8600075,1,Meetme,8600075 +exten => 8600076,1,Meetme,8600076 +exten => 8600077,1,Meetme,8600077 +exten => 8600078,1,Meetme,8600078 +exten => 8600079,1,Meetme,8600079 +exten => 8600080,1,Meetme,8600080 +exten => 8600081,1,Meetme,8600081 +exten => 8600082,1,Meetme,8600082 +exten => 8600083,1,Meetme,8600083 +exten => 8600084,1,Meetme,8600084 +exten => 8600085,1,Meetme,8600085 +exten => 8600086,1,Meetme,8600086 +exten => 8600087,1,Meetme,8600087 +exten => 8600088,1,Meetme,8600088 +exten => 8600089,1,Meetme,8600089 +exten => 8600090,1,Meetme,8600090 +exten => 8600091,1,Meetme,8600091 +exten => 8600092,1,Meetme,8600092 +exten => 8600093,1,Meetme,8600093 +exten => 8600094,1,Meetme,8600094 +exten => 8600095,1,Meetme,8600095 +exten => 8600096,1,Meetme,8600096 +exten => 8600097,1,Meetme,8600097 +exten => 8600098,1,Meetme,8600098 +exten => 8600099,1,Meetme,8600099 +exten => 8600100,1,Meetme,8600100 +; quiet entry and leaving conferences for VICIDIAL +exten => 78600051,1,Meetme,8600051|q +exten => 78600052,1,Meetme,8600052|q +exten => 78600053,1,Meetme,8600053|q +exten => 78600054,1,Meetme,8600054|q +exten => 78600055,1,Meetme,8600055|q +exten => 78600056,1,Meetme,8600056|q +exten => 78600057,1,Meetme,8600057|q +exten => 78600058,1,Meetme,8600058|q +exten => 78600059,1,Meetme,8600059|q +exten => 78600060,1,Meetme,8600060|q +exten => 78600061,1,Meetme,8600061|q +exten => 78600062,1,Meetme,8600062|q +exten => 78600063,1,Meetme,8600063|q +exten => 78600064,1,Meetme,8600064|q +exten => 78600065,1,Meetme,8600065|q +exten => 78600066,1,Meetme,8600066|q +exten => 78600067,1,Meetme,8600067|q +exten => 78600068,1,Meetme,8600068|q +exten => 78600069,1,Meetme,8600069|q +exten => 78600070,1,Meetme,8600070|q +exten => 78600071,1,Meetme,8600071|q +exten => 78600072,1,Meetme,8600072|q +exten => 78600073,1,Meetme,8600073|q +exten => 78600074,1,Meetme,8600074|q +exten => 78600075,1,Meetme,8600075|q +exten => 78600076,1,Meetme,8600076|q +exten => 78600077,1,Meetme,8600077|q +exten => 78600078,1,Meetme,8600078|q +exten => 78600079,1,Meetme,8600079|q +exten => 78600080,1,Meetme,8600080|q +exten => 78600081,1,Meetme,8600081|q +exten => 78600082,1,Meetme,8600082|q +exten => 78600083,1,Meetme,8600083|q +exten => 78600084,1,Meetme,8600084|q +exten => 78600085,1,Meetme,8600085|q +exten => 78600086,1,Meetme,8600086|q +exten => 78600087,1,Meetme,8600087|q +exten => 78600088,1,Meetme,8600088|q +exten => 78600089,1,Meetme,8600089|q +exten => 78600090,1,Meetme,8600090|q +exten => 78600091,1,Meetme,8600091|q +exten => 78600092,1,Meetme,8600092|q +exten => 78600093,1,Meetme,8600093|q +exten => 78600094,1,Meetme,8600094|q +exten => 78600095,1,Meetme,8600095|q +exten => 78600096,1,Meetme,8600096|q +exten => 78600097,1,Meetme,8600097|q +exten => 78600098,1,Meetme,8600098|q +exten => 78600099,1,Meetme,8600099|q +exten => 78600100,1,Meetme,8600100|q +; quiet monitor extensions for meetme rooms (for room managers) +exten => 68600051,1,Meetme,8600051|mq +exten => 68600052,1,Meetme,8600052|mq +exten => 68600053,1,Meetme,8600053|mq +exten => 68600054,1,Meetme,8600054|mq +exten => 68600055,1,Meetme,8600055|mq +exten => 68600056,1,Meetme,8600056|mq +exten => 68600057,1,Meetme,8600057|mq +exten => 68600058,1,Meetme,8600058|mq +exten => 68600059,1,Meetme,8600059|mq +exten => 68600060,1,Meetme,8600060|mq +exten => 68600061,1,Meetme,8600061|mq +exten => 68600062,1,Meetme,8600062|mq +exten => 68600063,1,Meetme,8600063|mq +exten => 68600064,1,Meetme,8600064|mq +exten => 68600065,1,Meetme,8600065|mq +exten => 68600066,1,Meetme,8600066|mq +exten => 68600067,1,Meetme,8600067|mq +exten => 68600068,1,Meetme,8600068|mq +exten => 68600069,1,Meetme,8600069|mq +exten => 68600070,1,Meetme,8600070|mq +exten => 68600071,1,Meetme,8600071|mq +exten => 68600072,1,Meetme,8600072|mq +exten => 68600073,1,Meetme,8600073|mq +exten => 68600074,1,Meetme,8600074|mq +exten => 68600075,1,Meetme,8600075|mq +exten => 68600076,1,Meetme,8600076|mq +exten => 68600077,1,Meetme,8600077|mq +exten => 68600078,1,Meetme,8600078|mq +exten => 68600079,1,Meetme,8600079|mq +exten => 68600080,1,Meetme,8600080|mq +exten => 68600081,1,Meetme,8600081|mq +exten => 68600082,1,Meetme,8600082|mq +exten => 68600083,1,Meetme,8600083|mq +exten => 68600084,1,Meetme,8600084|mq +exten => 68600085,1,Meetme,8600085|mq +exten => 68600086,1,Meetme,8600086|mq +exten => 68600087,1,Meetme,8600087|mq +exten => 68600088,1,Meetme,8600088|mq +exten => 68600089,1,Meetme,8600089|mq +exten => 68600090,1,Meetme,8600090|mq +exten => 68600091,1,Meetme,8600091|mq +exten => 68600092,1,Meetme,8600092|mq +exten => 68600093,1,Meetme,8600093|mq +exten => 68600094,1,Meetme,8600094|mq +exten => 68600095,1,Meetme,8600095|mq +exten => 68600096,1,Meetme,8600096|mq +exten => 68600097,1,Meetme,8600097|mq +exten => 68600098,1,Meetme,8600098|mq +exten => 68600099,1,Meetme,8600099|mq +exten => 68600100,1,Meetme,8600100|mq +######------ END extensions.conf changes for VD conf ------###### + +NOTE: If you want to use app_conference instead of meetme and you already have +it installed, you will need to do the following: + +In your extensions.conf file you would replace these lines: +exten => 8600051,1,Meetme,8600051 +exten => 8600052,1,Meetme,8600052 +...continue through 8600100... +exten => 78600051,1,Meetme,8600051|q +exten => 78600052,1,Meetme,8600052|q +...continue through 78600100... +exten => 68600051,1,Meetme,8600051|mq +exten => 68600052,1,Meetme,8600052|mq +...continue through 68600100... + +with these lines: +exten => 8600051,1,Conference(8600051) +exten => 8600052,1,Conference(8600052) +...continue through 8600100... +exten => 78600051,1,Conference(8600051|q) +exten => 78600052,1,Conference(8600052|q) +...continue through 78600100... +exten => 68600051,1,Conference(8600051|Lq) +exten => 68600052,1,Conference(8600052|Lq) +...continue through 68600100... + +NOTE: If you want to do DTMF passthru with app_conference bee sure to add the +"i" and "t" flags to the 8600XX lines: Conference(8600051|it) + + +7. Add the more entries for astGUIclient specific uses: + - here are some more dialplan additions needed to use astGUIclient(this is a +pure addition, nothing is being modified): +######------ START extensions.conf other additions ------###### +; park channel for client GUI parking, hangup after 30 minutes +; create a GSM formatted audio file named "park.gsm" that is 30 minutes long +; and put it in /var/lib/asterisk/sounds +exten => 8301,1,Answer +exten => 8301,2,AGI(park_CID.agi) +exten => 8301,3,Playback(park) +exten => 8301,4,Hangup +exten => 8303,1,Answer +exten => 8303,2,AGI(park_CID.agi) +exten => 8303,3,Playback(conf) +exten => 8303,4,Hangup + +; park channel for client GUI conferencing, hangup after 30 minutes +; create a GSM formatted audio file named "conf.gsm" that is 30 minutes long +; and put it in /var/lib/asterisk/sounds +exten => 8302,1,Answer +exten => 8302,2,Playback(conf) +exten => 8302,3,Hangup + +; default audio for safe harbor 2-second-after-hello message then hangup +; create a GSM formatted audio file complies with safe harbor rules +; and put it in /var/lib/asterisk/sounds then change filename below +exten => 8307,1,Answer +exten => 8307,2,Playback(vm-goodbye) +exten => 8307,3,Hangup + +; this is used for recording conference calls, the client app sends the filename +; value as a callerID recordings go to /var/spool/asterisk/monitor (WAV) +exten => 8309,1,Answer +exten => 8309,2,Monitor(wav,${CALLERIDNAME}) +exten => 8309,3,Wait,3600 +exten => 8309,4,Hangup + +; this is used for recording conference calls, the client app sends the filename +; value as a callerID recordings go to /var/spool/asterisk/monitor (GSM) +exten => 8310,1,Answer +exten => 8310,2,Monitor(gsm,${CALLERIDNAME}) +exten => 8310,3,Wait,3600 +exten => 8310,4,Hangup + +; this is used for playing a message to an answering machine forwarded from AMD in VICIDIAL +; replace conf with the message file you want to leave +exten => 8320,1,WaitForSilence(2000,2) ; AMD got machine. leave message after recording +exten => 8320,2,Playback(conf) +exten => 8320,3,AGI(VD_amd_post.agi,${EXTEN}) +exten => 8320,4,Hangup + +; this is used to allow the GUI to send you directly into voicemail +; don't forget to set GUI variable $voicemail_exten to this extension +exten => 8501,1,VoicemailMain(s${CALLERIDNUM}) +exten => 8501,2,Hangup + +; this is used to allow the GUI to send live calls directly into voicemail +; don't forget to set GUI variable $voicemail_dump_exten to this extension +exten => _85026666666666.,1,Wait(2) +exten => _85026666666666.,2,Voicemail(${EXTEN:14}) +exten => _85026666666666.,3,Hangup + +; this is used for sending DTMF signals within conference calls, the client app +; sends the digits to be played in the callerID field +; sound files must be placed in /var/lib/asterisk/sounds +exten => 8500998,1,Answer +exten => 8500998,2,Playback(silence) +exten => 8500998,3,AGI(agi-dtmf.agi) +exten => 8500998,4,Hangup + +; prompt recording AGI script, ID is 4321 +exten => 8168,1,Answer +exten => 8168,2,AGI(agi-record_prompts.agi) +exten => 8168,3,Hangup + +; playback of recorded prompts +exten => _851XXXXX,1,Answer +exten => _851XXXXX,2,Playback(${EXTEN}) +exten => _851XXXXX,3,Hangup + +; VICIDIAL_auto_dialer transfer script: +exten => 8365,1,AGI(call_log.agi,${EXTEN}) +exten => 8365,2,AGI(agi-VDADtransfer.agi,${EXTEN}) +exten => 8365,3,AGI(agi-VDADtransfer.agi,${EXTEN}) +exten => 8365,4,AGI(agi-VDADtransfer.agi,${EXTEN}) +exten => 8365,5,Hangup + +; VICIDIAL_auto_dialer transfer script SURVEY at beginning: +exten => 8366,1,AGI(call_log.agi,${EXTEN}) +exten => 8366,2,AGI(agi-VDADtransferSURVEY.agi,${EXTEN}) +exten => 8366,3,AGI(agi-VDADtransferSURVEY.agi,${EXTEN}) +exten => 8366,4,AGI(agi-VDADtransferSURVEY.agi,${EXTEN}) +exten => 8366,5,Hangup + +; VICIDIAL_auto_dialer transfer script Load Balance Overflow: +exten => 8367,1,AGI(call_log.agi,${EXTEN}) +exten => 8367,2,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) +exten => 8367,3,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) +exten => 8367,4,AGI(agi-VDAD_LO_transfer.agi,${EXTEN}) +exten => 8367,5,Hangup + +; VICIDIAL_auto_dialer transfer script Load Balanced: +exten => 8368,1,AGI(call_log.agi,${EXTEN}) +exten => 8368,2,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +exten => 8368,3,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +exten => 8368,4,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +exten => 8368,5,Hangup + +; VICIDIAL_auto_dialer transfer script AMD with Load Balanced: +exten => 8369,1,AGI(call_log.agi,${EXTEN}) +exten => 8369,2,AMD(3500|1500|300|5000|120|50|5|256) +exten => 8369,3,AGI(VD_amd.agi,${EXTEN}) +exten => 8369,4,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +exten => 8369,5,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +exten => 8369,6,AGI(agi-VDAD_LB_transfer.agi,${EXTEN}) +exten => 8369,7,Hangup + +; VICIDIAL auto-dial reminder script +exten => 8372,1,AGI(call_log.agi,${EXTEN}) +exten => 8372,2,AGI(agi-VDADautoREMINDER.agi,${EXTEN}) +exten => 8372,3,AGI(agi-VDADautoREMINDER.agi,${EXTEN}) +exten => 8372,4,AGI(agi-VDADautoREMINDER.agi,${EXTEN}) +exten => 8372,5,Hangup + +### OPTIONAL IAX Load Balance extens to allow for Overflow and Balanced VDAD +### In this setup, the serverIP is the prefix followed by agent conf_exten +### If you have more than 1 server doing VICIDIAL outbound, these lines are +### REQUIRED for Load Balancing to work properly +### server 1 extens: + exten => _010*010*010*016*8600XXX,1,Dial(${TRUNKIAX2}/${EXTEN:16},55,o) + exten => _010*010*010*016*8600XXX,2,Hangup +### server 2 extens: + exten => _010*010*010*015*8600XXX,1,Dial(${TRUNKIAX1}/${EXTEN:16},55,o) + exten => _010*010*010*015*8600XXX,2,Hangup + + +SUBPHASE 6.3: adding entries to your MySQL "asterisk" database for vicidial +applications + +We need to add a few initial values to the vicidial tables in the "asterisk" +database in order to start setting up the vicidial dialer system for use. + +1. at the command prompt type this to go to the mysql client: +/usr/local/mysql/bin/mysql +2. type the following into the mysql client prompt: + (make sure you put your IP address in place of "10.10.10.15" in the queries below) +######------ BEGIN Mysql data entry(you can copy and paste this into terminal) # + +insert into vicidial_users (user,pass,full_name,user_level,user_group,load_leads,campaign_detail,ast_admin_access) values('6666','1234','Admin','9','ADMIN','1','1','1'); + +insert into vicidial_conferences values('8600051','10.10.10.15',''); +insert into vicidial_conferences values('8600052','10.10.10.15',''); +insert into vicidial_conferences values('8600053','10.10.10.15',''); +insert into vicidial_conferences values('8600054','10.10.10.15',''); +insert into vicidial_conferences values('8600055','10.10.10.15',''); +insert into vicidial_conferences values('8600056','10.10.10.15',''); +insert into vicidial_conferences values('8600057','10.10.10.15',''); +insert into vicidial_conferences values('8600058','10.10.10.15',''); +insert into vicidial_conferences values('8600059','10.10.10.15',''); +insert into vicidial_conferences values('8600060','10.10.10.15',''); +insert into vicidial_conferences values('8600061','10.10.10.15',''); +insert into vicidial_conferences values('8600062','10.10.10.15',''); +insert into vicidial_conferences values('8600063','10.10.10.15',''); +insert into vicidial_conferences values('8600064','10.10.10.15',''); +insert into vicidial_conferences values('8600065','10.10.10.15',''); +insert into vicidial_conferences values('8600066','10.10.10.15',''); +insert into vicidial_conferences values('8600067','10.10.10.15',''); +insert into vicidial_conferences values('8600068','10.10.10.15',''); +insert into vicidial_conferences values('8600069','10.10.10.15',''); +insert into vicidial_conferences values('8600070','10.10.10.15',''); +insert into vicidial_conferences values('8600071','10.10.10.15',''); +insert into vicidial_conferences values('8600072','10.10.10.15',''); +insert into vicidial_conferences values('8600073','10.10.10.15',''); +insert into vicidial_conferences values('8600074','10.10.10.15',''); +insert into vicidial_conferences values('8600075','10.10.10.15',''); +insert into vicidial_conferences values('8600076','10.10.10.15',''); +insert into vicidial_conferences values('8600077','10.10.10.15',''); +insert into vicidial_conferences values('8600078','10.10.10.15',''); +insert into vicidial_conferences values('8600079','10.10.10.15',''); +insert into vicidial_conferences values('8600080','10.10.10.15',''); +insert into vicidial_conferences values('8600081','10.10.10.15',''); +insert into vicidial_conferences values('8600082','10.10.10.15',''); +insert into vicidial_conferences values('8600083','10.10.10.15',''); +insert into vicidial_conferences values('8600084','10.10.10.15',''); +insert into vicidial_conferences values('8600085','10.10.10.15',''); +insert into vicidial_conferences values('8600086','10.10.10.15',''); +insert into vicidial_conferences values('8600087','10.10.10.15',''); +insert into vicidial_conferences values('8600088','10.10.10.15',''); +insert into vicidial_conferences values('8600089','10.10.10.15',''); +insert into vicidial_conferences values('8600090','10.10.10.15',''); +insert into vicidial_conferences values('8600091','10.10.10.15',''); +insert into vicidial_conferences values('8600092','10.10.10.15',''); +insert into vicidial_conferences values('8600093','10.10.10.15',''); +insert into vicidial_conferences values('8600094','10.10.10.15',''); +insert into vicidial_conferences values('8600095','10.10.10.15',''); +insert into vicidial_conferences values('8600096','10.10.10.15',''); +insert into vicidial_conferences values('8600097','10.10.10.15',''); +insert into vicidial_conferences values('8600098','10.10.10.15',''); +insert into vicidial_conferences values('8600099','10.10.10.15',''); +insert into vicidial_conferences values('8600100','10.10.10.15',''); + +######------ END Mysql data entry ------###### + + + +SUBPHASE 6.4: setting up asterisk and helper applications for startup + +1. Make several entries in the rc.local of your system: + - on the command line type: + - vi /etc/rc.d/rc.local + - add the following entries(here's what we used): + +### startup tftp server (if you have them installed) +/usr/local/sbin/in.tftpd --verbose=6 --daemon --port=69 --user cron /usr/local/tftp + +### add the CVSROOT variable definition +export CVSROOT=:pserver:anoncvs@cvs.digium.com:/usr/cvsroot + +### start time server +/usr/local/bin/ntpdate -u 18.145.0.30 +/usr/sbin/ntpd + +### start up the MySQL server +/usr/local/mysql/bin/mysqld_safe --user=mysql --skip-name-resolve --skip-host-cache & + +### start up the MySQL 4.1.X server (with old passwords) +/usr/local/mysql/bin/safe_mysqld --old-passwords --skip-name-resolve --skip-host-cache & + +### start up the apache web server +/usr/local/apache2/bin/apachectl start + +### load digium tormenta 4xT1 drivers into system +modprobe zaptel +modprobe wct1xxp +/sbin/ztcfg -vvvvvvvvvvvv + +### sybsys local login +touch /var/lock/subsys/local + +### sleep for 20 seconds before launching Asterisk +sleep 20 + +### start up asterisk +/home/cron/start_asterisk_boot.pl + + - you are done + + + + +SUBPHASE 6.5: setting up astguiclient scripts for continuous running + +1. Make several entries in the cron of your system: + - on the command line type: + - cd /home/cron + - crontab -e + - add the following entries(here's what we used): + (Note if you have not edited the AST_CRON_mix_recordings.pl script +to FTP to a different server, then you should use the +AST_CRON_mix_recordings_BASIC.pl file in it's place) + +### recording mixing for Asterisk run every 5 minutes +1,6,11,16,21,26,31,36,41,46,51,56 * * * 1,2,3,4,5,6 /home/cron/AST_CRON_mix_recordings_BASIC.pl + +### keepalive script for Asterisk updaters +* * * * * /home/cron/ADMIN_keepalive_AST_update.pl + +### keepalive script for Asterisk manager queue system +* * * * * /home/cron/ADMIN_keepalive_AST_send_listen.pl + +### keepalive script for Asterisk VICIDIAL autodial system +* * * * * /home/cron/ADMIN_keepalive_AST_VDautodial.pl + +### keepalive script for VICIDIAL remote agents +* * * * * /home/cron/ADMIN_keepalive_AST_VDremote_agents.pl + +### kill Hangup script for Asterisk updaters +* * * * * /home/cron/AST_manager_kill_hung_congested.pl + +### updater for voicemail +* * * * * /home/cron/AST_vm_update.pl + +### updater for conference validator +* * * * * /home/cron/AST_conf_update.pl + +### flush queue DB table every hour for entries older than 1 hour +11 * * * * /home/cron/AST_flush_DBqueue.pl -q + +### fix the vicidial_agent_log once every hour +33 * * * * /home/cron/AST_cleanup_agent_log.pl + +### updater for VICIDIAL hopper +* * * * * /home/cron/AST_VDhopper.pl -q + +### adjust the GMT offset for the leads in the vicidial_list table +1 1 * * * /home/cron/ADMIN_adjust_GMTnow_on_leads.pl --debug + +### reset several temporary-info tables in the database +2 1 * * * /home/cron/AST_reset_mysql_vars.pl + +### optimize the database tables within the asterisk database +3 1 * * * /home/cron/AST_DB_optimize.pl + +## adjust time on the server with ntp +30 * * * * /usr/local/bin/ntpdate -u 18.145.0.30 2>/dev/null 1>&2 + +### VICIDIAL agent time log weekly summary report generation +2 0 * * 0 /home/cron/AST_agent_week.pl + + - once your system starts up you can attach to the screen running asterisk by +typing "screen -r " find which screen by typing "screen -r" and +looking for the lowest screen number. Then to detach again from the screen +while you are in it type 'Ctrl+a' then 'd' + - you are done + + + + +SUBPHASE 6.6: adding test leads to the VICIDIAL database and configuring a +VICIDIAL campaign and users + +First we will add a few test leads to the vicidial_list table so that we can +test our system. There is also an application included with the distribution +that will accept a delimited file of leads placed in the /home/cron/VICIDIAL/LEADS_IN/ +directory and load it into the database automatically(VICIDIAL_IN_new_leads_file.pl +[a sample lead file in the proper format is included with this release: + - test_VICIDIAL_lead_file.txt]) +If you want to use the lead import script I suggest looking at the code to make +sure it is entering what you want it to. We are not going to go over that +particular script in this document. + +Also, there is a web-based lead loader that was made available as of the 1.1.1 +release and is accessible from the VICIDIAL admin.php web page(click on the +"LOAD NEW LEADS" link at the top of the admin page). To get to this page you +must have permissions in the vicidial_user table(Load Leads set to 1) . +Instructions on it's use are included on the page through the help question +mark link. +NOTE: in PHP you must have "fileuploads" enabled for this page to work. + +Second we need to add the disposition statuses into the system, all of these +queries are below: +(Note: you may want to replace 7275551212 with a real number to test in these +records) + +1. at the command prompt type go to the mysql client: +/usr/local/mysql/bin/mysql +2. type the following into the mysql client prompt: + (make sure you put your IP address in place of "10.10.10.15" in the queries +below) +######------ BEGIN Mysql data entry(you can copy and paste this into terminal) # + +insert into vicidial_list values('','2004-01-06','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead01','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); +insert into vicidial_list values('','2004-01-06','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead02','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); +insert into vicidial_list values('','2004-01-07','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead03','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); +insert into vicidial_list values('','2004-01-07','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead04','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); +insert into vicidial_list values('','2004-01-07','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead05','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); +insert into vicidial_list values('','2004-01-07','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead06','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); +insert into vicidial_list values('','2004-01-07','','NEW','','','TEST01','101','TESTCAMP','N','1','7275551212','Mr','Matt','X','lead07','1234 Fake St.','','','Clearwater','FL','','33760','USA','M','1970-01-01','','test@test.com','suprise','comments go here','0'); + +### these first 5 must be in all VICIDIAL systems for it to work properly # +insert into vicidial_statuses values('NEW','New Lead','N'); +insert into vicidial_statuses values('QUEUE','Lead To Be Called','N'); +insert into vicidial_statuses values('INCALL','Lead Being Called','N'); +insert into vicidial_statuses values('DROP','Agent Not Available','N'); +insert into vicidial_statuses values('NA','No Answer AutoDial','N'); + +insert into vicidial_statuses values('CALLBK','Call Back','Y'); +insert into vicidial_statuses values('A','Answering Machine','Y'); +insert into vicidial_statuses values('B','Busy','Y'); +insert into vicidial_statuses values('DC','Disconnected Number','Y'); +insert into vicidial_statuses values('DEC','Declined Sale','Y'); +insert into vicidial_statuses values('DNC','DO NOT CALL','Y'); +insert into vicidial_statuses values('SALE','Sale Made','Y'); +insert into vicidial_statuses values('N','No Answer','Y'); +insert into vicidial_statuses values('NI','Not Interested','Y'); +insert into vicidial_statuses values('NP','No Pitch No Price','Y'); +insert into vicidial_statuses values('XFER','Call Transferred','Y'); + +quit +######------ END Mysql data entry ------###### + +Now that the sample leads and disposition codes have been entered, we can go +into the VICIDIAL administration website and set up our campaigns, lists and users. +But first let's make sure that they have the right GMT offset: + run this on the command line: + - /home/cron/ADMIN_adjust_GMTnow_on_leads.pl + +3. Enter the astguiclient administration page: +http://10.10.10.15/vicidial/admin.php +(use the username and password created when we entered a record into the +vicidial_users table in SUBPHASE 6.3, In our case this is 6666 and 1234) +NOTE: if you click on the Logout button you must leave the user/pass empty and click OK + - Now that you are logged into the vicidial administration system we can add +new user entries for each of the new users and enter new campaigns and new +lists. + - The first step is to enter your new users, Click on the ADD A NEW USER +and fill in the appropriate information for each now user you want to +add. + - Next, you need to create a new campaign, click on the ADD A NEW +CAMPAIGN link and fill in what you want the campaign to be called as +well as a description + - Next, you need to define a new list, click on the ADD A NEW LIST link +and fill in what you want the list to be called as well as a using the +list ID of the leads that we loaded in the previous step "101" and +select the new campaign from the pull-down menu that we just created. + - Now that you have created your list, make it active by changing active to Y + - now modify your campaign ang change the first status to be called to +NEW and submit. Now your system is ready to dial. + - you are done + + + +SUBPHASE 6.7: VICIDIAL remote agents: + +With v1.0 of VICIDIAL we have the ability to use a simple web form to give +remote agents a way to receive calls to whatever number they happen to be at, +and they can view/edit call details and see a call log all through a web page +(vdremote.php) or http://10.10.10.15/vicidial/vdremote.php on this installation. +Remote Agents is only recommended for inbound calls because of the extra time +needed to dial a number out to transfer the call to. To set up remote agents, +just go to the vicidial admin.php page and ADD NEW REMOTE AGENTS(Make sure the +userID start also has a user login so they can get to the vdremote page). You +will see that you can set up a remote agent entry to take multiple lines if you +wish meaning that, for example, if you need to send all of your calls to another +location because of a massive snowstorm(and none of your agents showed up at work) +you just log in that remote agent record with say 10 lines and then all of those +calls will be directed to the same number you set up for the remote agent. Then +again you could just get your agents to log in from home if they have a phone +and computer + + + +SUBPHASE 6.8: astGUIclient web-only client: + +With 1.1.1 release of astguiclient we have completely rewritten the astGUIclient +client app in AJAX(PHP/Javascript/XMLHTTPRequest) to enable a full, real-time +GUI interface using only a web browser. The browser requirements for this are: +- Firefox 0.9 or greater (Firefox 1.0.7 is the recommended browser) +- Mozilla 1.7 or greater +- Netscape 8 or greater +- Opera 8.5 or greater +- Microsoft Internet Explorer 5.0 or greater (we have noticed some serious + memory leaks in IE5 and IE6 when using this program, they do not occur in + Firefox which is why we recommend it overall.) + +This new version also has more flexibility and functionality than the perl/Tk +version as well as being prettier. We have successfully tested this on many +platforms and in remote locations. It functioned wonderfully off-site with one +of our IAX hardphones and offers a lot of promise for road warriors who need +a lot of options on their phone usage like conferencing and a detailed call log. + +To log into this app you will need a login setup in the vicidial_users table +with a user_level of 4 or greater as well as an entry for the phone you are +using in the phones table. You will first get a login prompt for the vicidial +login then you will have the phone login where you enter the Login and Password +for that phone entry. From there the app should display and you will see the +MAIN screen with your phone information, voicemail display and your inbound/ +outbound phone call log. + +The example web page you would go to on this installation would be: +http://10.10.10.15/agc/astguiclient.php + +The inbound log and callerID popup is dependant on having a call_inbound.agi +entry in your dialplan before you phone is dialed(see subphase 6.2 step 2) + +Another thing to note is that you can have the agc folder(with the .php files +in it) copied to multiple web servers, you just need to make sure that the +MySQL database connection works (check the settings in the dbconnect.php file +that is in the agc directory). We have had astguiclient.php running on 3 +separate web servers for the same DB server and Asterisk server. This is an +easy way to allow for auto failover and/or redundancy. Also, this client will +work over SSL connections(https) for encrypted communications with the server. + +New in astGUIclient release 1.1.7 is multi-language support. multi-language +versions of web-clients and admin pages are available in the LANG_agc.zip and +LANG_admin.zip files and can be unzipped into your webroot directory. Make sure +you check the dbconnect.php file in each directory. + +NOTE: make sure you have your machine time-syncing with an ntp server + Windows instructions: http://www.tech-recipes.com/windows_tips466.html + http://support.microsoft.com/kb/q216734/ + + +SUBPHASE 6.9: VICIDIAL web-only client: + +NOTE: There is a VICIDIAL Agent manual available from http://www.eflo.net + +With 1.1.6 release of astguiclient we have finished the rewrite of the VICIDIAL +client app in AJAX(PHP/Javascript/XMLHTTPRequest) to enable a full, real-time +GUI interface using only a web browser like we have done with astGUIclient. +The browser requirements for this are: +- Firefox 0.9 or greater (Firefox 1.0.7 is the recommended browser) +- Mozilla 1.7 or greater +- Netscape 8 or greater +- Opera 8.5 or greater +- Microsoft Internet Explorer 5.0 or greater (we have noticed some serious + memory leaks in IE5 and IE6 when using this program, they do not occur in + Firefox which is why we recommend it overall.) + +This version is fully functional and has been tested in our production +call center with no problems. On RedHat 9.0 Linux workstations we have noticed +a decrease in system load running the web-client as compared to the Perl/Tk +client. Also, the memory usage stayed at about 22MB for a full shift of +activity, so no memory leaks with Firefox. + +To log into this app you will need a login setup in the vicidial_users table +with a user_level of 1 or greater as well as an entry for the phone you are +using in the phones table. You will first get a login prompt for the vicidial +login then you will have the phone login where you enter the Login and Password +for that phone entry. From there the app should display and you will see the +VICIDIAL screen with your phone information. + +The example web page you would go to on this installation would be: +http://10.10.10.15/agc/vicidial.php + +One more feature that the VICIDIAL web-client offers is the ability to set up +an EXTERNAL phone extension in the astguiclient admin section so that you can +have agents log in to vicidial.php wherever they have access to a phone with +an external phone number and a web browser. To do this follow these steps: +- "ADD A NEW PHONE" in the admin.php web page and enter whatever name you want +- For the dialplan number field put in the full digits that you would dial from + the Asterisk server to get to that agent's external phone(with 91 if used) +- For the Protocol select EXTERNAL +- make sure the agent knows the login and password set for this phone entry. +Then the agent will go to the vicidial.php page and enter in their phone +login/pass, their vicidial user/pass/campaign and their phone should ring in a +few seconds, and they are logged in and ready to take calls. + +Another thing to note is that you can have the agc folder(with the .php files +in it) copied to multiple web servers, you just need to make sure that the +MySQL database connection works (check the settings in the dbconnect.php file +that is in the agc directory). We have had astguiclient.php running on 3 +separate web servers for the same DB server and Asterisk server. This is an +easy way to allow for auto failover and/or redundancy. Also, this client will +work over SSL connections(https) for encrypted communications with the server. + +New in astGUIclient release 1.1.7 is multi-language support. multi-language +versions of web-clients and admin pages are available in the LANG_agc.zip and +LANG_admin.zip files and can be unzipped into your webroot directory. Make sure +you check the dbconnect.php file in each directory. + +Admin Note: If you want to enable your agents to login with only their user/pass +you can hardcode the phone_login and phone_pass into the query string(URL) and +use a bookmark on their desktop, taking one more step out of their login process +example: http://10.10.10.15/agc/vicidial.php?pl=gs102&pp=test + +It is recommended if you are in a call center environment that you would disable +the "Saved Form Information" option in Firefox settings. This is a checkbox in +the Privacy settings under the Options menu. + +NOTE: make sure you have your machine time-syncing with an ntp server + Windows instructions: http://www.tech-recipes.com/windows_tips466.html + http://support.microsoft.com/kb/q216734/ + + + +PHASE 7.0: You are done with installation + +Now you can celebrate, you have installed a complete phone system with dialer +and GUI applications on all of your clients. the astGUIclient has a help screen +that pops up and explains most of it's features. + +If you have problems and it is not working right(and are NOT celebrating right +now), feel free to take a look at the FAQ for solutions to common installation +errors or send an email to the mailing list: +https://lists.sourceforge.net/lists/listinfo/astguiclient-users + +Also, check out our weblog: http://astguiclient.blogspot.com/ + + +**** IMPORTANT - In order for vicidial/astguiclient to function correctly please +read the REQUIREMENTS.txt for a minimum requirements list. *** diff --git a/agc_2-X/trunk/docs/TODO.txt b/agc_2-X/trunk/docs/TODO.txt new file mode 100644 index 00000000..29ccfa07 --- /dev/null +++ b/agc_2-X/trunk/docs/TODO.txt @@ -0,0 +1,116 @@ ++------------------------------------------------------------------------------+ +| Asterisk GUI client - TODO v.2.0.1 | +| | +| TODO file is a list of what is new from previous version as well a list of | +| features that are planned to be completed for future releases. HIGH priority | +| items are usually going to be completed for the next release. This file is | +| kept updated on the project website by the developers and does not | +| necessarily reflect the status of features for the last release. If you are | +| reading this file from the release package, then it is accurate for the | +| version your downloaded. | ++------------------------------------------------------------------------------+ + +- HIGH add option to disable detailed logging for VICIDIAL and astGUIclient server apps. + +- HIGH add new ALLFORCE to recording method for campaigns. will force recording of all calls and disable the button for agents no matter their vicidial_users setting. + +- HIGH add a basic predictive/adaptive algorithm to VICIDIAL to automatically speed-up and slow-down dialing by altering the dial_level at regular intervals. Would need more settings in the vicidial_campaigns table for adaptive like maximum lines per agent, dropped call ratio, dropped call rule to guide the predictive app. Would also need to change dial_level to be a DOUBLE or VARCHAR field to allow for different fractional increments. The admin.php page would have to be altered to ignore auto_dial_level changes when adaptive dialing is activated. The minimum dial_level would be set to '1' for adaptive dialing + auto_dial_level VARCHAR(6), # allow for just about anything. precision decimal too + adaptive_dial_level ENUM('Y','N'), # turns on adaptive script and prevents dial_level admin changes + adaptive_maximum_level VARCHAR(6), # sets highest dial_level possible by adaptive app + adaptive_dropped_percentage SMALLINT(3), # percentage of accaptable dropped calls + adaptive_dropped_rule ENUM('HARD_LIMIT','TAPERED','AVERAGE'), # method for adhearing to % limit + +- HIGH room manager documentation - manual. Probably a free 2 chapter black and white manual and a full color print download available for sale. + +- HIGH fix lead recycling so that it will allow recycling of non-selectable leads + +- HIGH change minimum phone_number length in leadloader to 7 digits and note in documentation that country code is needed in phone_code field fro proper GMT coding. + + + + + +- MEDIUM add checkbox options for campaigns(Art Tarsha new feature) needs to be modified to be multi-campaign compliant: http://www.eflo.net/files/customer_checkboxes.zip + +- MEDIUM Add auto dial next number option to manual dialing in vicidial.php. With preview enabled this would allow for a preview timeout and would auto dial if the STOP DIALING checkbox was not checked on the dispo screen. + +- MEDIUM Try converting the call_log and/or VD_hangup scripts to FastAGI and see what the load difference would be. + +- MEDIUM Add buttons and selector box to script modification page to allow for insertion of field codes without having to manually type them. + +- MEDIUM Rewrite the inbound and closer call handling to allow for music on hold per in-group and a single queue app instead of multiple AGIs each running their own queries. Currently with large queues and long wait times a lot of load is generated with calls on hold in the queue. Switching to a central queue application would reduce the load and speed things up. + +- MEDIUM Add optional field to phones table to allow for different recording file names in astguiclient.php, Similar to vicidial options. + +- MEDIUM make 3rd party consultative transfers work for Local extensions, also for internal/local transfer to vicidial closers if possible. + +- MEDIUM Attempt to make some kind of holiday schedule function for national and state holidays that would be able block out states on specific no-call days. This is rather difficult because of the way some holidays are scheduled, I.E. Easter. + +- MEDIUM Add ChanSpy functionality to listen-in on VOIP channels in astguiclient.php. Maybe not since Chanspy can cause problems like crashing the Asterisk server. Need to do more testing. + +- MEDIUM Create a script to allow vicidial agents to dial into an AGI script that would ask for user/pass and then place them onto their vicidial.php-defined sessionid. + +- MEDIUM add link in astguiclient to login and logout from Asterisk Queues + +- MEDIUM add script to get "show queues" information and place in a DB table to be used to see who is in an Asterisk Queue. This would mostly be used to give a LOGGED-IN and LOGGED-OUT display for astguiclient.php and possibly add an Asterisk Queue display tab or popup for astguiclient.php. Info would be updated one to four times a minute so it would not be real-time. + +- MEDIUM add new tab to astguiclient.php script to show status of Asterisk queues + +- MEDIUM Convert all scripts to DBD::MySQL perl library in place of Net::MySQL. DBD::MySQL is faster because it uses the MySQL client libs on the machine. One problem is that you need the mysqlclientlibs installed on every +Asterisk server and the default installation of only the MySQL client libs will result in having to do a force install of cpan DBD::MySQL(because it tries to test with the local DB). Not to mention all of the code changes that would need to be made. There are also MySQL client licensing issues for certain installation circumstances(Net::MySQL doesn't use mysql client libs so it doesn't have those issues) but I really don't want to get into that discussion. We will start by converting at least one perl script for each release until we have converted then all, then we will no longer support Net::MySQL. This will probably take some time, but the scripts that are added to the DBI-scripts folder will be drop-in replacements for the Net versions that are installed by default. + +- MEDIUM Create a visual SQL builder for the filter SQL section. + +- MEDIUM add ability to call CLOSER campaigns "BLEND" or "INBND". would require many script changes from server side to client side, not set in stone yet, but considering it. + +- MEDIUM add some kind of intelligent call-routing to astguiclient so that you can auto-forward calls to another extension from within astguiclient.php instead of using your phone or something like Queues which can mess up other things. This will need it's own table in the DB and probably some extensions.conf entries and an AGI script or two to do the actual call routing. + +- MEDIUM add skills-based routing to give the ability for a manager to set an agent at a higher or lower level per campaign or in-group. Defaults to level 0 possible values will be -9 through 9 + +- MEDIUM add all possible fields to the SCRIPT tab to auto-populate like in-group for inbound/closer, campaign and others + +- MEDIUM add ability to scrub leads being imported in the lead loader against the vicidial_dnc list as they are being imported. + +- MEDIUM add ability upon vicidial.php login to take a number to dial as a password and a reserved word(something like MANUAL in all caps) that would allow the use of an EXTERNAL phone without setting it up as an asterisk.phones entry. + +- MEDIUM rebuild the vdremote.php remote agents pages to use AJAX(PHP/Javascript/XMLHTTPRequest) for real-time popups of call data. + +- MEDIUM allow custom audio welcome message for vicidial campaigns. This might be an app_conference only feature. + +- MEDIUM create a cron script and method for creating new extensions in the sip.conf/iax.conf files as well as dialplan entries(extensions.conf). This will require more fields in the phones table to account for variables available to the protocols. The conf files would need to be altered before to have a flag for the beginning and ending of the auto-generated content. This would also necessitate a TEXT area for the extensions.conf content(that would be default generated but could be manually altered). The cron script would be run every 5 minutes or so to see if any phones had altered content, and if so generate new auto-content and do a 'reload' on the asterisk server to activate the new content. + +- MEDIUM add a count-up-timer to active channels on the astguiclient MAIN screen(this may be an Asterisk 1.2+ required feature). + +- MEDIUM Change VICIDIAL autodialing configuration to allow dialing of alt_phone numbers as well as address3 phone numbers after dialing main number. It is already possible to dial an alternate phone number manually as an agent once the customer info is up on the screen, but this would be doing it in an automated fashion. Best way for this may be to reconfigure the called_since_last_reset field to allow N, 1, 2, Y. This would require reprogramming several server scripts and php pages. + +- MEDIUM Try a few of the frequently launched scripts as C programs(call_log.agi and the AST_send child scripts) to see if they reduce system load and/or speed up those processes. + +- MEDIUM Change the autodialing system around so that there can be dialing-out-only servers and agent-only servers in a multi-server load-balanced environment. This is suprisingly simple to do, but would require all servers to be controlled by a single instance of AST_VDauto_dial.pl running on one machine. Also, in the case of IAX2 channel native transfers, we would need to change the AGI scripts that route the calls and create a new script to alter the vicidial_auto_calls records to the agent server call_server_ip and channel name because the call would disappear from the originating server causing "customer hungup" warnings. + +- MEDIUM Add method of picking up astGUIclient parked calls by only dialing digits on a regular extension without using the astGUIclient. + +- MEDIUM admin/installer/maintainer documentation as well as troubleshooting guide + +- MEDIUM Run some lab-style load tests on VICIDIAL and show recommended configurations as well as "highest recommended" settings + + + +- LOW add the ability to run separate companies on the same VICIDIAL server. This will not be easy. All admin tasks as well asl user tasks and stats will need to have divisions so that nothing is accessible from the other groups. Also, the resources of the system(outbound trunks, hard drive space, other shared elements, etc...) so that one group cannot hog the shared resources of the the server. + +- LOW Making the server install script a customizable with installer prompts + +- LOW Create guidelines and suggestions for deactivating unused modules from Asterisk for astGUIclient users + +- LOW Revisit possibility of using something other than CallerIDname to tag a call process, probably a long shot without altering the Asterisk code, but that may be an option. + +- LOW add new method for capping the maximum number of attempts to try leads of a specific status. This would be set up like HotKeys are, per campaign where you would select the status and define the maximum number of attempts for that type of status for that campaign and the VDhopper wouldn't allow that kind of lead into the hopper if it was over the max value of call_count.(having filters reduced the priority of this item since you can do a lot of custom coding to duplicate this feature in vicidial_lead_filters) + +- LOW add a new script for using SoX to analyze the first 5 seconds of a ring-time recording within 15 minutes of the NA call ending and detecting if it has the SIT tone at the beginning of it so the lead can be taken out of the list as a DC. adding PRI hangup codes has reduced priority for this item. + +- ON-HOLD We are also looking at creating an inbound-agent-specific GUI that would ideally work with Asterisk queues but that is not very likely given the current lack of events being given off by queues(this is much less likely to be built now that VICIDIAL takes inbound calls) + +- ON-HOLD add a way of checking that there is no more than 1 channel in the meetme room with the agent before another call to that agent. Currently this happens less than 0.1% of the time(mostly on heavily loaded systems), but another check might change that to zero. + +- ON-HOLD Localization of each server based on Intl. dial codes and/or country codes. very difficult to do this based on dial-codes, if used in other country, best to not use the adjust_gmt script. + diff --git a/agc_2-X/trunk/docs/TODO_1.1.11.txt b/agc_2-X/trunk/docs/TODO_1.1.11.txt new file mode 100644 index 00000000..a0f15e73 --- /dev/null +++ b/agc_2-X/trunk/docs/TODO_1.1.11.txt @@ -0,0 +1,208 @@ ++------------------------------------------------------------------------------+ +| Asterisk GUI client - TODO v.1.1.11 | +| | +| TODO file is a list of what is new from previous version as well a list of | +| features that are planned to be completed for future releases. HIGH priority | +| items are usually going to be completed for the next release. This file is | +| kept updated on the project website by the developers and does not | +| necessarily reflect the status of features for the last release. If you are | +| reading this file from the release package, then it is accurate for the | +| version your downloaded. | ++------------------------------------------------------------------------------+ + + +- DONE Add ability in AST_CRON_mix_recordings_BASIC.pl and AST_CRON_mix_recordings.pl to mix gsm in and out audio files + +- DONE Added deletion from hopper of inactive list leads. AST_VDhopper.pl + +- DONE Create AGI script for customer entering PIN number. very limited use and difficult to setup, internal project. agi-VDADlisten_DTMF.agi + +- DONE Change the phone_codes_GMT.txt file to reflect Indiana's move to adopting Daylight Savings Time + +- DONE Add to update.sql script changes in Indiana's timezone data in database, and send out announcement to change production systems as of 2006-04-02 + +- DONE Alter AST_manager_listen.pl to work with new SVN manager output that includes a Timestamp field + +- DONE change wording of vicidial.php disposition screen bottom phrases to be more clear + +- DONE Alter list_id to be BIGINT(14) to allow for timestamped list_ids + +- DONE Add notes to LOAD_BALANCING.txt file about which cron scripts only need to be run on one server. + +- DONE Add a vicidial.php variable at the top of the script to allow for the change in behaviour of pausing after dispositioning of a call, something like $dispo_check_all_pause =1; If set to 1 then it will stay the way it is and pause after every call if checked once. if set to 0 (which will be the default) it will only pause once and uncheck the box for subsequent calls. + +- DONE Add a WEB FORM submit link to the dispo screen that would dispo the call as well as open a web form link with the customer info and status dispod when clicked. + +- DONE Add notice to a call that was CALLBK on the agent screen next time it is called so agent knows it was a scheduled callback. Positioned to the right of the customer info header. + +- DONE Add link to the dispo screen to allow the agent to try to hangup the call again if it did not hangup. Only can click it once per call then it disappears. + +- DONE Add link to "noone is in your session" window to call agent back and update status to PAUSE. + +- DONE Add a Hangup Customer link on the "Customer has hungup" popup to reduce the steps to dispo. options would now be "back to Main" and "Disposition and finish call" + +- DONE Add display for agent status and number of calls being dialed to vicidial.php. $agentcallsstatus set to 1 activates the display below the SENDDTMF button, $campagentstatctmax sets the number of seconds delay between updates of that information + +- DONE Fixed bug in AST_update.pl test section that would crash script when ** came through as extension on Asterisk 1.2.6 in certain circumstances. + +- DONE Added status name to list modification screen in admin.php. Also consolidated called and not-called into one row for each status. Added status name to campaign dial_statuses select lists + +- DONE Second stage Scheduled-Callback functionality: add agent-specific callback status with date and time definition to vicidial.php. This second stage will allow a callback to be restricted to the specific agent that set the callback. There will need to be some other provisions in place on the vicidial.php to handle what are basically manual dial calls happening on an auto-dial session. Also, a counter on the vicidial.php page to show how many active or live callbacks the agent has and an interface for the agent to see and call back which callbacks are ready to be called back. + +- DONE Add the ability to manually dial a number from within vicidial.php. There will be an option to add the number as a new lead to the campaign the agent is logged into, or just call the number and go back to the main screen(the call would then need to be dropped from the CALLS IN THIS SESSION link at the bottom). This feature will only be enabled when the agent is paused and not on a call. + +- DONE Fix "waiting for ring" bug with manual dial override in vicidial.php. + +- DONE Fixed manual dial lead preview bug. caused by undefined function variable created for manual dial override, just defined the variable in all function calls to fix it. + +- DONE Add capability to allow manual dialing of an alt_phone or address3 phone number in vicidial.php in auto_dial mode. This required a lot of changes to the code where dial_level>0 for things to work correctly, but most of the changes were already done for the agent-only callbacks feature so it wasn't that difficult. + +- DONE Change the links at the top of the vicidial admin.php page to be color-coded sectional links with sub-link row below the main sections in the same color. This will make navigating the admin.php page easier. suggested by Mike Fedyk. + +- DONE Added script name to campaign and in-group modification screens in admin.php. + +- DONE add a field to vicidial_campaigns for alt_number_dialing. This would override the vicidial.php hard-coded variable and would allow it per campaign. The default will be to DISABLE alt_number_dialing. + +- DONE add a permission field to vicidial_campaigns for scheduled_callbacks to allow an agent to dispo a lead as a callback and choose a callback date/time. The default will be to DISABLE scheduled callbacks. Both this and the vicidial_users field must be enabled for and agent to leave scheduled callbacks. + +- DONE add a permission field to vicidial_users for scheduled_callbacks to allow an agent to dispo a lead as a callback and choose a callback date/time. The default will be to ENABLE scheduled callbacks. + +- DONE add a permission field to vicidial_users for agentonly_callbacks to allow an agent to set a callback as USERONLY as well as call that lead back. The default will be to DISABLE USERONLY callbacks. + +- DONE add a permission field to vicidial_users for agentcall_manual manual dialing within vicidial.php. The default will be to DISABLE manual dialing. + +- DONE add a permission field to vicidial_users to restrict recording in vicidial.php per user. Default would be to ENABLE recording + +- DONE add a permission field to vicidial_users to restrict transfers in vicidial.php per user. Default would be to ENABLE transfers + +- DONE Add a FILTERS section to the vicidial admin screen and a FILTERS feature that would operate a lot like how the lead filters work in the GnuDialer project. It would be a way of defining SQL subsets on leads that the campaign would be dialing. You would create new filters in the ADD NEW FILTER section and a vicidial_campaign can only have one active FILTER at any one time. The Filter modification page would have something like a SQL builder that would let you select a parameter field(like called_count, state, postal_code, etc...) and then a value set, or you could directly edit the SQL it generates. This feature could make it rather easy to mess up dialing for a campaign since it lets managers directly edit the SQL statement that is used to put leads into the hopper. The SQL would only be SELECT based and would not effect the order that the leads are selected in. would require a new table(vicidial_filters) as well as a new field in vicidial_campaigns(filter_id). + create table vicidial_filters ( + filter_id VARCHAR(10), + filter_name VARCHAR(30), + filter_comments VARCHAR(255), + filter_sqlTEXT); + +- DONE Add auto-hopper-insertion to triggered ANYONE callbacks. This will need to check on campaign and list status before insertion. This is an option at the top of the script that can be disabled if you do not want this functionality: insert_auto_CB_to_hopper + +- DONE For ANYONE callbacks, alter vdc_db_query.php script to update the vicidial_callback record to INACTIVE after it has been sent to an agent. + +- DONE Need to prevent launching of a manual dial call or callback when in alt-dial-mode before finishing lead. + +- DONE For USERONLY callbacks there will need to be an admin interface change necessary to be able to override this and a method to change a USERONLY callback to ANYONE. Allow the other-way-around as well. + +- DONE change PHP variable checking and definitions at the top of php scripts to isset/elseif for all php scripts. + +- DONE Fix alt_phone_dial disabled bug (no dispo when campaign alt_dial disabled and calling a callback or manual dial) + +- DONE Fix default park hold exten 8303 to 8301 and added 8303 to SCRATCH_INSTALL. + +- DONE end-user agent documentation - manual. Probably a free text-only manual and a full color print book available for sale as PDF and Hardcopy. Available at http://www.eflo.net/ + +- DONE Add "alter agent interface options" as option to vicidial_users table for admin.php permissions + +- DONE separate agent interface options from admin options in the vicidial_users modification portion of admin.php + +- DONE Add a closer blended default field to vicidial_users to allow setting the blended checkbox as checked upon CLOSER campaign login for a specific agent. + +- DONE Fix phone search bug in astguiclient/admin.php. + +- DONE Fix AST_VDauto_dial issue that causes continuous calls to be placed in blended campaigns if the closer campaign name didn't begin with CL. + +- DONE Fix vdc_db_query issue with manager override of in-group choices for CLOSER campaign Agents + +- DONE Fix VDAD inbound scripts to use status of "INBND" for new vicidial_list entries instead of "INBOUND" which is not compliant with the database schema. + + + + + + + + +- MEDIUM Add wrapup_seconds and wrapup_message fields to vicidial_campaigns along with a function to force a minimum wrapup time into vicidial.php after an Agent hangs up a call. The timer would start when the agent clicks on the HANGUP CUSTOMER button and if the agent dispositions the call before the wrapup time is up then they would see a screen blanking out the vicidial screen that would display the wrapup message until the timer ran out. If the wrapup timer runs out before the agent is finished dispositioning a call, nothing would happen, so the agent would not be able to move on to the next call until they selected a disposition. + +- MEDIUM Add internal DNC list of phone numbers(vicidial_dnc table) that would be scrubbed against by the AST_VDhopper.pl script while putting leads into the hopper to be dialed and it would kick the internal DNC matches out with a special status as DNCL(Do-Not-Call-Load) so they would be in the system but unable to be dialed. Would need to add a mechanism to add a lead to this list upon agent-dispo of a call as DNC within vicidial.php. Would need to create a new admin page section to manually add leads to DNC list. Also, would add a parameter to vicidial_campaigns(dnc_list_enabled ENUM('Y','N')) where a campaign could be exempted from the system's DNC list restrictions(would be active by default 'Y'). + +- MEDIUM add a basic predictive/adaptive algorithm to VICIDIAL to automatically speed-up and slow-down dialing by altering the dial_level at regular intervals. Would need more settings in the vicidial_campaigns table for adaptive like maximum lines per agent, dropped call ratio, dropped call rule to guide the predictive app. Would also need to change dial_level to be a DOUBLE or VARCHAR field to allow for different fractional increments. The admin.php page would have to be altered to ignore auto_dial_level changes when adaptive dialing is activated. The minimum dial_level would be set to '1' for adaptive dialing + auto_dial_level VARCHAR(6), # allow for just about anything. precision decimal too + adaptive_dial_level ENUM('Y','N'), # turns on adaptive script and prevents dial_level admin changes + adaptive_maximum_level VARCHAR(6), # sets highest dial_level possible by adaptive app + adaptive_dropped_percentage SMALLINT(3), # percentage of accaptable dropped calls + adaptive_dropped_rule ENUM('HARD_LIMIT','TAPERED','AVERAGE'), # method for adhearing to % limit + +- MEDIUM Add optional set of scripts for PRI system usage with VICIDIAL to automatically grab Busy and disconnect information from PRI call termincation codes and use those for NA dispositions. The problem with these is that they are not 100% accurate. + +- MEDIUM Add some sort of method to be able to auto-insert Busy/Ring-no-answer/other-NA calls back into the hopper after a certain timeout. Not sure on a method or formula yet. + +- MEDIUM Add optional field to phones table to allow for different recording file names in astguiclient.php, Similar to vicidial options. + +- MEDIUM make 3rd party consultative transfers work for Local extensions, also for internal/local transfer to closers if possible. + +- MEDIUM Add ChanSpy functionality to listen-in on VOIP channels in astguiclient.php. Maybe not since Chanspy can cause problems like crashing the Asterisk server. + +- MEDIUM Create a script to allow vicidial agents to dial into an AGI script that would ask for user/pass and then pass them onto their vicidial.php-defined sessionid. + +- MEDIUM add link in astguiclient to login and logout from Asterisk Queues + +- MEDIUM add script to get "show queues" information and place in a DB table to be used to see who is in an Asterisk Queue. This would mostly be used to give a LOGGED-IN and LOGGED-OUT display for astguiclient.php and possibly add an Asterisk Queue display tab or popup for astguiclient.php. Info would be updated one to four times a minute so it would not be real-time. + +- MEDIUM add new tab to astguiclient.php script to show status of Asterisk queues + +- MEDIUM Convert scripts to DBD::MySQL perl library in place of Net::MySQL. DBD::MySQL is faster because it uses the MySQL client libs on the machine. One problem is that you need the mysqlclientlibs installed on every +Asterisk server and the default installation of only the MySQL client libs will result in having to do a force install of cpan DBD::MySQL(because it tries to test with the local DB). Not to mention all of the code changes that would need to be made. There are also MySQL client licensing issues for certain installation circumstances(Net::MySQL doesn't use mysql client libs so it doesn't have those issues) but I really don't want to get into that discussion. + +- MEDIUM add ability to call CLOSER campaigns "BLEND" or "INBND". would require many script changes from server side to client side, not set in stone yet, but considering it. + +- MEDIUM add new method for capping the maximum number of attempts to try leads of a specific status. This would be set up like HotKeys are, per campaign where you would select the status and define the maximum number of attempts for that type of status for that campaign and the VDhopper wouldn't allow that kind of lead into the hopper if it was over the max value of call_count.(having filters reduced the priority of this item since you can do a lot of custom coding to duplicate this feature in vicidial_lead_filters) + +- MEDIUM add some kind of intelligent call-routing to astguiclient so that you can auto-forward calls to another extension from within astguiclient.php instead of using your phone or something like Queues which can mess up other things. This will need it's own table in the DB and probably some extensions.conf entries and an AGI script or two to do the actual call routing. + +- MEDIUM add a new script for using SoX to analyze the first 5 seconds of a ring-time recording within 15 minutes of the NA call ending and detecting if it has the SIT tone at the beginning of it so the lead can be taken out of the list as a DC + +- MEDIUM add skills-based routing to give the ability for a manager to set an agent at a higher or lower level per campaign or in-group. Defaults to level 0 possible values will be -9 through 9 + +- MEDIUM add all possible fields to the SCRIPT tab to auto-populate like in-group for inbound/closer, campaign and others + +- MEDIUM add ability to specify list_id in lead loader at time of picking fields + +- MEDIUM add ability upon vicidial.php login to take a number to dial as a password and a reserved word(something like MANUAL in all caps) that would allow the use of an EXTERNAL phone without setting it up as a aasterisk.phones entry. + +- MEDIUM rebuild the vdremote.php remote agents pages to use AJAX(PHP/Javascript/XMLHTTPRequest) for real-time popups of call data. + +- MEDIUM allow custom audio welcome message for vicidial campaigns. + +- MEDIUM change local_call_time to allow for variable time ranges instead of the presets that are available in the current version + +- MEDIUM create a cron script and method for creating new extensions in the sip.conf/iax.conf files as well as dialplan entries(extensions.conf). This will require more fields in the phones table to account for variables available to the protocols. The conf files would need to be altered before to have a flag for the beginning and ending of the auto-generated content. This would also necessitate a TEXT area for the extensions.conf content(that would be default generated but could be manually altered). The cron script would be run every 5 minutes or so to see if any phones had altered content, and if so generate new auto-content and do a 'reload' on the asterisk server to activate the new content. + +- MEDIUM add a count-up-timer to active channels on the astguiclient MAIN screen(this may be an Asterisk 1.2+ required feature). + +- MEDIUM Change VICIDIAL autodialing configuration to allow dialing of alt_phone numbers as well as address3 phone numbers after dialing main number. It is already possible to dial an alternate phone number manually as an agent once the customer info is up on the screen, but this would be doing it in an automated fashion. Best way for this may be to reconfigure the called_since_last_reset field to allow N, 1, 2, Y. This would require reprogramming several server scripts and php pages. + +- MEDIUM Try a few of the frequently launched scripts as C programs(call_log.agi and the AST_send child scripts) to see if they reduce system load and/or speed up those processes. + +- MEDIUM Change the autodialing system around so that there can be dialing-out-only servers and agent-only servers in a multi-server load-balanced environment. This is suprisingly simple to do, but would require all servers to be controlled by a single instance of AST_VDauto_dial.pl running on one machine. Also, in the case of IAX2 channel native transfers, we would need to change the AGI scripts that route the calls and create a new script to alter the vicidial_auto_calls records to the agent server call_server_ip and channel name because the call would disappear from the originating server causing "customer hungup" warnings. + +- MEDIUM Add method of picking up astGUIclient parked calls by only dialing digits on a regular extension without using the astGUIclient. + +- MEDIUM room manager documentation - manual. Probably a free text-only manual and a full color print book available for sale + +- MEDIUM admin/installer/maintainer documentation as well as troubleshooting guide + +- MEDIUM Run some lab-style load tests on VICIDIAL and show recommended configurations as well as "highest recommended" settings + + + +- LOW add the ability to run separate companies on the same VICIDIAL server. This will not be easy. All admin tasks as well asl user tasks and stats will need to have divisions so that nothing is accessible from the other groups. Also, the resources of the system(outbound trunks, hard drive space, other shared elements, etc...) so that one group cannot hog the shared resources of the the server. + +- LOW Making the server install script a customizable with installer prompts + +- LOW Create guidelines and suggestions for deactivating unused modules from Asterisk for astGUIclient users + +- LOW Revisit possibility of using something other than CallerIDname to tag a call process, probably a long shot without altering the Asterisk code, but that may be an option. + +- ON-HOLD We are also looking at creating an inbound-agent-specific GUI that would ideally work with Asterisk queues but that is not very likely given the current lack of events being given off by queues(this is much less likely to be built now that VICIDIAL takes inbound calls) + +- ON-HOLD add a way of checking that there is no more than 1 channel in the meetme room with the agent before another call to that agent. Currently this happens less than 0.1% of the time(mostly on heavily loaded systems), but another check might change that to zero. + +- ON-HOLD Localization of each server based on Intl. dial codes and/or country codes. very difficult to do this based on dial-codes, if used in other country, best to not use the adjust_gmt script. diff --git a/agc_2-X/trunk/docs/TODO_1.1.12.txt b/agc_2-X/trunk/docs/TODO_1.1.12.txt new file mode 100644 index 00000000..4408bbc7 --- /dev/null +++ b/agc_2-X/trunk/docs/TODO_1.1.12.txt @@ -0,0 +1,489 @@ ++------------------------------------------------------------------------------+ +| Asterisk GUI client - TODO v.1.1.12 | +| | +| TODO file is a list of what is new from previous version as well a list of | +| features that are planned to be completed for future releases. HIGH priority | +| items are usually going to be completed for the next release. This file is | +| kept updated on the project website by the developers and does not | +| necessarily reflect the status of features for the last release. If you are | +| reading this file from the release package, then it is accurate for the | +| version your downloaded. | ++------------------------------------------------------------------------------+ + +- DONE Fix several errors in the install script. moving -R to before +the chmod rwx settings. changing call_park_CID to park_CID. + +- DONE Added option to manual dialing to allow lookup of existing +vicidial_list lead by phone number. If found, would not insert a new lead. + +- DONE Add drop_call_seconds(TINYINT), safe_harbor_message(Y/N) and +safe_harbor_exten(VARCHAR) to the vicidial_campaigns table to allow for the +playing of the safe harbor message to outbound calls two seconds after customer +completes greeting(average of 5 seconds from call pickup[definable by the +safe_harbor_seconds variable]), also needs to be added to the +vicidial/admin.php. + +- DONE Modify all of the outbound AGI scripts to read the +drop_call_seconds and safe_harbor_ fields and use them for DROP timeout as well +as playing of the safe_harbor message if selected to do so. + +- DONE Add drop_call_seconds(SMALLINT), drop_message(Y/N) and +drop_exten(VARCHAR) to the vicidial_inbound_groups table to allow for the +playing of drop call message to inbound calls a set number of seconds after +customer calls in, also needs to be added to the vicidial/admin.php. + +- DONE Modify all of the inbound(and closer) AGI scripts to read the +drop_call_seconds and drop_ fields and use them for DROP timeout as well as +playing of the drop message if selected to do so. + +- DONE Fix agentonly_callback checkbox not-defined bug in scheduled +callbacks screen + +- DONE Fix alert message when transfer/conf is inactive for +vicidial_user and they go to disposition a call the warning shows up even if +they did not try to transfer/conf. + +- DONE Fix permissions issue in vicidial.php where +vicidial_campaigns.auto_dial_level=0 and vicidial_user.manual_dial=0 the manual +dial link still shows up. + +- DONE Fix recording filename display when the filename is longer than +the span supports. chop off the last few characters to make it fit should be +acceptable. If over 25 characters, it will chop off the end to 22 characters and +place ... at the end of the display filename. This does not effect the actualy +recording filename. + +- DONE Added AST_timeonVDADall_SIPmonitor.php from Angelito Manansala +that allows SIP listening of sessions through click on the campaign timeonVDAD +script. Added link from server_stats.php page as well. + +- DONE Add permissions to vicidial admin.php for admin interfaces to +restrict going into the call times and deleting the call times records: + +- DONE Add validation to only allow one state_call_times record per +state per call_times record + +- DONE Add method for disabling the showing of the +leads-able-to-be-dialed in the campaign screen of vicidial/admin.php. This will +help to reduce load time of the page and reduce load on the database for systems +with very large vicidial_list tables(several million records or more). This will +mean adding another field to the vicidial_campaigns table. Default is to display +the count. + +- DONE Add a popup link that would show the dialable leads count from +the campaigns screen if the dialable leads count has been hidden. + +- DONE Add link or form that would show the results and query of a +filter in the filter modification page without making it the active filter. + +- DONE Add state to the vicidial_hopper for compatibility with the new +local_call_times functions. + +- DONE Change local_call_time to allow for variable time ranges instead +of the presets that are available in the current version. Allow definitions by +days of the week as well as by state[state will be defined in another table and +referenced in a many-to-many relationship through the ct_state_call_times field +which will be pipe-delimited with a list of state_call_time_ids]. There would be +a default time scheme for all calls not covered by state. This will require +another new table and a new section under the vicidial/admin.php page. + +- DONE For the call_times and state_call_times include some presets for +records including several state restrictions on dialing hours and days in the +United States(USA). + +- DONE Fixed alt_number_dialing form element in admin.php campaign +screen + +- DONE Add wrapup_seconds and wrapup_message fields to +vicidial_campaigns along with a function to force a minimum wrapup time into +vicidial.php after an Agent hangs up a call. The timer would start when the +agent clicks on the HANGUP CUSTOMER button and if the agent dispositions the +call before the wrapup time is up then they would see a screen blanking out the +vicidial screen that would display the wrapup message until the timer ran out. +If the wrapup timer runs out before the agent is finished dispositioning a call, +nothing would happen, so the agent would not be able to move on to the next call +until they selected a disposition. Wrapup time would not be in effect if the +Agent uses HotKeys. + +- DONE Change all vicidial stats and reports scripts to use UTF-8 +instead of latin-english for multi-language support + +- DONE Fix admin pages SQL errors(vicidial campaign when no active +lists present and astguiclient phone searches) + +- DONE Rewrite the multi-language translations to use one file per +language and to allow translation to be done on a single file at a time. +es_language.txt and es_language_admin.txt would be the files used for Spanish. +Also, the order of the translated lines in the files would be unimportant +because the translation script would order the phrases by character length to +ensure that larger phrases that could contain parts of smaller phrases would be +translated correctly, this allows for comments to be placed in-line with new +sections of phrases for newer versions making it easier to find new un-verified +translations sections and submit changes to translations files. + +- DONE Create a table that will keep a current statistics cache for +items like drop count and percentages per campaign per day(and for the future: +last 1 minute/5 minutes/30 minutes) and dialable leads counts. + +- DONE Add number of leads in hopper, link to admin.php campaign modify +screen(and link from admin to this screen) and hopper and leads stats as well as +drops and drop percentage to the AST_timeonVDADall page. + +- DONE Convert the AST_VDhopper.pl script to DBD::MySQL perl library in +place of Net::MySQL. DBD::MySQL is faster because it uses the MySQL client libs +on the machine. One problem is that you need the mysqlclientlibs installed on +every Asterisk server and the default installation of only the MySQL client libs +will result in having to do a force install of cpan DBD::MySQL(because it tries +to test with the local DB). Not to mention all of the code changes that would +need to be made. There are also MySQL client licensing issues for certain +installation circumstances(Net::MySQL doesn't use mysql client libs so it +doesn't have those issues) but I really don't want to get into that discussion. +The reason for this change is that Net::MySQL is limiting in the capacity of the +queries that you can use because of how it's connection to MySQL is used. DBI +doesn't have those issues and is much better supported. This is the first script +to be converted to DBI, you can find the Net::MySQL version in the main +directory and the DBI(DBD::mysql) version in the new DBI-scripts directory. + +- DONE Test and package app_conference for beta usage with VICIDIAL as +a meetme replacement. This has many performance benefits including not having to +use a zaptel timer. Packaged and released on the project site. Tested in medium +to low capacity VICIDIAL server, some random infrequent bugs. In contact with +app_conference developers working on stabilizing code. Added instructions to +SCRATCH_INSTALL on how to get app_conferenc working with VICIDIAL. + +- DONE Add a link from the campaign-based reports pages to go back to +the campaign screen. + +- DONE Create a script to grab the login time stats from +vicidial_agent_log and create a day-by-day timesheet log each week +AST_agent_week.pl script. Add script to the cron instructions in SCRATCH_INSTALL +doc. + +- DONE Fix issues with ast_VDauto_dial script when you have two CLOSER +campaigns in Blended mode dialing at the same time. To fix this we need to +change many things in how the CLOSER campaigns work. We need to add a new field +to the vicidial_auto_calls table to denote whether the call is from inbound or +outbound(call_type ENUM('IN','OUT') default 'OUT'). For each CLOSER campaign, a +special field needs to be added to vicidial_campaigns for allowable inbound +groups. This will change what in-groups an agent logging into the campaign can +select from as well as changing how the auto_dial script calculates how many +calls to place on CLOSER campaigns in blended mode. the vicidial.php script +needs to be changed as well as several changes in the admin.php script. The +AST_VDauto_dial.pl script needs to be changed as well as all of the +agi-VDAD....closer.agi scripts. + +- DONE Fix active calls stats for multiple CLOSER campaigns in Realtime +Campaign screen. + +- DONE Add internal DNC list of phone numbers(vicidial_dnc table) that +would be scrubbed against by the AST_VDhopper.pl script while putting leads into +the hopper to be dialed and it would kick the internal DNC matches out with a +special status as DNCL(Do-Not-Call-Load) so they would be in the system but +unable to be dialed. Would need to add a mechanism to add a lead to this list +upon agent-dispo of a call as DNC within vicidial.php. Would need to create a +new admin page section to manually add leads to DNC list, ADD TO DNC link in the +LISTS section. Also, would add a parameter to +vicidial_campaigns(dnc_list_enabled ENUM('Y','N')) where a campaign could be +exempted from the system's DNC list restrictions if set to N(would not be active +by default 'N'). + +- DONE Add option for PRI T1 system usage with VICIDIAL outbound to +automatically grab Busy and Disconnect information from PRI call termincation +codes and use those for NA dispositions. VD_hangup.agi and AST_VDauto_dial.pl +modified. + +- DONE Remove gmt time validation of leads from AST_VDauto-dial because +AST_VDhopper already removes leads that are outside of the appropriate range of +GMT offsets when it is run every minute. Removing this redundancy should speed +up the dialing slightly. + +- DONE Fix VD_hangup to work with CLOSER transfer-from-fronter calls, +different log contents than from CLOSER inbound call. + +- DONE Add option for disposition-based lead recycling on an automated +and timed basis per campaign. It will be some sort of method to be able to +auto-insert Busy/Ring-no-answer/other-NA calls back into the hopper after a +certain timeout. there will be a minimum of 120 seconds before the lead will be +allowed to go back into the hopper and a lead can only go back into the hopper a +maximum of 10 times before the list would need to be reset. The +vicidial_list.called_since_last_reset field needs to be altered to allow for +counting of recycle attempts. All scripts need to be able to keep the state of +call_since_last_reset. A new table: vicidial_lead_recycle that will function +somewhat like HotKeys on the campaign screen. admin.php and AST_VDhopper.pl will +need to be modified. + +- DONE Change ADMIN_area_code_populate.pl script to ignore the header +row of the phone codes gmt file DB import + +- DONE Add database GMT lookup to the VICIDIAL_IN_new_leads_file.pl +lead loader lead import process. + +- DONE Change ADMIN_adjust_GMTnow_on_leads.pl script to use database +instead of flat text file. + +- DONE Fix display issues with LIST MODIFY page on admin.php for +statuses because of lead recycling and with GMT offset for positive GMT offsets. + +- DONE Add listID override feature to the VICIDIAL_IN_new_leads_file.pl +lead loader lead import process to force all leads being loaded into the same +list_id. + +- DONE Add listID override feature to the basic web-based lead loader +lead import process to force all leads being loaded into the same list_id. + +- DONE Add database GMT lookup to the basic web-based lead loader lead +import process. + +- DONE Add listID override feature to the super web-based lead loader +lead import process to force all leads being loaded into the same list_id. + +- DONE Add database GMT lookup to the super web-based lead loader lead +import process. This one is more difficult because of the many scripts and +sections used to parse and insert leads for the different formats and field +orders: listloader_super.pl, listloader.pl, new_listloader_superL.php + +- DONE standardize the query results variable in PHP scripts to $rslt. + +- DONE SECURITY FIX, filter all variables relating to SQL queries in +agc scripts(vicidial.php, astguiclient.php, etc...) This is for a SQL injection +vulnerability where a malicious user puts SQL fragments into a variable field in +order to manipulate or destroy the database. + +- DONE SECURITY FIX, filter all variables relating to SQL queries in +admin scripts(vicidial and astguiclient folders, admin.php, etc...) + +- DONE Change the admin_search_lead page to include multiple results. + +- DONE Add an AGI script to record audio for prompts with an 8-digit +filename that can be played by dialing the 8 digit filename. 85100001-85199999. +The AGI script would announce beginning of recording and to press pound when +done recording, then would say thank-you and announce the filename of the +recording. The recordings would be saved in GSM format and can be used in any of +the fields within VICIDIAL that call for a message exten like the survey script. +agi-record_prompts.agi script created. + +- DONE Add link from reports pages back to main reports page. + +- DONE fix MySQL errors on campaign modify and leads modify pages for +dialable leads when no active lists for campaign lists. + +- DONE Fix call_log entries for Zap client phones where call +information is in different places than if calls are placed from SIP or IAX +client phones. call_log and call_logCID AGI scripts. + +- DONE Finish rough German Admin pages translations + + + + + + + + + + +- MEDIUM add option to disable detailed logging for VICIDIAL and +astGUIclient server apps. + +- MEDIUM add new ALLFORCE to recording method for campaigns. will force +recording of all calls and disable the button for agents no matter their +vicidial_users setting. + +- MEDIUM add a basic predictive/adaptive algorithm to VICIDIAL to +automatically speed-up and slow-down dialing by altering the dial_level at +regular intervals. Would need more settings in the vicidial_campaigns table for +adaptive like maximum lines per agent, dropped call ratio, dropped call rule to +guide the predictive app. Would also need to change dial_level to be a DOUBLE or +VARCHAR field to allow for different fractional increments. The admin.php page +would have to be altered to ignore auto_dial_level changes when adaptive dialing +is activated. The minimum dial_level would be set to '1' for adaptive dialing + auto_dial_level VARCHAR(6), # allow for just about anything. +precision decimal too + adaptive_dial_level ENUM('Y','N'), # turns on adaptive script and +prevents dial_level admin changes + adaptive_maximum_level VARCHAR(6), # sets highest dial_level +possible by adaptive app + adaptive_dropped_percentage SMALLINT(3), # percentage of +accaptable dropped calls + adaptive_dropped_rule ENUM('HARD_LIMIT','TAPERED','AVERAGE'), # method +for adhearing to % limit + +- MEDIUM room manager documentation - manual. Probably a free 2 chapter +black and white manual and a full color print download available for sale. + +- MEDIUM Rewrite the inbound and closer call handling to allow for music +on hold per in-group and a single queue app instead of multiple AGIs each +running their own queries. Currently with large queues and long wait times a lot +of load is generated with calls on hold in the queue. Switching to a central +queue application would reduce the load and speed things up. + +- MEDIUM Add optional field to phones table to allow for different +recording file names in astguiclient.php, Similar to vicidial options. + +- MEDIUM make 3rd party consultative transfers work for Local extensions, +also for internal/local transfer to vicidial closers if possible. + +- MEDIUM Attempt to make some kind of holiday schedule function for +national and state holidays that would be able block out states on specific +no-call days. This is rather difficult because of the way some holidays are +scheduled, I.E. Easter. + +- MEDIUM Add ChanSpy functionality to listen-in on VOIP channels in +astguiclient.php. Maybe not since Chanspy can cause problems like crashing the +Asterisk server. Need to do more testing. + +- MEDIUM Create a script to allow vicidial agents to dial into an AGI +script that would ask for user/pass and then place them onto their +vicidial.php-defined sessionid. + +- MEDIUM add link in astguiclient to login and logout from Asterisk +Queues + +- MEDIUM add script to get "show queues" information and place in a DB +table to be used to see who is in an Asterisk Queue. This would mostly be used +to give a LOGGED-IN and LOGGED-OUT display for astguiclient.php and possibly add +an Asterisk Queue display tab or popup for astguiclient.php. Info would be +updated one to four times a minute so it would not be real-time. + +- MEDIUM add new tab to astguiclient.php script to show status of +Asterisk queues + +- MEDIUM Convert all scripts to DBD::MySQL perl library in place of +Net::MySQL. DBD::MySQL is faster because it uses the MySQL client libs on the +machine. One problem is that you need the mysqlclientlibs installed on every +Asterisk server and the default installation of only the MySQL client libs will +result in having to do a force install of cpan DBD::MySQL(because it tries to +test with the local DB). Not to mention all of the code changes that would need +to be made. There are also MySQL client licensing issues for certain +installation circumstances(Net::MySQL doesn't use mysql client libs so it +doesn't have those issues) but I really don't want to get into that discussion. +We will start by converting at least one perl script for each release until we +have converted then all, then we will no longer support Net::MySQL. This will +probably take some time, but the scripts that are added to the DBI-scripts +folder will be drop-in replacements for the Net versions that are installed by +default. + +- MEDIUM Create a visual SQL builder for the filter SQL section. + +- MEDIUM add ability to call CLOSER campaigns "BLEND" or "INBND". would +require many script changes from server side to client side, not set in stone +yet, but considering it. + +- MEDIUM add some kind of intelligent call-routing to astguiclient so +that you can auto-forward calls to another extension from within +astguiclient.php instead of using your phone or something like Queues which can +mess up other things. This will need it's own table in the DB and probably some +extensions.conf entries and an AGI script or two to do the actual call routing. + +- MEDIUM add skills-based routing to give the ability for a manager to +set an agent at a higher or lower level per campaign or in-group. Defaults to +level 0 possible values will be -9 through 9 + +- MEDIUM add all possible fields to the SCRIPT tab to auto-populate like +in-group for inbound/closer, campaign and others + +- MEDIUM add ability to scrub leads being imported in the lead loader +against the vicidial_dnc list as they are being imported. + +- MEDIUM add ability upon vicidial.php login to take a number to dial as +a password and a reserved word(something like MANUAL in all caps) that would +allow the use of an EXTERNAL phone without setting it up as an asterisk.phones +entry. + +- MEDIUM rebuild the vdremote.php remote agents pages to use +AJAX(PHP/Javascript/XMLHTTPRequest) for real-time popups of call data. + +- MEDIUM allow custom audio welcome message for vicidial campaigns. This +might be an app_conference only feature. + +- MEDIUM create a cron script and method for creating new extensions in +the sip.conf/iax.conf files as well as dialplan entries(extensions.conf). This +will require more fields in the phones table to account for variables available +to the protocols. The conf files would need to be altered before to have a flag +for the beginning and ending of the auto-generated content. This would also +necessitate a TEXT area for the extensions.conf content(that would be default +generated but could be manually altered). The cron script would be run every 5 +minutes or so to see if any phones had altered content, and if so generate new +auto-content and do a 'reload' on the asterisk server to activate the new +content. + +- MEDIUM add a count-up-timer to active channels on the astguiclient MAIN +screen(this may be an Asterisk 1.2+ required feature). + +- MEDIUM Change VICIDIAL autodialing configuration to allow dialing of +alt_phone numbers as well as address3 phone numbers after dialing main number. +It is already possible to dial an alternate phone number manually as an agent +once the customer info is up on the screen, but this would be doing it in an +automated fashion. Best way for this may be to reconfigure the +called_since_last_reset field to allow N, 1, 2, Y. This would require +reprogramming several server scripts and php pages. + +- MEDIUM Try a few of the frequently launched scripts as C +programs(call_log.agi and the AST_send child scripts) to see if they reduce +system load and/or speed up those processes. + +- MEDIUM Change the autodialing system around so that there can be +dialing-out-only servers and agent-only servers in a multi-server load-balanced +environment. This is suprisingly simple to do, but would require all servers to +be controlled by a single instance of AST_VDauto_dial.pl running on one machine. +Also, in the case of IAX2 channel native transfers, we would need to change the +AGI scripts that route the calls and create a new script to alter the +vicidial_auto_calls records to the agent server call_server_ip and channel name +because the call would disappear from the originating server causing "customer +hungup" warnings. + +- MEDIUM Add method of picking up astGUIclient parked calls by only +dialing digits on a regular extension without using the astGUIclient. + +- MEDIUM admin/installer/maintainer documentation as well as +troubleshooting guide + +- MEDIUM Run some lab-style load tests on VICIDIAL and show recommended +configurations as well as "highest recommended" settings + + + +- LOW add the ability to run separate companies on the same VICIDIAL +server. This will not be easy. All admin tasks as well asl user tasks and stats +will need to have divisions so that nothing is accessible from the other groups. +Also, the resources of the system(outbound trunks, hard drive space, other +shared elements, etc...) so that one group cannot hog the shared resources of +the the server. + +- LOW Making the server install script a customizable with installer +prompts + +- LOW Create guidelines and suggestions for deactivating unused +modules from Asterisk for astGUIclient users + +- LOW Revisit possibility of using something other than CallerIDname +to tag a call process, probably a long shot without altering the Asterisk code, +but that may be an option. + +- LOW add new method for capping the maximum number of attempts to try +leads of a specific status. This would be set up like HotKeys are, per campaign +where you would select the status and define the maximum number of attempts for +that type of status for that campaign and the VDhopper wouldn't allow that kind +of lead into the hopper if it was over the max value of call_count.(having +filters reduced the priority of this item since you can do a lot of custom +coding to duplicate this feature in vicidial_lead_filters) + +- LOW add a new script for using SoX to analyze the first 5 seconds of +a ring-time recording within 15 minutes of the NA call ending and detecting if +it has the SIT tone at the beginning of it so the lead can be taken out of the +list as a DC. adding PRI hangup codes has reduced priority for this item. + +- ON-HOLD We are also looking at creating an inbound-agent-specific GUI +that would ideally work with Asterisk queues but that is not very likely given +the current lack of events being given off by queues(this is much less likely to +be built now that VICIDIAL takes inbound calls) + +- ON-HOLD add a way of checking that there is no more than 1 channel in +the meetme room with the agent before another call to that agent. Currently this +happens less than 0.1% of the time(mostly on heavily loaded systems), but +another check might change that to zero. + +- ON-HOLD Localization of each server based on Intl. dial codes and/or +country codes. very difficult to do this based on dial-codes, if used in other +country, best to not use the adjust_gmt script. + diff --git a/agc_2-X/trunk/docs/VICIDIAL.txt b/agc_2-X/trunk/docs/VICIDIAL.txt new file mode 100644 index 00000000..9882ac6d --- /dev/null +++ b/agc_2-X/trunk/docs/VICIDIAL.txt @@ -0,0 +1,185 @@ +# pronounced (VEE-CHEE DIAL) + +This system was initially created to fill the need of a customer service group +being able to call up clients efficiently and without using a predictive dialer +that would potentially lose calls and alienate clients. Since then we have added +the ability to do limited predictive dialing alongside the traditional +one-call-at-a-time dialing as well as the ability to take inbound calls and set +up campaigns to do blended inbound and outbound at the same time. + +Features: +- Ability for an agent to call clients in succession from a database through a web-client +- Ability to display a script for the agent to read with fields like name, address, etc. filled-in +- Ability to set a campaign to auto-dial and send live calls to available agents +- Ability to dial on a single campaign across multiple Asterisk servers, or multiple campaigns on a single server +- All calls are logged and statuses of calls are logged as well as agent time breakdowns +- Ability to transfer calls with customer data to a closer on the local system or a remote Asterisk server +- Ability to open a custom web page with user data from the call per campaign +- Ability to autodial campaigns to start with a simple IVR then direct to agent +- Ability to park the customer with custom music per campaign +- Ability to send a dropped call to a voicemail box per campaign if no agent is available +- Ability to set outbound CallerID per campaign +- Ability to take inbound calls grabbing CallerID +- Ability to function as an ACD for inbound and closer calls +- Ability to have an agent take both inbound and outbound calls in one session(blended) +- Ability for agents to log in remotely and have calls redirected to any phone number +- Ability to start and stop recording an agent's calls at any time +- Ability to automatically record all calls +- Ability to call upto two other customer numbers for the same lead +- Ability to schedule a callback with a customer as either any agent or agent specific +- Faster dispositioning of calls with agent key-binding (HotKeys) +- Ability to add custom call dispositions per campaign +- Dialing with custom TimeZone restrictions including per state and per weekday +- Dialing with Answering Machine Detection, also playing a message for AM calls +- Ability in Manual dial mode to preview leads before dialing +- Ability for agents to be logged in remotely anywhere with just a phone and a web browser +- Multiple campaigns and lead-lists are possible +- Recycling of Busy calls at a specified interval without resetting a list +- Ability to use custom database queries in campaign dialing +- Option of a drop timer with safe-harbor message for FTC compliance +- Internal DNC list can optionally be activated per campaign +- Definable Wrapup-time per campaign +- Load Balancing across multiple inbound or outbound Asterisk servers is possible +- Several real-time and summary reports available +- Real-time campaign display screens +- 3rd party conferencing(with DTMF macros and number presets) +- 3rd party blind call transfer +- 3rd party conferencing with agent drop-off +- Ability to set user levels and permissions for certain features +- Ability for managers to listen-in on agent conversations +- Ability for managers to enter conversations with agents and customers +- Each user has their own login +- Web-based administration +- Client web-app and admin web pages available in English, Spanish, Greek and German +- Client web-app web pages available in English, Spanish, Greek, German, French, Italian, Portuguese and Brazillian Portuguese +- Admin web pages available in English, Spanish, Greek and German + +Required components: +- Asterisk server with Zap, IAX2 or SIP trunks +- SIP/IAX/Zap phones(hard or soft single-line or multiple) +- Computer with proper software installed + - on Win32 Activestate perl + - on UNIX Xwindows Activestate perl recommended with perlTK libs loaded +- Asterisk server with proper software installed +- astGUIclient must be installed with the Asterisk Central Queue System(ACQS) +running + +Approach: +This system is dependant on a MySQL server acting as the storage place of +all data and settings for the system. This was done so that it would be very +scalable and flexible. This application draws on a lot of the core scripting +inside of the astGUIclient suite of applications and was built with flexibility +in mind. We have used VICIDIAL for over nine months now on up to 70 seats at +once across 4 separate Asterisk servers all using the same MySQL server and +dialing on the same campaign. It is important to keep in mind that because +VICIDIAL uses Asterisk meetme rooms for it's dialing that the Asterisk server +will see an increased load as compared to a simple Zap/SIP-only calls. + +Installation: +Look at the INSTALL FROM SCRATCH documentation and start at phase 6 if you +already have asterisk running + +Process flow of a one-call-at-a-time call: + - all components are installed and running(with Asterisk and MySQL servers) + - user logs in to the client GUI [user/password/campaign] + - GUI assigns an open meetme extension to the user, this is called the +session_id + - GUI sends manager command ORIGINATE to connect the user to the meetme ext + - user clicks DIAL NEXT NUMBER and GUI UPDATEs first available number-to-call +in DB to PENDING status + - GUI SELECTs info on that number[name/address/...] + - GUI sends ORIGINATE command to call that client's number from meetme ext + - user is talking to the client + - user transfers call to 3rd party, client Zap channel is REDIRECTed to +3rd party + or + - User transfers client to a closer to finish the call + or + - user puts client on park and dials 3rd party, then transfers client +back to meetme room + - Call is Hung up + - user hangs up call and clicks HANGUP CALL on GUI + or + - person called hangs up so user clicks on the CALL HUNGUP then HANGUP +CALL + - call is disconnected + - user selects disposition status of the call and clicks OK + - goes back to step 4 and repeats + +Process flow of an auto-dial call: + - The lead hopper app(AST_VDhopper.pl) that is running every minute keeps the +hopper for each campaign up to at least the minimum hopper lead size providing +there are enough leads to fill it. + - The call center manager can either set the auto_dial_level (on the campaign +screen of the admin web page) to 0(zero) for no autodialing or any other choice +for a different number of lines-per-agent-logged-in. + - As soon as an agent logs into a campaign, the client app will look at the +auto_dial_level setting of the campaign and determine whether + - it will insert a record into the vicidial_live_agents table(and set +status to READY) and update that record every second with a random 8 +digit number to show that the client is still alive and ready. Also, +the client app will show a "pause" and "resume" button to start or stop +receiving calls automatically instead of the usual "dial next number" +button. + or + - it will allow normal manual dialing operation + - The auto_dial app(AST_VDauto_dial.pl) will: + - count how many agents are READY,QUEUE,INCALL with updated +last_update_time in the last 5 seconds + - look at the campaign's auto_dial_level to determine how many calls +should be placed each specific campaign on each server. + - update the vicidial_auto_calls records by searching for active +callerids in the vicidial_manager to see if they have hung up + - count the number of active calls that are +occuring(vicidial_auto_calls records with a status of SENT,RINGING or +LIVE) + - place the calls for each server if the active calls is less than the +total that should be placed + - The auto_dial app will then: + - grab the next lead to be called from the vicidial_hopper for each +campaign(it will update that lead record in the vicidial_hopper table +to QUEUE with VDAD as the user) + - grab the lead information from vicidial_list and update +called_since_last_reset Y, the user to VDAD and increment the +called_count by 1 + - delete the record from vicidial_hopper for that lead + - place the call first to the Zap trunk(Exten: 917275551212), then to a +specified Local extension number(Channel: Local/99999@default) where +the auto_dial_transfer_agent app(agi-VDADtransfer.agi) is waiting to +take over. + - if the call is busy, disconnect or telco voicemail the call is never +technically picked up so it never makes it to the +auto_dial_transfer_agent app + - check for dead calls by looking in the call_log for and end time of +the call keyed by callerID(caller_code) and delete them t=from the +vicidial_auto_calls table + - The auto_dial_transfer_agent app takes the call and: + - immediately grabs the uniqueid and callerid of the call and updates +the vicidial_auto_calls record to LIVE + - logs the call to vicidial_log using the callerid to find out the lead +number(VmmddhhmmssLLLLLLLLL[where LLLLLLLLL is the zero-padded lead_id +from vicidial_list]) + - inserts the number_dialed and the caller_code in the vicidial_log +table for the uniqueid record of the call + - attempts to update(limit 1) a record in the vicidial_live_agents +table to see who is the next agent to receive a call(ordered by +last_call_time)[update the status to QUEUE, the lead_id to the proper +lead_id and the uniqueid and callerID to proper values for the call] + - if there are agents available[affected rows = 1](goto substep VII.) + - if there are no agents available: + - wait in 1 second increments and then checking substep IV. + - if no agent is available for 1 minute, the call is hung up +and logged as ABANDN in vicidial_log under user VDAD + - grabs the agent info from the vicidial_live_agents[conf_exten] and +does a redirect to the agent's meetme room. + - agent's app checks the vicidial_live_agents record every second for +itself to see if it is changed to QUEUE + - agent's app changes the vicidial_live_agents status to INCALL and +updates the vicidial_list record to INCALL and user to the agent's +userID and the call progresses normally + - The agent hangs up and the vicidial_live_agents record is changed back to +READY with the lead and call fields cleared out so the agent is ready to take +another call + + + diff --git a/agc_2-X/trunk/install_server_files.pl b/agc_2-X/trunk/install_server_files.pl new file mode 100644 index 00000000..580dfdde --- /dev/null +++ b/agc_2-X/trunk/install_server_files.pl @@ -0,0 +1,510 @@ +#!/usr/bin/perl + +# install_server_files.pl +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +############################################ +# install_server_files.pl - puts server files in the right places +# +# modify the variables below to customize for your system. +# +# path to home directory: (assumes it already exists) +$home = '/home/cron'; + +# path to agi-bin directory: (assumes it already exists) +$agibin = '/var/lib/asterisk/agi-bin'; + +# path to web root directory: (assumes it already exists) +#$webroot = '/var/www/html'; +#$webroot = '/home/www/htdocs'; +$webroot = '/usr/local/apache2/htdocs'; + +# path to asterisk sounds directory: (assumes it already exists) +$sounds = '/var/lib/asterisk/sounds'; + +# path to asterisk recordings directory: (assumes it already exists) +$monitor = '/var/spool/asterisk'; + +############################################ + +$secX = time(); + +# constants +$DB=1; # Debug flag, set to 0 for no debug messages, lots of output +$US='_'; +$MT[0]=''; +$language_admin_file = 'language_admin.txt'; +$language_file = 'language.txt'; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n[--admin-only] = only translate admin pages\n[--client-only] = only translate client pages\n[--without-en] = only translate non-english\n[--language=] = which language to build, 2 letter code, defaults to es-spanish\n\n"; + + exit; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--language/i) + { + $LANG=1; + print "\n----- LANGUAGE WEB SCRIPT ONLY BUILD -----\n\n"; + } + if ($args =~ /--language=/i) + { + @data_in = split(/--language=/,$args); + $CLIlanguage = $data_in[1]; + } + else + {$CLIlanguage = 'es';} # default to build all languages + if ($args =~ /-admin-only/i) + { + $admin_only=1; # Admin flag + print "\n----- ADMIN PAGES ONLY BUILD -----\n\n"; + } + if ($args =~ /-client-only/i) + { + $client_only=1; # Client flag + print "\n----- CLIENT PAGES ONLY BUILD -----\n\n"; + } + if ($args =~ /-without-en/i) + { + print "\n----- NON-ENGLISH ONLY BUILD -----\n\n"; + $without_en=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### end parsing run-time options ### + + +if ($LANG) +{ +if ( (!$admin_only) && (!$client_only) ) + {$admin_only=1; $client_only=1;} + +if ($admin_only==1) + { + print "\n----- LANGUAGE BUILD: $CLIlanguage -----\n\n"; + $LANG_FILE_ADMIN = "./translations/$CLIlanguage$US$language_admin_file"; + open(lang, "$LANG_FILE_ADMIN") || die "can't open $LANG_FILE_ADMIN: $!\n"; + @lang = ; + close(lang); + &translate_pages; + } + +@lang=@MT; +@LANGUAGES=@MT; +@FILES=@MT; +@TRANSLATIONS=@MT; +@TRANSLATIONS_RAW=@MT; + +if ($client_only==1) + { + $LANG_FILE = "./translations/$CLIlanguage$US$language_file"; + open(lang, "$LANG_FILE") || die "can't open $LANG_FILE: $!\n"; + @lang = ; + close(lang); + &translate_pages; + } +} + +else +{ +print "INSTALLING SERVER SIDE COMPONENTS...\n"; + +print "Creating cron/LOGS directory...\n"; +`mkdir $home/LOGS/`; + +print "setting LOGS directory to executable...\n"; +`chmod 0766 $home/LOGS`; + +print "Creating $home/VICIDIAL/LEADS_IN/DONE directory...\n"; +`mkdir $home/VICIDIAL`; +`mkdir $home/VICIDIAL/LEADS_IN`; +`mkdir $home/VICIDIAL/LEADS_IN/DONE`; +`chmod -R 0766 $home/VICIDIAL`; + +print "Creating $monitor directories...\n"; +`mkdir $monitor/monitor`; +`mkdir $monitor/monitor/ORIG`; +`mkdir $monitor/monitor/DONE`; +`chmod -R 0766 $monitor/monitor`; + +print "Copying cron scripts...\n"; +`cp -f ./ADMIN_adjust_GMTnow_on_leads.pl $home/`; +`cp -f ./ADMIN_area_code_populate.pl $home/`; +`cp -f ./ADMIN_keepalive_AST_send_listen.pl $home/`; +`cp -f ./ADMIN_keepalive_send_listen.at $home/`; +`cp -f ./ADMIN_keepalive_AST_update.pl $home/`; +`cp -f ./ADMIN_keepalive_AST_VDautodial.pl $home/`; +`cp -f ./ADMIN_keepalive_AST_VDremote_agents.pl $home/`; +`cp -f ./ADMIN_restart_roll_logs.pl $home/`; +`cp -f ./AST_agent_week.pl $home/`; +`cp -f ./AST_cleanup_agent_log.pl $home/`; +`cp -f ./AST_conf_update.pl $home/`; +`cp -f ./AST_CRON_mix_recordings.pl $home/`; +`cp -f ./AST_CRON_mix_recordings_BASIC.pl $home/`; +`cp -f ./AST_CRON_mix_recordings_GSM.pl $home/`; +`cp -f ./AST_DB_optimize.pl $home/`; +`cp -f ./AST_flush_DBqueue.pl $home/`; +`cp -f ./AST_manager_kill_hung_congested.pl $home/`; +`cp -f ./AST_manager_listen.pl $home/`; +`cp -f ./AST_manager_send.pl $home/`; +`cp -f ./AST_reset_mysql_vars.pl $home/`; +`cp -f ./AST_send_action_child.pl $home/`; +`cp -f ./AST_SERVER_conf.pl $home/`; +`cp -f ./AST_update.pl $home/`; +`cp -f ./AST_VDauto_dial.pl $home/`; +`cp -f ./AST_VDhopper.pl $home/`; +`cp -f ./AST_VDremote_agents.pl $home/`; +`cp -f ./AST_vm_update.pl $home/`; +`cp -f ./phone_codes_GMT.txt $home/`; +`cp -f ./start_asterisk_boot.pl $home/`; +`cp -f ./VICIDIAL_IN_new_leads_file.pl $home/`; +`cp -f ./test_VICIDIAL_lead_file.txt $home/VICIDIAL/LEADS_IN/`; + + +print "setting cron scripts to executable...\n"; +`chmod 0755 $home/*`; + +print "Copying agi-bin scripts...\n"; +`cp -f ./agi-dtmf.agi $agibin/`; +`cp -f ./agi-record_prompts.agi $agibin/`; +`cp -f ./agi-VDAD_LB_closer.agi $agibin/`; +`cp -f ./agi-VDAD_LB_closer_inbound.agi $agibin/`; +`cp -f ./agi-VDAD_LB_transfer.agi $agibin/`; +`cp -f ./agi-VDAD_LO_closer.agi $agibin/`; +`cp -f ./agi-VDAD_LO_closer_inbound.agi $agibin/`; +`cp -f ./agi-VDAD_LO_transfer.agi $agibin/`; +`cp -f ./agi-VDADautoREMINDER.agi $agibin/`; +`cp -f ./agi-VDADautoREMINDERxfer.agi $agibin/`; +`cp -f ./agi-VDADcloser.agi $agibin/`; +`cp -f ./agi-VDADcloser_inbound.agi $agibin/`; +`cp -f ./agi-VDADcloser_inbound_5ID.agi $agibin/`; +`cp -f ./agi-VDADcloser_inbound_NOCID.agi $agibin/`; +`cp -f ./agi-VDADcloser_inboundANI.agi $agibin/`; +`cp -f ./agi-VDADcloser_inboundCID.agi $agibin/`; +`cp -f ./agi-VDADcloser_inboundCIDlookup.agi $agibin/`; +`cp -f ./agi-VDADcloser_PHONE.agi $agibin/`; +`cp -f ./agi-VDADtransfer.agi $agibin/`; +`cp -f ./agi-VDADtransferSURVEY.agi $agibin/`; +`cp -f ./call_inbound.agi $agibin/`; +`cp -f ./call_log.agi $agibin/`; +`cp -f ./call_logCID.agi $agibin/`; +`cp -f ./call_park.agi $agibin/`; +`cp -f ./call_park_EXT.agi $agibin/`; +`cp -f ./call_park_I.agi $agibin/`; +`cp -f ./call_park_L.agi $agibin/`; +`cp -f ./call_park_W.agi $agibin/`; +`cp -f ./debug_speak.agi $agibin/`; +`cp -f ./invalid_speak.agi $agibin/`; +`cp -f ./park_CID.agi $agibin/`; +`cp -f ./VD_amd.agi $agibin/`; +`cp -f ./VD_amd_post.agi $agibin/`; +`cp -f ./VD_hangup.agi $agibin/`; + + +print "setting agi-bin scripts to executable...\n"; +`chmod 0755 $agibin/*`; + +print "Copying sounds...\n"; +`cp -f ./DTMF_sounds/* $sounds/`; + +print "Creating vicidial web directory...\n"; +`mkdir $webroot/vicidial/`; +`mkdir $webroot/vicidial/ploticus/`; +`mkdir $webroot/vicidial/agent_reports/`; + +print "Copying VICIDIALweb php files...\n"; +`cp -f ./VICIDIAL_web/* $webroot/vicidial/`; + +print "setting VICIDIALweb scripts to executable...\n"; +`chmod -R 0755 $webroot/vicidial/`; +`chmod 0777 $webroot/vicidial/`; +`chmod 0777 $webroot/vicidial/ploticus/`; +`chmod 0777 $webroot/vicidial/agent_reports/`; + +print "Creating agc web directory...\n"; +`mkdir $webroot/agc/`; + +print "Copying agc php files...\n"; +`cp -R -f ./agc/* $webroot/agc/`; + +print "setting agc scripts to executable...\n"; +`chmod -R 0755 $webroot/agc/`; +`chmod 0777 $webroot/agc/`; + +print "Creating astguiclient web directory...\n"; +`mkdir $webroot/astguiclient/`; + +print "Copying astguiclient web php files...\n"; +`cp -f ./astguiclient_web/* $webroot/astguiclient/`; + +print "setting astguiclient web scripts to executable...\n"; +`chmod -R 0755 $webroot/astguiclient/`; +`chmod 0777 $webroot/astguiclient/`; + +} + + + +$secy = time(); $secz = ($secy - $secX); $minz = ($secz/60); # calculate script runtime so far +print "\n - process runtime ($secz sec) ($minz minutes)\n"; +print "\n\nDONE and EXITING\n"; + + +exit; + + + +sub translate_pages +{ +#***LANGUAGES*** +#en-English|es-Espaol| +#***FILES*** +#agc/astguiclient.php +#agc/vicidial.php +#***TRANSLATIONS*** +#English|Ingls| +#Spanish|Espaol| + +##### PARSE THE LANGUAGES SETTING FILE ##### +$section=''; +$i=0; +$Lct=0; $Fct=0; $Tct=0; +foreach(@lang) + { + if ($lang[$i] !~ /^\#/) + { + if ($lang[$i] =~ /^\*\*\*/) + { + $section = $lang[$i]; + $section =~ s/\*|\n|\r//gi; + # print "section heading: $section: $lang[$i]"; + } + else + { + if ($section =~ /LANGUAGES/) + { + $LANGUAGES = $lang[$i]; + $Lct++; + } + else + { + if ($section =~ /FILES/) + { + # print "section: $section line: $lang[$i]"; + $FILES[$Fct] = $lang[$i]; + $Fct++; + } + else + { + if ($section =~ /TRANSLATIONS/) + { + # print "section: $section line: $lang[$i]"; + @TRANSlineX = split(/\|/, $lang[$i]); + $ORIGtextX = "$TRANSlineX[0]"; + $lengthX = length($ORIGtextX); + $lengthX = sprintf("%04d",$lengthX); + $TRANSLATIONS_RAW[$Tct] = "$lengthX|$lang[$i]"; + $Tct++; + } + } + } + } + } + $i++; + } + +if ($DB) + { + print "LANGUAGE FILE PARSE RESULTS: $#lang lines in file\n"; + print "LANGUAGES: $LANGUAGES\n"; + print "FILES: $Fct\n"; + print "TRANSLATIONS: $Tct\n"; + } + +#@TRANSLATIONS = sort { length($b) <=> length($a) } @TRANSLATIONS_RAW; +@TRANSLATIONS = sort { $b <=> $a } @TRANSLATIONS_RAW; + +#$k=0; +#foreach(@TRANSLATIONS) +# { +# $length = length($TRANSLATIONS[$k]); +# print "$TRANSLATIONS[$k]|$length|\n"; +# $k++; +# } + +##### LOOP THROUGH THE LANGUAGES +@lang_list = split(/\|/, $LANGUAGES); +@lang_link_list = @lang_list; +$i=0; +$gif = '.gif'; +foreach(@lang_list) + { + if (length($lang_list[$i]) > 2) + { + @lang_detail = split(/-/, $lang_list[$i]); + $lang_abb = $lang_detail[0]; + $lang_name = $lang_detail[1]; + + if ( ($without_en==1) && ($lang_abb =~ /en/) ) + { + print "SKIPPING ENGLISH COPYING: $lang_abb|$i\n\n"; + } + else + { + ##### LOOP THROUGH THE FILES + $Fct=0; + foreach(@FILES) + { + $a=0; + @file_detail = split(/\|/, $FILES[$Fct]); + $file_path = $file_detail[0]; + $file_name = $file_detail[1]; + $file_name =~ s/\t|\r|\n//gi; + $file_passthru = $file_detail[2]; + $file_passthru =~ s/\t|\r|\n//gi; + if (-e "$webroot/$file_path/$file_name") + { + open(file, "$webroot/$file_path/$file_name") || die "can't open $webroot/$file_path/$file_name: $!\n"; + @file = @MT; + @file = ; + close(file); + + print "File exists: ./$file_path/$file_name\n"; + if (-e "$webroot/$file_path$US$lang_abb") + { + print "Lang Directory exists: $webroot/$file_path$US$lang_abb\n"; + } + else + { + `mkdir $webroot/$file_path$US$lang_abb`; + `chmod 0777 $webroot/$file_path$US$lang_abb`; + print "Lang Directory created: $webroot/$file_path$US$lang_abb\n"; + } + + if ($file_passthru < 1) + { + ##### LOOP THROUGH THE TRANSLATIONS + $Tct=0; + foreach(@TRANSLATIONS) + { + @TRANSline = split(/\|/, $TRANSLATIONS[$Tct]); + $ORIGtext = "$TRANSline[1]"; + $TRANStext = "$TRANSline[$i+1]"; + $LINESct=0; + foreach(@file) + { + if ($file[$LINESct] !~ /^\#|^\s*function |'INCALL'|'PAUSED'|'READY'|'NEW'|xmlhttp|ILPV |ILPA |SELECT cmd_line_f|=\"SELECT/) + { + if ($file[$LINESct] =~ /INTERNATIONALIZATION-LINKS-PLACEHOLDER-VICIDIAL/) + { + $file[$LINESct] =~ s/INTERNATIONALIZATION-LINKS-PLACEHOLDER-VICIDIAL/ILPV/g; + $e=0; + $gif = '.gif'; + foreach(@lang_link_list) + { + if (length($lang_link_list[$e]) > 2) + { + @lang_list_detail = split(/-/, $lang_link_list[$e]); + $lang_list_abb = $lang_list_detail[0]; + $lang_list_name = $lang_list_detail[1]; + if ($lang_list_abb =~ /$lang_abb/) {$list_bgcolor = ' BGCOLOR=\"#CCFFCC\"';} + else {$list_bgcolor = '';} + $file[$LINESct] .= "echo \"
\\n\";"; + } + $e++; + } + } + else + { + if ($file[$LINESct] =~ /INTERNATIONALIZATION-LINKS-PLACEHOLDER-AGC/) + { + $file[$LINESct] =~ s/INTERNATIONALIZATION-LINKS-PLACEHOLDER-AGC/ILPA/g; + $e=0; + $gif = '.gif'; + foreach(@lang_link_list) + { + if (length($lang_link_list[$e]) > 2) + { + @lang_list_detail = split(/-/, $lang_link_list[$e]); + $lang_list_abb = $lang_list_detail[0]; + $lang_list_name = $lang_list_detail[1]; + if ($lang_list_abb =~ /$lang_abb/) {$list_bgcolor = ' BGCOLOR=\"#CCFFCC\"';} + else {$list_bgcolor = '';} + $file[$LINESct] .= "echo \"\\n\";"; + } + $e++; + } + } + else + { + if ( ($lang_abb =~ /^en/) && ($Tct > 2) ) + { + $file[$LINESct] =~ s/\.\/images\//\.\.\/agc\/images\//g; + $file[$LINESct] =~ s/\"help.gif/\"..\/astguiclient\/help.gif/g; + } + if ($lang_abb !~ /^en/) + {$file[$LINESct] =~ s/$ORIGtext/$TRANStext/g;} + } + } + } + $LINESct++; + + if ($a =~ /00000$/i) {print "$a $file[$LINESct]\n|$ORIGtext|$TRANStext|";} + $a++; + } + $Tct++; + } + } + ### open the translation result file for writing ### + open(out, ">$webroot/$file_path$US$lang_abb/$file_name") + || die "Can't open $webroot/$file_path$US$lang_abb/$file_name: $!\n"; + # print out "Header(\"Content-type: text/html; charset=utf-8\");\n"; + $LINESct=0; + foreach(@file) + { + print out "$file[$LINESct]"; + $LINESct++; + } + close(out); + print "\n"; + print "File Written: $webroot/$file_path$US$lang_abb/$file_name\n"; + } + else + { + print "File does not exist: $webroot/$file_path/$file_name\n"; + } + $Fct++; + } + } + } + $i++; + } + +} \ No newline at end of file diff --git a/agc_2-X/trunk/invalid_speak.agi b/agc_2-X/trunk/invalid_speak.agi new file mode 100644 index 00000000..2b7dd9f8 --- /dev/null +++ b/agc_2-X/trunk/invalid_speak.agi @@ -0,0 +1,139 @@ +#!/usr/bin/perl +# +# invalid_speak.agi version 0.1 +# +# runs during an invalid extension and speaks the extension sent to it while printing to STDERR +# +# You need to put lines similar to those below in your extensions.conf file: +# +# ;inbound errors with speaking of extension: +#exten => _XXXX,1,AGI(invalid_speak.agi,${EXTEN}) +#exten => _XXXX,2,Playback(invalid) +#exten => _XXXX,3,Hangup +# +#exten => _*XXXXXXXXXX*XXXX,1,AGI(invalid_speak.agi,${EXTEN}) +#exten => _*XXXXXXXXXX*XXXX,2,Playback(invalid) +#exten => _*XXXXXXXXXX*XXXX,3,Hangup +# +#exten => _*XXXXXXXXXX*XXXX*,1,AGI(invalid_speak.agi,${EXTEN}) +#exten => _*XXXXXXXXXX*XXXX*,2,Playback(invalid) +#exten => _*XXXXXXXXXX*XXXX*,3,Hangup +# +#exten => _**XXXX,1,AGI(invalid_speak.agi,${EXTEN}) +#exten => _**XXXX,2,Playback(invalid) +#exten => _**XXXX,3,Hangup +# +#exten => _**XXXX*,1,AGI(invalid_speak.agi,${EXTEN}) +#exten => _**XXXX*,2,Playback(invalid) +#exten => _**XXXX*,3,Hangup +# +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# + +$V = 0; # set to 1 for verbose mode +$CLIOUT = 1; # set to 1 for printing 1 line to STDERR +$SPEAK = 1; # set to 1 for saying invalid digits + +($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) {$Fhour = "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"; + + +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ +if ($V) {print STDERR "Perl Environment Dump:\n";} + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + if ($V) {print STDERR "$i|$ARGV[$i]|\n";} + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n"; + } + else + { + if ($args =~ /-V/i) + { + $V=1; + } + if ($args =~ /-debug/i) + { + $DG=1; + } + if ($args =~ /-dbAVS/i) + { + $DGA=1; + } + if ($args =~ /-q/i) + { + $q=1; + $Q=1; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +if ($V) {print "no command line options set\n";} +} + +use Asterisk::AGI; +$AGI = new Asterisk::AGI; + +$|=1; +while() { + chomp; + last unless length($_); + if ($V) + { + if (/^agi_(\w+)\:\s+(.*)$/) + { + $AGI{$1} = $2; + } + } + + if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1;} + if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} + if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} + if (/^agi_type\:\s+(.*)$/) {$type = $1;} + if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1;} +} + + if ($V) + { + + if ($V) {print STDERR "AGI Environment Dump:\n";} + foreach $i (sort keys %AGI) { + if ($V) {print STDERR " -- $i = $AGI{$i}\n";} + } + } + +if ($CLIOUT) {print STDERR "****** INVALID EXTENSION: |$unique_id|$channel|$extension|$type|$callerid|\n";} + +if ($SPEAK) + { + $AGI->stream_file('beep'); + sleep(1); + $AGI->say_digits("$extension"); + } + + +exit; diff --git a/agc_2-X/trunk/libs/AST_VICI_conf.pl.bak b/agc_2-X/trunk/libs/AST_VICI_conf.pl.bak new file mode 100644 index 00000000..c4039f2b --- /dev/null +++ b/agc_2-X/trunk/libs/AST_VICI_conf.pl.bak @@ -0,0 +1,146 @@ +#!/usr/bin/perl + +### AST_VICI_conf.pl +### +### Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +### + +### Customized Variables +$SIP_user = 'SIP/cc100'; # your phone id +$server_ip = '10.10.10.15'; # Asterisk server IP +$DB_server = '10.10.10.15'; # MySQL server IP +$DB_database = 'asterisk'; # MySQL database name +$DB_user = 'idcheck'; # MySQL user +$DB_pass = '1234'; # MySQL pass +$DB_port = '3306'; # MySQL connection port + +### Constants +$record_channel=''; +$filename=''; +$recording_id=''; +$US = '_'; +$MT[0] = ''; + +return 1; + + +# this subroutine is to be used with the callerID function to customize the +# variables that are passed in the URL string and the way that they are passed, +# these are the variables you have to work with: +# $callerID_areacode +# $callerID_prefix +# $callerID_last4 +# $callerID_Time +# $callerID_Channel +# $callerID_uniqueID +# $callerID_phone_ext +# $callerID_server_ip +# $callerID_extension +# $callerID_inbound_number +# $callerID_comment_a +# $callerID_comment_b +# $callerID_comment_c +# $callerID_comment_d +# $callerID_comment_e + +sub create_callerID_local_query_string +{ +$local_web_callerID_QUERY_STRING =''; +$local_web_callerID_QUERY_STRING.="?callerID_areacode=$callerID_areacode"; +$local_web_callerID_QUERY_STRING.="&callerID_prefix=$callerID_prefix"; +$local_web_callerID_QUERY_STRING.="&callerID_last4=$callerID_last4"; +$local_web_callerID_QUERY_STRING.="&callerID_Time=$callerID_Time"; +$local_web_callerID_QUERY_STRING.="&callerID_Channel=$callerID_Channel"; +$local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$callerID_uniqueID"; +$local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$callerID_phone_ext"; +$local_web_callerID_QUERY_STRING.="&callerID_server_ip=$callerID_server_ip"; +$local_web_callerID_QUERY_STRING.="&callerID_extension=$callerID_extension"; +$local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$callerID_inbound_number"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_a=$callerID_comment_a"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_b=$callerID_comment_b"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_c=$callerID_comment_c"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_d=$callerID_comment_d"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_e=$callerID_comment_e"; +} + +# $lead_id +# $vendor_id +# $list_id +# $phone_code +# $phone_number +# $title +# $first_name +# $middle_initial +# $last_name +# $address1 +# $address2 +# $address3 +# $city +# $state +# $province +# $postal_code +# $country_code +# $gender +# $date_of_birth +# $alt_phone +# $email +# $security +# $comments +# $user +# $pass +# $fronter +# $closer +# $campaign +# $group +# $SQLdate +# $epoch +# $uniqueid +# $customer_zap_channel +# $server_ip +# $SIPexten + +sub create_VICIDIAL_query_string +{ +$VICIDIAL_web_QUERY_STRING =''; +$VICIDIAL_web_QUERY_STRING.="?lead_id=$lead_id"; +$VICIDIAL_web_QUERY_STRING.="&vendor_id=$vendor_id"; +$VICIDIAL_web_QUERY_STRING.="&list_id=$list_id"; +$VICIDIAL_web_QUERY_STRING.="&phone_code=$phone_code"; +$VICIDIAL_web_QUERY_STRING.="&phone_number=$phone_number"; +$VICIDIAL_web_QUERY_STRING.="&title=$title"; +$VICIDIAL_web_QUERY_STRING.="&first_name=$first_name"; +$VICIDIAL_web_QUERY_STRING.="&middle_initial=$middle_initial"; +$VICIDIAL_web_QUERY_STRING.="&last_name=$last_name"; +$VICIDIAL_web_QUERY_STRING.="&address1=$address1"; +$VICIDIAL_web_QUERY_STRING.="&address2=$address2"; +$VICIDIAL_web_QUERY_STRING.="&address3=$address3"; +$VICIDIAL_web_QUERY_STRING.="&city=$city"; +$VICIDIAL_web_QUERY_STRING.="&state=$state"; +$VICIDIAL_web_QUERY_STRING.="&province=$province"; +$VICIDIAL_web_QUERY_STRING.="&postal_code=$postal_code"; +$VICIDIAL_web_QUERY_STRING.="&country_code=$country_code"; +$VICIDIAL_web_QUERY_STRING.="&gender=$gender"; +$VICIDIAL_web_QUERY_STRING.="&date_of_birth=$date_of_birth"; +$VICIDIAL_web_QUERY_STRING.="&alt_phone=$alt_phone"; +$VICIDIAL_web_QUERY_STRING.="&email=$email"; +$VICIDIAL_web_QUERY_STRING.="&security=$security"; +$VICIDIAL_web_QUERY_STRING.="&comments=$comments"; +$VICIDIAL_web_QUERY_STRING.="&user=$user"; +$VICIDIAL_web_QUERY_STRING.="&pass=$userpass"; +$VICIDIAL_web_QUERY_STRING.="&fronter=$fronter"; +$VICIDIAL_web_QUERY_STRING.="&closer=$user"; +$VICIDIAL_web_QUERY_STRING.="&campaign=$campaign"; +$VICIDIAL_web_QUERY_STRING.="&group=$group"; +$VICIDIAL_web_QUERY_STRING.="&channel_group=$channel_group"; +$VICIDIAL_web_QUERY_STRING.="&SQLdate=$SQLdate"; +$VICIDIAL_web_QUERY_STRING.="&epoch=$secX"; +$VICIDIAL_web_QUERY_STRING.="&uniqueid=$uniqueid"; +$VICIDIAL_web_QUERY_STRING.="&customer_zap_channel=$customer_zap_channel"; +$VICIDIAL_web_QUERY_STRING.="&server_ip=$server_ip"; +$VICIDIAL_web_QUERY_STRING.="&SIPexten=$SIPexten"; +$VICIDIAL_web_QUERY_STRING.="&session_id=$session_id"; +$VICIDIAL_web_QUERY_STRING.="&phone=$phone_number"; +$VICIDIAL_web_QUERY_STRING.="&parked_by=$lead_id"; +$VICIDIAL_web_QUERY_STRING =~ s/ /+/gi; +$VICIDIAL_web_QUERY_STRING =~ s/\`|\~|\:|\;|\#|\'|\"|\{|\}|\(|\)|\*|\^|\%|\$|\!|\%|\r|\t|\n//gi; +} \ No newline at end of file diff --git a/agc_2-X/trunk/libs/AUS_zipcode_ranges.txt b/agc_2-X/trunk/libs/AUS_zipcode_ranges.txt new file mode 100644 index 00000000..af434eb0 --- /dev/null +++ b/agc_2-X/trunk/libs/AUS_zipcode_ranges.txt @@ -0,0 +1,14 @@ +ACT|0200|0399 +NT|0800|0999 +NSW|1000|2599 +ACT|2600|2618 +NSW|2619|2899 +ACT|2900|2920 +NSW|2921|2999 +VIC|3000|3999 +QLD|4000|4999 +SA|5000|5999 +WA|6000|6999 +TAS|7000|7999 +VIC|8000|8999 +QLD|9000|9999 \ No newline at end of file diff --git a/agc_2-X/trunk/libs/Asterisk.pm b/agc_2-X/trunk/libs/Asterisk.pm new file mode 100644 index 00000000..15ecd4a8 --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk.pm @@ -0,0 +1,20 @@ +package Asterisk; + +require 5.004; + +$VERSION = '0.08'; + +sub version { $VERSION; } + +sub new { + my ($class, %args) = @_; + my $self = {}; + $self->{configfile} = undef; + $self->{config} = {}; + bless $self, ref $class || $class; + return $self; +} + +sub DESTROY { } + +1; diff --git a/agc_2-X/trunk/libs/Asterisk/AGI.pm b/agc_2-X/trunk/libs/Asterisk/AGI.pm new file mode 100644 index 00000000..b1680ea6 --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk/AGI.pm @@ -0,0 +1,685 @@ +package Asterisk::AGI; + +require 5.004; + +use Asterisk; + +@ISA = ( 'Asterisk' ); + +=head1 NAME + +Asterisk::AGI - Simple Asterisk Gateway Interface Class + +=head1 SYNOPSIS + +use Asterisk::AGI; + +$AGI = new Asterisk::AGI; + +# pull AGI variables into %input + + %input = $AGI->ReadParse(); + +# say the number 1984 + + $AGI->say_number(1984); + +=head1 DESCRIPTION + +This module should make it easier to write scripts that interact with the +asterisk open source pbx via AGI (asterisk gateway interface) + +=head1 AGI COMMANDS + +=cut + +sub new { + my ($class, %args) = @_; + my $self = {}; + $self->{'callback'} = undef; + $self->{'status'} = undef; + $self->{'lastresponse'} = undef; + bless $self, ref $class || $class; + return $self; +} + +sub ReadParse { + my ($self, $fh) = @_; + + my %input = (); + + $fh = \*STDIN if (!$fh); + + while (<$fh>) { + chomp; + last unless length($_); + if (/^agi_(\w+)\:\s+(.*)$/) { + $input{$1} = $2; + } + } + + + if (defined($DEBUG)&&($DEBUG>0)) { + print STDERR "AGI Environment Dump:\n"; + foreach $i (sort keys %input) { + print STDERR " -- $i = $input{$i}\n"; + } + } + + return %input; +} + +sub setcallback { + my ($self, $function) = @_; + + if (defined($function) && ref($function) eq 'CODE') { + $self->{'callback'} = $function; + } +} + +sub callback { + my ($self, $result) = @_; + + if (defined($self->{'callback'}) && ref($self->{'callback'}) eq 'CODE') { + &{$self->{'callback'}}($result); + } +} + +sub execute { + my ($self, $command) = @_; + + $self->_execcommand($command); + my $res = $self->_readresponse(); + + return $self->_checkresult($res); +} + +sub _execcommand { + my ($self, $command, $fh) = @_; + + $fh = \*STDOUT if (!$fh); + + select ((select ($fh), $| = 1)[0]); + + return -1 if (!defined($command)); + + return print $fh "$command\n"; +} + +sub _readresponse { + my ($self, $fh) = @_; + + my $response = undef; + $fh = \*STDIN if (!$fh); + $response = <$fh> || return '200 result=-1 (noresponse)'; + chomp($response); + return $response; +} + +sub _checkresult { + my ($self, $response) = @_; + + return undef if (!defined($response)); + my $result = undef; + + $self->_lastresponse($response); + if ($response =~ /^200/) { + if ($response =~ /result=(-?[\d*#]+)/) { + $result = $1; + } + } elsif ($response =~ /\(noresponse\)/) { + $self->_status('noresponse'); + } else { + print STDERR "Unexpected result '$response'\n" if (defined($DEBUG) && $DEBUG); + } + print STDERR "_checkresult($response) = $result\n" if (defined($DEBUG) && $DEBUG>3); + + return $result; +} + +sub _status { + my ($self, $status) = @_; + + if (defined($status)) { + $self->{'status'} = $status; + } else { + return $self->{'status'}; + } +} + +sub _lastresponse { + my ($self, $response) = @_; + + if (defined($response)) { + $self->{'lastresponse'} = $response; + } else { + return $self->{'lastresponse'}; + } +} + +=over 4 + +=item $AGI->stream_file($filename, $digits) + +Executes AGI Command "STREAM FILE $filename $digits" + +This command instructs Asterisk to play the given sound file and listen for the given dtmf digits. The +fileextension must not be used in the filename because Asterisk will find the most appropriate file +type. + +Example: $AGI->stream_file('demo-echotest', '0123'); + +Returns: -1 on error or hangup, +0 if playback completes without a digit being pressed, +or the ASCII numerical value of the digit if a digit was pressed + +=cut + +sub stream_file { + my ($self, $filename, $digits) = @_; + + my $ret = 0; + + $digits = '""' if (!defined($digits)); + + return -1 if (!defined($filename)); + $ret = $self->execute("STREAM FILE $filename $digits"); + + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +=item $AGI->send_text($text) + +Executes AGI Command "SEND TEXT "$text" + +Sends the given text on a channel. Most channels do not support the transmission of text. + +Example: $AGI->send_text('You've got mail!'); + +Returns: -1 on error or hangup, +0 if the text was sent or if the channel does not support text transmission. + +=cut + +sub send_text { + my ($self, $text) = @_; + + my $ret = 0; + + return $ret if (!defined($text)); + $ret = $self->execute("SEND TEXT \"$text\""); + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +=item $AGI->send_image($image) + +Executes AGI Command "SEND IMAGE $image + +Sends the given image on a channel. Most channels do not support the transmission of images. + +Example: $AGI->send_image('image.png'); + +Returns: -1 on error or hangup, +0 if the image was sent or if the channel does not support image transmission. + +=cut + +sub send_image { + my ($self, $image) = @_; + + my $ret = 0; + return -1 if (!defined($image)); + + $ret = $self->execute("SEND IMAGE $image"); + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +=item $AGI->say_number($number, $digits) + +Executes AGI Command "SAY NUMBER $number $digits" + +Says the given $number, returning early if any of the $digits are received. + +Example: $AGI->say_number('98765'); + +Returns: -1 on error or hangup, +0 if playback completes without a digit being pressed, +or the ASCII numerical value of the digit of one was pressed. + +=cut + +sub say_number { + my ($self, $number, $digits) = @_; + + my $ret = 0; + + $digits = '""' if (!defined($digits)); + + return -1 if (!defined($number)); + $number =~ s/\D//g; + $ret = $self->execute("SAY NUMBER $number $digits"); + + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +=item $AGI->say_digits($number, $digits) + +Executes AGI Command "SAY DIGITS $number $digits" + +Says the given digit string $number, returning early if any of the $digits are received. + +Example: $AGI->say_digits('8675309'); + +Returns: -1 on error or hangup, +0 if playback completes without a digit being pressed, +or the ASCII numerical value of the digit of one was pressed. + +=cut + +sub say_digits { + my ($self, $number, $digits) = @_; + + my $ret = 0; + $digits = '""' if (!defined($digits)); + + return -1 if (!defined($number)); + $number =~ s/\D//g; + $ret = $self->execute("SAY DIGITS $number $digits"); + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +=item $AGI->answer() + +Executes AGI Command "ANSWER" + +Answers channel if not already in answer state + +Example: $AGI->answer(); + +Returns: -1 on channel failure, or +0 if successful + +=cut + +sub answer { + my ($self) = @_; + + my $ret = 0; + $ret = $self->execute('ANSWER'); + $self->callback($ret) if ($ret == -1); + + return $ret; + +} + +=item $AGI->get_data($filename, $timeout, $maxdigits) + +Executes AGI Command "GET DATA $filename $timeout $maxdigits" + +Streams $filename and returns when $maxdigits have been received or +when $timeout has been reached. Timeout is specified in ms + +Example: $AGI->get_data('demo-welcome', 15000, 5); + +=cut + +sub get_data { + my ($self, $filename, $timeout, $maxdigits) = @_; + + my $ret = undef; + + return -1 if (!defined($filename)); + $ret = $self->execute("GET DATA $filename $timeout $maxdigits"); + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +=item $AGI->set_callerid($number) + +Executes AGI Command "SET CALLERID $number" + +Changes the callerid of the current channel to + +Example: $AGI->set_callerid('9995551212'); + +Returns: Always returns 1 + +=cut + +sub set_callerid { + my ($self, $number) = @_; + + return if (!defined($number)); + return $self->execute("SET CALLERID $number"); +} + +=item $AGI->set_context($context) + +Executes AGI Command "SET CONTEXT $context" + +Changes the context for continuation upon exiting the agi application + +Example: $AGI->set_context('dialout'); + +Returns: Always returns 0 + +=cut + +sub set_context { + my ($self, $context) = @_; + + return -1 if (!defined($context)); + return $self->execute("SET CONTEXT $context"); +} + +=item $AGI->set_extension($extension) + +Executes AGI Command "SET EXTENSION $extension" + +Changes the extension for continuation upon exiting the agi application + +Example: $AGI->set_extension('7'); + +Returns: Always returns 0 + +=cut + +sub set_extension { + my ($self, $extension) = @_; + + return -1 if (!defined($extension)); + return $self->execute("SET EXTENSION $extension"); +} + +=item $AGI->set_priority($priority) + +Executes AGI Command "SET PRIORITY $priority" + +Changes the priority for continuation upon exiting the agi application + +Example: $AGI->set_priority(1); + +Returns: Always returns 0 + +=cut + +sub set_priority { + my ($self, $priority) = @_; + + return -1 if (!defined($priority)); + return $self->execute("SET PRIORITY $priority"); +} + +sub receive_char { + my ($self, $timeout) = @_; + + my $ret = 0; +#wait forever if timeout is not set. is this the prefered default? + $timeout = 0 if (!defined($timeout)); + $ret = $self->execute("RECEIVE CHAR $timeout"); + $self->callback($ret) if ($ret == -1); + + return $ret; + +} + +sub tdd_mode { + my ($self, $mode) = @_; + + return 0 if (!defined($mode)); + return $self->execute("TDD MODE $mode"); +} + + +sub wait_for_digit { + my ($self, $timeout) = @_; + + my $ret = 0; + $timeout = -1 if (!defined($timeout)); + $ret = $self->execute("WAIT FOR DIGIT $timeout"); + + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +sub record_file { + my ($self, $filename, $format, $digits, $timeout, $beep) = @_; + + my $ret = 0; + + return -1 if (!defined($filename)); + $digits = '""' if (!defined($digits)); + $ret = $self->execute("RECORD FILE $filename $format $digits $timeout"); + + $self->callback($ret) if ($ret == -1); + + return $ret; +} + +sub set_autohangup { + my ($self, $time) = @_; + + $time = 0 if (!defined($time)); + return $self->execute("SET AUTOHANGUP $time"); +} + +=item $AGI->hangup($channel) + +Executes AGI Command "HANGUP $channel" + +Hangs up the passed $channel, or the current channel if $channel is not passed. +It is left to the AGI script to exit properly, otherwise you could end up with zombies. + +Example: $AGI->hangup(); + +Returns: Always returns 1 + +=cut + +sub hangup { + my ($self, $channel) = @_; + + if ($channel) { + return $self->execute("HANGUP $channel"); + } else { + return $self->execute("HANGUP"); + } +} + +=item $AGI->exec($app, $options) + +Executes AGI Command "EXEC $app $options" + +The most powerful AGI command. Executes the given application passing the given options. + +Example: $AGI->exec('Dial', 'Zap/g2/8005551212'); + +Returns: -2 on failure to find application, or +whatever the given application returns + +=cut + +sub exec { + my ($self, $app, $options) = @_; + return -1 if (!defined($app)); + $options = '""' if (!defined($options)); + return $self->execute("EXEC $app $options"); +} + +sub channel_status { + my ($self, $channel) = @_; + + return $self->execute("CHANNEL STATUS $channel"); +} + +=item $AGI->set_variable($variable, $value) + +Executes AGI Command "SET VARIABLE $variable $value" + +Sets the channel variable to + +Example: $AGI->set_variable('status', 'authorized'); + +Returns: Always returns 1 + +=cut + +sub set_variable { + my ($self, $variable, $value) = @_; + + return $self->execute("SET VARIABLE $variable $value"); +} + +=item $AGI->get_variable($variable) + +Executes AGI Command "GET VARIABLE $variablename" + +Gets the channel variable + +Example: $AGI->get_variable('status'); + +Returns: The value of the variable, or undef if variable does not exist + +=cut + +sub get_variable { + my ($self, $variable) = @_; + + my $result = undef; + + if ($self->execute("GET VARIABLE $variable")) { + my $tempresult = $self->_lastresponse(); + if ($tempresult =~ /\((.*)\)/) { + $result = $1; + } + } + return $result; +} + +=item $AGI->verbose($message, $level) + +Executes AGI Command "VERBOSE $message $level" + +Logs $message with verboselevel $level + +Example: $AGI->verbose("System Crashed\n", 1); + +Returns: Always returns 1 + +=cut + + +sub verbose { + my ($self, $message, $level) = @_; + + return $self->execute("VERBOSE \"$message\" $level"); +} + +=item $AGI->database_get($family, $key) + +Executes AGI Command "DATABASE GET $family $key" + +Example: $var = $AGI->database_get('test', 'status'); + +Returns: The value of the variable, or undef if variable does not exist + +=cut + +sub database_get { + my ($self, $family, $key) = @_; + + my $result = undef; + + if ($self->execute("DATABASE GET $family $key")) { + my $tempresult = $self->_lastresponse(); + if ($tempresult =~ /\((.*)\)/) { + $result = $1; + } + } + return $result; +} + +=item $AGI->database_put($family, $key, $value) + +Executes AGI Command "DATABASE PUT $family $key $value" + +Set/modifes database entry / to + +Example: $AGI->database_put('test', 'status', 'authorized'); + +Returns: 1 on success, 0 otherwise + +=cut + +sub database_put { + my ($self, $family, $key, $value) = @_; + + return $self->execute("DATABASE PUT $family $key $value"); +} + +=item $AGI->database_del($family, $key) + +Executes AGI Command "DATABASE DEL $family $key" + +Removes database entry / + +Example: $AGI->database_del('test', 'status'); + +Returns: 1 on success, 0 otherwise + +=cut + +sub database_del { + my ($self, $family, $key) = @_; + + return $self->execute("DATABASE DEL $family $key"); +} + +=item $AGI->database_deltree($family, $key) + +Executes AGI Command "DATABASE DELTREE $family $key" + +Deletes a family or specific keytree within a family in the Asterisk database + +Example: $AGI->database_deltree('test', 'status'); +Example: $AGI->database_deltree('test'); + +Returns: 1 on success, 0 otherwise + +=cut + +sub database_deltree { + my ($self, $family, $key) = @_; + + return $self->execute("DATABASE DELTREE $family $key"); +} + +sub noop { + my ($self) = @_; + + return $self->execute("NOOP"); +} + +sub set_music { + my ($self, $mode, $class) = @_; + + return $self->execute("SET MUSIC $mode $class"); +} + +1; + +__END__ + +=back diff --git a/agc_2-X/trunk/libs/Asterisk/DONOTUSE_AST_VICI_conf.pl b/agc_2-X/trunk/libs/Asterisk/DONOTUSE_AST_VICI_conf.pl new file mode 100644 index 00000000..c4039f2b --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk/DONOTUSE_AST_VICI_conf.pl @@ -0,0 +1,146 @@ +#!/usr/bin/perl + +### AST_VICI_conf.pl +### +### Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +### + +### Customized Variables +$SIP_user = 'SIP/cc100'; # your phone id +$server_ip = '10.10.10.15'; # Asterisk server IP +$DB_server = '10.10.10.15'; # MySQL server IP +$DB_database = 'asterisk'; # MySQL database name +$DB_user = 'idcheck'; # MySQL user +$DB_pass = '1234'; # MySQL pass +$DB_port = '3306'; # MySQL connection port + +### Constants +$record_channel=''; +$filename=''; +$recording_id=''; +$US = '_'; +$MT[0] = ''; + +return 1; + + +# this subroutine is to be used with the callerID function to customize the +# variables that are passed in the URL string and the way that they are passed, +# these are the variables you have to work with: +# $callerID_areacode +# $callerID_prefix +# $callerID_last4 +# $callerID_Time +# $callerID_Channel +# $callerID_uniqueID +# $callerID_phone_ext +# $callerID_server_ip +# $callerID_extension +# $callerID_inbound_number +# $callerID_comment_a +# $callerID_comment_b +# $callerID_comment_c +# $callerID_comment_d +# $callerID_comment_e + +sub create_callerID_local_query_string +{ +$local_web_callerID_QUERY_STRING =''; +$local_web_callerID_QUERY_STRING.="?callerID_areacode=$callerID_areacode"; +$local_web_callerID_QUERY_STRING.="&callerID_prefix=$callerID_prefix"; +$local_web_callerID_QUERY_STRING.="&callerID_last4=$callerID_last4"; +$local_web_callerID_QUERY_STRING.="&callerID_Time=$callerID_Time"; +$local_web_callerID_QUERY_STRING.="&callerID_Channel=$callerID_Channel"; +$local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$callerID_uniqueID"; +$local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$callerID_phone_ext"; +$local_web_callerID_QUERY_STRING.="&callerID_server_ip=$callerID_server_ip"; +$local_web_callerID_QUERY_STRING.="&callerID_extension=$callerID_extension"; +$local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$callerID_inbound_number"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_a=$callerID_comment_a"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_b=$callerID_comment_b"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_c=$callerID_comment_c"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_d=$callerID_comment_d"; +$local_web_callerID_QUERY_STRING.="&callerID_comment_e=$callerID_comment_e"; +} + +# $lead_id +# $vendor_id +# $list_id +# $phone_code +# $phone_number +# $title +# $first_name +# $middle_initial +# $last_name +# $address1 +# $address2 +# $address3 +# $city +# $state +# $province +# $postal_code +# $country_code +# $gender +# $date_of_birth +# $alt_phone +# $email +# $security +# $comments +# $user +# $pass +# $fronter +# $closer +# $campaign +# $group +# $SQLdate +# $epoch +# $uniqueid +# $customer_zap_channel +# $server_ip +# $SIPexten + +sub create_VICIDIAL_query_string +{ +$VICIDIAL_web_QUERY_STRING =''; +$VICIDIAL_web_QUERY_STRING.="?lead_id=$lead_id"; +$VICIDIAL_web_QUERY_STRING.="&vendor_id=$vendor_id"; +$VICIDIAL_web_QUERY_STRING.="&list_id=$list_id"; +$VICIDIAL_web_QUERY_STRING.="&phone_code=$phone_code"; +$VICIDIAL_web_QUERY_STRING.="&phone_number=$phone_number"; +$VICIDIAL_web_QUERY_STRING.="&title=$title"; +$VICIDIAL_web_QUERY_STRING.="&first_name=$first_name"; +$VICIDIAL_web_QUERY_STRING.="&middle_initial=$middle_initial"; +$VICIDIAL_web_QUERY_STRING.="&last_name=$last_name"; +$VICIDIAL_web_QUERY_STRING.="&address1=$address1"; +$VICIDIAL_web_QUERY_STRING.="&address2=$address2"; +$VICIDIAL_web_QUERY_STRING.="&address3=$address3"; +$VICIDIAL_web_QUERY_STRING.="&city=$city"; +$VICIDIAL_web_QUERY_STRING.="&state=$state"; +$VICIDIAL_web_QUERY_STRING.="&province=$province"; +$VICIDIAL_web_QUERY_STRING.="&postal_code=$postal_code"; +$VICIDIAL_web_QUERY_STRING.="&country_code=$country_code"; +$VICIDIAL_web_QUERY_STRING.="&gender=$gender"; +$VICIDIAL_web_QUERY_STRING.="&date_of_birth=$date_of_birth"; +$VICIDIAL_web_QUERY_STRING.="&alt_phone=$alt_phone"; +$VICIDIAL_web_QUERY_STRING.="&email=$email"; +$VICIDIAL_web_QUERY_STRING.="&security=$security"; +$VICIDIAL_web_QUERY_STRING.="&comments=$comments"; +$VICIDIAL_web_QUERY_STRING.="&user=$user"; +$VICIDIAL_web_QUERY_STRING.="&pass=$userpass"; +$VICIDIAL_web_QUERY_STRING.="&fronter=$fronter"; +$VICIDIAL_web_QUERY_STRING.="&closer=$user"; +$VICIDIAL_web_QUERY_STRING.="&campaign=$campaign"; +$VICIDIAL_web_QUERY_STRING.="&group=$group"; +$VICIDIAL_web_QUERY_STRING.="&channel_group=$channel_group"; +$VICIDIAL_web_QUERY_STRING.="&SQLdate=$SQLdate"; +$VICIDIAL_web_QUERY_STRING.="&epoch=$secX"; +$VICIDIAL_web_QUERY_STRING.="&uniqueid=$uniqueid"; +$VICIDIAL_web_QUERY_STRING.="&customer_zap_channel=$customer_zap_channel"; +$VICIDIAL_web_QUERY_STRING.="&server_ip=$server_ip"; +$VICIDIAL_web_QUERY_STRING.="&SIPexten=$SIPexten"; +$VICIDIAL_web_QUERY_STRING.="&session_id=$session_id"; +$VICIDIAL_web_QUERY_STRING.="&phone=$phone_number"; +$VICIDIAL_web_QUERY_STRING.="&parked_by=$lead_id"; +$VICIDIAL_web_QUERY_STRING =~ s/ /+/gi; +$VICIDIAL_web_QUERY_STRING =~ s/\`|\~|\:|\;|\#|\'|\"|\{|\}|\(|\)|\*|\^|\%|\$|\!|\%|\r|\t|\n//gi; +} \ No newline at end of file diff --git a/agc_2-X/trunk/libs/Asterisk/Manager.pm b/agc_2-X/trunk/libs/Asterisk/Manager.pm new file mode 100644 index 00000000..69d860a1 --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk/Manager.pm @@ -0,0 +1,412 @@ +package Asterisk::Manager; + +require 5.004; + +use Asterisk; +use IO::Socket; +use Digest::MD5; + +#use strict; +#use warnings; + +=head1 NAME + +Asterisk::Manager - Asterisk Manager Interface + +=head1 SYNOPSIS + +use Asterisk::Manager; + +my $astman = new Asterisk::Manager; + +$astman->user('username'); + +$astman->secret('test'); + +$astman->host('localhost'); + +$astman->connect || die "Could not connect to " . $astman->host . "!\n"; + +$astman->disconnect; + +=head1 DESCRIPTION + +This module provides a simple interface to the asterisk manager interface. + +=cut + +my $EOL = "\r\n"; +my $BLANK = $EOL x 2; + +my $VERSION = '0.01'; + +sub version { $VERSION; } + +sub new { + my ($class, %args) = @_; + + my $self = {}; + $self->{_CONNFD} = undef; + $self->{_PROTOVERS} = undef; + $self->{_ERRORSTR} = undef; + $self->{_HOST} = 'localhost'; + $self->{_PORT} = 5038; + $self->{_USER} = undef; + $self->{_SECRET} = undef; + $self->{_EVENTCB} = {}; + $self->{_DEBUG} = 0; + $self->{_CONNECTED} = 0; + bless $self, ref $class || $class; + return $self; +} + +sub DESTROY { } + +sub user { + my ($self, $user) = @_; + + if ($user) { + $self->{_USER} = $user; + } + + return $self->{_USER}; +} + +sub secret { + my ($self, $secret) = @_; + + if ($secret) { + $self->{_SECRET} = $secret; + } + + return $self->{_SECRET}; +} + +sub host { + my ($self, $host) = @_; + + if ($host) { + $self->{_HOST} = $host; + } + + return $self->{_HOST}; +} + +sub port { + my ($self, $port) = @_; + + if ($port) { + $self->{_PORT} = $port; + } + + return $self->{_PORT}; +} + +sub connected { + my ($self, $connected) = @_; + + if (defined($connected)) { + $self->{_CONNECTED} = $connected; + } + + return $self->{_CONNECTED}; +} + +sub error { + my ($self, $error) = @_; + + if ($error) { + $self->{_ERRORSTR} = $error; + } + + return $self->{_ERRORSTR}; +} + +sub debug { + my ($self, $debug) = @_; + + if ($debug) { + $self->{_DEBUG} = $debug; + } + + return $self->{_DEBUG}; +} + +sub connfd { + my ($self, $connfd) = @_; + + if ($connfd) { + $self->{_CONNFD} = $connfd; + } + + return $self->{_CONNFD}; +} + +sub read_response { + my ($self, $connfd) = @_; + + my @response; + + if (!$connfd) { + $connfd = $self->connfd; + } + + while (my $line = <$connfd>) { + last if ($line eq $EOL); + + if (wantarray) { + $line =~ s/$EOL//g; + push(@response, $line) if $line; + } else { + $response[0] .= $line; + } + + } + + return wantarray ? @response : $response[0]; +} + +sub connect { + my ($self) = @_; + + my $host = $self->host; + my $port = $self->port; + my $user = $self->user; + my $secret = $self->secret; + my %resp; + + my $conn = new IO::Socket::INET( Proto => 'tcp', + PeerAddr => $host, + PeerPort => $port + ); + if (!$conn) { + $self->error("Connection refused ($host:$port)\n"); + return undef; + } + + $conn->autoflush(1); + + my $input = <$conn>; + $input =~ s/$EOL//g; + + my ($manager, $version) = split('/', $input); + + if ($manager !~ /Asterisk Call Manager/) { + return $self->error("Unknown Protocol\n"); + } + + $self->{_PROTOVERS} = $version; + $self->connfd($conn); + + # check if the remote host supports MD5 Challenge authentication + my %authresp = $self->sendcommand( Action => 'Challenge', + AuthType => 'MD5' + ); + + if (($authresp{Response} eq 'Success')) { + # do md5 login + my $md5 = new Digest::MD5; + $md5->add($authresp{Challenge}); + $md5->add($secret); + my $digest = $md5->hexdigest; + %resp = $self->sendcommand( Action => 'Login', + AuthType => 'MD5', + Username => $user, + Key => $digest + ); + } else { + # do plain text login + %resp = $self->sendcommand( Action => 'Login', + Username => $user, + Secret => $secret + ); + + } + + if ( ($resp{Response} ne 'Success') && ($resp{Message} ne 'Authentication accepted') ) { + $self->error("Authentication failed for user $user\n"); + return undef; + } + + $self->connected(1); + + return $conn; +} + +sub astman_h2s { + my ($self, %thash) = @_; + + my $tstring = ''; + + foreach my $key (keys %thash) { + $tstring .= $key . ': ' . $thash{$key} . ${EOL}; + } + + return $tstring; +} + +sub astman_s2h { + my ($self, $tstring) = @_; + + my %thash; + + foreach my $line (split(/$EOL/, $tstring)) { + if ($line =~ /(\w*):\s*(\w*)/) { + $thash{$1} = $2; + } + } + + return %thash; +} + +#$want is how you want the data returned +#$want = 0 (default) returns the results in a hash +#$want = 1 returns the results in a large string +#$want = 2 returns the results in an array +sub sendcommand { + my ($self, %command, $want) = @_; + + if (!defined($want)) { + $want = 0; + } + + my $conn = $self->connfd || return; + my $cstring = $self->astman_h2s(%command); + + $conn->send("$cstring$EOL"); + + if ($want == 1) { + my $response = $self->read_response($conn); + return $response; + } + + my @resp = $self->read_response($conn); + + if ($want == 2) { + return @resp; + } else { + return map { split(': ', $_) } @resp; + } +} + +sub setcallback { + my ($self, $event, $function) = @_; + + if (defined($function) && ref($function) eq 'CODE') { + $self->{_EVENTCB}{$event} = $function; + } +} + +sub eventcallback { + my ($self, %resp) = @_; + + my $callback; + my $event = $resp{Event}; + + return if (!$event); + + if (defined($self->{_EVENTCB}{$event})) { + $callback = $self->{_EVENTCB}{$event}; + } elsif (defined($self->{_EVENTCB}{DEFAULT})) { + $callback = $self->{_EVENTCB}{DEFAULT}; + } else { + return; + } + + return &{$callback}(%resp); +} + +sub eventloop { + my ($self) = @_; + + while (1) { + $self->handleevent; + } +} + +sub handleevent { + my ($self) = @_; + + my %resp = map { split(': ', $_); } $self->read_response; + $self->eventcallback(%resp); + + return %resp; +} + +sub action { + my ($self, $command, $wanthash) = @_; + + return if (!$command); + + my $conn = $self->connfd || return; + + print $conn "Action: $command" . $BLANK; + my @resp = $self->read_response($conn); + + if ($wanthash) { + return map { split(': ', $_) } @resp; + } elsif (wantarray) { + return @resp; + } else { + return $resp[0]; + } +} + +sub command { + my ($self, $command) = @_; + + return if (!$command); + + return $self->sendcommand('Action' => 'Command', + 'Command' => $command, 1 ); +} + +sub monitor { + my ($self, $channel, $file) = @_; + + return if (!$channel); + + return $self->sendcommand('Action' => 'Monitor', + 'Channel' => $channel, + 'File' => $file, 1 ); +} + +sub changemonitor { + my ($self, $channel, $file) = @_; + + return if (!$channel); + + return $self->sendcommand('Action' => 'ChangeMonitor', + 'Channel' => $channel, + 'File' => $file, 1 ); +} + +sub stopmonitor { + my ($self, $channel, $file) = @_; + + return if (!$channel); + + return $self->sendcommand('Action' => 'StopMonitor', + 'Channel' => $channel, + 'File' => $file, 1 ); +} + + +sub disconnect { + my ($self) = @_; + + my $conn = $self->connfd; + + my %resp = $self->sendcommand('Action' => 'Logoff'); + + + if ($resp{Response} eq 'Goodbye') { + $self->{_CONNFD} = undef; + $self->connected(0); + return 1; + } + + return 0; +} + +1; diff --git a/agc_2-X/trunk/libs/Asterisk/Outgoing.pm b/agc_2-X/trunk/libs/Asterisk/Outgoing.pm new file mode 100644 index 00000000..6e128332 --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk/Outgoing.pm @@ -0,0 +1,110 @@ +package Asterisk::Outgoing; + +=head1 NAME + +Asterisk::Outgoing - Create outgoing call queue file + +=head1 SYNOPSIS + +use Asterisk::Outgoing; + +my $out = new Asterisk::Outgoing; + +$out->setvariable('Channel', 'Zap/1/'); + +$out->setvariable('MaxRetries', 0); + +$out->setvariable('RetryTime', 60); + +$out->setvariable('WaitTime', 60); + +$out->setvariable('Application', 'Playback'); + +$out->setvariable('Data', 'beep'); + +$out->create_outgoing; + +=cut + +require 5.004; + +use Fcntl ':flock'; +use Asterisk; +@ISA = ('Asterisk'); + +$VERSION = '0.01'; + +sub new { + my ($class, %args) = @_; + my $self = {}; + $self->{OUTDIR} = '/var/spool/asterisk/outgoing'; + $self->{OUTTIME} = undef; + $self->{OUTVARS} = {}; + $self->{ALLOWEDVARS} = [ 'channel', 'maxretries', 'retrytime', 'waittime', 'context', 'extension', 'priority', 'application', 'data', 'callerid' ]; + bless $self, ref $class || $class; + return $self; +} + +sub outdir { + my ($self, $dir) = @_; + + if (defined($dir)) { + $self->{OUTDIR} = $dir; + } + + return $self->{OUTDIR}; +} + +sub outtime { + my ($self, $time) = @_; + + if (defined($time)) { + $self->{OUTTIME} = $time; + } elsif (!defined($self->{OUTTIME})) { + $self->{OUTTIME} = time(); + } + + return $self->{OUTTIME}; +} + +sub checkvariable { + my ($self, $var) = @_; + + my $ret = 0; + + foreach $allowed (@{$self->{ALLOWEDVARS}}) { + if ($allowed =~ /$var/i) { + $ret = 1; + } + } + return $ret; +} + +sub setvariable { + my ($self, $var, $value) = @_; + + if ($self->checkvariable($var)) { + $self->{OUTVARS}{$var} = $value; + } +} + +sub create_outgoing { + my ($self) = @_; + + my $time = $self->outtime(); + + my $outdir = $self->outdir(); + my $filename = $outdir . '/' . $time . '.outgoing'; + open(OUTFILE, ">$filename") || return 0; + flock(OUTFILE, LOCK_EX); + utime($time, $time, $filename); + foreach my $var (keys %{$self->{OUTVARS}}) { + print OUTFILE "$var: " . $self->{OUTVARS}{$var} . "\n"; + } + flock(OUTFILE, LOCK_UN); + close(OUTFILE); + utime($time, $time, $filename); + return 1; +} + +1; diff --git a/agc_2-X/trunk/libs/Asterisk/QCall.pm b/agc_2-X/trunk/libs/Asterisk/QCall.pm new file mode 100644 index 00000000..25f75a9c --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk/QCall.pm @@ -0,0 +1,61 @@ +package Asterisk::QCall; + +require 5.004; + +use Fcntl ':flock'; +use Asterisk; + +$VERSION = '0.01'; + +sub version { $VERSION; } + +sub new { + my ($class, %args) = @_; + my $self = {}; + $self->{QUEUEDIR} = '/var/spool/asterisk/qcall'; + $self->{QUEUETIME} = undef; + bless $self, ref $class || $class; + return $self; +} + +sub DESTROY { } + +sub queuedir { + my ($self, $dir) = @_; + + if (defined($dir)) { + $self->{QUEUEDIR} = $dir; + } + + return $self->{QUEUEDIR}; +} + +sub queuetime { + my ($self, $time) = @_; + + if (defined($time)) { + $self->{QUEUETIME} = $time; + } elsif (!defined($self->{QUEUETIME})) { + $self->{QUEUETIME} = time(); + } + + return $self->{QUEUETIME}; +} + +sub create_qcall { + my ($self, $dialstring, $callerid, $extension, $maxsecs, $identifier, $response) = @_; + + my $time = $self->queuetime(); + + my $queuedir = $self->queuedir(); + my $filename = $queuedir . '/' . $time . '.queue'; + open(QFILE, ">$filename") || return 0; + flock(QFILE, LOCK_EX); + print QFILE "$dialstring $callerid $extension $maxsecs $identifier $response"; + flock(QFILE, LOCK_UN); + close(QFILE); + my $ret = utime($time, $time, $filename); + return 1; +} + +1; diff --git a/agc_2-X/trunk/libs/Asterisk/Voicemail.pm b/agc_2-X/trunk/libs/Asterisk/Voicemail.pm new file mode 100644 index 00000000..780cef56 --- /dev/null +++ b/agc_2-X/trunk/libs/Asterisk/Voicemail.pm @@ -0,0 +1,261 @@ +package Asterisk::Voicemail; + +require 5.004; + +=head1 NAME + +Asterisk::Voicemail - Stuff to deal with asterisk voicemail + +=head1 SYNOPSIS + +This is not completed yet + +=head1 DESCRIPTION + +description + +=cut + +use Asterisk; + +@ISA = ( 'Asterisk' ); + +$VERSION = '0.01'; + +$DEBUG = 5; + +sub version { $VERSION; } + +sub new { + my ($class, %args) = @_; + my $self = {}; + bless $self, ref $class || $class; +# while (my ($key,$value) = each %args) { $self->set($key,$value); } + return $self; +} + +sub DESTROY { } + +sub spooldirectory { + my ($self, $directory) = @_; + + if (defined($directory)) { + $self->{'spooldirectory'} = $directory; + } else { + $self->{'spooldirectory'} = '/var/spool/asterisk/vm' if (!defined($self->{'spooldirectory'})); + } + + return $self->{'spooldirectory'}; +} + +sub sounddirectory { + my ($self, $directory) = @_; + + if (defined($directory)) { + $self->{'sounddirectory'} = $directory; + } else { + $self->{'sounddirectory'} = '/var/lib/asterisk/sounds' if (!defined($self->{'sounddirectory'})); + } + + return $self->{'sounddirectory'}; +} + +sub serveremail { + my ($self, $email) = @_; + + $self->{'serveremail'} = $email if (defined($email)); + + return $self->{'serveremail'}; +} + +sub format { + my ($self, @formats) = @_; + + if (@formats) { + $self->{'formats'} = @formats; + } + + return $self->{'formats'}; +} + +sub vmbox { + my ($self, $vmbox, $vmpass, $vmfn, $vmemail) = @_; + + if (defined($vmbox) && (defined($vmpass) || defined($vmfn) || defined($vmemail)) ) { + $self->{'vmbox'}{$vmbox}{'pass'} = $vmpass if (defined($vmpass)); + $self->{'vmbox'}{$vmbox}{'fn'} = $vmfn if (defined($vmfn)); + $self->{'vmbox'}{$vmbox}{'email'} = $vmemail if (defined($vmemail)); + } elsif (defined($vmbox)) { + return ($self->{'vmbox'}{$vmbox}{'pass'}, + $self->{'vmbox'}{$vmbox}{'fn'}, + $self->{'vmbox'}{$vmbox}{'email'} ); + } + +} + +sub getfolders { + my ($self, $vmbox) = @_; + + my @folders = (); + + my $spool = $self->spooldirectory(); + + foreach $file (<$spool/$vmbox/*>) { + if ( -d $file ) { + $file =~ s/$spool\/$vmbox\///; + push(@folders, $file); + } + } + return @folders; +} + +sub configfile { + my ($self, $configfile) = @_; + + if (defined($configfile)) { + $self->{'configfile'} = $configfile; + } else { + $self->{'configfile'} = '/etc/asterisk/voicemail.conf' if (!defined($self->{'configfile'})); + } + + return $self->{'configfile'}; +} + +sub readconfig { + my ($self) = @_; + + my $context = ''; + my $line = ''; + + my $configfile = $self->configfile(); + + open(CF, "<$configfile") || die "Error loading $configfile: $!\n"; + while ($line = ) { + chop($line); + + $line =~ s/;.*$//; + $line =~ s/\s*$//; + + if ($line =~ /^;/) { + next; + } elsif ($line =~ /^\s*$/) { + next; + } elsif ($line =~ /^\[(\w+)\]$/) { + $context = $1; + print STDERR "Context: $context\n" if ($DEBUG>3); + } elsif ($line =~ /^format\s*[=>]+\s*(.*)/) { + my $formats = $1; + $self->format(split(/|/, $formats)); + } elsif ($line =~ /^serveremail\s*[=>]+\s*(.*)/) { + $self->serveremail($1); + } elsif ($line =~ /^(\d+)\s*[=>]+\s*(.*)/) { + my $vmbox = $1; + my $vmstr = $2; + my ($vmpass, $vmfn, $vmemail) = split(/,/, $vmstr); + print STDERR "VM BOX ($vmbox)\n" if ($DEBUG>3); + $self->vmbox($vmbox, $vmpass, $vmfn, $vmstr); + } else { + print STDERR "Unknown line: $line\n" if ($DEBUG); + } + } + + close(CF); +} + +sub appendsoundfile { + my ($self, $source, $dest) = @_; + + open(IN, "<$source") || return 0; + open(OUT, ">>$dest") || return 0; + while () { + print OUT $_; + } + close(IN); + close(OUT); + return 1; +} + +sub validmailbox { + my ($self, $vmbox) = @_; + + return 1 if ($self->vmbox($vmbox)); + return 0; +} + +sub msgcount { + my ($self, $vmbox, $folder) = @_; + + my $count = 0; + + return $count if (!defined($vmbox) || !defined($folder)); + + my $spool = $self->spooldirectory() . '/' . $vmbox . '/' . $folder; + + if (opendir(DIR, $spool)) { + my @msgs = grep(/^msg.*\.txt$/, readdir(DIR)); + $count = $#msgs+1; + closedir(DIR); + } + return $count; +} + +sub msgcountstr { + my ($self, $vmbox, $folder) = @_; + + my $count = $self->msgcount($vmbox, $folder); + + if ($count > 1) { + return "$count messages"; + } elsif ($count > 0) { + return "$count message"; + } else { + return "no messages"; + } +} + +sub createdefaultmailbox { + my ($self, $vmbox) = @_; + + my $spool = $self->spooldirectory(); + my $sounddir = $self->sounddirectory(); + + my $vmdir = "$spool/$vmbox"; + + + if ( -d $vmdir ) { + print STDERR "Directory already exists: $vmdir\n" if ($DEBUG); + } else { + mkdir($vmdir, 0755) || return 0; + mkdir("$vmdir/INBOX", 0755) || return 0; + } + + $self->appendsoundfile("$sounddir/vm-theperson.gsm", "$vmdir/unavail.gsm"); + $self->appendsoundfile("$sounddir/vm-theperson.gsm", "$vmdir/busy.gsm"); + $self->appendsoundfile("$sounddir/vm-extension.gsm", "$vmdir/greet.gsm"); + + foreach $chr (split(//, $vmbox)) { + $self->appendsoundfile("$sounddir/digits/$chr.gsm", "$vmdir/unavail.gsm"); + $self->appendsoundfile("$sounddir/digits/$chr.gsm", "$vmdir/busy.gsm"); + $self->appendsoundfile("$sounddir/digits/$chr.gsm", "$vmdir/greet.gsm"); + } + + $self->appendsoundfile("$sounddir/vm-isunavail.gsm", "$vmdir/unavail.gsm"); + $self->appendsoundfile("$sounddir/vm-isonphone.gsm", "$vmdir/busy.gsm"); + + return 1; +} + +sub messages { + my ($self, $messages, $folder) = @_; + + my $path = $self->spooldirectory() . '/' . $mailbox . '/' . $folder; + if (opendir(DIR, $path)) { + my @msgs = sort grep(/^msg....\.txt$/, readdir(DIR)); + closedir(DIR); + return map { s/^msg(....)\.txt$/$1/; $_ } @msgs; + } + return (); +} + +1; + diff --git a/agc_2-X/trunk/libs/Asterisk/buttons.gif b/agc_2-X/trunk/libs/Asterisk/buttons.gif new file mode 100644 index 00000000..6de93e84 Binary files /dev/null and b/agc_2-X/trunk/libs/Asterisk/buttons.gif differ diff --git a/agc_2-X/trunk/libs/Asterisk/vm_indicator_anim.gif b/agc_2-X/trunk/libs/Asterisk/vm_indicator_anim.gif new file mode 100644 index 00000000..9445e76f Binary files /dev/null and b/agc_2-X/trunk/libs/Asterisk/vm_indicator_anim.gif differ diff --git a/agc_2-X/trunk/libs/Asterisk/voicemail_digits.gif b/agc_2-X/trunk/libs/Asterisk/voicemail_digits.gif new file mode 100644 index 00000000..4ed7026f Binary files /dev/null and b/agc_2-X/trunk/libs/Asterisk/voicemail_digits.gif differ diff --git a/agc_2-X/trunk/libs/Asterisk/voicemail_new.gif b/agc_2-X/trunk/libs/Asterisk/voicemail_new.gif new file mode 100644 index 00000000..240d4ef8 Binary files /dev/null and b/agc_2-X/trunk/libs/Asterisk/voicemail_new.gif differ diff --git a/agc_2-X/trunk/libs/Asterisk/voicemail_old.gif b/agc_2-X/trunk/libs/Asterisk/voicemail_old.gif new file mode 100644 index 00000000..a9bbc75e Binary files /dev/null and b/agc_2-X/trunk/libs/Asterisk/voicemail_old.gif differ diff --git a/agc_2-X/trunk/libs/Asterisk/voicemail_up.gif b/agc_2-X/trunk/libs/Asterisk/voicemail_up.gif new file mode 100644 index 00000000..8e6fda81 Binary files /dev/null and b/agc_2-X/trunk/libs/Asterisk/voicemail_up.gif differ diff --git a/agc_2-X/trunk/libs/MySQL.pm b/agc_2-X/trunk/libs/MySQL.pm new file mode 100644 index 00000000..e6a92c80 --- /dev/null +++ b/agc_2-X/trunk/libs/MySQL.pm @@ -0,0 +1,1015 @@ +package Net::MySQL; + +use 5.004; +use IO::Socket; +use Carp; +use vars qw($VERSION $DEBUG); +use strict; +$VERSION = '0.08'; + +use constant COMMAND_SLEEP => "\x00"; +use constant COMMAND_QUIT => "\x01"; +use constant COMMAND_INIT_DB => "\x02"; +use constant COMMAND_QUERY => "\x03"; +use constant COMMAND_FIELD_LIST => "\x04"; +use constant COMMAND_CREATE_DB => "\x05"; +use constant COMMAND_DROP_DB => "\x06"; +use constant COMMAND_REFRESH => "\x07"; +use constant COMMAND_SHUTDOWN => "\x08"; +use constant COMMAND_STATISTICS => "\x09"; +use constant COMMAND_PROCESS_INFO => "\x0A"; +use constant COMMAND_CONNECT => "\x0B"; +use constant COMMAND_PROCESS_KILL => "\x0C"; +use constant COMMAND_DEBUG => "\x0D"; +use constant COMMAND_PING => "\x0E"; +use constant COMMAND_TIME => "\x0F"; +use constant COMMAND_DELAYED_INSERT => "\x10"; +use constant COMMAND_CHANGE_USER => "\x11"; +use constant COMMAND_BINLOG_DUMP => "\x12"; +use constant COMMAND_TABLE_DUMP => "\x13"; +use constant COMMAND_CONNECT_OUT => "\x14"; + +use constant DEFAULT_PORT_NUMBER => 3306; +use constant BUFFER_LENGTH => 1460; +use constant DEFAULT_UNIX_SOCKET => '/tmp/mysql.sock'; + + +sub new +{ + my $class = shift; + my %args = @_; + + my $self = bless { + hostname => $args{hostname}, + unixsocket => $args{unixsocket} || DEFAULT_UNIX_SOCKET, + port => $args{port} || DEFAULT_PORT_NUMBER, + database => $args{database}, + user => $args{user}, + password => $args{password}, + timeout => $args{timeout} || 60, + socket => undef, + salt => '', + protocol_version => undef, + client_capabilities => 0, + affected_rows_length => 0, + }, $class; + $self->debug($args{debug}); + $self->_initialize; + return $self; +} + + +sub query +{ + my $self = shift; + my $sql = join '', @_; + my $mysql = $self->{socket}; + + return $self->_execute_command(COMMAND_QUERY, $sql); +} + + +sub create_database +{ + my $self = shift; + my $db_name = shift; + my $mysql = $self->{socket}; + + return $self->_execute_command(COMMAND_CREATE_DB, $db_name); +} + + +sub drop_database +{ + my $self = shift; + my $db_name = shift; + my $mysql = $self->{socket}; + + return $self->_execute_command(COMMAND_DROP_DB, $db_name); +} + + +sub close +{ + my $self = shift; + my $mysql = $self->{socket}; + return unless $mysql->can('send'); + + my $quit_message = + chr(length(COMMAND_QUIT)). "\x00\x00\x00". COMMAND_QUIT; + $mysql->send($quit_message, 0); + $self->_dump_packet($quit_message) if Net::MySQL->debug; + $mysql->close; +} + + +sub get_affected_rows_length +{ + my $self = shift; + $self->{affected_rows_length}; +} + + +sub get_insert_id +{ + my $self = shift; + $self->{insert_id}; +} + + +sub create_record_iterator +{ + my $self = shift; + return undef unless $self->has_selected_record; + + my $record = Net::MySQL::RecordIterator->new( + $self->{selected_record} + ); + $self->{selected_record} = undef; + $record->parse; + return $record; +} + + +sub has_selected_record +{ + my $self = shift; + $self->{selected_record} ? 1 : undef; +} + + +sub is_error +{ + my $self = shift; + $self->{error_code} ? 1 : undef; +} + + +sub get_error_code +{ + my $self = shift; + $self->{error_code}; +} + + +sub get_error_message +{ + my $self = shift; + $self->{server_message}; +} + + +sub debug +{ + my $class = shift; + $DEBUG = shift if @_; + $DEBUG; +} + + +sub _connect +{ + my $self = shift; + + my $mysql; + if ($self->{hostname}) { + printf "Use INET Socket: %s %d/tcp\n", $self->{hostname}, $self->{port} + if $self->debug; + $mysql = IO::Socket::INET->new( + PeerAddr => $self->{hostname}, + PeerPort => $self->{port}, + Proto => 'tcp', + Timeout => $self->{timeout} || 60, + ) or croak "Couldn't connect to $self->{hostname}:$self->{port}/tcp: $@"; + } + else { + printf "Use UNIX Socket: %s\n", $self->{unixsocket} if $self->debug; + $mysql = IO::Socket::UNIX->new( + Type => SOCK_STREAM, + Peer => $self->{unixsocket}, + ) or croak "Couldn't connect to $self->{unixsocket}: $@"; + } + $mysql->autoflush(1); + $self->{socket} = $mysql; +} + + +sub _get_server_information +{ + my $self = shift; + my $mysql = $self->{socket}; + + my $message; + $mysql->recv($message, BUFFER_LENGTH, 0); + $self->_dump_packet($message) + if Net::MySQL->debug; + my $i = 0; + my $packet_length = ord substr $message, $i, 1; + $i += 4; + $self->{protocol_version} = ord substr $message, $i, 1; + printf "Protocol Version: %d\n", $self->{protocol_version} + if Net::MySQL->debug; + if ($self->{protocol_version} == 10) { + $self->{client_capabilities} = 1; + } + + ++$i; + my $string_end = index($message, "\0", $i) - $i; + $self->{server_version} = substr $message, $i, $string_end; + printf "Server Version: %s\n", $self->{server_version} + if Net::MySQL->debug; + + $i += $string_end + 1; + $self->{server_thread_id} = unpack 'v', substr $message, $i, 2; + $i += 4; + $self->{salt} = substr $message, $i, 8; + printf "Salt: %s\n", $self->{salt} if Net::MySQL->debug; +} + + +sub _request_authentication +{ + my $self = shift; + my $mysql = $self->{socket}; + $self->_send_login_message(); + + my $auth_result; + $mysql->recv($auth_result, BUFFER_LENGTH, 0); + $self->_dump_packet($auth_result) if Net::MySQL->debug; + if ($self->_is_error($auth_result)) { + $mysql->close; + if (length $auth_result < 7) { + croak "Timeout of authentication"; + } + croak substr $auth_result, 7; + } + print "connect database\n" if Net::MySQL->debug; +} + + +sub _send_login_message +{ + my $self = shift; + my $mysql = $self->{socket}; + + my $body = "\0\0\x01\x8d\x00\00\00\00". join "\0", + $self->{user}, + Net::MySQL::Password->scramble( + $self->{password}, $self->{salt}, $self->{client_capabilities} + ), + $self->{database}; + my $login_message = chr(length($body)-3). $body; + $mysql->send($login_message, 0); + $self->_dump_packet($login_message) if Net::MySQL->debug; +} + + + +sub _execute_command +{ + my $self = shift; + my $command = shift; + my $sql = shift; + my $mysql = $self->{socket}; + + my $message = pack('V', length($sql) + 1). $command. $sql; + + $mysql->send($message, 0); + $self->_dump_packet($message) if Net::MySQL->debug; + + my $result; + $mysql->recv($result, BUFFER_LENGTH, 0); + $self->_dump_packet($result) if Net::MySQL->debug; + $self->_reset_status; + + if ($self->_is_error($result)) { + return $self->_set_error_by_packet($result); + } + elsif ($self->_is_select_query_result($result)) { + return $self->_get_record_by_server($result); + } + elsif ($self->_is_update_query_result($result)){ + return $self->_get_affected_rows_information_by_packet($result); + } + else { + croak 'Unknown Result: '. $self->_get_result_length($result). 'byte'; + } +} + + +sub _initialize +{ + my $self = shift; + $self->_connect; + $self->_get_server_information; + $self->_request_authentication; +} + + +sub _set_error_by_packet +{ + my $self = shift; + my $packet = shift; + + my $error_message = $self->_get_server_message($packet); + $self->{server_message} = $error_message; + $self->{error_code} = $self->_get_error_code($packet); + return undef; +} + + +sub _get_record_by_server +{ + my $self = shift; + my $packet = shift; + my $mysql = $self->{socket}; + + $self->_get_column_length($packet); + while ($self->_has_next_packet($packet)) { + my $next_result; + $mysql->recv($next_result, BUFFER_LENGTH, 0); + $packet .= $next_result; + $self->_dump_packet($next_result) if Net::MySQL->debug; + } + $self->{selected_record} = $packet; +} + + +sub _get_affected_rows_information_by_packet +{ + my $self = shift; + my $packet = shift; + + $self->{affected_rows_length} = $self->_get_affected_rows_length($packet); + $self->{insert_id} = $self->_get_insert_id($packet); + $self->{server_message} = $self->_get_server_message($packet); + return $self->{affected_rows_length}; +} + + +sub _is_error +{ + my $self = shift; + my $packet = shift; + return 1 if length $packet < 4; + ord(substr $packet, 4) == 255; +} + + +sub _is_select_query_result +{ + my $self = shift; + my $packet = shift; + return undef if $self->_is_error($packet); + ord(substr $packet, 4) >= 1; +} + + +sub _is_update_query_result +{ + my $self = shift; + my $packet = shift; + return undef if $self->_is_error($packet); + ord(substr $packet, 4) == 0; +} + + +sub _get_result_length +{ + my $self = shift; + my $packet = shift; + ord(substr $packet, 0, 1) +} + + +sub _get_column_length +{ + my $self = shift; + my $packet = shift; + ord(substr $packet, 4); +} + + +sub _get_affected_rows_length +{ + my $self = shift; + my $packet = shift; + ord(substr $packet, 5, 1); +} + + +sub _get_insert_id +{ + my $self = shift; + my $packet = shift; + return ord(substr $packet, 6, 1) if ord(substr $packet, 6, 1) != 0xfc; + unpack 'v', substr $packet, 7, 2; +} + + +sub _get_server_message +{ + my $self = shift; + my $packet = shift; + return '' if length $packet < 7; + substr $packet, 7; +} + + +sub _get_error_code +{ + my $self = shift; + my $packet = shift; + $self->_is_error($packet) + or croak "_get_error_code(): Is not error packet"; + unpack 'v', substr $packet, 5, 2; +} + + +sub _reset_status +{ + my $self = shift; + $self->{insert_id} = 0; + $self->{server_message} = ''; + $self->{error_code} = undef; + $self->{selected_record} = undef; +} + + +sub _has_next_packet +{ + my $self = shift; + substr($_[0], -1) ne "\xfe"; +} + + +sub _dump_packet +{ + my $self = shift; + my $packet = shift; + + my ($method_name) = (caller(1))[3]; + printf "%s():\n%s\n", + $method_name, + join ' ', map { sprintf "%02x", ord $_ } split //, $packet; + printf "%s():\n%s\n", + $method_name, + join ' ', map { m/[\d \w\._]/ ? $_ : '.' } split //, $packet; + print "--\n"; +} + + + +package Net::MySQL::RecordIterator; +use strict; + +use constant NULL_COLUMN => 251; +use constant UNSIGNED_CHAR_COLUMN => 251; +use constant UNSIGNED_SHORT_COLUMN => 252; +use constant UNSIGNED_INT24_COLUMN => 253; +use constant UNSIGNED_INT32_COLUMN => 254; +use constant UNSIGNED_CHAR_LENGTH => 1; +use constant UNSIGNED_SHORT_LENGTH => 2; +use constant UNSIGNED_INT24_LENGTH => 3; +use constant UNSIGNED_INT32_LENGTH => 4; +use constant UNSIGNED_INT32_PAD_LENGTH => 4; + + +sub new +{ + my $class = shift; + my $packet = shift; + bless { + packet => $packet, + position => 0, + column => [], + }, $class; +} + + +sub parse +{ + my $self = shift; + $self->_get_column_length; + $self->_get_column_name; +} + + +sub each +{ + my $self = shift; + my @result; + return undef if $self->is_end_of_packet; + + for (1..$self->{column_length}) { + push @result, $self->_get_string_and_seek_position; + } + $self->{position} += 4; + return \@result; +} + + +sub is_end_of_packet +{ + my $self = shift; + length $self->{packet} <= $self->{position} + 1; +} + + +sub get_field_length +{ + my $self = shift; + $self->{column_length}; +} + + +sub get_field_names +{ + my $self = shift; + map { $_->{column} } @{$self->{column}}; +} + + +sub _get_column_length +{ + my $self = shift; + $self->{position} += 4; + $self->{column_length} = ord substr $self->{packet}, $self->{position}, 1; + $self->{position} += 5; + printf "Column Length: %d\n", $self->{column_length} + if Net::MySQL->debug; +} + + +sub _get_column_name +{ + my $self = shift; + for my $i (1.. $self->{column_length}) { + push @{$self->{column}}, { + table => $self->_get_string_and_seek_position, + column => $self->_get_string_and_seek_position, + }; + $self->{position} += 14; + } + $self->{position} += 5; + + printf "Column name: %s\n", + join ", ", map { $_->{column} } @{$self->{column}} + if Net::MySQL->debug; +} + + +sub _get_string_and_seek_position +{ + my $self = shift; + + my $length = $self->_get_field_length(); + return undef unless defined $length; + + my $string = substr $self->{packet}, $self->{position}, $length; + $self->{position} += $length; + return $string; +} + + +sub _get_field_length +{ + my $self = shift; + + my $head = ord substr( + $self->{packet}, + $self->{position}, + UNSIGNED_CHAR_LENGTH + ); + $self->{position} += UNSIGNED_CHAR_LENGTH; + + return undef if $head == NULL_COLUMN; + if ($head < UNSIGNED_CHAR_COLUMN) { + return $head; + } + elsif ($head == UNSIGNED_SHORT_COLUMN) { + warn "in short"; + my $length = unpack 'v', substr( + $self->{packet}, + $self->{position}, + UNSIGNED_SHORT_LENGTH + ); + $self->{position} += UNSIGNED_SHORT_LENGTH; + return $length; + } + elsif ($head == UNSIGNED_INT24_COLUMN) { + warn "in int23"; + my $int24 = substr( + $self->{packet}, $self->{position}, + UNSIGNED_INT24_LENGTH + ); + my $length = unpack('C', substr($int24, 0, 1)) + + (unpack('C', substr($int24, 1, 1)) << 8) + + (unpack('C', substr($int24, 2, 1)) << 16); + $self->{position} += UNSIGNED_INT24_LENGTH; + return $length; + } + else { + warn "in int32"; + my $int32 = substr( + $self->{packet}, $self->{position}, + UNSIGNED_INT32_LENGTH + ); + my $length = unpack('C', substr($int32, 0, 1)) + + (unpack('C', substr($int32, 1, 1)) << 8) + + (unpack('C', substr($int32, 2, 1)) << 16) + + (unpack('C', substr($int32, 3, 1)) << 24); + $self->{position} += UNSIGNED_INT32_LENGTH; + $self->{position} += UNSIGNED_INT32_PAD_LENGTH; + return $length; + } +} + + +package Net::MySQL::Password; +use strict; + +sub scramble +{ + my $class = shift; + my $password = shift; + my $hash_seed = shift; + my $client_capabilities = shift; + + return '' unless $password; + return '' if length $password == 0; + + my $hsl = length $hash_seed; + my @out; + my @hash_pass = _get_hash($password); + my @hash_mess = _get_hash($hash_seed); + + my ($max_value, $seed, $seed2); + my ($dRes, $dSeed, $dMax); + if ($client_capabilities < 1) { + $max_value = 0x01FFFFFF; + $seed = _xor_by_long($hash_pass[0], $hash_mess[0]) % $max_value; + $seed2 = int($seed / 2); + } else { + $max_value= 0x3FFFFFFF; + $seed = _xor_by_long($hash_pass[0], $hash_mess[0]) % $max_value; + $seed2 = _xor_by_long($hash_pass[1], $hash_mess[1]) % $max_value; + } + $dMax = $max_value; + + for (my $i=0; $i < $hsl; $i++) { + $seed = int(($seed * 3 + $seed2) % $max_value); + $seed2 = int(($seed + $seed2 + 33) % $max_value); + $dSeed = $seed; + $dRes = $dSeed / $dMax; + push @out, int($dRes * 31) + 64; + } + + if ($client_capabilities == 1) { + # Make it harder to break + $seed = ($seed * 3 + $seed2 ) % $max_value; + $seed2 = ($seed + $seed2 + 33 ) % $max_value; + $dSeed = $seed; + + $dRes = $dSeed / $dMax; + my $e = int($dRes * 31); + for (my $i=0; $i < $hsl ; $i++) { + $out[$i] ^= $e; + } + } + return join '', map { chr $_ } @out; +} + + +sub _get_hash +{ + my $password = shift; + + my $nr = 1345345333; + my $add = 7; + my $nr2 = 0x12345671; + my $tmp; + my $pwlen = length $password; + my $c; + + for (my $i=0; $i < $pwlen; $i++) { + my $c = substr $password, $i, 1; + next if $c eq ' ' || $c eq "\t"; + my $tmp = ord $c; + my $value = ((_and_by_char($nr, 63) + $add) * $tmp) + $nr * 256; + $nr = _xor_by_long($nr, $value); + $nr2 += _xor_by_long(($nr2 * 256), $nr); + $add += $tmp; + } + return (_and_by_long($nr, 0x7fffffff), _and_by_long($nr2, 0x7fffffff)); +} + + +sub _and_by_char +{ + my $source = shift; + my $mask = shift; + + return $source & $mask; +} + + +sub _and_by_long +{ + my $source = shift; + my $mask = shift || 0xFFFFFFFF; + + return _cut_off_to_long($source) & _cut_off_to_long($mask); +} + + +sub _xor_by_long +{ + my $source = shift; + my $mask = shift || 0; + + return _cut_off_to_long($source) ^ _cut_off_to_long($mask); +} + + +sub _cut_off_to_long +{ + my $source = shift; + + if ($] >= 5.006) { + $source = $source % (0xFFFFFFFF + 1) if $source > 0xFFFFFFFF; + return $source; + } + while ($source > 0xFFFFFFFF) { + $source -= 0xFFFFFFFF + 1; + } + return $source; +} + + +1; +__END__ + +=head1 NAME + +Net::MySQL - Pure Perl MySQL network protocol interface. + +=head1 SYNOPSIS + + use Net::MySQL; + + my $mysql = Net::MySQL->new( + # hostname => 'mysql.example.jp', # Default use UNIX socket + database => 'your_database_name', + user => 'user', + password => 'password' + ); + + # INSERT example + $mysql->query(q{ + INSERT INTO tablename (first, next) VALUES ('Hello', 'World') + }); + printf "Affected row: %d\n", $mysql->get_affected_rows_length; + + # SLECT example + $mysql->query(q{SELECT * FROM tablename}); + my $record_set = $mysql->create_record_iterator; + while (my $record = $record_set->each) { + printf "First column: %s Next column: %s\n", + $record->[0], $record->[1]; + } + $mysql->close; + +=head1 DESCRIPTION + +Net::MySQL is a Pure Perl client interface for the MySQL database. This module implements network protocol between server and client of MySQL, thus you don't need external MySQL client library like libmysqlclient for this module to work. It means this module enables you to connect to MySQL server from some operation systems which MySQL is not ported. How nifty! + +Since this module's final goal is to completely replace DBD::mysql, API is made similar to that of DBI. + +From perl you activate the interface with the statement + + use Net::MySQL; + +After that you can connect to multiple MySQL daemon and send multiple queries to any of them via a simple object oriented interface. + +There are two classes which have public APIs: Net::MySQL and Net::MySQL::RecordIterator. + + $mysql = Net::MySQL->new( + hostname => $host, + database => $database, + user => $user, + password => $password, + ); + +Once you have connected to a daemon, you can can execute SQL with: + + $mysql->query(q{ + INSERT INTO foo (id, message) VALUES (1, 'Hello World') + }); + +If you want to retrieve results, you need to create a so-called statement handle with: + + $mysql->query(q{ + SELECT id, message FROM foo + }); + if ($mysql->has_selected_record) { + my $a_record_iterator = $mysql->create_record_iterator; + # ... + } + +This Net::MySQL::RecordIterator object can be used for multiple purposes. First of all you can retreive a row of data: + + my $record = $a_record_iterator->each; + +The each() method takes out the reference result of one line at a time, and the return value is ARRAY reference. + +=head2 Net::MySQL API + +=over 4 + +=item new(HASH) + + use Net::MySQL; + use strict; + + my $mysql = Net::MySQL->new( + unixsocket => $path_to_socket, + hostname => $host, + database => $database, + user => $user, + password => $password, + ); + +The constructor of Net::MySQL. Connection with MySQL daemon is established and the object is returned. Argument hash contains following parameters: + +=over 8 + +=item unixsocket + +Path of the UNIX socket where MySQL daemon. default is F. +Supposing I is omitted, it will connect by I. + +=item hostname + +Name of the host where MySQL daemon runs. +Supposing I is specified, it will connect by I. + +=item port + +Port where MySQL daemon listens to. default is 3306. + +=item database + +Name of the database to connect. + +=item user / password + +Username and password for database authentication. + +=item timeout + +The waiting time which carries out a timeout when connection is overdue is specified. + +=item debug + +The exchanged packet will be outputted if a true value is given. + +=back + + +=item create_database(DB_NAME) + +A create_DATABASE() method creates a database by the specified name. + + $mysql->create_database('example_db'); + die $mysql->get_error_message if $mysql->is_error; + +=item drop_database(DB_NAME) + +A drop_database() method deletes the database of the specified name. + + $mysql->drop_database('example_db'); + die $mysql->get_error_message if $mysql->is_error; + +=item query(SQL_STRING) + +A query() method transmits the specified SQL string to MySQL database, and obtains the response. + +=item create_record_iterator() + +When SELECT type SQL is specified, Net::MySQL::RecordIterator object which shows the reference result is returned. + + $mysql->query(q{SELECT * FROM table}); + my $a_record_iterator = $mysql->create_recrod_iterator(); + +Net::MySQL::RecordIterator object is applicable to acquisition of a reference result. See L<"/Net::SQL::RecordIterator API"> for more. + +=item get_affected_rows_length() + +returns the number of records finally influenced by specified SQL. + + my $affected_rows = $mysql->get_affected_rows_length; + +=item get_insert_id() + +MySQL has the ability to choose unique key values automatically. If this happened, the new ID will be stored in this attribute. + +=item is_error() + +TRUE will be returned if the error has occurred. + +=item has_selected_record() + +TRUE will be returned if it has a reference result by SELECT. + +=item get_field_length() + +return the number of column. + +=item get_field_names() + +return column names by ARRAY. + +=item close() + +transmits an end message to MySQL daemon, and closes a socket. + +=back + +=head2 Net::MySQL::RecordIterator API + +Net::MySQL::RecordIterator object is generated by the query() method of Net::MySQL object. Thus it has no public constructor method. + +=over 4 + +=item each() + +each() method takes out only one line from a result, and returns it as an ARRAY reference. C is returned when all the lines has been taken out. + + while (my $record = $a_record_iterator->each) { + printf "Column 1: %s Column 2: %s Collumn 3: %s\n", + $record->[0], $record->[1], $record->[2]; + } + +=back + +=head1 SUPPORT OPERATING SYSTEM + +This module has been tested on these OSes. + +=over 4 + +=item * MacOS 9.x + +with MacPerl5.6.1r. + +=item * MacOS X + +with perl5.6.0 build for darwin. + +=item * Windows2000 + +with ActivePerl5.6.1 build631. + +=item * FreeBSD 3.4 and 4.x + +with perl5.6.1 build for i386-freebsd. + +with perl5.005_03 build for i386-freebsd. + +=item * Linux + +with perl 5.005_03 built for ppc-linux. + +with perl 5.6.0 bult for i386-linux. + +=item * Solaris 2.6 (SPARC) + +with perl 5.6.1 built for sun4-solaris. + +with perl 5.004_04 built for sun4-solaris. + +Can use on Solaris2.6 with perl5.004_04, although I is failure. + +=back + +This list is the environment which I can use by the test usually. Net::MySQL will operate also in much environment which is not in a list. + +I believe this module can work with whatever perls which has B. I'll be glad if you give me a report of successful installation of this module on I OSes. + +=head1 SEE ALSO + +L, L + +=head1 AUTHOR + +Hiroyuki OYAMA Eoyama@module.jpE + +=head1 COPYRIGHT AND LICENCE + +Copyright (C) 2002 Hiroyuki OYAMA. Japan. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/agc_2-X/trunk/libs/Net/HTTP.pm b/agc_2-X/trunk/libs/Net/HTTP.pm new file mode 100644 index 00000000..80786825 --- /dev/null +++ b/agc_2-X/trunk/libs/Net/HTTP.pm @@ -0,0 +1,266 @@ +package Net::HTTP; + +# $Id: HTTP.pm,v 1.43 2002/12/26 09:13:53 gisle Exp $ + +use strict; +use vars qw($VERSION @ISA); + +$VERSION = "1.00"; +eval { require IO::Socket::INET } || require IO::Socket; +require Net::HTTP::Methods; + +@ISA=qw(IO::Socket::INET Net::HTTP::Methods); + +sub configure { + my($self, $cnf) = @_; + $self->http_configure($cnf); +} + +sub http_connect { + my($self, $cnf) = @_; + $self->SUPER::configure($cnf); +} + +1; + +__END__ + +=head1 NAME + +Net::HTTP - Low-level HTTP connection (client) + +=head1 SYNOPSIS + + use Net::HTTP; + my $s = Net::HTTP->new(Host => "www.perl.com) || die $@; + $s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0"); + my($code, $mess, %h) = $s->read_response_headers; + + while (1) { + my $buf; + my $n = $s->read_entity_body($buf, 1024); + die "read failed: $!" unless defined $n; + last unless $n; + print $buf; + } + +=head1 DESCRIPTION + +The C class is a low-level HTTP client. An instance of the +C class represents a connection to an HTTP server. The +HTTP protocol is described in RFC 2616. The C class +support C and C. + +C is a sub-class of C. You can mix the +methods described below with reading and writing from the socket +directly. This is not necessary a good idea, unless you know what you +are doing. + +The following methods are provided (in addition to those of +C): + +=over + +=item $s = Net::HTTP->new( %options ) + +The C constructor method takes the same options as +C's as well as these: + + Host: Initial host attribute value + KeepAlive: Initial keep_alive attribute value + SendTE: Initial send_te attribute_value + HTTPVersion: Initial http_version attribute value + PeerHTTPVersion: Initial peer_http_version attribute value + MaxLineLength: Initial max_line_length attribute value + MaxHeaderLines: Initial max_header_lines attribute value + +The C option is also the default for C's +C. The C defaults to 80 if not provided. + +The C option provided by C's constructor +method is not allowed. + +If unable to connect to the given HTTP server then the constructor +returns C and $@ contains the reason. After a successful +connect, a C object is returned. + +=item $s->host + +Get/set the default value of the C header to send. The $host +should not be set to an empty string (or C). + +=item $s->keep_alive + +Get/set the I value. If this value is TRUE then the +request will be sent with headers indicating that the server should try +to keep the connection open so that multiple requests can be sent. + +The actual headers set will depend on the value of the C +and C attributes. + +=item $s->send_te + +Get/set the a value indicating if the request will be sent with a "TE" +header to indicate the transfer encodings that the server can chose to +use. If the C module is installed then this will +annouce that this client accept both the I and I +encodings. + +=item $s->http_version + +Get/set the HTTP version number that this client should announce. +This value can only be set to "1.0" or "1.1". The default is "1.1". + +=item $s->peer_http_version + +Get/set the protocol version number of our peer. This value will +initially be "1.0", but will be updated by a successful +read_response_headers() method call. + +=item $s->max_line_length + +Get/set a limit on the length of response line and response header +lines. The default is 4096. A value of 0 means no limit. + +=item $s->max_header_length + +Get/set a limit on the number of headers lines that a response can +have. The default is 128. A value of 0 means no limit. + +=item $s->format_request($method, $uri, %headers, [$content]) + +Format a request message and return it as a string. If the headers do +not include a C header, then a header is inserted with the value +of the C attribute. Headers like C and +C might also be added depending on the status of the +C attribute. + +If $content is given (and it is non-empty), then a C +header is automatically added unless it was already present. + +=item $s->write_request($method, $uri, %headers, [$content]) + +Format and send a request message. Arguments are the same as for +format_request(). Returns true if successful. + +=item $s->format_chunk( $data ) + +Returns the string to be written for the given chunk of data. + +=item $s->write_chunk($data) + +Will write a new chunk of request entity body data. This method +should only be used if the C header with a value of +C was sent in the request. Note, writing zero-length data is +a no-op. Use the write_chunk_eof() method to signal end of entity +body data. + +Returns true if successful. + +=item $s->format_chunk_eof( %trailers ) + +Returns the string to be written for signaling EOF when a +C of C is used. + +=item $s->write_chunk_eof( %trailers ) + +Will write eof marker for chunked data and optional trailers. Note +that trailers should not really be used unless is was signaled +with a C header. + +Returns true if successful. + +=item ($code, $mess, %headers) = $s->read_response_headers( %opts ) + +Read response headers from server and return it. The $code is the 3 +digit HTTP status code (see L) and $mess is the textual +message that came with it. Headers are then returned as key/value +pairs. Since key letter casing is not normalized and the same key can +even occur multiple times, assigning these values directly to a hash +is not wise. Only the $code is returned if this method is called in +scalar context. + +As a side effect this method updates the 'peer_http_version' +attribute. + +Options might be passed in as key/value pairs. There are currently +only two options supported; C and C. + +The C option will make read_response_headers() more forgiving +towards servers that have not learned how to speak HTTP properly. The +C option is a boolean flag, and is enabled by passing in a TRUE +value. The C option can be used to capture bad header lines +when C is enabled. The value should be an array reference. +Bad header lines will be pushed onto the array. + +The C option must be specified in order to communicate with +pre-HTTP/1.0 servers that don't describe the response outcome or the +data they send back with a header block. For these servers +peer_http_version is set to "0.9" and this method returns (200, +"Assumed OK"). + +The method will raise an exception (die) if the server does not speak +proper HTTP or if the C or C +limits are reached. If the C option is turned on and +C and C checks are turned off, +then no exception will be raised and this method will always +return a response code. + +=item $n = $s->read_entity_body($buf, $size); + +Reads chunks of the entity body content. Basically the same interface +as for read() and sysread(), but the buffer offset argument is not +supported yet. This method should only be called after a successful +read_response_headers() call. + +The return value will be C on read errors, 0 on EOF, -1 if no data +could be returned this time, otherwise the number of bytes assgined +to $buf. The $buf set to "" when the return value is -1. + +This method will raise exceptions (die) if the server does not speak +proper HTTP. This can only happen when reading chunked data. + +=item %headers = $s->get_trailers + +After read_entity_body() has returned 0 to indicate end of the entity +body, you might call this method to pick up any trailers. + +=item $s->_rbuf + +Get/set the read buffer content. The read_response_headers() and +read_entity_body() methods use an internal buffer which they will look +for data before they actually sysread more from the socket itself. If +they read too much, the remaining data will be left in this buffer. + +=item $s->_rbuf_length + +Returns the number of bytes in the read buffer. This should always be +the same as: + + length($s->_rbuf) + +but might be more efficient. + +=back + +=head1 SUBCLASSING + +The read_response_headers() and read_entity_body() will invoke the +sysread() method when they need more data. Subclasses might want to +override this method to contol how reading takes place. + +The object itself is a glob. Subclasses should avoid using hash key +names prefixed with C and C. + +=head1 SEE ALSO + +L, L, L + +=head1 COPYRIGHT + +Copyright 2001-2003 Gisle Aas. + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=cut diff --git a/agc_2-X/trunk/libs/Net/HTTP/Methods.pm b/agc_2-X/trunk/libs/Net/HTTP/Methods.pm new file mode 100644 index 00000000..b1b2115f --- /dev/null +++ b/agc_2-X/trunk/libs/Net/HTTP/Methods.pm @@ -0,0 +1,520 @@ +package Net::HTTP::Methods; + +# $Id: Methods.pm,v 1.12 2002/12/26 09:13:55 gisle Exp $ + +require 5.005; # 4-arg substr + +use strict; +use vars qw($VERSION); + +$VERSION = "1.00"; + +my $CRLF = "\015\012"; # "\r\n" is not portable + +sub new { + my($class, %cnf) = @_; + require Symbol; + my $self = bless Symbol::gensym(), $class; + return $self->http_configure(\%cnf); +} + +sub http_configure { + my($self, $cnf) = @_; + + die "Listen option not allowed" if $cnf->{Listen}; + my $host = delete $cnf->{Host}; + my $peer = $cnf->{PeerAddr} || $cnf->{PeerHost}; + if ($host) { + $cnf->{PeerAddr} = $host unless $peer; + } + else { + $host = $peer; + $host =~ s/:.*//; + } + $cnf->{PeerPort} = $self->http_default_port unless $cnf->{PeerPort}; + $cnf->{Proto} = 'tcp'; + + my $keep_alive = delete $cnf->{KeepAlive}; + my $http_version = delete $cnf->{HTTPVersion}; + $http_version = "1.1" unless defined $http_version; + my $peer_http_version = delete $cnf->{PeerHTTPVersion}; + $peer_http_version = "1.0" unless defined $peer_http_version; + my $send_te = delete $cnf->{SendTE}; + my $max_line_length = delete $cnf->{MaxLineLength}; + $max_line_length = 4*1024 unless defined $max_line_length; + my $max_header_lines = delete $cnf->{MaxHeaderLines}; + $max_header_lines = 128 unless defined $max_header_lines; + + return undef unless $self->http_connect($cnf); + + unless ($host =~ /:/) { + my $p = $self->peerport; + $host .= ":$p"; + } + $self->host($host); + $self->keep_alive($keep_alive); + $self->send_te($send_te); + $self->http_version($http_version); + $self->peer_http_version($peer_http_version); + $self->max_line_length($max_line_length); + $self->max_header_lines($max_header_lines); + + ${*$self}{'http_buf'} = ""; + + return $self; +} + +sub http_default_port { + 80; +} + +# set up property accessors +for my $method (qw(host keep_alive send_te max_line_length max_header_lines peer_http_version)) { + my $prop_name = "http_" . $method; + no strict 'refs'; + *$method = sub { + my $self = shift; + my $old = ${*$self}{$prop_name}; + ${*$self}{$prop_name} = shift if @_; + return $old; + }; +} + +# we want this one to be a bit smarter +sub http_version { + my $self = shift; + my $old = ${*$self}{'http_version'}; + if (@_) { + my $v = shift; + $v = "1.0" if $v eq "1"; # float + unless ($v eq "1.0" or $v eq "1.1") { + require Carp; + Carp::croak("Unsupported HTTP version '$v'"); + } + ${*$self}{'http_version'} = $v; + } + $old; +} + +sub format_request { + my $self = shift; + my $method = shift; + my $uri = shift; + + my $content = (@_ % 2) ? pop : ""; + + for ($method, $uri) { + require Carp; + Carp::croak("Bad method or uri") if /\s/ || !length; + } + + push(@{${*$self}{'http_request_method'}}, $method); + my $ver = ${*$self}{'http_version'}; + my $peer_ver = ${*$self}{'http_peer_http_version'} || "1.0"; + + my @h; + my @connection; + my %given = (host => 0, "content-length" => 0, "te" => 0); + while (@_) { + my($k, $v) = splice(@_, 0, 2); + my $lc_k = lc($k); + if ($lc_k eq "connection") { + push(@connection, split(/\s*,\s*/, $v)); + next; + } + if (exists $given{$lc_k}) { + $given{$lc_k}++; + } + push(@h, "$k: $v"); + } + + if (length($content) && !$given{'content-length'}) { + push(@h, "Content-Length: " . length($content)); + } + + my @h2; + if ($given{te}) { + push(@connection, "TE") unless grep lc($_) eq "te", @connection; + } + elsif ($self->send_te && zlib_ok()) { + # gzip is less wanted since the Compress::Zlib interface for + # it does not really allow chunked decoding to take place easily. + push(@h2, "TE: deflate,gzip;q=0.3"); + push(@connection, "TE"); + } + + unless (grep lc($_) eq "close", @connection) { + if ($self->keep_alive) { + if ($peer_ver eq "1.0") { + # from looking at Netscape's headers + push(@h2, "Keep-Alive: 300"); + unshift(@connection, "Keep-Alive"); + } + } + else { + push(@connection, "close") if $ver ge "1.1"; + } + } + push(@h2, "Connection: " . join(", ", @connection)) if @connection; + push(@h2, "Host: ${*$self}{'http_host'}") unless $given{host}; + + return join($CRLF, "$method $uri HTTP/$ver", @h2, @h, "", $content); +} + + +sub write_request { + my $self = shift; + $self->print($self->format_request(@_)); +} + +sub format_chunk { + my $self = shift; + return $_[0] unless defined($_[0]) && length($_[0]); + return sprintf("%x", length($_[0])) . $CRLF . $_[0] . $CRLF; +} + +sub write_chunk { + my $self = shift; + return 1 unless defined($_[0]) && length($_[0]); + $self->print(sprintf("%x", length($_[0])) . $CRLF . $_[0] . $CRLF); +} + +sub format_chunk_eof { + my $self = shift; + my @h; + while (@_) { + push(@h, sprintf "%s: %s$CRLF", splice(@_, 0, 2)); + } + return join("", "0$CRLF", @h, $CRLF); +} + +sub write_chunk_eof { + my $self = shift; + $self->print($self->format_chunk_eof(@_)); +} + + +sub my_read { + die if @_ > 3; + my $self = shift; + my $len = $_[1]; + for (${*$self}{'http_buf'}) { + if (length) { + $_[0] = substr($_, 0, $len, ""); + return length($_[0]); + } + else { + return $self->sysread($_[0], $len); + } + } +} + + +sub my_readline { + my $self = shift; + for (${*$self}{'http_buf'}) { + my $max_line_length = ${*$self}{'http_max_line_length'}; + my $pos; + while (1) { + # find line ending + $pos = index($_, "\012"); + last if $pos >= 0; + die "Line too long (limit is $max_line_length)" + if $max_line_length && length($_) > $max_line_length; + + # need to read more data to find a line ending + my $n = $self->sysread($_, 1024, length); + if (!$n) { + return undef unless length; + return substr($_, 0, length, ""); + } + } + die "Line too long ($pos; limit is $max_line_length)" + if $max_line_length && $pos > $max_line_length; + + my $line = substr($_, 0, $pos+1, ""); + $line =~ s/(\015?\012)\z// || die "Assert"; + return wantarray ? ($line, $1) : $line; + } +} + + +sub _rbuf { + my $self = shift; + if (@_) { + for (${*$self}{'http_buf'}) { + my $old; + $old = $_ if defined wantarray; + $_ = shift; + return $old; + } + } + else { + return ${*$self}{'http_buf'}; + } +} + +sub _rbuf_length { + my $self = shift; + return length ${*$self}{'http_buf'}; +} + + +sub _read_header_lines { + my $self = shift; + my $junk_out = shift; + + my @headers; + my $line_count = 0; + my $max_header_lines = ${*$self}{'http_max_header_lines'}; + while (my $line = my_readline($self)) { + if ($line =~ /^(\S+)\s*:\s*(.*)/s) { + push(@headers, $1, $2); + } + elsif (@headers && $line =~ s/^\s+//) { + $headers[-1] .= " " . $line; + } + elsif ($junk_out) { + push(@$junk_out, $line); + } + else { + die "Bad header: '$line'\n"; + } + if ($max_header_lines) { + $line_count++; + if ($line_count >= $max_header_lines) { + die "Too many header lines (limit is $max_header_lines)"; + } + } + } + return @headers; +} + + +sub read_response_headers { + my($self, %opt) = @_; + my $laxed = $opt{laxed}; + + my($status, $eol) = my_readline($self); + unless (defined $status) { + die "EOF instead of response status line" unless $laxed; + # assume HTTP/0.9 + ${*$self}{'http_peer_http_version'} = "0.9"; + ${*$self}{'http_status'} = "200"; + return 200 unless wantarray; + return (200, "EOF"); + } + + my($peer_ver, $code, $message) = split(/\s+/, $status, 3); + if (!$peer_ver || $peer_ver !~ s,^HTTP/,, || $code !~ /^[1-5]\d\d$/) { + die "Bad response status line: '$status'" unless $laxed; + # assume HTTP/0.9 + ${*$self}{'http_peer_http_version'} = "0.9"; + ${*$self}{'http_status'} = "200"; + substr(${*$self}{'http_buf'}, 0, 0) = $status . $eol; + return 200 unless wantarray; + return (200, "Assumed OK"); + }; + + ${*$self}{'http_peer_http_version'} = $peer_ver; + ${*$self}{'http_status'} = $code; + + my $junk_out; + if ($laxed) { + $junk_out = $opt{junk_out} || []; + } + my @headers = $self->_read_header_lines($junk_out); + + # pick out headers that read_entity_body might need + my @te; + my $content_length; + for (my $i = 0; $i < @headers; $i += 2) { + my $h = lc($headers[$i]); + if ($h eq 'transfer-encoding') { + push(@te, $headers[$i+1]); + } + elsif ($h eq 'content-length') { + $content_length = $headers[$i+1]; + } + } + ${*$self}{'http_te'} = join(",", @te); + ${*$self}{'http_content_length'} = $content_length; + ${*$self}{'http_first_body'}++; + delete ${*$self}{'http_trailers'}; + return $code unless wantarray; + return ($code, $message, @headers); +} + + +sub read_entity_body { + my $self = shift; + my $buf_ref = \$_[0]; + my $size = $_[1]; + die "Offset not supported yet" if $_[2]; + + my $chunked; + my $bytes; + + if (${*$self}{'http_first_body'}) { + ${*$self}{'http_first_body'} = 0; + delete ${*$self}{'http_chunked'}; + delete ${*$self}{'http_bytes'}; + my $method = shift(@{${*$self}{'http_request_method'}}); + my $status = ${*$self}{'http_status'}; + if ($method eq "HEAD" || $status =~ /^(?:1|[23]04)/) { + # these responses are always empty + $bytes = 0; + } + elsif (my $te = ${*$self}{'http_te'}) { + my @te = split(/\s*,\s*/, lc($te)); + die "Chunked must be last Transfer-Encoding '$te'" + unless pop(@te) eq "chunked"; + + for (@te) { + if ($_ eq "deflate" && zlib_ok()) { + #require Compress::Zlib; + my $i = Compress::Zlib::inflateInit(); + die "Can't make inflator" unless $i; + $_ = sub { scalar($i->inflate($_[0])) } + } + elsif ($_ eq "gzip" && zlib_ok()) { + #require Compress::Zlib; + my @buf; + $_ = sub { + push(@buf, $_[0]); + return Compress::Zlib::memGunzip(join("", @buf)) if $_[1]; + return ""; + }; + } + elsif ($_ eq "identity") { + $_ = sub { $_[0] }; + } + else { + die "Can't handle transfer encoding '$te'"; + } + } + + @te = reverse(@te); + + ${*$self}{'http_te2'} = @te ? \@te : ""; + $chunked = -1; + } + elsif (defined(my $content_length = ${*$self}{'http_content_length'})) { + $bytes = $content_length; + } + else { + # XXX Multi-Part types are self delimiting, but RFC 2616 says we + # only has to deal with 'multipart/byteranges' + + # Read until EOF + } + } + else { + $chunked = ${*$self}{'http_chunked'}; + $bytes = ${*$self}{'http_bytes'}; + } + + if (defined $chunked) { + # The state encoded in $chunked is: + # $chunked == 0: read CRLF after chunk, then chunk header + # $chunked == -1: read chunk header + # $chunked > 0: bytes left in current chunk to read + + if ($chunked <= 0) { + my $line = my_readline($self); + if ($chunked == 0) { + die "Missing newline after chunk data: '$line'" unless $line eq ""; + $line = my_readline($self); + } + my $chunk_len = $line; + $chunk_len =~ s/;.*//; # ignore potential chunk parameters + unless ($chunk_len =~ /^([\da-fA-F]+)\s*$/) { + die "Bad chunk-size in HTTP response: $line"; + } + $chunked = hex($1); + if ($chunked == 0) { + ${*$self}{'http_trailers'} = [$self->_read_header_lines]; + $$buf_ref = ""; + + my $n = 0; + if (my $transforms = delete ${*$self}{'http_te2'}) { + for (@$transforms) { + $$buf_ref = &$_($$buf_ref, 1); + } + $n = length($$buf_ref); + } + + # in case somebody tries to read more, make sure we continue + # to return EOF + delete ${*$self}{'http_chunked'}; + ${*$self}{'http_bytes'} = 0; + + return $n; + } + } + + my $n = $chunked; + $n = $size if $size && $size < $n; + $n = my_read($self, $$buf_ref, $n); + return undef unless defined $n; + + ${*$self}{'http_chunked'} = $chunked - $n; + + if ($n > 0) { + if (my $transforms = ${*$self}{'http_te2'}) { + for (@$transforms) { + $$buf_ref = &$_($$buf_ref, 0); + } + $n = length($$buf_ref); + $n = -1 if $n == 0; + } + } + return $n; + } + elsif (defined $bytes) { + unless ($bytes) { + $$buf_ref = ""; + return 0; + } + my $n = $bytes; + $n = $size if $size && $size < $n; + $n = my_read($self, $$buf_ref, $n); + return undef unless defined $n; + ${*$self}{'http_bytes'} = $bytes - $n; + return $n; + } + else { + # read until eof + $size ||= 8*1024; + return my_read($self, $$buf_ref, $size); + } +} + +sub get_trailers { + my $self = shift; + @{${*$self}{'http_trailers'} || []}; +} + +BEGIN { +my $zlib_ok; + +sub zlib_ok { + return $zlib_ok if defined $zlib_ok; + + # Try to load Compress::Zlib. + local $@; + local $SIG{__DIE__}; + $zlib_ok = 0; + + eval { + require Compress::Zlib; + Compress::Zlib->VERSION(1.10); + $zlib_ok++; + }; + + return $zlib_ok; +} + +} # BEGIN + +1; diff --git a/agc_2-X/trunk/libs/Net/HTTP/NB.pm b/agc_2-X/trunk/libs/Net/HTTP/NB.pm new file mode 100644 index 00000000..feeee310 --- /dev/null +++ b/agc_2-X/trunk/libs/Net/HTTP/NB.pm @@ -0,0 +1,106 @@ +package Net::HTTP::NB; + +# $Id: NB.pm,v 1.5 2001/08/28 03:03:42 gisle Exp $ + +use strict; +use vars qw($VERSION @ISA); + +$VERSION = "0.02"; +require Net::HTTP; +@ISA=qw(Net::HTTP); + +sub sysread { + my $self = $_[0]; + if (${*$self}{'httpnb_read_count'}++) { + ${*$self}{'http_buf'} = ${*$self}{'httpnb_save'}; + die "Multi-read\n"; + } + my $buf; + my $offset = $_[3] || 0; + my $n = sysread($self, $_[1], $_[2], $offset); + ${*$self}{'httpnb_save'} .= substr($_[1], $offset); + return $n; +} + +sub read_response_headers { + my $self = shift; + ${*$self}{'httpnb_read_count'} = 0; + ${*$self}{'httpnb_save'} = ${*$self}{'http_buf'}; + my @h = eval { $self->SUPER::read_response_headers(@_) }; + if ($@) { + return if $@ eq "Multi-read\n"; + die; + } + return @h; +} + +sub read_entity_body { + my $self = shift; + ${*$self}{'httpnb_read_count'} = 0; + ${*$self}{'httpnb_save'} = ${*$self}{'http_buf'}; + # XXX I'm not so sure this does the correct thing in case of + # transfer-encoding tranforms + my $n = eval { $self->SUPER::read_entity_body(@_); }; + if ($@) { + $_[0] = ""; + return -1; + } + return $n; +} + +1; + +__END__ + +=head1 NAME + +Net::HTTP::NB - Non-blocking HTTP client + +=head1 SYNOPSIS + + use Net::HTTP::NB; + my $s = Net::HTTP::NB->new(Host => "www.perl.com) || die $@; + $s->write_request(GET => "/"); + + use IO::Select; + my $sel = IO::Select->new($s); + + READ_HEADER: { + die "Header timeout" unless $sel->can_read(10); + my($code, $mess, %h) = $s->read_response_headers; + redo READ_HEADER unless $code; + } + + while (1) { + die "Body timeout" unless $sel->can_read(10); + my $buf; + my $n = $s->read_entity_body($buf, 1024); + last unless $n; + print $buf; + } + +=head1 DESCRIPTION + +Same interface as C but it will never try multiple reads +when the read_response_headers() or read_entity_body() methods are +invoked. This make it possible to multiplex multiple Net::HTTP::NB +using select without risk blocking. + +If read_response_headers() did not see enough data to complete the +headers an empty list is returned. + +If read_entity_body() did not see new entity data in its read +the value -1 is returned. + +=head1 SEE ALSO + +L + +=head1 COPYRIGHT + +Copyright 2001 Gisle Aas. + +This library is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=cut diff --git a/agc_2-X/trunk/libs/Net/HTTPS.pm b/agc_2-X/trunk/libs/Net/HTTPS.pm new file mode 100644 index 00000000..1549a06d --- /dev/null +++ b/agc_2-X/trunk/libs/Net/HTTPS.pm @@ -0,0 +1,55 @@ +package Net::HTTPS; + +# $Id: HTTPS.pm,v 1.3 2002/12/23 18:16:29 gisle Exp $ + +use strict; +use vars qw($VERSION $SSL_SOCKET_CLASS @ISA); + +$VERSION = "1.00"; + +# Figure out which SSL implementation to use +if ($IO::Socket::SSL::VERSION) { + $SSL_SOCKET_CLASS = "IO::Socket::SSL"; # it was already loaded +} +else { + eval { require Net::SSL; }; # from Crypt-SSLeay + if ($@) { + my $old_errsv = $@; + eval { + require IO::Socket::SSL; + }; + if ($@) { + $old_errsv =~ s/\s\(\@INC contains:.*\)/)/g; + die $old_errsv . $@; + } + $SSL_SOCKET_CLASS = "IO::Socket::SSL"; + } + else { + $SSL_SOCKET_CLASS = "Net::SSL"; + } +} + +require Net::HTTP::Methods; + +@ISA=($SSL_SOCKET_CLASS, 'Net::HTTP::Methods'); + +sub configure { + my($self, $cnf) = @_; + $self->http_configure($cnf); +} + +sub http_connect { + my($self, $cnf) = @_; + $self->SUPER::configure($cnf); +} + +sub http_default_port { + 443; +} + +# The underlying SSLeay classes fails to work if the socket is +# placed in non-blocking mode. This override of the blocking +# method makes sure it stays the way it was created. +sub blocking { } # noop + +1; diff --git a/agc_2-X/trunk/libs/Net/MySQL.pm b/agc_2-X/trunk/libs/Net/MySQL.pm new file mode 100644 index 00000000..e6a92c80 --- /dev/null +++ b/agc_2-X/trunk/libs/Net/MySQL.pm @@ -0,0 +1,1015 @@ +package Net::MySQL; + +use 5.004; +use IO::Socket; +use Carp; +use vars qw($VERSION $DEBUG); +use strict; +$VERSION = '0.08'; + +use constant COMMAND_SLEEP => "\x00"; +use constant COMMAND_QUIT => "\x01"; +use constant COMMAND_INIT_DB => "\x02"; +use constant COMMAND_QUERY => "\x03"; +use constant COMMAND_FIELD_LIST => "\x04"; +use constant COMMAND_CREATE_DB => "\x05"; +use constant COMMAND_DROP_DB => "\x06"; +use constant COMMAND_REFRESH => "\x07"; +use constant COMMAND_SHUTDOWN => "\x08"; +use constant COMMAND_STATISTICS => "\x09"; +use constant COMMAND_PROCESS_INFO => "\x0A"; +use constant COMMAND_CONNECT => "\x0B"; +use constant COMMAND_PROCESS_KILL => "\x0C"; +use constant COMMAND_DEBUG => "\x0D"; +use constant COMMAND_PING => "\x0E"; +use constant COMMAND_TIME => "\x0F"; +use constant COMMAND_DELAYED_INSERT => "\x10"; +use constant COMMAND_CHANGE_USER => "\x11"; +use constant COMMAND_BINLOG_DUMP => "\x12"; +use constant COMMAND_TABLE_DUMP => "\x13"; +use constant COMMAND_CONNECT_OUT => "\x14"; + +use constant DEFAULT_PORT_NUMBER => 3306; +use constant BUFFER_LENGTH => 1460; +use constant DEFAULT_UNIX_SOCKET => '/tmp/mysql.sock'; + + +sub new +{ + my $class = shift; + my %args = @_; + + my $self = bless { + hostname => $args{hostname}, + unixsocket => $args{unixsocket} || DEFAULT_UNIX_SOCKET, + port => $args{port} || DEFAULT_PORT_NUMBER, + database => $args{database}, + user => $args{user}, + password => $args{password}, + timeout => $args{timeout} || 60, + socket => undef, + salt => '', + protocol_version => undef, + client_capabilities => 0, + affected_rows_length => 0, + }, $class; + $self->debug($args{debug}); + $self->_initialize; + return $self; +} + + +sub query +{ + my $self = shift; + my $sql = join '', @_; + my $mysql = $self->{socket}; + + return $self->_execute_command(COMMAND_QUERY, $sql); +} + + +sub create_database +{ + my $self = shift; + my $db_name = shift; + my $mysql = $self->{socket}; + + return $self->_execute_command(COMMAND_CREATE_DB, $db_name); +} + + +sub drop_database +{ + my $self = shift; + my $db_name = shift; + my $mysql = $self->{socket}; + + return $self->_execute_command(COMMAND_DROP_DB, $db_name); +} + + +sub close +{ + my $self = shift; + my $mysql = $self->{socket}; + return unless $mysql->can('send'); + + my $quit_message = + chr(length(COMMAND_QUIT)). "\x00\x00\x00". COMMAND_QUIT; + $mysql->send($quit_message, 0); + $self->_dump_packet($quit_message) if Net::MySQL->debug; + $mysql->close; +} + + +sub get_affected_rows_length +{ + my $self = shift; + $self->{affected_rows_length}; +} + + +sub get_insert_id +{ + my $self = shift; + $self->{insert_id}; +} + + +sub create_record_iterator +{ + my $self = shift; + return undef unless $self->has_selected_record; + + my $record = Net::MySQL::RecordIterator->new( + $self->{selected_record} + ); + $self->{selected_record} = undef; + $record->parse; + return $record; +} + + +sub has_selected_record +{ + my $self = shift; + $self->{selected_record} ? 1 : undef; +} + + +sub is_error +{ + my $self = shift; + $self->{error_code} ? 1 : undef; +} + + +sub get_error_code +{ + my $self = shift; + $self->{error_code}; +} + + +sub get_error_message +{ + my $self = shift; + $self->{server_message}; +} + + +sub debug +{ + my $class = shift; + $DEBUG = shift if @_; + $DEBUG; +} + + +sub _connect +{ + my $self = shift; + + my $mysql; + if ($self->{hostname}) { + printf "Use INET Socket: %s %d/tcp\n", $self->{hostname}, $self->{port} + if $self->debug; + $mysql = IO::Socket::INET->new( + PeerAddr => $self->{hostname}, + PeerPort => $self->{port}, + Proto => 'tcp', + Timeout => $self->{timeout} || 60, + ) or croak "Couldn't connect to $self->{hostname}:$self->{port}/tcp: $@"; + } + else { + printf "Use UNIX Socket: %s\n", $self->{unixsocket} if $self->debug; + $mysql = IO::Socket::UNIX->new( + Type => SOCK_STREAM, + Peer => $self->{unixsocket}, + ) or croak "Couldn't connect to $self->{unixsocket}: $@"; + } + $mysql->autoflush(1); + $self->{socket} = $mysql; +} + + +sub _get_server_information +{ + my $self = shift; + my $mysql = $self->{socket}; + + my $message; + $mysql->recv($message, BUFFER_LENGTH, 0); + $self->_dump_packet($message) + if Net::MySQL->debug; + my $i = 0; + my $packet_length = ord substr $message, $i, 1; + $i += 4; + $self->{protocol_version} = ord substr $message, $i, 1; + printf "Protocol Version: %d\n", $self->{protocol_version} + if Net::MySQL->debug; + if ($self->{protocol_version} == 10) { + $self->{client_capabilities} = 1; + } + + ++$i; + my $string_end = index($message, "\0", $i) - $i; + $self->{server_version} = substr $message, $i, $string_end; + printf "Server Version: %s\n", $self->{server_version} + if Net::MySQL->debug; + + $i += $string_end + 1; + $self->{server_thread_id} = unpack 'v', substr $message, $i, 2; + $i += 4; + $self->{salt} = substr $message, $i, 8; + printf "Salt: %s\n", $self->{salt} if Net::MySQL->debug; +} + + +sub _request_authentication +{ + my $self = shift; + my $mysql = $self->{socket}; + $self->_send_login_message(); + + my $auth_result; + $mysql->recv($auth_result, BUFFER_LENGTH, 0); + $self->_dump_packet($auth_result) if Net::MySQL->debug; + if ($self->_is_error($auth_result)) { + $mysql->close; + if (length $auth_result < 7) { + croak "Timeout of authentication"; + } + croak substr $auth_result, 7; + } + print "connect database\n" if Net::MySQL->debug; +} + + +sub _send_login_message +{ + my $self = shift; + my $mysql = $self->{socket}; + + my $body = "\0\0\x01\x8d\x00\00\00\00". join "\0", + $self->{user}, + Net::MySQL::Password->scramble( + $self->{password}, $self->{salt}, $self->{client_capabilities} + ), + $self->{database}; + my $login_message = chr(length($body)-3). $body; + $mysql->send($login_message, 0); + $self->_dump_packet($login_message) if Net::MySQL->debug; +} + + + +sub _execute_command +{ + my $self = shift; + my $command = shift; + my $sql = shift; + my $mysql = $self->{socket}; + + my $message = pack('V', length($sql) + 1). $command. $sql; + + $mysql->send($message, 0); + $self->_dump_packet($message) if Net::MySQL->debug; + + my $result; + $mysql->recv($result, BUFFER_LENGTH, 0); + $self->_dump_packet($result) if Net::MySQL->debug; + $self->_reset_status; + + if ($self->_is_error($result)) { + return $self->_set_error_by_packet($result); + } + elsif ($self->_is_select_query_result($result)) { + return $self->_get_record_by_server($result); + } + elsif ($self->_is_update_query_result($result)){ + return $self->_get_affected_rows_information_by_packet($result); + } + else { + croak 'Unknown Result: '. $self->_get_result_length($result). 'byte'; + } +} + + +sub _initialize +{ + my $self = shift; + $self->_connect; + $self->_get_server_information; + $self->_request_authentication; +} + + +sub _set_error_by_packet +{ + my $self = shift; + my $packet = shift; + + my $error_message = $self->_get_server_message($packet); + $self->{server_message} = $error_message; + $self->{error_code} = $self->_get_error_code($packet); + return undef; +} + + +sub _get_record_by_server +{ + my $self = shift; + my $packet = shift; + my $mysql = $self->{socket}; + + $self->_get_column_length($packet); + while ($self->_has_next_packet($packet)) { + my $next_result; + $mysql->recv($next_result, BUFFER_LENGTH, 0); + $packet .= $next_result; + $self->_dump_packet($next_result) if Net::MySQL->debug; + } + $self->{selected_record} = $packet; +} + + +sub _get_affected_rows_information_by_packet +{ + my $self = shift; + my $packet = shift; + + $self->{affected_rows_length} = $self->_get_affected_rows_length($packet); + $self->{insert_id} = $self->_get_insert_id($packet); + $self->{server_message} = $self->_get_server_message($packet); + return $self->{affected_rows_length}; +} + + +sub _is_error +{ + my $self = shift; + my $packet = shift; + return 1 if length $packet < 4; + ord(substr $packet, 4) == 255; +} + + +sub _is_select_query_result +{ + my $self = shift; + my $packet = shift; + return undef if $self->_is_error($packet); + ord(substr $packet, 4) >= 1; +} + + +sub _is_update_query_result +{ + my $self = shift; + my $packet = shift; + return undef if $self->_is_error($packet); + ord(substr $packet, 4) == 0; +} + + +sub _get_result_length +{ + my $self = shift; + my $packet = shift; + ord(substr $packet, 0, 1) +} + + +sub _get_column_length +{ + my $self = shift; + my $packet = shift; + ord(substr $packet, 4); +} + + +sub _get_affected_rows_length +{ + my $self = shift; + my $packet = shift; + ord(substr $packet, 5, 1); +} + + +sub _get_insert_id +{ + my $self = shift; + my $packet = shift; + return ord(substr $packet, 6, 1) if ord(substr $packet, 6, 1) != 0xfc; + unpack 'v', substr $packet, 7, 2; +} + + +sub _get_server_message +{ + my $self = shift; + my $packet = shift; + return '' if length $packet < 7; + substr $packet, 7; +} + + +sub _get_error_code +{ + my $self = shift; + my $packet = shift; + $self->_is_error($packet) + or croak "_get_error_code(): Is not error packet"; + unpack 'v', substr $packet, 5, 2; +} + + +sub _reset_status +{ + my $self = shift; + $self->{insert_id} = 0; + $self->{server_message} = ''; + $self->{error_code} = undef; + $self->{selected_record} = undef; +} + + +sub _has_next_packet +{ + my $self = shift; + substr($_[0], -1) ne "\xfe"; +} + + +sub _dump_packet +{ + my $self = shift; + my $packet = shift; + + my ($method_name) = (caller(1))[3]; + printf "%s():\n%s\n", + $method_name, + join ' ', map { sprintf "%02x", ord $_ } split //, $packet; + printf "%s():\n%s\n", + $method_name, + join ' ', map { m/[\d \w\._]/ ? $_ : '.' } split //, $packet; + print "--\n"; +} + + + +package Net::MySQL::RecordIterator; +use strict; + +use constant NULL_COLUMN => 251; +use constant UNSIGNED_CHAR_COLUMN => 251; +use constant UNSIGNED_SHORT_COLUMN => 252; +use constant UNSIGNED_INT24_COLUMN => 253; +use constant UNSIGNED_INT32_COLUMN => 254; +use constant UNSIGNED_CHAR_LENGTH => 1; +use constant UNSIGNED_SHORT_LENGTH => 2; +use constant UNSIGNED_INT24_LENGTH => 3; +use constant UNSIGNED_INT32_LENGTH => 4; +use constant UNSIGNED_INT32_PAD_LENGTH => 4; + + +sub new +{ + my $class = shift; + my $packet = shift; + bless { + packet => $packet, + position => 0, + column => [], + }, $class; +} + + +sub parse +{ + my $self = shift; + $self->_get_column_length; + $self->_get_column_name; +} + + +sub each +{ + my $self = shift; + my @result; + return undef if $self->is_end_of_packet; + + for (1..$self->{column_length}) { + push @result, $self->_get_string_and_seek_position; + } + $self->{position} += 4; + return \@result; +} + + +sub is_end_of_packet +{ + my $self = shift; + length $self->{packet} <= $self->{position} + 1; +} + + +sub get_field_length +{ + my $self = shift; + $self->{column_length}; +} + + +sub get_field_names +{ + my $self = shift; + map { $_->{column} } @{$self->{column}}; +} + + +sub _get_column_length +{ + my $self = shift; + $self->{position} += 4; + $self->{column_length} = ord substr $self->{packet}, $self->{position}, 1; + $self->{position} += 5; + printf "Column Length: %d\n", $self->{column_length} + if Net::MySQL->debug; +} + + +sub _get_column_name +{ + my $self = shift; + for my $i (1.. $self->{column_length}) { + push @{$self->{column}}, { + table => $self->_get_string_and_seek_position, + column => $self->_get_string_and_seek_position, + }; + $self->{position} += 14; + } + $self->{position} += 5; + + printf "Column name: %s\n", + join ", ", map { $_->{column} } @{$self->{column}} + if Net::MySQL->debug; +} + + +sub _get_string_and_seek_position +{ + my $self = shift; + + my $length = $self->_get_field_length(); + return undef unless defined $length; + + my $string = substr $self->{packet}, $self->{position}, $length; + $self->{position} += $length; + return $string; +} + + +sub _get_field_length +{ + my $self = shift; + + my $head = ord substr( + $self->{packet}, + $self->{position}, + UNSIGNED_CHAR_LENGTH + ); + $self->{position} += UNSIGNED_CHAR_LENGTH; + + return undef if $head == NULL_COLUMN; + if ($head < UNSIGNED_CHAR_COLUMN) { + return $head; + } + elsif ($head == UNSIGNED_SHORT_COLUMN) { + warn "in short"; + my $length = unpack 'v', substr( + $self->{packet}, + $self->{position}, + UNSIGNED_SHORT_LENGTH + ); + $self->{position} += UNSIGNED_SHORT_LENGTH; + return $length; + } + elsif ($head == UNSIGNED_INT24_COLUMN) { + warn "in int23"; + my $int24 = substr( + $self->{packet}, $self->{position}, + UNSIGNED_INT24_LENGTH + ); + my $length = unpack('C', substr($int24, 0, 1)) + + (unpack('C', substr($int24, 1, 1)) << 8) + + (unpack('C', substr($int24, 2, 1)) << 16); + $self->{position} += UNSIGNED_INT24_LENGTH; + return $length; + } + else { + warn "in int32"; + my $int32 = substr( + $self->{packet}, $self->{position}, + UNSIGNED_INT32_LENGTH + ); + my $length = unpack('C', substr($int32, 0, 1)) + + (unpack('C', substr($int32, 1, 1)) << 8) + + (unpack('C', substr($int32, 2, 1)) << 16) + + (unpack('C', substr($int32, 3, 1)) << 24); + $self->{position} += UNSIGNED_INT32_LENGTH; + $self->{position} += UNSIGNED_INT32_PAD_LENGTH; + return $length; + } +} + + +package Net::MySQL::Password; +use strict; + +sub scramble +{ + my $class = shift; + my $password = shift; + my $hash_seed = shift; + my $client_capabilities = shift; + + return '' unless $password; + return '' if length $password == 0; + + my $hsl = length $hash_seed; + my @out; + my @hash_pass = _get_hash($password); + my @hash_mess = _get_hash($hash_seed); + + my ($max_value, $seed, $seed2); + my ($dRes, $dSeed, $dMax); + if ($client_capabilities < 1) { + $max_value = 0x01FFFFFF; + $seed = _xor_by_long($hash_pass[0], $hash_mess[0]) % $max_value; + $seed2 = int($seed / 2); + } else { + $max_value= 0x3FFFFFFF; + $seed = _xor_by_long($hash_pass[0], $hash_mess[0]) % $max_value; + $seed2 = _xor_by_long($hash_pass[1], $hash_mess[1]) % $max_value; + } + $dMax = $max_value; + + for (my $i=0; $i < $hsl; $i++) { + $seed = int(($seed * 3 + $seed2) % $max_value); + $seed2 = int(($seed + $seed2 + 33) % $max_value); + $dSeed = $seed; + $dRes = $dSeed / $dMax; + push @out, int($dRes * 31) + 64; + } + + if ($client_capabilities == 1) { + # Make it harder to break + $seed = ($seed * 3 + $seed2 ) % $max_value; + $seed2 = ($seed + $seed2 + 33 ) % $max_value; + $dSeed = $seed; + + $dRes = $dSeed / $dMax; + my $e = int($dRes * 31); + for (my $i=0; $i < $hsl ; $i++) { + $out[$i] ^= $e; + } + } + return join '', map { chr $_ } @out; +} + + +sub _get_hash +{ + my $password = shift; + + my $nr = 1345345333; + my $add = 7; + my $nr2 = 0x12345671; + my $tmp; + my $pwlen = length $password; + my $c; + + for (my $i=0; $i < $pwlen; $i++) { + my $c = substr $password, $i, 1; + next if $c eq ' ' || $c eq "\t"; + my $tmp = ord $c; + my $value = ((_and_by_char($nr, 63) + $add) * $tmp) + $nr * 256; + $nr = _xor_by_long($nr, $value); + $nr2 += _xor_by_long(($nr2 * 256), $nr); + $add += $tmp; + } + return (_and_by_long($nr, 0x7fffffff), _and_by_long($nr2, 0x7fffffff)); +} + + +sub _and_by_char +{ + my $source = shift; + my $mask = shift; + + return $source & $mask; +} + + +sub _and_by_long +{ + my $source = shift; + my $mask = shift || 0xFFFFFFFF; + + return _cut_off_to_long($source) & _cut_off_to_long($mask); +} + + +sub _xor_by_long +{ + my $source = shift; + my $mask = shift || 0; + + return _cut_off_to_long($source) ^ _cut_off_to_long($mask); +} + + +sub _cut_off_to_long +{ + my $source = shift; + + if ($] >= 5.006) { + $source = $source % (0xFFFFFFFF + 1) if $source > 0xFFFFFFFF; + return $source; + } + while ($source > 0xFFFFFFFF) { + $source -= 0xFFFFFFFF + 1; + } + return $source; +} + + +1; +__END__ + +=head1 NAME + +Net::MySQL - Pure Perl MySQL network protocol interface. + +=head1 SYNOPSIS + + use Net::MySQL; + + my $mysql = Net::MySQL->new( + # hostname => 'mysql.example.jp', # Default use UNIX socket + database => 'your_database_name', + user => 'user', + password => 'password' + ); + + # INSERT example + $mysql->query(q{ + INSERT INTO tablename (first, next) VALUES ('Hello', 'World') + }); + printf "Affected row: %d\n", $mysql->get_affected_rows_length; + + # SLECT example + $mysql->query(q{SELECT * FROM tablename}); + my $record_set = $mysql->create_record_iterator; + while (my $record = $record_set->each) { + printf "First column: %s Next column: %s\n", + $record->[0], $record->[1]; + } + $mysql->close; + +=head1 DESCRIPTION + +Net::MySQL is a Pure Perl client interface for the MySQL database. This module implements network protocol between server and client of MySQL, thus you don't need external MySQL client library like libmysqlclient for this module to work. It means this module enables you to connect to MySQL server from some operation systems which MySQL is not ported. How nifty! + +Since this module's final goal is to completely replace DBD::mysql, API is made similar to that of DBI. + +From perl you activate the interface with the statement + + use Net::MySQL; + +After that you can connect to multiple MySQL daemon and send multiple queries to any of them via a simple object oriented interface. + +There are two classes which have public APIs: Net::MySQL and Net::MySQL::RecordIterator. + + $mysql = Net::MySQL->new( + hostname => $host, + database => $database, + user => $user, + password => $password, + ); + +Once you have connected to a daemon, you can can execute SQL with: + + $mysql->query(q{ + INSERT INTO foo (id, message) VALUES (1, 'Hello World') + }); + +If you want to retrieve results, you need to create a so-called statement handle with: + + $mysql->query(q{ + SELECT id, message FROM foo + }); + if ($mysql->has_selected_record) { + my $a_record_iterator = $mysql->create_record_iterator; + # ... + } + +This Net::MySQL::RecordIterator object can be used for multiple purposes. First of all you can retreive a row of data: + + my $record = $a_record_iterator->each; + +The each() method takes out the reference result of one line at a time, and the return value is ARRAY reference. + +=head2 Net::MySQL API + +=over 4 + +=item new(HASH) + + use Net::MySQL; + use strict; + + my $mysql = Net::MySQL->new( + unixsocket => $path_to_socket, + hostname => $host, + database => $database, + user => $user, + password => $password, + ); + +The constructor of Net::MySQL. Connection with MySQL daemon is established and the object is returned. Argument hash contains following parameters: + +=over 8 + +=item unixsocket + +Path of the UNIX socket where MySQL daemon. default is F. +Supposing I is omitted, it will connect by I. + +=item hostname + +Name of the host where MySQL daemon runs. +Supposing I is specified, it will connect by I. + +=item port + +Port where MySQL daemon listens to. default is 3306. + +=item database + +Name of the database to connect. + +=item user / password + +Username and password for database authentication. + +=item timeout + +The waiting time which carries out a timeout when connection is overdue is specified. + +=item debug + +The exchanged packet will be outputted if a true value is given. + +=back + + +=item create_database(DB_NAME) + +A create_DATABASE() method creates a database by the specified name. + + $mysql->create_database('example_db'); + die $mysql->get_error_message if $mysql->is_error; + +=item drop_database(DB_NAME) + +A drop_database() method deletes the database of the specified name. + + $mysql->drop_database('example_db'); + die $mysql->get_error_message if $mysql->is_error; + +=item query(SQL_STRING) + +A query() method transmits the specified SQL string to MySQL database, and obtains the response. + +=item create_record_iterator() + +When SELECT type SQL is specified, Net::MySQL::RecordIterator object which shows the reference result is returned. + + $mysql->query(q{SELECT * FROM table}); + my $a_record_iterator = $mysql->create_recrod_iterator(); + +Net::MySQL::RecordIterator object is applicable to acquisition of a reference result. See L<"/Net::SQL::RecordIterator API"> for more. + +=item get_affected_rows_length() + +returns the number of records finally influenced by specified SQL. + + my $affected_rows = $mysql->get_affected_rows_length; + +=item get_insert_id() + +MySQL has the ability to choose unique key values automatically. If this happened, the new ID will be stored in this attribute. + +=item is_error() + +TRUE will be returned if the error has occurred. + +=item has_selected_record() + +TRUE will be returned if it has a reference result by SELECT. + +=item get_field_length() + +return the number of column. + +=item get_field_names() + +return column names by ARRAY. + +=item close() + +transmits an end message to MySQL daemon, and closes a socket. + +=back + +=head2 Net::MySQL::RecordIterator API + +Net::MySQL::RecordIterator object is generated by the query() method of Net::MySQL object. Thus it has no public constructor method. + +=over 4 + +=item each() + +each() method takes out only one line from a result, and returns it as an ARRAY reference. C is returned when all the lines has been taken out. + + while (my $record = $a_record_iterator->each) { + printf "Column 1: %s Column 2: %s Collumn 3: %s\n", + $record->[0], $record->[1], $record->[2]; + } + +=back + +=head1 SUPPORT OPERATING SYSTEM + +This module has been tested on these OSes. + +=over 4 + +=item * MacOS 9.x + +with MacPerl5.6.1r. + +=item * MacOS X + +with perl5.6.0 build for darwin. + +=item * Windows2000 + +with ActivePerl5.6.1 build631. + +=item * FreeBSD 3.4 and 4.x + +with perl5.6.1 build for i386-freebsd. + +with perl5.005_03 build for i386-freebsd. + +=item * Linux + +with perl 5.005_03 built for ppc-linux. + +with perl 5.6.0 bult for i386-linux. + +=item * Solaris 2.6 (SPARC) + +with perl 5.6.1 built for sun4-solaris. + +with perl 5.004_04 built for sun4-solaris. + +Can use on Solaris2.6 with perl5.004_04, although I is failure. + +=back + +This list is the environment which I can use by the test usually. Net::MySQL will operate also in much environment which is not in a list. + +I believe this module can work with whatever perls which has B. I'll be glad if you give me a report of successful installation of this module on I OSes. + +=head1 SEE ALSO + +L, L + +=head1 AUTHOR + +Hiroyuki OYAMA Eoyama@module.jpE + +=head1 COPYRIGHT AND LICENCE + +Copyright (C) 2002 Hiroyuki OYAMA. Japan. All rights reserved. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/agc_2-X/trunk/libs/Net/SSH.pm b/agc_2-X/trunk/libs/Net/SSH.pm new file mode 100644 index 00000000..41f87f1f --- /dev/null +++ b/agc_2-X/trunk/libs/Net/SSH.pm @@ -0,0 +1,255 @@ +package Net::SSH; + +use strict; +use vars qw($VERSION @ISA @EXPORT_OK $ssh $equalspace $DEBUG @ssh_options); +use Exporter; +use IO::File; +use IPC::Open2; +use IPC::Open3; + +@ISA = qw(Exporter); +@EXPORT_OK = qw( ssh issh ssh_cmd sshopen2 sshopen3 ); +$VERSION = '0.07'; + +$DEBUG = 0; + +$ssh = "ssh"; + +=head1 NAME + +Net::SSH - Perl extension for secure shell + +=head1 SYNOPSIS + + use Net::SSH qw(ssh issh sshopen2 sshopen3); + + ssh('user@hostname', $command); + + issh('user@hostname', $command); + + ssh_cmd('user@hostname', $command); + ssh_cmd( { + user => 'user', + host => 'host.name', + command => 'command', + args => [ '-arg1', '-arg2' ], + stdin_string => "string\n", + } ); + + sshopen2('user@hostname', $reader, $writer, $command); + + sshopen3('user@hostname', $writer, $reader, $error, $command); + +=head1 DESCRIPTION + +Simple wrappers around ssh commands. + +For an all-perl implementation that does not require the system B command, +see L instead. + +=head1 SUBROUTINES + +=over 4 + +=item ssh [USER@]HOST, COMMAND [, ARGS ... ] + +Calls ssh in batch mode. + +=cut + +sub ssh { + my($host, @command) = @_; + @ssh_options = &_ssh_options unless @ssh_options; + my @cmd = ($ssh, @ssh_options, $host, @command); + warn "[Net::SSH::ssh] executing ". join(' ', @cmd). "\n" + if $DEBUG; + system(@cmd); +} + +=item issh [USER@]HOST, COMMAND [, ARGS ... ] + +Prints the ssh command to be executed, waits for the user to confirm, and +(optionally) executes the command. + +=cut + +sub issh { + my($host, @command) = @_; + my @cmd = ($ssh, $host, @command); + print join(' ', @cmd), "\n"; + if ( &_yesno ) { + system(@cmd); + } +} + +=item ssh_cmd [USER@]HOST, COMMAND [, ARGS ... ] + +=item ssh_cmd OPTIONS_HASHREF + +Calls ssh in batch mode. Throws a fatal error if data occurs on the command's +STDERR. Returns any data from the command's STDOUT. + +If using the hashref-style of passing arguments, possible keys are: + + user (optional) + host (requried) + command (required) + args (optional, arrayref) + stdin_string (optional) - written to the command's STDIN + +=cut + +sub ssh_cmd { + my($host, $stdin_string, @command); + if ( ref($_[0]) ) { + my $opt = shift; + $host = $opt->{host}; + $host = $opt->{user}. '@'. $host if exists $opt->{user}; + @command = ( $opt->{command} ); + push @command, @{ $opt->{args} } if exists $opt->{args}; + $stdin_string = $opt->{stdin_string}; + } else { + ($host, @command) = @_; + undef $stdin_string; + } + + my $reader = IO::File->new(); + my $writer = IO::File->new(); + my $error = IO::File->new(); + + sshopen3( $host, $writer, $reader, $error, @command ) or die $!; + + print $writer $stdin_string if defined $stdin_string; + close $writer; + + local $/ = undef; + my $output_stream = <$reader>; + my $error_stream = <$error>; + + if ( length $error_stream ) { + die "[Net:SSH::ssh_cmd] STDERR $error_stream"; + } + + return $output_stream; + +} + +=item sshopen2 [USER@]HOST, READER, WRITER, COMMAND [, ARGS ... ] + +Connects the supplied filehandles to the ssh process (in batch mode). + +=cut + +sub sshopen2 { + my($host, $reader, $writer, @command) = @_; + @ssh_options = &_ssh_options unless @ssh_options; + open2($reader, $writer, $ssh, @ssh_options, $host, @command); +} + +=item sshopen3 HOST, WRITER, READER, ERROR, COMMAND [, ARGS ... ] + +Connects the supplied filehandles to the ssh process (in batch mode). + +=cut + +sub sshopen3 { + my($host, $writer, $reader, $error, @command) = @_; + @ssh_options = &_ssh_options unless @ssh_options; + open3($writer, $reader, $error, $ssh, @ssh_options, $host, @command); +} + +sub _yesno { + print "Proceed [y/N]:"; + my $x = scalar(); + $x =~ /^y/i; +} + +sub _ssh_options { + my $reader = IO::File->new(); + my $writer = IO::File->new(); + my $error = IO::File->new(); + open3($writer, $reader, $error, $ssh, '-V'); + my $ssh_version = <$error>; + chomp($ssh_version); + if ( $ssh_version =~ /.*OpenSSH[-|_](\w+)\./ && $1 == 1 ) { + $equalspace = " "; + } else { + $equalspace = "="; + } + my @options = ( '-o', 'BatchMode'.$equalspace.'yes' ); + if ( $ssh_version =~ /.*OpenSSH[-|_](\w+)\./ && $1 > 1 ) { + unshift @options, '-T'; + } + @options; +} + +=back + +=head1 EXAMPLE + + use Net::SSH qw(sshopen2); + use strict; + + my $user = "username"; + my $host = "hostname"; + my $cmd = "command"; + + sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!"; + + while () { + chomp(); + print "$_\n"; + } + + close(READER); + close(WRITER); + +=head1 FREQUENTLY ASKED QUESTIONS + +Q: How do you supply a password to connect with ssh within a perl script +using the Net::SSH module? + +A: You don't. Use RSA or DSA keys. See the ssh-keygen(1) manpage. + +Q: My script is "leaking" ssh processes. + +A: See L, L, +L and L. + +=head1 AUTHORS + +Ivan Kohler + +John Harrison contributed an example for the documentation. + +Martin Langhoff contributed the ssh_cmd command, and +Jeff Finucane updated it and took care of the 0.04 release. + +Anthony Awtrey contributed a fix for those still using +OpenSSH v1. + +=head1 COPYRIGHT + +Copyright (c) 2002 Ivan Kohler. +Copyright (c) 2002 Freeside Internet Services, LLC +All rights reserved. +This program is free software; you can redistribute it and/or modify it under +the same terms as Perl itself. + +=head1 BUGS + +Not OO. + +Look at IPC::Session (also fsh) + +=head1 SEE ALSO + +For an all-perl implementation that does not require the system B command, +see L instead. + +ssh-keygen(1), ssh(1), L, L, L + +=cut + +1; + diff --git a/agc_2-X/trunk/libs/Net/Telnet.pm b/agc_2-X/trunk/libs/Net/Telnet.pm new file mode 100644 index 00000000..9f84fe31 --- /dev/null +++ b/agc_2-X/trunk/libs/Net/Telnet.pm @@ -0,0 +1,5252 @@ +package Net::Telnet; + +## Copyright 1997, 2000, 2002 Jay Rogers. All rights reserved. +## This program is free software; you can redistribute it and/or +## modify it under the same terms as Perl itself. + +## See user documentation at the end of this file. Search for =head + +use strict; +require 5.002; + +## Module export. +use vars qw(@EXPORT_OK); +@EXPORT_OK = qw(TELNET_IAC TELNET_DONT TELNET_DO TELNET_WONT TELNET_WILL + TELNET_SB TELNET_GA TELNET_EL TELNET_EC TELNET_AYT TELNET_AO + TELNET_IP TELNET_BREAK TELNET_DM TELNET_NOP TELNET_SE + TELNET_EOR TELNET_ABORT TELNET_SUSP TELNET_EOF TELNET_SYNCH + TELOPT_BINARY TELOPT_ECHO TELOPT_RCP TELOPT_SGA TELOPT_NAMS + TELOPT_STATUS TELOPT_TM TELOPT_RCTE TELOPT_NAOL TELOPT_NAOP + TELOPT_NAOCRD TELOPT_NAOHTS TELOPT_NAOHTD TELOPT_NAOFFD + TELOPT_NAOVTS TELOPT_NAOVTD TELOPT_NAOLFD TELOPT_XASCII + TELOPT_LOGOUT TELOPT_BM TELOPT_DET TELOPT_SUPDUP + TELOPT_SUPDUPOUTPUT TELOPT_SNDLOC TELOPT_TTYPE TELOPT_EOR + TELOPT_TUID TELOPT_OUTMRK TELOPT_TTYLOC TELOPT_3270REGIME + TELOPT_X3PAD TELOPT_NAWS TELOPT_TSPEED TELOPT_LFLOW + TELOPT_LINEMODE TELOPT_XDISPLOC TELOPT_OLD_ENVIRON + TELOPT_AUTHENTICATION TELOPT_ENCRYPT TELOPT_NEW_ENVIRON + TELOPT_EXOPL); + +## Module import. +use Exporter (); +use Socket qw(AF_INET SOCK_STREAM inet_aton sockaddr_in); +use Symbol qw(qualify); + +## Base classes. +use vars qw(@ISA); +@ISA = qw(Exporter); +if (&_io_socket_include) { # successfully required module IO::Socket + push @ISA, "IO::Socket::INET"; +} +else { # perl version < 5.004 + require FileHandle; + push @ISA, "FileHandle"; +} + +## Global variables. +use vars qw($VERSION @Telopts); +$VERSION = "3.03"; +@Telopts = ("BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", + "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", + "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", + "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", + "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", + "NAWS", "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC", "OLD-ENVIRON", + "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"); + + +########################### Public Methods ########################### + + +sub new { + my ($class) = @_; + my ( + $errmode, + $fh_open, + $host, + $self, + %args, + ); + local $_; + + ## Create a new object with defaults. + $self = $class->SUPER::new; + *$self->{net_telnet} = { + bin_mode => 0, + blksize => &_optimal_blksize(), + buf => "", + cmd_prompt => '/[\$%#>] $/', + cmd_rm_mode => "auto", + dumplog => '', + eofile => 1, + errormode => "die", + errormsg => "", + fdmask => '', + host => "localhost", + inputlog => '', + last_line => "", + last_prompt => "", + maxbufsize => 1_048_576, + num_wrote => 0, + ofs => "", + opened => '', + opt_cback => '', + opt_log => '', + opts => {}, + ors => "\n", + outputlog => '', + pending_errormsg => "", + port => 23, + pushback_buf => "", + rs => "\n", + subopt_cback => '', + telnet_mode => 1, + time_out => 10, + timedout => '', + unsent_opts => "", + }; + + ## Indicate that we'll accept an offer from remote side for it to echo + ## and suppress go aheads. + &_opt_accept($self, + { option => &TELOPT_ECHO, + is_remote => 1, + is_enable => 1 }, + { option => &TELOPT_SGA, + is_remote => 1, + is_enable => 1 }, + ); + + ## Parse the args. + if (@_ == 2) { # one positional arg given + $host = $_[1]; + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse all other named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $self->binmode($args{$_}); + } + elsif (/^-?cmd_remove_mode$/i) { + $self->cmd_remove_mode($args{$_}); + } + elsif (/^-?dump_log$/i) { + $self->dump_log($args{$_}); + } + elsif (/^-?errmode$/i) { + $errmode = $args{$_}; + } + elsif (/^-?fhopen$/i) { + $fh_open = $args{$_}; + } + elsif (/^-?host$/i) { + $host = $args{$_}; + } + elsif (/^-?input_log$/i) { + $self->input_log($args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $self->input_record_separator($args{$_}); + } + elsif (/^-?option_log$/i) { + $self->option_log($args{$_}); + } + elsif (/^-?output_log$/i) { + $self->output_log($args{$_}); + } + elsif (/^-?output_record_separator$/i or /^-?ors$/i) { + $self->output_record_separator($args{$_}); + } + elsif (/^-?port$/i) { + $self->port($args{$_}); + } + elsif (/^-?prompt$/i) { + $self->prompt($args{$_}); + } + elsif (/^-?telnetmode$/i) { + $self->telnetmode($args{$_}); + } + elsif (/^-?timeout$/i) { + $self->timeout($args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::new()"); + } + } + } + + if (defined $errmode) { # user wants to set errmode + $self->errmode($errmode); + } + + if (defined $fh_open) { # user wants us to attach to existing filehandle + $self->fhopen($fh_open) + or return; + } + elsif (defined $host) { # user wants us to open a connection to host + $self->host($host); + $self->open + or return; + } + + $self; +} # end sub new + + +sub DESTROY { +} # end sub DESTROY + + +sub binmode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{bin_mode}; + + if (@_ >= 2) { + unless (defined $mode) { + $mode = 0; + } + + $s->{bin_mode} = $mode; + } + + $prev; +} # end sub binmode + + +sub break { + my ($self) = @_; + my $s = *$self->{net_telnet}; + my $break_cmd = "\xff\xf3"; + + $s->{timedout} = ''; + + &_put($self, \$break_cmd, "break"); +} # end sub break + + +sub buffer { + my ($self) = @_; + my $s = *$self->{net_telnet}; + + \$s->{buf}; +} # end sub buffer + + +sub buffer_empty { + my ($self) = @_; + my ( + $buffer, + ); + + $buffer = $self->buffer; + $$buffer = ""; +} # end sub buffer_empty + + +sub close { + my ($self) = @_; + my $s = *$self->{net_telnet}; + + $s->{eofile} = 1; + $s->{opened} = ''; + close $self + if defined fileno($self); + + 1; +} # end sub close + + +sub cmd { + my ($self, @args) = @_; + my ( + $cmd_remove_mode, + $errmode, + $firstpos, + $last_prompt, + $lastpos, + $lines, + $ors, + $output, + $output_ref, + $prompt, + $remove_echo, + $rs, + $rs_len, + $s, + $telopt_echo, + $timeout, + %args, + ); + my $cmd = ""; + local $_; + + ## Init. + $self->timed_out(''); + $self->last_prompt(""); + $s = *$self->{net_telnet}; + $output = []; + $cmd_remove_mode = $self->cmd_remove_mode; + $errmode = $self->errmode; + $ors = $self->output_record_separator; + $prompt = $self->prompt; + $rs = $self->input_record_separator; + $timeout = $self->timeout; + + ## Parse args. + if (@_ == 2) { # one positional arg given + $cmd = $_[1]; + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?cmd_remove/i) { + $cmd_remove_mode = &_parse_cmd_remove_mode($self, $args{$_}); + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $rs = &_parse_input_record_separator($self, $args{$_}); + } + elsif (/^-?output$/i) { + $output_ref = $args{$_}; + if (defined($output_ref) and ref($output_ref) eq "ARRAY") { + $output = $output_ref; + } + } + elsif (/^-?output_record_separator$/i or /^-?ors$/i) { + $ors = $self->output_record_separator($args{$_}); + } + elsif (/^-?prompt$/i) { + $prompt = &_parse_prompt($self, $args{$_}); + } + elsif (/^-?string$/i) { + $cmd = $args{$_}; + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::cmd()"); + } + } + } + + ## Override some user settings. + local $s->{errormode} = "return"; + local $s->{time_out} = &_endtime($timeout); + $self->errmsg(""); + + ## Send command and wait for the prompt. + $self->put($cmd . $ors) + and ($lines, $last_prompt) = $self->waitfor($prompt); + + ## Check for failure. + $s->{errormode} = $errmode; + return $self->error("command timed-out") if $self->timed_out; + return $self->error($self->errmsg) if $self->errmsg ne ""; + + ## Save the most recently matched prompt. + $self->last_prompt($last_prompt); + + ## Split lines into an array, keeping record separator at end of line. + $firstpos = 0; + $rs_len = length $rs; + while (($lastpos = index($lines, $rs, $firstpos)) > -1) { + push(@$output, + substr($lines, $firstpos, $lastpos - $firstpos + $rs_len)); + $firstpos = $lastpos + $rs_len; + } + + if ($firstpos < length $lines) { + push @$output, substr($lines, $firstpos); + } + + ## Determine if we should remove the first line of output based + ## on the assumption that it's an echoed back command. + if ($cmd_remove_mode eq "auto") { + ## See if remote side told us they'd echo. + $telopt_echo = $self->option_state(&TELOPT_ECHO); + $remove_echo = $telopt_echo->{remote_enabled}; + } + else { # user explicitly told us how many lines to remove. + $remove_echo = $cmd_remove_mode; + } + + ## Get rid of possible echo back command. + while ($remove_echo--) { + shift @$output; + } + + ## Ensure at least a null string when there's no command output - so + ## "true" is returned in a list context. + unless (@$output) { + @$output = (""); + } + + ## Return command output via named arg, if requested. + if (defined $output_ref) { + if (ref($output_ref) eq "SCALAR") { + $$output_ref = join "", @$output; + } + elsif (ref($output_ref) eq "HASH") { + %$output_ref = @$output; + } + } + + wantarray ? @$output : 1; +} # end sub cmd + + +sub cmd_remove_mode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{cmd_rm_mode}; + + if (@_ >= 2) { + $s->{cmd_rm_mode} = &_parse_cmd_remove_mode($self, $mode); + } + + $prev; +} # end sub cmd_remove_mode + + +sub dump_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{dumplog}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{dumplog} = $fh; + } + + $fh; +} # end sub dump_log + + +sub eof { + my ($self) = @_; + + *$self->{net_telnet}{eofile}; +} # end sub eof + + +sub errmode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{errormode}; + + if (@_ >= 2) { + $s->{errormode} = &_parse_errmode($self, $mode); + } + + $prev; +} # end sub errmode + + +sub errmsg { + my ($self, @errmsgs) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{errormsg}; + + if (@_ >= 2) { + $s->{errormsg} = join "", @errmsgs; + } + + $prev; +} # end sub errmsg + + +sub error { + my ($self, @errmsg) = @_; + my ( + $errmsg, + $func, + $mode, + $s, + @args, + ); + local $_; + + $s = *$self->{net_telnet}; + + if (@_ >= 2) { + ## Put error message in the object. + $errmsg = join "", @errmsg; + $s->{errormsg} = $errmsg; + + ## Do the error action as described by error mode. + $mode = $s->{errormode}; + if (ref($mode) eq "CODE") { + &$mode($errmsg); + return; + } + elsif (ref($mode) eq "ARRAY") { + ($func, @args) = @$mode; + &$func(@args); + return; + } + elsif ($mode =~ /^return$/i) { + return; + } + else { # die + if ($errmsg =~ /\n$/) { + die $errmsg; + } + else { + ## Die and append caller's line number to message. + &_croak($self, $errmsg); + } + } + } + else { + return $s->{errormsg} ne ""; + } +} # end sub error + + +sub fhopen { + my ($self, $fh) = @_; + my ( + $globref, + $s, + ); + + ## Convert given filehandle to a typeglob reference, if necessary. + $globref = &_qualify_fh($self, $fh); + + ## Ensure filehandle is already open. + return $self->error("fhopen filehandle isn't already open") + unless defined($globref) and defined(fileno $globref); + + ## Ensure we're closed. + $self->close; + + ## Save our private data. + $s = *$self->{net_telnet}; + + ## Switch ourself with the given filehandle. + *$self = *$globref; + + ## Restore our private data. + *$self->{net_telnet} = $s; + + ## Re-initialize ourself. + select((select($self), $|=1)[$[]); # don't buffer writes + $s = *$self->{net_telnet}; + $s->{blksize} = &_optimal_blksize((stat $self)[11]); + $s->{buf} = ""; + $s->{eofile} = ''; + $s->{errormsg} = ""; + vec($s->{fdmask}='', fileno($self), 1) = 1; + $s->{host} = ""; + $s->{last_line} = ""; + $s->{last_prompt} = ""; + $s->{num_wrote} = 0; + $s->{opened} = 1; + $s->{pending_errormsg} = ""; + $s->{port} = ''; + $s->{pushback_buf} = ""; + $s->{timedout} = ''; + $s->{unsent_opts} = ""; + &_reset_options($s->{opts}); + + 1; +} # end sub fhopen + + +sub get { + my ($self, %args) = @_; + my ( + $binmode, + $endtime, + $errmode, + $line, + $s, + $telnetmode, + $timeout, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $timeout = $s->{time_out}; + $s->{timedout} = ''; + return if $s->{eofile}; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::get()"); + } + } + + ## If any args given, override corresponding instance data. + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + + ## Set wall time when we time out. + $endtime = &_endtime($timeout); + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + ## Try to read just the waiting data using return error mode. + { + local $s->{errormode} = "return"; + $s->{errormsg} = ""; + &_fillbuf($self, $s, 0); + } + + ## We're done if we timed-out and timeout value is set to "poll". + return $self->error($s->{errormsg}) + if ($s->{timedout} and defined($timeout) and $timeout == 0 + and !length $s->{buf}); + + ## We're done if we hit an error other than timing out. + if ($s->{errormsg} and !$s->{timedout}) { + if (!length $s->{buf}) { + return $self->error($s->{errormsg}); + } + else { # error encountered but there's some data in buffer + $s->{pending_errormsg} = $s->{errormsg}; + } + } + + ## Clear time-out error from first read. + $s->{timedout} = ''; + $s->{errormsg} = ""; + + ## If buffer is still empty, try to read according to user's timeout. + if (!length $s->{buf}) { + &_fillbuf($self, $s, $endtime) + or do { + return if $s->{timedout}; + + ## We've reached end-of-file. + $self->close; + return; + }; + } + + ## Extract chars from buffer. + $line = $s->{buf}; + $s->{buf} = ""; + + $line; +} # end sub get + + +sub getline { + my ($self, %args) = @_; + my ( + $binmode, + $endtime, + $errmode, + $len, + $line, + $offset, + $pos, + $rs, + $s, + $telnetmode, + $timeout, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return if $s->{eofile}; + $rs = $s->{rs}; + $timeout = $s->{time_out}; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $rs = &_parse_input_record_separator($self, $args{$_}); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::getline()"); + } + } + + ## If any args given, override corresponding instance data. + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + + ## Set wall time when we time out. + $endtime = &_endtime($timeout); + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + ## Keep reading into buffer until end-of-line is read. + $offset = 0; + while (($pos = index($s->{buf}, $rs, $offset)) == -1) { + $offset = length $s->{buf}; + &_fillbuf($self, $s, $endtime) + or do { + return if $s->{timedout}; + + ## We've reached end-of-file. + $self->close; + if (length $s->{buf}) { + return $s->{buf}; + } + else { + return; + } + }; + } + + ## Extract line from buffer. + $len = $pos + length $rs; + $line = substr($s->{buf}, 0, $len); + substr($s->{buf}, 0, $len) = ""; + + $line; +} # end sub getline + + +sub getlines { + my ($self, %args) = @_; + my ( + $binmode, + $errmode, + $line, + $rs, + $s, + $telnetmode, + $timeout, + ); + my $all = 1; + my @lines = (); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return if $s->{eofile}; + $timeout = $s->{time_out}; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?all$/i) { + $all = $args{$_}; + unless (defined $all) { + $all = ''; + } + } + elsif (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $rs = &_parse_input_record_separator($self, $args{$_}); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::getlines()"); + } + } + + ## If any args given, override corresponding instance data. + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{rs} = $rs + if defined $rs; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + local $s->{time_out} = &_endtime($timeout); + + ## User requested only the currently available lines. + if (! $all) { + return &_next_getlines($self, $s); + } + + ## Read lines until eof or error. + while (1) { + $line = $self->getline + or last; + push @lines, $line; + } + + ## Check for error. + return if ! $self->eof; + + @lines; +} # end sub getlines + + +sub host { + my ($self, $host) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{host}; + + if (@_ >= 2) { + unless (defined $host) { + $host = ""; + } + + $s->{host} = $host; + } + + $prev; +} # end sub host + + +sub input_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{inputlog}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{inputlog} = $fh; + } + + $fh; +} # end sub input_log + + +sub input_record_separator { + my ($self, $rs) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{rs}; + + if (@_ >= 2) { + $s->{rs} = &_parse_input_record_separator($self, $rs); + } + + $prev; +} # end sub input_record_separator + + +sub last_prompt { + my ($self, $string) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{last_prompt}; + + if (@_ >= 2) { + unless (defined $string) { + $string = ""; + } + + $s->{last_prompt} = $string; + } + + $prev; +} # end sub last_prompt + + +sub lastline { + my ($self, $line) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{last_line}; + + if (@_ >= 2) { + unless (defined $line) { + $line = ""; + } + + $s->{last_line} = $line; + } + + $prev; +} # end sub lastline + + +sub login { + my ($self) = @_; + my ( + $errmode, + $error, + $is_passwd_arg, + $is_username_arg, + $lastline, + $match, + $ors, + $passwd, + $prematch, + $prompt, + $s, + $timeout, + $username, + %args, + ); + local $_; + + ## Init. + $self->timed_out(''); + $self->last_prompt(""); + $s = *$self->{net_telnet}; + $timeout = $self->timeout; + $ors = $self->output_record_separator; + $prompt = $self->prompt; + + ## Parse args. + if (@_ == 3) { # just username and passwd given + $username = $_[1]; + $passwd = $_[2]; + + $is_username_arg = 1; + $is_passwd_arg = 1; + } + else { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?name$/i) { + $username = $args{$_}; + unless (defined $username) { + $username = ""; + } + + $is_username_arg = 1; + } + elsif (/^-?pass/i) { + $passwd = $args{$_}; + unless (defined $passwd) { + $passwd = ""; + } + + $is_passwd_arg = 1; + } + elsif (/^-?prompt$/i) { + $prompt = &_parse_prompt($self, $args{$_}); + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given ", + "to " . ref($self) . "::login()"); + } + } + } + + ## Ensure both username and password argument given. + &_croak($self,"Name argument not given to " . ref($self) . "::login()") + unless $is_username_arg; + &_croak($self,"Password argument not given to " . ref($self) . "::login()") + unless $is_passwd_arg; + + ## Override some user settings. + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{time_out} = &_endtime($timeout); + + ## Create a subroutine to generate an error. + $error + = sub { + my ($errmsg) = @_; + + if ($self->timed_out) { + return $self->error($errmsg); + } + elsif ($self->eof) { + ($lastline = $self->lastline) =~ s/\n+//; + return $self->error($errmsg, ": ", $lastline); + } + else { + return $self->error($self->errmsg); + } + }; + + + return $self->error("login failed: filehandle isn't open") + if $self->eof; + + ## Wait for login prompt. + $self->waitfor(Match => '/login[: ]*$/i', + Match => '/username[: ]*$/i', + Errmode => "return") + or do { + return &$error("eof read waiting for login prompt") + if $self->eof; + return &$error("timed-out waiting for login prompt"); + }; + + ## Delay sending response because of bug in Linux login program. + &_sleep(0.01); + + ## Send login name. + $self->put(String => $username . $ors, + Errmode => "return") + or return &$error("login disconnected"); + + ## Wait for password prompt. + $self->waitfor(Match => '/password[: ]*$/i', + Errmode => "return") + or do { + return &$error("eof read waiting for password prompt") + if $self->eof; + return &$error("timed-out waiting for password prompt"); + }; + + ## Delay sending response because of bug in Linux login program. + &_sleep(0.01); + + ## Send password. + $self->put(String => $passwd . $ors, + Errmode => "return") + or return &$error("login disconnected"); + + ## Wait for command prompt or another login prompt. + ($prematch, $match) = $self->waitfor(Match => '/login[: ]*$/i', + Match => '/username[: ]*$/i', + Match => $prompt, + Errmode => "return") + or do { + return &$error("eof read waiting for command prompt") + if $self->eof; + return &$error("timed-out waiting for command prompt"); + }; + + ## It's a bad login if we got another login prompt. + return $self->error("login failed: bad name or password") + if $match =~ /login[: ]*$/i or $match =~ /username[: ]*$/i; + + ## Save the most recently matched command prompt. + $self->last_prompt($match); + + 1; +} # end sub login + + +sub max_buffer_length { + my ($self, $maxbufsize) = @_; + my ( + $prev, + $s, + ); + my $minbufsize = 512; + + $s = *$self->{net_telnet}; + $prev = $s->{maxbufsize}; + + if (@_ >= 2) { + ## Ensure a positive integer value. + unless (defined $maxbufsize + and $maxbufsize =~ /^\d+$/ + and $maxbufsize) + { + &_carp($self, "ignoring bad Max_buffer_length " . + "argument \"$maxbufsize\": it's not a positive integer"); + $maxbufsize = $prev; + } + + ## Adjust up values that are too small. + if ($maxbufsize < $minbufsize) { + $maxbufsize = $minbufsize; + } + + $s->{maxbufsize} = $maxbufsize; + } + + $prev; +} # end sub max_buffer_length + + +## Make ofs() synonymous with output_field_separator(). +*ofs = \&output_field_separator; + + +sub open { + my ($self) = @_; + my ( + $errmode, + $errno, + $host, + $ip_addr, + $port, + $s, + $timeout, + %args, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $timeout = $s->{time_out}; + $s->{timedout} = ''; + + if (@_ == 2) { # one positional arg given + $self->host($_[1]); + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?host$/i) { + $self->host($args{$_}); + } + elsif (/^-?port$/i) { + $self->port($args{$_}) + or return; + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given ", + "to " . ref($self) . "::open()"); + } + } + } + + ## If any args given, override corresponding instance data. + local $s->{errormode} = $errmode + if defined $errmode; + + ## Get host and port. + $host = $self->host; + $port = $self->port; + + ## Ensure we're already closed. + $self->close; + + ## Connect with or without a timeout. + if (defined($timeout) and &_have_alarm) { # use a timeout + ## Convert possible absolute timeout to relative timeout. + if ($timeout >= $^T) { # it's an absolute time + $timeout = $timeout - time; + } + + ## Ensure a valid timeout value for alarm. + if ($timeout < 1) { + $timeout = 1; + } + $timeout = int($timeout + 1.5); + + ## Connect to server, timing out if it takes too long. + eval { + ## Turn on timer. + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{ALRM} = sub { die "timed-out\n" }; + alarm $timeout; + + ## Lookup server's IP address. + $ip_addr = inet_aton $host + or die "unknown remote host: $host\n"; + + ## Create a socket and attach the filehandle to it. + socket $self, AF_INET, SOCK_STREAM, 0 + or die "problem creating socket: $!\n"; + + ## Open connection to server. + connect $self, sockaddr_in($port, $ip_addr) + or die "problem connecting to \"$host\", port $port: $!\n"; + }; + alarm 0; + + ## Check for error. + if ($@ =~ /^timed-out$/) { # time out failure + $s->{timedout} = 1; + $self->close; + if (!$ip_addr) { + return $self->error("unknown remote host: $host: ", + "name lookup timed-out"); + } + else { + return $self->error("problem connecting to \"$host\", ", + "port $port: connect timed-out"); + } + } + elsif ($@) { # hostname lookup or connect failure + $self->close; + chomp $@; + return $self->error($@); + } + } + else { # don't use a timeout + $timeout = undef; + + ## Lookup server's IP address. + $ip_addr = inet_aton $host + or return $self->error("unknown remote host: $host"); + + ## Create a socket and attach the filehandle to it. + socket $self, AF_INET, SOCK_STREAM, 0 + or return $self->error("problem creating socket: $!"); + + ## Open connection to server. + connect $self, sockaddr_in($port, $ip_addr) + or do { + $errno = "$!"; + $self->close; + return $self->error("problem connecting to \"$host\", ", + "port $port: $errno"); + }; + } + + select((select($self), $|=1)[$[]); # don't buffer writes + $s->{blksize} = &_optimal_blksize((stat $self)[11]); + $s->{buf} = ""; + $s->{eofile} = ''; + $s->{errormsg} = ""; + vec($s->{fdmask}='', fileno($self), 1) = 1; + $s->{last_line} = ""; + $s->{num_wrote} = 0; + $s->{opened} = 1; + $s->{pending_errormsg} = ""; + $s->{pushback_buf} = ""; + $s->{timedout} = ''; + $s->{unsent_opts} = ""; + &_reset_options($s->{opts}); + + 1; +} # end sub open + + +sub option_accept { + my ($self, @args) = @_; + my ( + $arg, + $option, + $s, + @opt_args, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + + ## Parse the named args. + while (($_, $arg) = splice @args, 0, 2) { + ## Verify and save arguments. + if (/^-?do$/i) { + ## Make sure a callback is defined. + return $self->error("usage: an option callback must already ", + "be defined when enabling with $_") + unless $s->{opt_cback}; + + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => '', + is_enable => 1, + }; + } + elsif (/^-?dont$/i) { + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => '', + is_enable => '', + }; + } + elsif (/^-?will$/i) { + ## Make sure a callback is defined. + return $self->error("usage: an option callback must already ", + "be defined when enabling with $_") + unless $s->{opt_cback}; + + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => 1, + is_enable => 1, + }; + } + elsif (/^-?wont$/i) { + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => 1, + is_enable => '', + }; + } + else { + return $self->error('usage: $obj->option_accept(' . + '[Do => $telopt,] ', + '[Dont => $telopt,] ', + '[Will => $telopt,] ', + '[Wont => $telopt,]'); + } + } + + ## Set "receive ok" for options specified. + &_opt_accept($self, @opt_args); +} # end sub option_accept + + +sub option_callback { + my ($self, $callback) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{opt_cback}; + + if (@_ >= 2) { + unless (defined $callback and ref($callback) eq "CODE") { + &_carp($self, "ignoring Option_callback argument because it's " . + "not a code ref"); + $callback = $prev; + } + + $s->{opt_cback} = $callback; + } + + $prev; +} # end sub option_callback + + +sub option_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{opt_log}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{opt_log} = $fh; + } + + $fh; +} # end sub option_log + + +sub option_state { + my ($self, $option) = @_; + my ( + $opt_state, + $s, + %opt_state, + ); + + ## Ensure telnet option is non-negative integer. + $option = &_verify_telopt_arg($self, $option); + return unless defined $option; + + ## Init. + $s = *$self->{net_telnet}; + unless (defined $s->{opts}{$option}) { + &_set_default_option($s, $option); + } + + ## Return hashref to a copy of the values. + $opt_state = $s->{opts}{$option}; + %opt_state = %$opt_state; + \%opt_state; +} # end sub option_state + + +## Make ors() synonymous with output_record_separator(). +*ors = \&output_record_separator; + + +sub output_field_separator { + my ($self, $ofs) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{ofs}; + + if (@_ >= 2) { + unless (defined $ofs) { + $ofs = ""; + } + + $s->{ofs} = $ofs; + } + + $prev; +} # end sub output_field_separator + + +sub output_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{outputlog}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{outputlog} = $fh; + } + + $fh; +} # end sub output_log + + +sub output_record_separator { + my ($self, $ors) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{ors}; + + if (@_ >= 2) { + unless (defined $ors) { + $ors = ""; + } + + $s->{ors} = $ors; + } + + $prev; +} # end sub output_record_separator + + +sub port { + my ($self, $port) = @_; + my ( + $prev, + $s, + $service, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{port}; + + if (@_ >= 2) { + unless (defined $port) { + $port = ""; + } + + if (!$port) { + &_carp($self, "ignoring bad Port argument \"$port\""); + $port = $prev; + } + elsif ($port !~ /^\d+$/) { # port isn't all digits + $service = $port; + $port = getservbyname($service, "tcp"); + unless ($port) { + &_carp($self, "ignoring bad Port argument \"$service\": " . + "it's an unknown TCP service"); + $port = $prev; + } + } + + $s->{port} = $port; + } + + $prev; +} # end sub port + + +sub print { + my ($self) = shift; + my ( + $buf, + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return $self->error("write error: filehandle isn't open") + unless $s->{opened}; + + ## Add field and record separators. + $buf = join($s->{ofs}, @_) . $s->{ors}; + + ## Log the output if requested. + if ($s->{outputlog}) { + &_log_print($s->{outputlog}, $buf); + } + + ## Convert native newlines to CR LF. + if (!$s->{bin_mode}) { + $buf =~ s(\n)(\015\012)g; + } + + ## Escape TELNET IAC and also CR not followed by LF. + if ($s->{telnet_mode}) { + $buf =~ s(\377)(\377\377)g; + &_escape_cr(\$buf); + } + + &_put($self, \$buf, "print"); +} # end sub print + + +sub print_length { + my ($self) = @_; + + *$self->{net_telnet}{num_wrote}; +} # end sub print_length + + +sub prompt { + my ($self, $prompt) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{cmd_prompt}; + + ## Parse args. + if (@_ == 2) { + $s->{cmd_prompt} = &_parse_prompt($self, $prompt); + } + + $prev; +} # end sub prompt + + +sub put { + my ($self) = @_; + my ( + $binmode, + $buf, + $errmode, + $is_timeout_arg, + $s, + $telnetmode, + $timeout, + %args, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + + ## Parse args. + if (@_ == 2) { # one positional arg given + $buf = $_[1]; + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?string$/i) { + $buf = $args{$_}; + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + $is_timeout_arg = 1; + } + else { + &_croak($self, "bad named parameter \"$_\" given ", + "to " . ref($self) . "::put()"); + } + } + } + + ## If any args given, override corresponding instance data. + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + local $s->{time_out} = $timeout + if defined $is_timeout_arg; + + ## Check for errors. + return $self->error("write error: filehandle isn't open") + unless $s->{opened}; + + ## Log the output if requested. + if ($s->{outputlog}) { + &_log_print($s->{outputlog}, $buf); + } + + ## Convert native newlines to CR LF. + if (!$s->{bin_mode}) { + $buf =~ s(\n)(\015\012)g; + } + + ## Escape TELNET IAC and also CR not followed by LF. + if ($s->{telnet_mode}) { + $buf =~ s(\377)(\377\377)g; + &_escape_cr(\$buf); + } + + &_put($self, \$buf, "print"); +} # end sub put + + +## Make rs() synonymous input_record_separator(). +*rs = \&input_record_separator; + + +sub suboption_callback { + my ($self, $callback) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{subopt_cback}; + + if (@_ >= 2) { + unless (defined $callback and ref($callback) eq "CODE") { + &_carp($self,"ignoring Suboption_callback argument because it's " . + "not a code ref"); + $callback = $prev; + } + + $s->{subopt_cback} = $callback; + } + + $prev; +} # end sub suboption_callback + + +sub telnetmode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{telnet_mode}; + + if (@_ >= 2) { + unless (defined $mode) { + $mode = 0; + } + + $s->{telnet_mode} = $mode; + } + + $prev; +} # end sub telnetmode + + +sub timed_out { + my ($self, $value) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{timedout}; + + if (@_ >= 2) { + unless (defined $value) { + $value = ""; + } + + $s->{timedout} = $value; + } + + $prev; +} # end sub timed_out + + +sub timeout { + my ($self, $timeout) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{time_out}; + + if (@_ >= 2) { + $s->{time_out} = &_parse_timeout($self, $timeout); + } + + $prev; +} # end sub timeout + + +sub waitfor { + my ($self, @args) = @_; + my ( + $arg, + $binmode, + $endtime, + $errmode, + $len, + $match, + $match_op, + $pos, + $prematch, + $s, + $search, + $search_cond, + $telnetmode, + $timeout, + @match_cond, + @match_ops, + @search_cond, + @string_cond, + @warns, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return if $s->{eofile}; + return unless @args; + $timeout = $s->{time_out}; + + ## Code template used to build string match conditional. + ## Values between array elements must be supplied later. + @string_cond = + ('if (($pos = index $s->{buf}, ', ') > -1) { + $len = ', '; + $prematch = substr $s->{buf}, 0, $pos; + $match = substr $s->{buf}, $pos, $len; + substr($s->{buf}, 0, $pos + $len) = ""; + last; + }'); + + ## Code template used to build pattern match conditional. + ## Values between array elements must be supplied later. + @match_cond = + ('if ($s->{buf} =~ ', ') { + $prematch = $`; + $match = $&; + substr($s->{buf}, 0, length($`) + length($&)) = ""; + last; + }'); + + ## Parse args. + if (@_ == 2) { # one positional arg given + $arg = $_[1]; + + ## Fill in the blanks in the code template. + push @match_ops, $arg; + push @search_cond, join("", $match_cond[0], $arg, $match_cond[1]); + } + elsif (@_ > 2) { # named args given + ## Parse the named args. + while (($_, $arg) = splice @args, 0, 2) { + if (/^-?binmode$/i) { + $binmode = $arg; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $arg); + } + elsif (/^-?match$/i) { + ## Fill in the blanks in the code template. + push @match_ops, $arg; + push @search_cond, join("", + $match_cond[0], $arg, $match_cond[1]); + } + elsif (/^-?string$/i) { + ## Fill in the blanks in the code template. + $arg =~ s/'/\\'/g; # quote ticks + push @search_cond, join("", + $string_cond[0], "'$arg'", + $string_cond[1], length($arg), + $string_cond[2]); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $arg; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $arg); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::waitfor()"); + } + } + } + + ## If any args given, override corresponding instance data. + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + + ## Check for bad match operator argument. + foreach $match_op (@match_ops) { + return $self->error("missing opening delimiter of match operator ", + "in argument \"$match_op\" given to ", + ref($self) . "::waitfor()") + unless $match_op =~ m(^\s*/) or $match_op =~ m(^\s*m\s*\W); + } + + ## Construct conditional to check for requested string and pattern matches. + ## Turn subsequent "if"s into "elsif". + $search_cond = join "\n\tels", @search_cond; + + ## Construct loop to fill buffer until string/pattern, timeout, or eof. + $search = join "", " + while (1) {\n\t", + $search_cond, ' + &_fillbuf($self, $s, $endtime) + or do { + last if $s->{timedout}; + $self->close; + last; + }; + }'; + + ## Set wall time when we timeout. + $endtime = &_endtime($timeout); + + ## Run the loop. + { + local $^W = 1; + local $SIG{"__WARN__"} = sub { push @warns, @_ }; + local $s->{errormode} = "return"; + $s->{errormsg} = ""; + eval $search; + } + + ## Check for failure. + return $self->error("pattern match timed-out") if $s->{timedout}; + return $self->error($s->{errormsg}) if $s->{errormsg} ne ""; + return $self->error("pattern match read eof") if $s->{eofile}; + + ## Check for Perl syntax errors or warnings. + if ($@ or @warns) { + foreach $match_op (@match_ops) { + &_match_check($self, $match_op) + or return; + } + return $self->error($@) if $@; + return $self->error(@warns) if @warns; + } + + wantarray ? ($prematch, $match) : 1; +} # end sub waitfor + + +######################## Private Subroutines ######################### + + +sub _append_lineno { + my ($obj, @msgs) = @_; + my ( + $file, + $line, + $pkg, + ); + + ## Find the caller that's not in object's class or one of its base classes. + ($pkg, $file , $line) = &_user_caller($obj); + join("", @msgs, " at ", $file, " line ", $line, "\n"); +} # end sub _append_lineno + + +sub _carp { + warn &_append_lineno(@_); +} # end sub _carp + + +sub _croak { + die &_append_lineno(@_); +} # end sub _croak + + +sub _endtime { + my ($interval) = @_; + + ## Compute wall time when timeout occurs. + if (defined $interval) { + if ($interval >= $^T) { # it's already an absolute time + return $interval; + } + elsif ($interval > 0) { # it's relative to the current time + return int(time + 1.5 + $interval); + } + else { # it's a one time poll + return 0; + } + } + else { # there's no timeout + return undef; + } +} # end sub _endtime + + +sub _escape_cr { + my ($string) = @_; + my ( + $nextchar, + ); + my $pos = 0; + + ## Convert all CR (not followed by LF) to CR NULL. + while (($pos = index($$string, "\015", $pos)) > -1) { + $nextchar = substr $$string, $pos + 1, 1; + + substr($$string, $pos, 1) = "\015\000" + unless $nextchar eq "\012"; + + $pos++; + } + + 1; +} # end sub _escape_cr + + +sub _fillbuf { + my ($self, $s, $endtime) = @_; + my ( + $msg, + $nfound, + $nread, + $pushback_len, + $read_pos, + $ready, + $timed_out, + $timeout, + $unparsed_pos, + ); + + ## If error from last read not yet reported then do it now. + if ($s->{pending_errormsg}) { + $msg = $s->{pending_errormsg}; + $s->{pending_errormsg} = ""; + return $self->error($msg); + } + + return unless $s->{opened}; + + while (1) { + ## Maximum buffer size exceeded? + return $self->error("maximum input buffer length exceeded: ", + $s->{maxbufsize}, " bytes") + unless length($s->{buf}) <= $s->{maxbufsize}; + + ## Determine how long to wait for input ready. + ($timed_out, $timeout) = &_timeout_interval($endtime); + if ($timed_out) { + $s->{timedout} = 1; + return $self->error("read timed-out"); + } + + ## Wait for input ready. + $nfound = select $ready=$s->{fdmask}, "", "", $timeout; + + ## Handle any errors while waiting. + if (!defined $nfound or $nfound <= 0) { # input not ready + if (defined $nfound and $nfound == 0) { # timed-out + $s->{timedout} = 1; + return $self->error("read timed-out"); + } + else { # error waiting for input ready + next if $! =~ /^interrupted/i; + + $s->{opened} = ''; + return $self->error("read error: $!"); + } + } + + ## Append to buffer any partially processed telnet or CR sequence. + $pushback_len = length $s->{pushback_buf}; + if ($pushback_len) { + $s->{buf} .= $s->{pushback_buf}; + $s->{pushback_buf} = ""; + } + + ## Read the waiting data. + $read_pos = length $s->{buf}; + $unparsed_pos = $read_pos - $pushback_len; + $nread = sysread $self, $s->{buf}, $s->{blksize}, $read_pos; + + ## Handle any read errors. + if (!defined $nread) { # read failed + next if $! =~ /^interrupted/i; # restart interrupted syscall + + $s->{opened} = ''; + return $self->error("read error: $!"); + } + + ## Handle eof. + if ($nread == 0) { # eof read + $s->{opened} = ''; + return; + } + + ## Display network traffic if requested. + if ($s->{dumplog}) { + &_log_dump('<', $s->{dumplog}, \$s->{buf}, $read_pos); + } + + ## Process any telnet commands in the data stream. + if ($s->{telnet_mode} and index($s->{buf},"\377",$unparsed_pos) > -1) { + &_interpret_tcmd($self, $s, $unparsed_pos); + } + + ## Process any carriage-return sequences in the data stream. + &_interpret_cr($s, $unparsed_pos); + + ## Read again if all chars read were consumed as telnet cmds. + next if $unparsed_pos >= length $s->{buf}; + + ## Log the input if requested. + if ($s->{inputlog}) { + &_log_print($s->{inputlog}, substr($s->{buf}, $unparsed_pos)); + } + + ## Save the last line read. + &_save_lastline($s); + + ## We've successfully read some data into the buffer. + last; + } # end while(1) + + 1; +} # end sub _fillbuf + + +sub _flush_opts { + my ($self) = @_; + my ( + $option_chars, + ); + my $s = *$self->{net_telnet}; + + ## Get option and clear the output buf. + $option_chars = $s->{unsent_opts}; + $s->{unsent_opts} = ""; + + ## Try to send options without waiting. + { + local $s->{errormode} = "return"; + local $s->{time_out} = 0; + &_put($self, \$option_chars, "telnet option negotiation") + or do { + ## Save chars not printed for later. + substr($option_chars, 0, $self->print_length) = ""; + $s->{unsent_opts} .= $option_chars; + }; + } + + 1; +} # end sub _flush_opts + + +sub _fname_to_handle { + my ($self, $fh) = @_; + my ( + $filename, + ); + + ## Ensure valid input. + return "" + unless defined $fh and (ref $fh or length $fh); + + ## Open a new filehandle if input is a filename. + no strict "refs"; + if (!ref($fh) and !defined(fileno $fh)) { # fh is a filename + $filename = $fh; + $fh = &_new_handle(); + CORE::open $fh, "> $filename" + or return $self->error("problem creating $filename: $!"); + } + + select((select($fh), $|=1)[$[]); # don't buffer writes + $fh; +} # end sub _fname_to_handle + + +sub _have_alarm { + eval { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{ALRM} = sub { die }; + alarm 0; + }; + + ! $@; +} # end sub _have_alarm + + +sub _interpret_cr { + my ($s, $pos) = @_; + my ( + $nextchar, + ); + + while (($pos = index($s->{buf}, "\015", $pos)) > -1) { + $nextchar = substr($s->{buf}, $pos + 1, 1); + if ($nextchar eq "\0") { + ## Convert CR NULL to CR when in telnet mode. + if ($s->{telnet_mode}) { + substr($s->{buf}, $pos + 1, 1) = ""; + } + } + elsif ($nextchar eq "\012") { + ## Convert CR LF to newline when not in binary mode. + if (!$s->{bin_mode}) { + substr($s->{buf}, $pos, 2) = "\n"; + } + } + elsif (!length($nextchar) and ($s->{telnet_mode} or !$s->{bin_mode})) { + ## Save CR in alt buffer for possible CR LF or CR NULL conversion. + $s->{pushback_buf} .= "\015"; + chop $s->{buf}; + } + + $pos++; + } + + 1; +} # end sub _interpret_cr + + +sub _interpret_tcmd { + my ($self, $s, $offset) = @_; + my ( + $callback, + $endpos, + $nextchar, + $option, + $parameters, + $pos, + $subcmd, + ); + local $_; + + ## Parse telnet commands in the data stream. + $pos = $offset; + while (($pos = index $s->{buf}, "\377", $pos) > -1) { # unprocessed IAC + $nextchar = substr $s->{buf}, $pos + 1, 1; + + ## Save command if it's only partially read. + if (!length $nextchar) { + $s->{pushback_buf} .= "\377"; + chop $s->{buf}; + last; + } + + if ($nextchar eq "\377") { # IAC is escaping "\377" char + ## Remove escape char from data stream. + substr($s->{buf}, $pos, 1) = ""; + $pos++; + } + elsif ($nextchar eq "\375" or $nextchar eq "\373" or + $nextchar eq "\374" or $nextchar eq "\376") { # opt negotiation + $option = substr $s->{buf}, $pos + 2, 1; + + ## Save command if it's only partially read. + if (!length $option) { + $s->{pushback_buf} .= "\377" . $nextchar; + chop $s->{buf}; + chop $s->{buf}; + last; + } + + ## Remove command from data stream. + substr($s->{buf}, $pos, 3) = ""; + + ## Handle option negotiation. + &_negotiate_recv($self, $s, $nextchar, ord($option), $pos); + } + elsif ($nextchar eq "\372") { # start of subnegotiation parameters + ## Save command if it's only partially read. + $endpos = index $s->{buf}, "\360", $pos; + if ($endpos == -1) { + $s->{pushback_buf} .= substr $s->{buf}, $pos; + substr($s->{buf}, $pos) = ""; + last; + } + + ## Remove subnegotiation cmd from buffer. + $subcmd = substr($s->{buf}, $pos, $endpos - $pos + 1); + substr($s->{buf}, $pos, $endpos - $pos + 1) = ""; + + ## Invoke subnegotiation callback. + if ($s->{subopt_cback} and length($subcmd) >= 5) { + $option = unpack "C", substr($subcmd, 2, 1); + if (length($subcmd) >= 6) { + $parameters = substr $subcmd, 3, length($subcmd) - 5; + } + else { + $parameters = ""; + } + + $callback = $s->{subopt_cback}; + &$callback($self, $option, $parameters); + } + } + else { # various two char telnet commands + ## Ignore and remove command from data stream. + substr($s->{buf}, $pos, 2) = ""; + } + } + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + 1; +} # end sub _interpret_tcmd + + +sub _io_socket_include { + local $SIG{"__DIE__"} = "DEFAULT"; + eval "require IO::Socket"; +} # end sub io_socket_include + + +sub _log_dump { + my ($direction, $fh, $data, $offset, $len) = @_; + my ( + $addr, + $hexvals, + $line, + ); + + $addr = 0; + $len = length($$data) - $offset + if !defined $len; + return 1 if $len <= 0; + + ## Print data in dump format. + while ($len > 0) { + ## Convert up to the next 16 chars to hex, padding w/ spaces. + if ($len >= 16) { + $line = substr $$data, $offset, 16; + } + else { + $line = substr $$data, $offset, $len; + } + $hexvals = unpack("H*", $line); + $hexvals .= ' ' x (32 - length $hexvals); + + ## Place in 16 columns, each containing two hex digits. + $hexvals = sprintf("%s %s %s %s " x 4, + unpack("a2" x 16, $hexvals)); + + ## For the ASCII column, change unprintable chars to a period. + $line =~ s/[\000-\037,\177-\237]/./g; + + ## Print the line in dump format. + &_log_print($fh, sprintf("%s 0x%5.5lx: %s%s\n", + $direction, $addr, $hexvals, $line)); + + $addr += 16; + $offset += 16; + $len -= 16; + } + + &_log_print($fh, "\n"); + + 1; +} # end sub _log_dump + + +sub _log_option { + my ($fh, $direction, $request, $option) = @_; + my ( + $name, + ); + + if ($option >= 0 and $option <= $#Telopts) { + $name = $Telopts[$option]; + } + else { + $name = $option; + } + + &_log_print($fh, "$direction $request $name\n"); +} # end sub _log_option + + +sub _log_print { + my ($fh, $buf) = @_; + local $\ = ''; + + if (ref($fh) and ref($fh) ne "GLOB") { # fh is blessed ref + $fh->print($buf); + } + else { # fh isn't blessed ref + print $fh $buf; + } +} # end sub _log_print + + +sub _match_check { + my ($self, $code) = @_; + my $error; + my @warns = (); + + ## Use eval to check for syntax errors or warnings. + { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{"__WARN__"} = sub { push @warns, @_ }; + local $^W = 1; + local $_ = ''; + eval "\$_ =~ $code;"; + } + if ($@) { + ## Remove useless lines numbers from message. + ($error = $@) =~ s/ at \(eval \d+\) line \d+.?//; + chomp $error; + return $self->error("bad match operator: $error"); + } + elsif (@warns) { + ## Remove useless lines numbers from message. + ($error = shift @warns) =~ s/ at \(eval \d+\) line \d+.?//; + $error =~ s/ while "strict subs" in use//; + chomp $error; + return $self->error("bad match operator: $error"); + } + + 1; +} # end sub _match_check + + +sub _negotiate_callback { + my ($self, $opt, $is_remote, $is_enabled, $was_enabled, $opt_bufpos) = @_; + my ( + $callback, + $s, + ); + local $_; + + ## Keep track of remote echo. + if ($is_remote and $opt == &TELOPT_ECHO) { # received WILL or WONT ECHO + $s = *$self->{net_telnet}; + + if ($is_enabled and !$was_enabled) { # received WILL ECHO + $s->{remote_echo} = 1; + } + elsif (!$is_enabled and $was_enabled) { # received WONT ECHO + $s->{remote_echo} = ''; + } + } + + ## Invoke callback, if there is one. + $callback = $self->option_callback; + if ($callback) { + &$callback($self, $opt, $is_remote, + $is_enabled, $was_enabled, $opt_bufpos); + } + + 1; +} # end sub _negotiate_callback + + +sub _negotiate_recv { + my ($self, $s, $opt_request, $opt, $opt_bufpos) = @_; + + ## Ensure data structure exists for this option. + unless (defined $s->{opts}{$opt}) { + &_set_default_option($s, $opt); + } + + ## Process the option. + if ($opt_request eq "\376") { # DONT + &_negotiate_recv_disable($self, $s, $opt, "dont", $opt_bufpos, + $s->{opts}{$opt}{local_enable_ok}, + \$s->{opts}{$opt}{local_enabled}, + \$s->{opts}{$opt}{local_state}); + } + elsif ($opt_request eq "\375") { # DO + &_negotiate_recv_enable($self, $s, $opt, "do", $opt_bufpos, + $s->{opts}{$opt}{local_enable_ok}, + \$s->{opts}{$opt}{local_enabled}, + \$s->{opts}{$opt}{local_state}); + } + elsif ($opt_request eq "\374") { # WONT + &_negotiate_recv_disable($self, $s, $opt, "wont", $opt_bufpos, + $s->{opts}{$opt}{remote_enable_ok}, + \$s->{opts}{$opt}{remote_enabled}, + \$s->{opts}{$opt}{remote_state}); + } + elsif ($opt_request eq "\373") { # WILL + &_negotiate_recv_enable($self, $s, $opt, "will", $opt_bufpos, + $s->{opts}{$opt}{remote_enable_ok}, + \$s->{opts}{$opt}{remote_enabled}, + \$s->{opts}{$opt}{remote_state}); + } + else { # internal error + die; + } + + 1; +} # end sub _negotiate_recv + + +sub _negotiate_recv_disable { + my ($self, $s, $opt, $opt_request, + $opt_bufpos, $enable_ok, $is_enabled, $state) = @_; + my ( + $ack, + $disable_cmd, + $enable_cmd, + $is_remote, + $nak, + $was_enabled, + ); + + ## What do we use to request enable/disable or respond with ack/nak. + if ($opt_request eq "wont") { + $enable_cmd = "\377\375" . pack("C", $opt); # do command + $disable_cmd = "\377\376" . pack("C", $opt); # dont command + $is_remote = 1; + $ack = "DO"; + $nak = "DONT"; + + &_log_option($s->{opt_log}, "RCVD", "WONT", $opt) + if $s->{opt_log}; + } + elsif ($opt_request eq "dont") { + $enable_cmd = "\377\373" . pack("C", $opt); # will command + $disable_cmd = "\377\374" . pack("C", $opt); # wont command + $is_remote = ''; + $ack = "WILL"; + $nak = "WONT"; + + &_log_option($s->{opt_log}, "RCVD", "DONT", $opt) + if $s->{opt_log}; + } + else { # internal error + die; + } + + ## Respond to WONT or DONT based on the current negotiation state. + if ($$state eq "no") { # state is already disabled + } + elsif ($$state eq "yes") { # they're initiating disable + $$is_enabled = ''; + $$state = "no"; + + ## Send positive acknowledgment. + $s->{unsent_opts} .= $disable_cmd; + &_log_option($s->{opt_log}, "SENT", $nak, $opt) + if $s->{opt_log}; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantno") { # they sent positive ack + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantno opposite") { # pos ack but we changed our mind + ## Indicate disabled but now we want to enable. + $$is_enabled = ''; + $$state = "wantyes"; + + ## Send queued request. + $s->{unsent_opts} .= $enable_cmd; + &_log_option($s->{opt_log}, "SENT", $ack, $opt) + if $s->{opt_log}; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes") { # they sent negative ack + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes opposite") { # nak but we changed our mind + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } +} # end sub _negotiate_recv_disable + + +sub _negotiate_recv_enable { + my ($self, $s, $opt, $opt_request, + $opt_bufpos, $enable_ok, $is_enabled, $state) = @_; + my ( + $ack, + $disable_cmd, + $enable_cmd, + $is_remote, + $nak, + $was_enabled, + ); + + ## What we use to send enable/disable request or send ack/nak response. + if ($opt_request eq "will") { + $enable_cmd = "\377\375" . pack("C", $opt); # do command + $disable_cmd = "\377\376" . pack("C", $opt); # dont command + $is_remote = 1; + $ack = "DO"; + $nak = "DONT"; + + &_log_option($s->{opt_log}, "RCVD", "WILL", $opt) + if $s->{opt_log}; + } + elsif ($opt_request eq "do") { + $enable_cmd = "\377\373" . pack("C", $opt); # will command + $disable_cmd = "\377\374" . pack("C", $opt); # wont command + $is_remote = ''; + $ack = "WILL"; + $nak = "WONT"; + + &_log_option($s->{opt_log}, "RCVD", "DO", $opt) + if $s->{opt_log}; + } + else { # internal error + die; + } + + ## Save current enabled state. + $was_enabled = $$is_enabled; + + ## Respond to WILL or DO based on the current negotiation state. + if ($$state eq "no") { # they're initiating enable + if ($enable_ok) { # we agree they/us should enable + $$is_enabled = 1; + $$state = "yes"; + + ## Send positive acknowledgment. + $s->{unsent_opts} .= $enable_cmd; + &_log_option($s->{opt_log}, "SENT", $ack, $opt) + if $s->{opt_log}; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + else { # we disagree they/us should enable + ## Send negative acknowledgment. + $s->{unsent_opts} .= $disable_cmd; + &_log_option($s->{opt_log}, "SENT", $nak, $opt) + if $s->{opt_log}; + } + } + elsif ($$state eq "yes") { # state is already enabled + } + elsif ($$state eq "wantno") { # error: our disable req answered by enable + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantno opposite") { # err: disable req answerd by enable + $$is_enabled = 1; + $$state = "yes"; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes") { # they sent pos ack + $$is_enabled = 1; + $$state = "yes"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes opposite") { # pos ack but we changed our mind + ## Indicate enabled but now we want to disable. + $$is_enabled = 1; + $$state = "wantno"; + + ## Inform other side we changed our mind. + $s->{unsent_opts} .= $disable_cmd; + &_log_option($s->{opt_log}, "SENT", $nak, $opt) + if $s->{opt_log}; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + + 1; +} # end sub _negotiate_recv_enable + + +sub _new_handle { + if ($INC{"IO/Handle.pm"}) { + return IO::Handle->new; + } + else { + require FileHandle; + return FileHandle->new; + } +} # end sub _new_handle + + +sub _next_getlines { + my ($self, $s) = @_; + my ( + $len, + $line, + $pos, + @lines, + ); + + ## Fill buffer and get first line. + $line = $self->getline + or return; + push @lines, $line; + + ## Extract subsequent lines from buffer. + while (($pos = index($s->{buf}, $s->{rs})) != -1) { + $len = $pos + length $s->{rs}; + push @lines, substr($s->{buf}, 0, $len); + substr($s->{buf}, 0, $len) = ""; + } + + @lines; +} # end sub _next_getlines + + +sub _opt_accept { + my ($self, @args) = @_; + my ( + $arg, + $option, + $s, + ); + + ## Init. + $s = *$self->{net_telnet}; + + foreach $arg (@args) { + ## Ensure data structure defined for this option. + $option = $arg->{option}; + if (!defined $s->{opts}{$option}) { + &_set_default_option($s, $option); + } + + ## Save whether we'll accept or reject this option. + if ($arg->{is_remote}) { + $s->{opts}{$option}{remote_enable_ok} = $arg->{is_enable}; + } + else { + $s->{opts}{$option}{local_enable_ok} = $arg->{is_enable}; + } + } + + 1; +} # end sub _opt_accept + + +sub _optimal_blksize { + my ($blksize) = @_; + local $^W = ''; # avoid non-numeric warning for ms-windows blksize of "" + + ## Use default when block size is invalid. + return 8192 + unless defined $blksize and $blksize >= 1 and $blksize <= 1_048_576; + + $blksize; +} # end sub _optimal_blksize + + +sub _parse_cmd_remove_mode { + my ($self, $mode) = @_; + + if (!defined $mode) { + $mode = 0; + } + elsif ($mode =~ /^\s*auto\s*$/i) { + $mode = "auto"; + } + elsif ($mode !~ /^\d+$/) { + &_carp($self, "ignoring bad Cmd_remove_mode " . + "argument \"$mode\": it's not \"auto\" or a " . + "non-negative integer"); + $mode = *$self->{net_telnet}{cmd_rm_mode}; + } + + $mode; +} # end sub _parse_cmd_remove_mode + + +sub _parse_errmode { + my ($self, $errmode) = @_; + + ## Set the error mode. + if (!defined $errmode) { + &_carp($self, "ignoring undefined Errmode argument"); + $errmode = *$self->{net_telnet}{errormode}; + } + elsif ($errmode =~ /^\s*return\s*$/i) { + $errmode = "return"; + } + elsif ($errmode =~ /^\s*die\s*$/i) { + $errmode = "die"; + } + elsif (ref($errmode) eq "CODE") { + } + elsif (ref($errmode) eq "ARRAY") { + unless (ref($errmode->[0]) eq "CODE") { + &_carp($self, "ignoring bad Errmode argument: " . + "first list item isn't a code ref"); + $errmode = *$self->{net_telnet}{errormode}; + } + } + else { + &_carp($self, "ignoring bad Errmode argument \"$errmode\""); + $errmode = *$self->{net_telnet}{errormode}; + } + + $errmode; +} # end sub _parse_errmode + + +sub _parse_input_record_separator { + my ($self, $rs) = @_; + + unless (defined $rs and length $rs) { + &_carp($self, "ignoring null Input_record_separator argument"); + $rs = *$self->{net_telnet}{rs}; + } + + $rs; +} # end sub _parse_input_record_separator + + +sub _parse_prompt { + my ($self, $prompt) = @_; + + unless (defined $prompt) { + $prompt = ""; + } + + unless ($prompt =~ m(^\s*/) or $prompt =~ m(^\s*m\s*\W)) { + &_carp($self, "ignoring bad Prompt argument \"$prompt\": " . + "missing opening delimiter of match operator"); + $prompt = *$self->{net_telnet}{cmd_prompt}; + } + + $prompt; +} # end sub _parse_prompt + + +sub _parse_timeout { + my ($self, $timeout) = @_; + + ## Ensure valid timeout. + if (defined $timeout) { + ## Test for non-numeric or negative values. + eval { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{"__WARN__"} = sub { die "non-numeric\n" }; + local $^W = 1; + $timeout *= 1; + }; + if ($@) { # timeout arg is non-numeric + &_carp($self, + "ignoring non-numeric Timeout argument \"$timeout\""); + $timeout = *$self->{net_telnet}{time_out}; + } + elsif ($timeout < 0) { # timeout arg is negative + &_carp($self, "ignoring negative Timeout argument \"$timeout\""); + $timeout = *$self->{net_telnet}{time_out}; + } + } + + $timeout; +} # end sub _parse_timeout + + +sub _put { + my ($self, $buf, $subname) = @_; + my ( + $endtime, + $len, + $nfound, + $nwrote, + $offset, + $ready, + $s, + $timed_out, + $timeout, + $zero_wrote_count, + ); + + ## Init. + $s = *$self->{net_telnet}; + $s->{num_wrote} = 0; + $zero_wrote_count = 0; + $offset = 0; + $len = length $$buf; + $endtime = &_endtime($s->{time_out}); + + return $self->error("write error: filehandle isn't open") + unless $s->{opened}; + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + ## Write until all data blocks written. + while ($len) { + ## Determine how long to wait for output ready. + ($timed_out, $timeout) = &_timeout_interval($endtime); + if ($timed_out) { + $s->{timedout} = 1; + return $self->error("$subname timed-out"); + } + + ## Wait for output ready. + $nfound = select "", $ready=$s->{fdmask}, "", $timeout; + + ## Handle any errors while waiting. + if (!defined $nfound or $nfound <= 0) { # output not ready + if (defined $nfound and $nfound == 0) { # timed-out + $s->{timedout} = 1; + return $self->error("$subname timed-out"); + } + else { # error waiting for output ready + next if $! =~ /^interrupted/i; + + $s->{opened} = ''; + return $self->error("write error: $!"); + } + } + + ## Write the data. + $nwrote = syswrite $self, $$buf, $len, $offset; + + ## Handle any write errors. + if (!defined $nwrote) { # write failed + next if $! =~ /^interrupted/i; # restart interrupted syscall + + $s->{opened} = ''; + return $self->error("write error: $!"); + } + elsif ($nwrote == 0) { # zero chars written + ## Try ten more times to write the data. + if ($zero_wrote_count++ <= 10) { + &_sleep(0.01); + next; + } + + $s->{opened} = ''; + return $self->error("write error: zero length write: $!"); + } + + ## Display network traffic if requested. + if ($s->{dumplog}) { + &_log_dump('>', $s->{dumplog}, $buf, $offset, $nwrote); + } + + ## Increment. + $s->{num_wrote} += $nwrote; + $offset += $nwrote; + $len -= $nwrote; + } + + 1; +} # end sub _put + + +sub _qualify_fh { + my ($obj, $name) = @_; + my ( + $user_class, + ); + local $_; + + ## Get user's package name. + ($user_class) = &_user_caller($obj); + + ## Ensure name is qualified with a package name. + $name = qualify($name, $user_class); + + ## If it's not already, make it a typeglob ref. + if (!ref $name) { + no strict; + local $^W = 0; + + $name =~ s/^\*+//; + $name = eval "\\*$name"; + return unless ref $name; + } + + $name; +} # end sub _qualify_fh + + +sub _reset_options { + my ($opts) = @_; + my ( + $opt, + ); + + foreach $opt (keys %$opts) { + $opts->{$opt}{remote_enabled} = ''; + $opts->{$opt}{remote_state} = "no"; + $opts->{$opt}{local_enabled} = ''; + $opts->{$opt}{local_state} = "no"; + } + + 1; +} # end sub _reset_options + + +sub _save_lastline { + my ($s) = @_; + my ( + $firstpos, + $lastpos, + $len_w_sep, + $len_wo_sep, + $offset, + ); + my $rs = "\n"; + + if (($lastpos = rindex $s->{buf}, $rs) > -1) { # eol found + while (1) { + ## Find beginning of line. + $firstpos = rindex $s->{buf}, $rs, $lastpos - 1; + if ($firstpos == -1) { + $offset = 0; + } + else { + $offset = $firstpos + length $rs; + } + + ## Determine length of line with and without separator. + $len_wo_sep = $lastpos - $offset; + $len_w_sep = $len_wo_sep + length $rs; + + ## Save line if it's not blank. + if (substr($s->{buf}, $offset, $len_wo_sep) + !~ /^\s*$/) + { + $s->{last_line} = substr($s->{buf}, + $offset, + $len_w_sep); + last; + } + + last if $firstpos == -1; + + $lastpos = $firstpos; + } + } + + 1; +} # end sub _save_lastline + + +sub _set_default_option { + my ($s, $option) = @_; + + $s->{opts}{$option} = { + remote_enabled => '', + remote_state => "no", + remote_enable_ok => '', + local_enabled => '', + local_state => "no", + local_enable_ok => '', + }; +} # end sub _set_default_option + + +sub _sleep { + my ($secs) = @_; + my $bitmask = ""; + local *SOCK; + + socket SOCK, AF_INET, SOCK_STREAM, 0; + vec($bitmask, fileno(SOCK), 1) = 1; + select $bitmask, "", "", $secs; + CORE::close SOCK; + + 1; +} # end sub _sleep + + +sub _timeout_interval { + my ($endtime) = @_; + my ( + $timeout, + ); + + ## Return timed-out boolean and timeout interval. + if (defined $endtime) { + ## Is it a one-time poll. + return ('', 0) if $endtime == 0; + + ## Calculate the timeout interval. + $timeout = $endtime - time; + + ## Did we already timeout. + return (1, 0) unless $timeout > 0; + + return ('', $timeout); + } + else { # there is no timeout + return ('', undef); + } +} # end sub _timeout_interval + + +sub _user_caller { + my ($obj) = @_; + my ( + $class, + $curr_pkg, + $file, + $i, + $line, + $pkg, + %isa, + @isa, + ); + local $_; + + ## Create a boolean hash to test for isa. Make sure current + ## package and the object's class are members. + $class = ref $obj; + @isa = eval "\@${class}::ISA"; + push @isa, $class; + ($curr_pkg) = caller 1; + push @isa, $curr_pkg; + %isa = map { $_ => 1 } @isa; + + ## Search back in call frames for a package that's not in isa. + $i = 1; + while (($pkg, $file, $line) = caller ++$i) { + next if $isa{$pkg}; + + return ($pkg, $file, $line); + } + + ## If not found, choose outer most call frame. + ($pkg, $file, $line) = caller --$i; + return ($pkg, $file, $line); +} # end sub _user_caller + + +sub _verify_telopt_arg { + my ($self, $option, $argname) = @_; + + ## If provided, use argument name in error message. + if (defined $argname) { + $argname = "for arg $argname"; + } + else { + $argname = ""; + } + + ## Ensure telnet option is a non-negative integer. + eval { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{"__WARN__"} = sub { die "non-numeric\n" }; + local $^W = 1; + $option = abs(int $option); + }; + return $self->error("bad telnet option $argname: non-numeric") + if $@; + + return $self->error("bad telnet option $argname: option > 255") + unless $option <= 255; + + $option; +} # end sub _verify_telopt_arg + + +######################## Exported Constants ########################## + + +sub TELNET_IAC () {255}; # interpret as command: +sub TELNET_DONT () {254}; # you are not to use option +sub TELNET_DO () {253}; # please, you use option +sub TELNET_WONT () {252}; # I won't use option +sub TELNET_WILL () {251}; # I will use option +sub TELNET_SB () {250}; # interpret as subnegotiation +sub TELNET_GA () {249}; # you may reverse the line +sub TELNET_EL () {248}; # erase the current line +sub TELNET_EC () {247}; # erase the current character +sub TELNET_AYT () {246}; # are you there +sub TELNET_AO () {245}; # abort output--but let prog finish +sub TELNET_IP () {244}; # interrupt process--permanently +sub TELNET_BREAK () {243}; # break +sub TELNET_DM () {242}; # data mark--for connect. cleaning +sub TELNET_NOP () {241}; # nop +sub TELNET_SE () {240}; # end sub negotiation +sub TELNET_EOR () {239}; # end of record (transparent mode) +sub TELNET_ABORT () {238}; # Abort process +sub TELNET_SUSP () {237}; # Suspend process +sub TELNET_EOF () {236}; # End of file +sub TELNET_SYNCH () {242}; # for telfunc calls + +sub TELOPT_BINARY () {0}; # Binary Transmission +sub TELOPT_ECHO () {1}; # Echo +sub TELOPT_RCP () {2}; # Reconnection +sub TELOPT_SGA () {3}; # Suppress Go Ahead +sub TELOPT_NAMS () {4}; # Approx Message Size Negotiation +sub TELOPT_STATUS () {5}; # Status +sub TELOPT_TM () {6}; # Timing Mark +sub TELOPT_RCTE () {7}; # Remote Controlled Trans and Echo +sub TELOPT_NAOL () {8}; # Output Line Width +sub TELOPT_NAOP () {9}; # Output Page Size +sub TELOPT_NAOCRD () {10}; # Output Carriage-Return Disposition +sub TELOPT_NAOHTS () {11}; # Output Horizontal Tab Stops +sub TELOPT_NAOHTD () {12}; # Output Horizontal Tab Disposition +sub TELOPT_NAOFFD () {13}; # Output Formfeed Disposition +sub TELOPT_NAOVTS () {14}; # Output Vertical Tabstops +sub TELOPT_NAOVTD () {15}; # Output Vertical Tab Disposition +sub TELOPT_NAOLFD () {16}; # Output Linefeed Disposition +sub TELOPT_XASCII () {17}; # Extended ASCII +sub TELOPT_LOGOUT () {18}; # Logout +sub TELOPT_BM () {19}; # Byte Macro +sub TELOPT_DET () {20}; # Data Entry Terminal +sub TELOPT_SUPDUP () {21}; # SUPDUP +sub TELOPT_SUPDUPOUTPUT () {22}; # SUPDUP Output +sub TELOPT_SNDLOC () {23}; # Send Location +sub TELOPT_TTYPE () {24}; # Terminal Type +sub TELOPT_EOR () {25}; # End of Record +sub TELOPT_TUID () {26}; # TACACS User Identification +sub TELOPT_OUTMRK () {27}; # Output Marking +sub TELOPT_TTYLOC () {28}; # Terminal Location Number +sub TELOPT_3270REGIME () {29}; # Telnet 3270 Regime +sub TELOPT_X3PAD () {30}; # X.3 PAD +sub TELOPT_NAWS () {31}; # Negotiate About Window Size +sub TELOPT_TSPEED () {32}; # Terminal Speed +sub TELOPT_LFLOW () {33}; # Remote Flow Control +sub TELOPT_LINEMODE () {34}; # Linemode +sub TELOPT_XDISPLOC () {35}; # X Display Location +sub TELOPT_OLD_ENVIRON () {36}; # Environment Option +sub TELOPT_AUTHENTICATION () {37}; # Authentication Option +sub TELOPT_ENCRYPT () {38}; # Encryption Option +sub TELOPT_NEW_ENVIRON () {39}; # New Environment Option +sub TELOPT_EXOPL () {255}; # Extended-Options-List + + +1; +__END__; + + +######################## User Documentation ########################## + + +## To format the following documentation into a more readable format, +## use one of these programs: perldoc; pod2man; pod2html; pod2text. +## For example, to nicely format this documentation for printing, you +## may use pod2man and groff to convert to postscript: +## pod2man Net/Telnet.pm | groff -man -Tps > Net::Telnet.ps + +=head1 NAME + +Net::Telnet - interact with TELNET port or other TCP ports + +=head1 SYNOPSIS + +C + +see METHODS section below + +=head1 DESCRIPTION + +Net::Telnet allows you to make client connections to a TCP port and do +network I/O, especially to a port using the TELNET protocol. Simple +I/O methods such as print, get, and getline are provided. More +sophisticated interactive features are provided because connecting to +a TELNET port ultimately means communicating with a program designed +for human interaction. These interactive features include the ability +to specify a time-out and to wait for patterns to appear in the input +stream, such as the prompt from a shell. + +Other reasons to use this module than strictly with a TELNET port are: + +=over 2 + +=item * + +You're not familiar with sockets and you want a simple way to make +client connections to TCP services. + +=item * + +You want to be able to specify your own time-out while connecting, +reading, or writing. + +=item * + +You're communicating with an interactive program at the other end of +some socket or pipe and you want to wait for certain patterns to +appear. + +=back + +Here's an example that prints who's logged-on to the remote host +sparky. In addition to a username and password, you must also know +the user's shell prompt, which for this example is C + + use Net::Telnet (); + $t = new Net::Telnet (Timeout => 10, + Prompt => '/bash\$ $/'); + $t->open("sparky"); + $t->login($username, $passwd); + @lines = $t->cmd("who"); + print @lines; + +More examples are in the B section below. + +Usage questions should be directed to the Usenet newsgroup +comp.lang.perl.modules. + +Contact me, Jay Rogers , if you find any bugs or have +suggestions for improvement. + +=head2 What To Know Before Using + +=over 2 + +=item * + +All output is flushed while all input is buffered. Each object +contains its own input buffer. + +=item * + +The output record separator for C and C is set to +C<"\n"> by default, so that you don't have to append all your commands +with a newline. To avoid printing a trailing C<"\n"> use C or +set the I to C<"">. + +=item * + +The methods C and C use the I setting in the +object to determine when a login or remote command is complete. Those +methods will fail with a time-out if you don't set the prompt +correctly. + +=item * + +Use a combination of C and C as an alternative to +C or C when they don't do what you want. + +=item * + +Errors such as timing-out are handled according to the error mode +action. The default action is to print an error message to standard +error and have the program die. See the C method for more +information. + +=item * + +When constructing the match operator argument for C or +C, always use single quotes instead of double quotes to +avoid unexpected backslash interpretation (e.g. C<'/bash\$ $/'>). If +you're constructing a DOS like file path, you'll need to use four +backslashes to represent one (e.g. C<'/c:\\\\users\\\\billE$/i'>). + +Of course don't forget about regexp metacharacters like C<.>, C<[>, or +C<$>. You'll only need a single backslash to quote them. The anchor +metacharacters C<^> and C<$> refer to positions in the input buffer. +To avoid matching characters read that look like a prompt, it's a good +idea to end your prompt pattern with the C<$> anchor. That way the +prompt will only match if it's the last thing read. + +=item * + +In the input stream, each sequence of I and I (i.e. C<"\015\012"> or CR LF) is converted to C<"\n">. In the +output stream, each occurrence of C<"\n"> is converted to a sequence +of CR LF. See C to change the behavior. TCP protocols +typically use the ASCII sequence, carriage return and line feed to +designate a newline. + +=item * + +Timing-out while making a connection is disabled for machines that +don't support the C function. Most notably these include +MS-Windows machines. + +=item * + +You'll need to be running at least Perl version 5.002 to use this +module. This module does not require any libraries that don't already +come with a standard Perl distribution. + +If you have the IO:: libraries installed (they come standard with +perl5.004 and later) then IO::Socket::INET is used as a base class, +otherwise FileHandle is used. + +=item * + +Contact me, Jay Rogers , if you find any bugs or have +suggestions for improvement. + +=back + +=head2 Debugging + +The typical usage bug causes a time-out error because you've made +incorrect assumptions about what the remote side actually sends. The +easiest way to reconcile what the remote side sends with your +expectations is to use C or C. + +C allows you to see the data being sent from the remote +side before any translation is done, while C shows you +the results after translation. The translation includes converting +end of line characters, removing and responding to TELNET protocol +commands in the data stream. + +=head2 Style of Named Parameters + +Two different styles of named parameters are supported. This document +only shows the IO:: style: + + Net::Telnet->new(Timeout => 20); + +however the dash-option style is also allowed: + + Net::Telnet->new(-timeout => 20); + +=head2 Connecting to a Remote MS-Windows Machine + +By default MS-Windows doesn't come with a TELNET server. However +third party TELNET servers are available. Unfortunately many of these +servers falsely claim to be a TELNET server. This is especially true +of the so-called "Microsoft Telnet Server" that comes installed with +some newer versions MS-Windows. + +When a TELNET server first accepts a connection, it must use the ASCII +control characters carriage-return and line-feed to start a new line +(see RFC854). A server like the "Microsoft Telnet Server" that +doesn't do this, isn't a TELNET server. These servers send ANSI +terminal escape sequences to position to a column on a subsequent line +and to even position while writing characters that are adjacent to +each other. Worse, when sending output these servers resend +previously sent command output in a misguided attempt to display an +entire terminal screen. + +Connecting Net::Telnet to one of these false TELNET servers makes your +job of parsing command output very difficult. It's better to replace +a false TELNET server with a real TELNET server. The better TELNET +servers for MS-Windows allow you to avoid the ANSI escapes by turning +off something some of them call I. + + +=head1 METHODS + +In the calling sequences below, square brackets B<[]> represent +optional parameters. + +=over 4 + +=item B - create a new Net::Telnet object + + $obj = new Net::Telnet ([$host]); + + $obj = new Net::Telnet ([Binmode => $mode,] + [Cmd_remove_mode => $mode,] + [Dump_Log => $filename,] + [Errmode => $errmode,] + [Fhopen => $filehandle,] + [Host => $host,] + [Input_log => $file,] + [Input_record_separator => $chars,] + [Option_log => $file,] + [Ors => $chars,] + [Output_log => $file,] + [Output_record_separator => $chars,] + [Port => $port,] + [Prompt => $matchop,] + [Rs => $chars,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This is the constructor for Net::Telnet objects. A new object is +returned on success, the error mode action is performed on failure - +see C. The optional arguments are short-cuts to methods of +the same name. + +If the I<$host> argument is given then the object is opened by +connecting to TCP I<$port> on I<$host>. Also see C. The new +object returned is given the following defaults in the absence of +corresponding named parameters: + +=over 4 + +=item + +The default I is C<"localhost"> + +=item + +The default I is C<23> + +=item + +The default I is C<'/[\$%#E] $/'> + +=item + +The default I is C<10> + +=item + +The default I is C<"die"> + +=item + +The default I is C<"\n">. Note that I +is synonymous with I. + +=item + +The default I is C<"\n">. Note that I is +synonymous with I. + +=item + +The default I is C<0>, which means do newline translation. + +=item + +The default I is C<1>, which means respond to TELNET +commands in the data stream. + +=item + +The default I is C<"auto"> + +=item + +The defaults for I, I, I, and +I are C<"">, which means that logging is turned-off. + +=back + +=back + + +=over 4 + +=item B - toggle newline translation + + $mode = $obj->binmode; + + $prev = $obj->binmode($mode); + +This method controls whether or not sequences of carriage returns and +line feeds (CR LF or more specifically C<"\015\012">) are translated. +By default they are translated (i.e. binmode is C<0>). + +If no argument is given, the current mode is returned. + +If I<$mode> is C<1> then binmode is I and newline translation is +not done. + +If I<$mode> is C<0> then binmode is I and newline translation is +done. In the input stream, each sequence of CR LF is converted to +C<"\n"> and in the output stream, each occurrence of C<"\n"> is +converted to a sequence of CR LF. + +Note that input is always buffered. Changing binmode doesn't effect +what's already been read into the buffer. Output is not buffered and +changing binmode will have an immediate effect. + +=back + + +=over 4 + +=item B - send TELNET break character + + $ok = $obj->break; + +This method sends the TELNET break character. This character is +provided because it's a signal outside the ASCII character set which +is currently given local meaning within many systems. It's intended +to indicate that the Break Key or the Attention Key was hit. + +This method returns C<1> on success, or performs the error mode action +on failure. + +=back + + +=over 4 + +=item B - scalar reference to object's input buffer + + $ref = $obj->buffer; + +This method returns a scalar reference to the input buffer for +I<$obj>. Data in the input buffer is data that has been read from the +remote side but has yet to be read by the user. Modifications to the +input buffer are returned by a subsequent read. + +=back + + +=over 4 + +=item B - discard all data in object's input buffer + + $obj->buffer_empty; + +This method removes all data in the input buffer for I<$obj>. + +=back + + +=over 4 + +=item B - close object + + $ok = $obj->close; + +This method closes the socket, file, or pipe associated with the +object. It always returns a value of C<1>. + +=back + + +=over 4 + +=item B - issue command and retrieve output + + $ok = $obj->cmd($string); + $ok = $obj->cmd(String => $string, + [Output => $ref,] + [Cmd_remove_mode => $mode,] + [Errmode => $mode,] + [Input_record_separator => $chars,] + [Ors => $chars,] + [Output_record_separator => $chars,] + [Prompt => $match,] + [Rs => $chars,] + [Timeout => $secs,]); + + @output = $obj->cmd($string); + @output = $obj->cmd(String => $string, + [Output => $ref,] + [Cmd_remove_mode => $mode,] + [Errmode => $mode,] + [Input_record_separator => $chars,] + [Ors => $chars,] + [Output_record_separator => $chars,] + [Prompt => $match,] + [Rs => $chars,] + [Timeout => $secs,]); + +This method sends the command I<$string>, and reads the characters +sent back by the command up until and including the matching prompt. +It's assumed that the program to which you're sending is some kind of +command prompting interpreter such as a shell. + +The command I<$string> is automatically appended with the +output_record_separator, By default that's C<"\n">. This is similar +to someone typing a command and hitting the return key. Set the +output_record_separator to change this behavior. + +In a scalar context, the characters read from the remote side are +discarded and C<1> is returned on success. On time-out, eof, or other +failures, the error mode action is performed. See C. + +In a list context, just the output generated by the command is +returned, one line per element. In other words, all the characters in +between the echoed back command string and the prompt are returned. +If the command happens to return no output, a list containing one +element, the empty string is returned. This is so the list will +indicate true in a boolean context. On time-out, eof, or other +failures, the error mode action is performed. See C. + +The characters that matched the prompt may be retrieved using +C. + +Many command interpreters echo back the command sent. In most +situations, this method removes the first line returned from the +remote side (i.e. the echoed back command). See C +for more control over this feature. + +Use C to debug when this method keeps timing-out and you +don't think it should. + +Consider using a combination of C and C as an +alternative to this method when it doesn't do what you want, e.g. the +command you send prompts for input. + +The I named parameter provides an alternative method of +receiving command output. If you pass a scalar reference, all the +output (even if it contains multiple lines) is returned in the +referenced scalar. If you pass an array or hash reference, the lines +of output are returned in the referenced array or hash. You can use +C to change the notion of what separates a +line. + +Optional named parameters are provided to override the current +settings of cmd_remove_mode, errmode, input_record_separator, ors, +output_record_separator, prompt, rs, and timeout. Rs is synonymous +with input_record_separator and ors is synonymous with +output_record_separator. + +=back + + +=over 4 + +=item B - toggle removal of echoed commands + + $mode = $obj->cmd_remove_mode; + + $prev = $obj->cmd_remove_mode($mode); + +This method controls how to deal with echoed back commands in the +output returned by cmd(). Typically, when you send a command to the +remote side, the first line of output returned is the command echoed +back. Use this mode to remove the first line of output normally +returned by cmd(). + +If no argument is given, the current mode is returned. + +If I<$mode> is C<0> then the command output returned from cmd() has no +lines removed. If I<$mode> is a positive integer, then the first +I<$mode> lines of command output are stripped. + +By default, I<$mode> is set to C<"auto">. Auto means that whether or +not the first line of command output is stripped, depends on whether +or not the remote side offered to echo. By default, Net::Telnet +always accepts an offer to echo by the remote side. You can change +the default to reject such an offer using C. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not C<"auto"> or a non-negative integer. + +=back + + +=over 4 + +=item B - log all I/O in dump format + + $fh = $obj->dump_log; + + $fh = $obj->dump_log($fh); + + $fh = $obj->dump_log($filename); + +This method starts or stops dump format logging of all the object's +input and output. The dump format shows the blocks read and written +in a hexadecimal and printable character format. This method is +useful when debugging, however you might want to first try +C as it's more readable. + +If no argument is given, the current log filehandle is returned. An +empty string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened and a filehandle to it is returned. If the file can't be +opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - end of file indicator + + $eof = $obj->eof; + +This method returns C<1> if end of file has been read, otherwise it +returns an empty string. Because the input is buffered this isn't the +same thing as I<$obj> has closed. In other words I<$obj> can be +closed but there still can be stuff in the buffer to be read. Under +this condition you can still read but you won't be able to write. + +=back + + +=over 4 + +=item B - define action to be performed on error + + $mode = $obj->errmode; + + $prev = $obj->errmode($mode); + +This method gets or sets the action used when errors are encountered +using the object. The first calling sequence returns the current +error mode. The second calling sequence sets it to I<$mode> and +returns the previous mode. Valid values for I<$mode> are C<"die"> +(the default), C<"return">, a I, or an I. + +When mode is C<"die"> and an error is encountered using the object, +then an error message is printed to standard error and the program +dies. + +When mode is C<"return"> then the method generating the error places +an error message in the object and returns an undefined value in a +scalar context and an empty list in list context. The error message +may be obtained using C. + +When mode is a I, then when an error is encountered +I is called with the error message as its first argument. +Using this mode you may have your own subroutine handle errors. If +I itself returns then the method generating the error returns +undefined or an empty list depending on context. + +When mode is an I, the first element of the array must be a +I. Any elements that follow are the arguments to I. +When an error is encountered, the I is called with its +arguments. Using this mode you may have your own subroutine handle +errors. If the I itself returns then the method generating +the error returns undefined or an empty list depending on context. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not C<"die">, C<"return">, a I, or an +I whose first element isn't a I. + +=back + + +=over 4 + +=item B - most recent error message + + $msg = $obj->errmsg; + + $prev = $obj->errmsg(@msgs); + +The first calling sequence returns the error message associated with +the object. The empty string is returned if no error has been +encountered yet. The second calling sequence sets the error message +for the object to the concatenation of I<@msgs> and returns the +previous error message. Normally, error messages are set internally +by a method when an error is encountered. + +=back + + +=over 4 + +=item B - perform the error mode action + + $obj->error(@msgs); + +This method concatenates I<@msgs> into a string and places it in the +object as the error message. Also see C. It then performs +the error mode action. Also see C. + +If the error mode doesn't cause the program to die, then an undefined +value or an empty list is returned depending on the context. + +This method is primarily used by this class or a sub-class to perform +the user requested action when an error is encountered. + +=back + + +=over 4 + +=item B - use already open filehandle for I/O + + $ok = $obj->fhopen($fh); + +This method associates the open filehandle I<$fh> with I<$obj> for +further I/O. Filehandle I<$fh> must already be opened. + +Suppose you want to use the features of this module to do I/O to +something other than a TCP port, for example STDIN or a filehandle +opened to read from a process. Instead of opening the object for I/O +to a TCP port by using C or C, call this method +instead. + +The value C<1> is returned success, the error mode action is performed +on failure. + +=back + + +=over 4 + +=item B - read block of data + + $data = $obj->get([Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method reads a block of data from the object and returns it along +with any buffered data. If no buffered data is available to return, +it will wait for data to read using the timeout specified in the +object. You can override that timeout using I<$secs>. Also see +C. If buffered data is available to return, it also checks +for a block of data that can be immediately read. + +On eof an undefined value is returned. On time-out or other failures, +the error mode action is performed. To distinguish between eof or an +error occurring when the error mode is not set to C<"die">, use +C. + +Optional named parameters are provided to override the current +settings of binmode, errmode, telnetmode, and timeout. + +=back + + +=over 4 + +=item B - read next line + + $line = $obj->getline([Binmode => $mode,] + [Errmode => $errmode,] + [Input_record_separator => $chars,] + [Rs => $chars,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method reads and returns the next line of data from the object. +You can use C to change the notion of what +separates a line. The default is C<"\n">. If a line isn't +immediately available, this method blocks waiting for a line or a +time-out. + +On eof an undefined value is returned. On time-out or other failures, +the error mode action is performed. To distinguish between eof or an +error occurring when the error mode is not set to C<"die">, use +C. + +Optional named parameters are provided to override the current +settings of binmode, errmode, input_record_separator, rs, telnetmode, +and timeout. Rs is synonymous with input_record_separator. + +=back + + +=over 4 + +=item B - read next lines + + @lines = $obj->getlines([Binmode => $mode,] + [Errmode => $errmode,] + [Input_record_separator => $chars,] + [Rs => $chars,] + [Telnetmode => $mode,] + [Timeout => $secs,] + [All => $boolean,]); + +This method reads and returns all the lines of data from the object +until end of file is read. You can use C to +change the notion of what separates a line. The default is C<"\n">. +A time-out error occurs if all the lines can't be read within the +time-out interval. See C. + +The behavior of this method was changed in version 3.03. Prior to +version 3.03 this method returned just the lines available from the +next read. To get that old behavior, use the optional named parameter +I and set I<$boolean> to C<""> or C<0>. + +If only eof is read then an empty list is returned. On time-out or +other failures, the error mode action is performed. Use C to +distinguish between reading only eof or an error occurring when the +error mode is not set to C<"die">. + +Optional named parameters are provided to override the current +settings of binmode, errmode, input_record_separator, rs, telnetmode, +and timeout. Rs is synonymous with input_record_separator. + +=back + + +=over 4 + +=item B - name of remote host + + $host = $obj->host; + + $prev = $obj->host($host); + +This method designates the remote host for C. With no +argument it returns the current host name set in the object. With an +argument it sets the current host name to I<$host> and returns the +previous host name. You may indicate the remote host using either a +hostname or an IP address. + +The default value is C<"localhost">. It may also be set by C +or C. + +=back + + +=over 4 + +=item B - log all input + + $fh = $obj->input_log; + + $fh = $obj->input_log($fh); + + $fh = $obj->input_log($filename); + +This method starts or stops logging of input. This is useful when +debugging. Also see C. Because most command interpreters +echo back commands received, it's likely all your output will also be +in this log. Note that input logging occurs after newline +translation. See C for details on newline translation. + +If no argument is given, the log filehandle is returned. An empty +string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened for logging and a filehandle to it is returned. If the file +can't be opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - input line delimiter + + $chars = $obj->input_record_separator; + + $prev = $obj->input_record_separator($chars); + +This method designates the line delimiter for input. It's used with +C, C, and C to determine lines in the +input. + +With no argument this method returns the current input record +separator set in the object. With an argument it sets the input +record separator to I<$chars> and returns the previous value. Note +that I<$chars> must have length. + +A warning is printed to STDERR when attempting to set this attribute +to a string with no length. + +=back + + +=over 4 + +=item B - last prompt read + + $string = $obj->last_prompt; + + $prev = $obj->last_prompt($string); + +With no argument this method returns the last prompt read by cmd() or +login(). See C. With an argument it sets the last prompt +read to I<$string> and returns the previous value. Normally, only +internal methods set the last prompt. + +=back + + +=over 4 + +=item B - last line read + + $line = $obj->lastline; + + $prev = $obj->lastline($line); + +This method retrieves the last line read from the object. This may be +a useful error message when the remote side abnormally closes the +connection. Typically the remote side will print an error message +before closing. + +With no argument this method returns the last line read from the +object. With an argument it sets the last line read to I<$line> and +returns the previous value. Normally, only internal methods set the +last line. + +=back + + +=over 4 + +=item B - perform standard login + + $ok = $obj->login($username, $password); + + $ok = $obj->login(Name => $username, + Password => $password, + [Errmode => $mode,] + [Prompt => $match,] + [Timeout => $secs,]); + +This method performs a standard login by waiting for a login prompt +and responding with I<$username>, then waiting for the password prompt +and responding with I<$password>, and then waiting for the command +interpreter prompt. If any of those prompts sent by the remote side +don't match what's expected, this method will time-out, unless timeout +is turned off. + +Login prompt must match either of these case insensitive patterns: + + /login[: ]*$/i + /username[: ]*$/i + +Password prompt must match this case insensitive pattern: + + /password[: ]*$/i + +The command interpreter prompt must match the current setting of +prompt. See C. + +Use C to debug when this method keeps timing-out and you +don't think it should. + +Consider using a combination of C and C as an +alternative to this method when it doesn't do what you want, e.g. the +remote host doesn't prompt for a username. + +On success, C<1> is returned. On time out, eof, or other failures, +the error mode action is performed. See C. + +Optional named parameters are provided to override the current +settings of errmode, prompt, and timeout. + +=back + + +=over 4 + +=item B - maximum size of input buffer + + $len = $obj->max_buffer_length; + + $prev = $obj->max_buffer_length($len); + +This method designates the maximum size of the input buffer. An error +is generated when a read causes the buffer to exceed this limit. The +default value is 1,048,576 bytes (1MB). The input buffer can grow +much larger than the block size when you continuously read using +C or C and the data stream contains no newlines +or matching waitfor patterns. + +With no argument, this method returns the current maximum buffer +length set in the object. With an argument it sets the maximum buffer +length to I<$len> and returns the previous value. Values of I<$len> +smaller than 512 will be adjusted to 512. + +A warning is printed to STDERR when attempting to set this attribute +to something that isn't a positive integer. + +=back + + +=over 4 + +=item B - field separator for print + + $chars = $obj->ofs + + $prev = $obj->ofs($chars); + +This method is synonymous with C. + +=back + + +=over 4 + +=item B - connect to port on remote host + + $ok = $obj->open($host); + + $ok = $obj->open([Host => $host,] + [Port => $port,] + [Errmode => $mode,] + [Timeout => $secs,]); + +This method opens a TCP connection to I<$port> on I<$host>. If either +argument is missing then the current value of C or C +is used. Optional named parameters are provided to override the +current setting of errmode and timeout. + +On success C<1> is returned. On time-out or other connection +failures, the error mode action is performed. See C. + +Time-outs don't work for this method on machines that don't implement +SIGALRM - most notably MS-Windows machines. For those machines, an +error is returned when the system reaches its own time-out while +trying to connect. + +A side effect of this method is to reset the alarm interval associated +with SIGALRM. + +=back + + +=over 4 + +=item B - indicate willingness to accept a TELNET option + + $fh = $obj->option_accept([Do => $telopt,] + [Dont => $telopt,] + [Will => $telopt,] + [Wont => $telopt,]); + +This method is used to indicate whether to accept or reject an offer +to enable a TELNET option made by the remote side. If you're using +I or I to indicate a willingness to enable, then a +notification callback must have already been defined by a prior call +to C. See C for details on +receiving enable/disable notification of a TELNET option. + +You can give multiple I, I, I, or I arguments +for different TELNET options in the same call to this method. + +The following example describes the meaning of the named parameters. +A TELNET option, such as C used below, is an integer +constant that you can import from Net::Telnet. See the source in file +Telnet.pm for the complete list. + +=over 4 + +=item + +I => C + +=over 4 + +=item + +we'll accept an offer to enable the echo option on the local side + +=back + +=item + +I => C + +=over 4 + +=item + +we'll reject an offer to enable the echo option on the local side + +=back + +=item + +I => C + +=over 4 + +=item + +we'll accept an offer to enable the echo option on the remote side + +=back + +=item + +I => C + +=over 4 + +=item + +we'll reject an offer to enable the echo option on the remote side + +=back + +=back + +=item + +Use C to send a request to the remote side to enable or +disable a particular TELNET option. + +=back + + +=over 4 + +=item B - define the option negotiation callback + + $coderef = $obj->option_callback; + + $prev = $obj->option_callback($coderef); + +This method defines the callback subroutine that's called when a +TELNET option is enabled or disabled. Once defined, the +I may not be undefined. However, calling this method +with a different I<$coderef> changes it. + +A warning is printed to STDERR when attempting to set this attribute +to something that isn't a coderef. + +Here are the circumstances that invoke I<$coderef>: + +=over 4 + +=item + +An option becomes enabled because the remote side requested an enable +and C had been used to arrange that it be accepted. + +=item + +The remote side arbitrarily decides to disable an option that is +currently enabled. Note that Net::Telnet always accepts a request to +disable from the remote side. + +=item + +C was used to send a request to enable or disable an +option and the response from the remote side has just been received. +Note, that if a request to enable is rejected then I<$coderef> is +still invoked even though the option didn't change. + +=back + +=item + +Here are the arguments passed to I<&$coderef>: + + &$coderef($obj, $option, $is_remote, + $is_enabled, $was_enabled, $buf_position); + +=over 4 + +=item + +1. I<$obj> is the Net::Telnet object + +=item + +2. I<$option> is the TELNET option. Net::Telnet exports constants +for the various TELNET options which just equate to an integer. + +=item + +3. I<$is_remote> is a boolean indicating for which side the option +applies. + +=item + +4. I<$is_enabled> is a boolean indicating the option is enabled or +disabled + +=item + +5. I<$was_enabled> is a boolean indicating the option was previously +enabled or disabled + +=item + +6. I<$buf_position> is an integer indicating the position in the +object's input buffer where the option takes effect. See C +to access the object's input buffer. + +=back + +=back + + +=over 4 + +=item B - log all TELNET options sent or received + + $fh = $obj->option_log; + + $fh = $obj->option_log($fh); + + $fh = $obj->option_log($filename); + +This method starts or stops logging of all TELNET options being sent +or received. This is useful for debugging when you send options via +C or you arrange to accept option requests from the +remote side via C. Also see C. + +If no argument is given, the log filehandle is returned. An empty +string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened for logging and a filehandle to it is returned. If the file +can't be opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - send TELNET option negotiation request + + $ok = $obj->option_send([Do => $telopt,] + [Dont => $telopt,] + [Will => $telopt,] + [Wont => $telopt,] + [Async => $boolean,]); + +This method is not yet implemented. Look for it in a future version. + +=back + + +=over 4 + +=item B - get current state of a TELNET option + + $hashref = $obj->option_state($telopt); + +This method returns a hashref containing a copy of the current state +of TELNET option I<$telopt>. + +Here are the values returned in the hash: + +=over 4 + +=item + +I<$hashref>->{remote_enabled} + +=over 4 + +=item + +boolean that indicates if the option is enabled on the remote side. + +=back + +=item + +I<$hashref>->{remote_enable_ok} + +=over 4 + +=item + +boolean that indicates if it's ok to accept an offer to enable this +option on the remote side. + +=back + +=item + +I<$hashref>->{remote_state} + +=over 4 + +=item + +string used to hold the internal state of option negotiation for this +option on the remote side. + +=back + +=item + +I<$hashref>->{local_enabled} + +=over 4 + +=item + +boolean that indicates if the option is enabled on the local side. + +=back + +=item + +I<$hashref>->{local_enable_ok} + +=over 4 + +=item + +boolean that indicates if it's ok to accept an offer to enable this +option on the local side. + +=back + +=item + +I<$hashref>->{local_state} + +=over 4 + +=item + +string used to hold the internal state of option negotiation for this +option on the local side. + +=back + +=back + +=back + + +=over 4 + +=item B - output line delimiter + + $chars = $obj->ors; + + $prev = $obj->ors($chars); + +This method is synonymous with C. + +=back + + +=over 4 + +=item B - field separator for print + + $chars = $obj->output_field_separator; + + $prev = $obj->output_field_separator($chars); + +This method designates the output field separator for C. +Ordinarily the print method simply prints out the comma separated +fields you specify. Set this to specify what's printed between +fields. + +With no argument this method returns the current output field +separator set in the object. With an argument it sets the output +field separator to I<$chars> and returns the previous value. + +By default it's set to an empty string. + +=back + + +=over 4 + +=item B - log all output + + $fh = $obj->output_log; + + $fh = $obj->output_log($fh); + + $fh = $obj->output_log($filename); + +This method starts or stops logging of output. This is useful when +debugging. Also see C. Because most command interpreters +echo back commands received, it's likely all your output would also be +in an input log. See C. Note that output logging occurs +before newline translation. See C for details on newline +translation. + +If no argument is given, the log filehandle is returned. An empty +string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened for logging and a filehandle to it is returned. If the file +can't be opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - output line delimiter + + $chars = $obj->output_record_separator; + + $prev = $obj->output_record_separator($chars); + +This method designates the output line delimiter for C and +C. Set this to specify what's printed at the end of C +and C. + +The output record separator is set to C<"\n"> by default, so there's +no need to append all your commands with a newline. To avoid printing +the output_record_separator use C or set the +output_record_separator to an empty string. + +With no argument this method returns the current output record +separator set in the object. With an argument it sets the output +record separator to I<$chars> and returns the previous value. + +=back + + +=over 4 + +=item B - remote port + + $port = $obj->port; + + $prev = $obj->port($port); + +This method designates the remote TCP port. With no argument this +method returns the current port number. With an argument it sets the +current port number to I<$port> and returns the previous port. If +I<$port> is a TCP service name, then it's first converted to a port +number using the perl function C. + +The default value is C<23>. It may also be set by C or +C. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not a positive integer or a valid TCP service +name. + +=back + + +=over 4 + +=item B - write to object + + $ok = $obj->print(@list); + +This method writes I<@list> followed by the I +to the open object and returns C<1> if all data was successfully +written. On time-out or other failures, the error mode action is +performed. See C. + +By default, the C is set to C<"\n"> so all +your commands automatically end with a newline. In most cases your +output is being read by a command interpreter which won't accept a +command until newline is read. This is similar to someone typing a +command and hitting the return key. To avoid printing a trailing +C<"\n"> use C instead or set the output_record_separator to an +empty string. + +On failure, it's possible that some data was written. If you choose +to try and recover from a print timing-out, use C to +determine how much was written before the error occurred. + +You may also use the output field separator to print a string between +the list elements. See C. + +=back + + +=over 4 + +=item B - number of bytes written by print + + $num = $obj->print_length; + +This returns the number of bytes successfully written by the most +recent C or C. + +=back + + +=over 4 + +=item B - pattern to match a prompt + + $matchop = $obj->prompt; + + $prev = $obj->prompt($matchop); + +This method sets the pattern used to find a prompt in the input +stream. It must be a string representing a valid perl pattern match +operator. The methods C and C try to read until +matching the prompt. They will fail with a time-out error if the +pattern you've chosen doesn't match what the remote side sends. + +With no argument this method returns the prompt set in the object. +With an argument it sets the prompt to I<$matchop> and returns the +previous value. + +The default prompt is C<'/[\$%#E] $/'> + +Always use single quotes, instead of double quotes, to construct +I<$matchop> (e.g. C<'/bash\$ $/'>). If you're constructing a DOS like +file path, you'll need to use four backslashes to represent one +(e.g. C<'/c:\\\\users\\\\billE$/i'>). + +Of course don't forget about regexp metacharacters like C<.>, C<[>, or +C<$>. You'll only need a single backslash to quote them. The anchor +metacharacters C<^> and C<$> refer to positions in the input buffer. + +A warning is printed to STDERR when attempting to set this attribute +with a match operator missing its opening delimiter. + +=back + + +=over 4 + +=item B - write to object + + $ok = $obj->put($string); + + $ok = $obj->put(String => $string, + [Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method writes I<$string> to the opened object and returns C<1> if +all data was successfully written. This method is like C +except that it doesn't write the trailing output_record_separator +("\n" by default). On time-out or other failures, the error mode +action is performed. See C. + +On failure, it's possible that some data was written. If you choose +to try and recover from a put timing-out, use C to +determine how much was written before the error occurred. + +Optional named parameters are provided to override the current +settings of binmode, errmode, telnetmode, and timeout. + +=back + + +=over 4 + +=item B - input line delimiter + + $chars = $obj->rs; + + $prev = $obj->rs($chars); + +This method is synonymous with C. + +=back + + +=over 4 + +=item B - turn off/on telnet command interpretation + + $mode = $obj->telnetmode; + + $prev = $obj->telnetmode($mode); + +This method controls whether or not TELNET commands in the data stream +are recognized and handled. The TELNET protocol uses certain +character sequences sent in the data stream to control the session. +If the port you're connecting to isn't using the TELNET protocol, then +you should turn this mode off. The default is I. + +If no argument is given, the current mode is returned. + +If I<$mode> is C<0> then telnet mode is off. If I<$mode> is C<1> then +telnet mode is on. + +=back + + +=over 4 + +=item B - time-out indicator + + $boolean = $obj->timed_out; + + $prev = $obj->timed_out($boolean); + +This method indicates if a previous read, write, or open method +timed-out. Remember that timing-out is itself an error. To be able +to invoke C after a time-out error, you'd have to change +the default error mode to something other than C<"die">. See +C. + +With no argument this method returns C<1> if the previous method +timed-out. With an argument it sets the indicator. Normally, only +internal methods set this indicator. + +=back + + +=over 4 + +=item B - I/O time-out interval + + $secs = $obj->timeout; + + $prev = $obj->timeout($secs); + +This method sets the timeout interval that's used when performing I/O +or connecting to a port. When a method doesn't complete within the +timeout interval then it's an error and the error mode action is +performed. + +A timeout may be expressed as a relative or absolute value. If +I<$secs> is greater than or equal to the time the program started, as +determined by $^T, then it's an absolute time value for when time-out +occurs. The perl function C may be used to obtain an absolute +time value. For a relative time-out value less than $^T, time-out +happens I<$secs> from when the method begins. + +If I<$secs> is C<0> then time-out occurs if the data cannot be +immediately read or written. Use the undefined value to turn off +timing-out completely. + +With no argument this method returns the timeout set in the object. +With an argument it sets the timeout to I<$secs> and returns the +previous value. The default timeout value is C<10> seconds. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not an C or a non-negative integer. + +=back + + +=over 4 + +=item B - wait for pattern in the input + + $ok = $obj->waitfor($matchop); + $ok = $obj->waitfor([Match => $matchop,] + [String => $string,] + [Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + + ($prematch, $match) = $obj->waitfor($matchop); + ($prematch, $match) = $obj->waitfor([Match => $matchop,] + [String => $string,] + [Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method reads until a pattern match or string is found in the +input stream. All the characters before and including the match are +removed from the input stream. + +In a list context the characters before the match and the matched +characters are returned in I<$prematch> and I<$match>. In a scalar +context, the matched characters and all characters before it are +discarded and C<1> is returned on success. On time-out, eof, or other +failures, for both list and scalar context, the error mode action is +performed. See C. + +You can specify more than one pattern or string by simply providing +multiple I and/or I named parameters. A I<$matchop> +must be a string representing a valid Perl pattern match operator. +The I<$string> is just a substring to find in the input stream. + +Use C to debug when this method keeps timing-out and you +don't think it should. + +An optional named parameter is provided to override the current +setting of timeout. + +To avoid unexpected backslash interpretation, always use single quotes +instead of double quotes to construct a match operator argument for +C and C (e.g. C<'/bash\$ $/'>). If you're +constructing a DOS like file path, you'll need to use four backslashes +to represent one (e.g. C<'/c:\\\\users\\\\billE$/i'>). + +Of course don't forget about regexp metacharacters like C<.>, C<[>, or +C<$>. You'll only need a single backslash to quote them. The anchor +metacharacters C<^> and C<$> refer to positions in the input buffer. + +Optional named parameters are provided to override the current +settings of binmode, errmode, telnetmode, and timeout. + +=back + + +=head1 SEE ALSO + +=over 2 + +=item RFC 854 + +S + +S + +=item RFC 1143 + +S + +S + +=item TELNET Option Assignments + +S + +=back + + +=head1 EXAMPLES + +This example gets the current weather forecast for Brainerd, Minnesota. + + my ($forecast, $t); + + use Net::Telnet (); + $t = new Net::Telnet; + $t->open("rainmaker.wunderground.com"); + + ## Wait for first prompt and "hit return". + $t->waitfor('/continue:.*$/'); + $t->print(""); + + ## Wait for second prompt and respond with city code. + $t->waitfor('/city code.*$/'); + $t->print("BRD"); + + ## Read and print the first page of forecast. + ($forecast) = $t->waitfor('/[ \t]+press return to continue/i'); + print $forecast; + + exit; + + +This example checks a POP server to see if you have mail. + + my ($hostname, $line, $passwd, $pop, $username); + + $hostname = "your_destination_host_here"; + $username = "your_username_here"; + $passwd = "your_password_here"; + + use Net::Telnet (); + $pop = new Net::Telnet (Telnetmode => 0); + $pop->open(Host => $hostname, + Port => 110); + + + ## Read connection message. + $line = $pop->getline; + die $line unless $line =~ /^\+OK/; + + ## Send user name. + $pop->print("user $username"); + $line = $pop->getline; + die $line unless $line =~ /^\+OK/; + + ## Send password. + $pop->print("pass $passwd"); + $line = $pop->getline; + die $line unless $line =~ /^\+OK/; + + ## Request status of messages. + $pop->print("list"); + $line = $pop->getline; + print $line; + + exit; + + +Here's an example that uses the ssh program to connect to a remote +host. Because the ssh program reads and writes to its controlling +terminal, the IO::Pty module is used to create a new pseudo terminal +for use by ssh. A new Net::Telnet object is then created to read and +write to that pseudo terminal. To use the code below, substitute +"changeme" with the actual host, user, password, and command prompt. + + ## Main program. + { + my ($pty, $ssh, @lines); + my $host = "changeme"; + my $user = "changeme"; + my $password = "changeme"; + my $prompt = '/changeme:~> $/'; + + ## Start ssh program. + $pty = &spawn("ssh", "-l", $user, $host); # spawn() defined below + + ## Create a Net::Telnet object to perform I/O on ssh's tty. + use Net::Telnet; + $ssh = new Net::Telnet (-fhopen => $pty, + -prompt => $prompt, + -telnetmode => 0, + -cmd_remove_mode => 1, + -output_record_separator => "\r"); + + ## Login to remote host. + $ssh->waitfor(-match => '/password: ?$/i', + -errmode => "return") + or die "problem connecting to host: ", $ssh->lastline; + $ssh->print($password); + $ssh->waitfor(-match => $ssh->prompt, + -errmode => "return") + or die "login failed: ", $ssh->lastline; + + ## Send command, get and print its output. + @lines = $ssh->cmd("who"); + print @lines; + + exit; + } # end main program + + sub spawn { + my(@cmd) = @_; + my($pid, $pty, $tty, $tty_fd); + + ## Create a new pseudo terminal. + use IO::Pty (); + $pty = new IO::Pty + or die $!; + + ## Execute the program in another process. + unless ($pid = fork) { # child process + die "problem spawning program: $!\n" unless defined $pid; + + ## Disassociate process from existing controlling terminal. + use POSIX (); + POSIX::setsid + or die "setsid failed: $!"; + + ## Associate process with a new controlling terminal. + $tty = $pty->slave; + $tty_fd = $tty->fileno; + close $pty; + + ## Make stdio use the new controlling terminal. + open STDIN, "<&$tty_fd" or die $!; + open STDOUT, ">&$tty_fd" or die $!; + open STDERR, ">&STDOUT" or die $!; + close $tty; + + ## Execute requested program. + exec @cmd + or die "problem executing $cmd[0]\n"; + } # end child process + + $pty; + } # end sub spawn + + +Here's an example that changes a user's login password. Because the +passwd program always prompts for passwords on its controlling +terminal, the IO::Pty module is used to create a new pseudo terminal +for use by passwd. A new Net::Telnet object is then created to read +and write to that pseudo terminal. To use the code below, substitute +"changeme" with the actual old and new passwords. + + my ($pty, $passwd); + my $oldpw = "changeme"; + my $newpw = "changeme"; + + ## Start passwd program. + $pty = &spawn("passwd"); # spawn() defined above + + ## Create a Net::Telnet object to perform I/O on passwd's tty. + use Net::Telnet; + $passwd = new Net::Telnet (-fhopen => $pty, + -timeout => 2, + -output_record_separator => "\r", + -telnetmode => 0, + -cmd_remove_mode => 1); + $passwd->errmode("return"); + + ## Send existing password. + $passwd->waitfor('/password: ?$/i') + or die "no old password prompt: ", $passwd->lastline; + $passwd->print($oldpw); + + ## Send new password. + $passwd->waitfor('/new password: ?$/i') + or die "bad old password: ", $passwd->lastline; + $passwd->print($newpw); + + ## Send new password verification. + $passwd->waitfor('/new password: ?$/i') + or die "bad new password: ", $passwd->lastline; + $passwd->print($newpw); + + ## Display success or failure. + $passwd->waitfor('/changed/') + or die "bad new password: ", $passwd->lastline; + print $passwd->lastline; + + $passwd->close; + exit; + + +Here's an example you can use to down load a file of any type. The +file is read from the remote host's standard output using cat. To +prevent any output processing, the remote host's standard output is +put in raw mode using the Bourne shell. The Bourne shell is used +because some shells, notably tcsh, prevent changing tty modes. Upon +completion, FTP style statistics are printed to stderr. + + my ($block, $filename, $host, $hostname, $k_per_sec, $line, + $num_read, $passwd, $prevblock, $prompt, $size, $size_bsd, + $size_sysv, $start_time, $total_time, $username); + + $hostname = "your_destination_host_here"; + $username = "your_username_here"; + $passwd = "your_password_here"; + $filename = "your_download_file_here"; + + ## Connect and login. + use Net::Telnet (); + $host = new Net::Telnet (Timeout => 30, + Prompt => '/[%#>] $/'); + $host->open($hostname); + $host->login($username, $passwd); + + ## Make sure prompt won't match anything in send data. + $prompt = "_funkyPrompt_"; + $host->prompt("/$prompt\$/"); + $host->cmd("set prompt = '$prompt'"); + + ## Get size of file. + ($line) = $host->cmd("/bin/ls -l $filename"); + ($size_bsd, $size_sysv) = (split ' ', $line)[3,4]; + if ($size_sysv =~ /^\d+$/) { + $size = $size_sysv; + } + elsif ($size_bsd =~ /^\d+$/) { + $size = $size_bsd; + } + else { + die "$filename: no such file on $hostname"; + } + + ## Start sending the file. + binmode STDOUT; + $host->binmode(1); + $host->print("/bin/sh -c 'stty raw; cat $filename'"); + $host->getline; # discard echoed back line + + ## Read file a block at a time. + $num_read = 0; + $prevblock = ""; + $start_time = time; + while (($block = $host->get) and ($block !~ /$prompt$/o)) { + if (length $block >= length $prompt) { + print $prevblock; + $num_read += length $prevblock; + $prevblock = $block; + } + else { + $prevblock .= $block; + } + + } + $host->close; + + ## Print last block without trailing prompt. + $prevblock .= $block; + $prevblock =~ s/$prompt$//; + print $prevblock; + $num_read += length $prevblock; + die "error: expected size $size, received size $num_read\n" + unless $num_read == $size; + + ## Print totals. + $total_time = (time - $start_time) || 1; + $k_per_sec = ($size / 1024) / $total_time; + $k_per_sec = sprintf "%3.1f", $k_per_sec; + warn("$num_read bytes received in $total_time seconds ", + "($k_per_sec Kbytes/s)\n"); + + exit; + + +=head1 AUTHOR + +Jay Rogers + + +=head1 COPYRIGHT + +Copyright 1997, 2000, 2002 by Jay Rogers. All rights reserved. +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. diff --git a/agc_2-X/trunk/libs/Telnet.pm b/agc_2-X/trunk/libs/Telnet.pm new file mode 100644 index 00000000..9f84fe31 --- /dev/null +++ b/agc_2-X/trunk/libs/Telnet.pm @@ -0,0 +1,5252 @@ +package Net::Telnet; + +## Copyright 1997, 2000, 2002 Jay Rogers. All rights reserved. +## This program is free software; you can redistribute it and/or +## modify it under the same terms as Perl itself. + +## See user documentation at the end of this file. Search for =head + +use strict; +require 5.002; + +## Module export. +use vars qw(@EXPORT_OK); +@EXPORT_OK = qw(TELNET_IAC TELNET_DONT TELNET_DO TELNET_WONT TELNET_WILL + TELNET_SB TELNET_GA TELNET_EL TELNET_EC TELNET_AYT TELNET_AO + TELNET_IP TELNET_BREAK TELNET_DM TELNET_NOP TELNET_SE + TELNET_EOR TELNET_ABORT TELNET_SUSP TELNET_EOF TELNET_SYNCH + TELOPT_BINARY TELOPT_ECHO TELOPT_RCP TELOPT_SGA TELOPT_NAMS + TELOPT_STATUS TELOPT_TM TELOPT_RCTE TELOPT_NAOL TELOPT_NAOP + TELOPT_NAOCRD TELOPT_NAOHTS TELOPT_NAOHTD TELOPT_NAOFFD + TELOPT_NAOVTS TELOPT_NAOVTD TELOPT_NAOLFD TELOPT_XASCII + TELOPT_LOGOUT TELOPT_BM TELOPT_DET TELOPT_SUPDUP + TELOPT_SUPDUPOUTPUT TELOPT_SNDLOC TELOPT_TTYPE TELOPT_EOR + TELOPT_TUID TELOPT_OUTMRK TELOPT_TTYLOC TELOPT_3270REGIME + TELOPT_X3PAD TELOPT_NAWS TELOPT_TSPEED TELOPT_LFLOW + TELOPT_LINEMODE TELOPT_XDISPLOC TELOPT_OLD_ENVIRON + TELOPT_AUTHENTICATION TELOPT_ENCRYPT TELOPT_NEW_ENVIRON + TELOPT_EXOPL); + +## Module import. +use Exporter (); +use Socket qw(AF_INET SOCK_STREAM inet_aton sockaddr_in); +use Symbol qw(qualify); + +## Base classes. +use vars qw(@ISA); +@ISA = qw(Exporter); +if (&_io_socket_include) { # successfully required module IO::Socket + push @ISA, "IO::Socket::INET"; +} +else { # perl version < 5.004 + require FileHandle; + push @ISA, "FileHandle"; +} + +## Global variables. +use vars qw($VERSION @Telopts); +$VERSION = "3.03"; +@Telopts = ("BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", + "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", + "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", + "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", + "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", + "NAWS", "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC", "OLD-ENVIRON", + "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"); + + +########################### Public Methods ########################### + + +sub new { + my ($class) = @_; + my ( + $errmode, + $fh_open, + $host, + $self, + %args, + ); + local $_; + + ## Create a new object with defaults. + $self = $class->SUPER::new; + *$self->{net_telnet} = { + bin_mode => 0, + blksize => &_optimal_blksize(), + buf => "", + cmd_prompt => '/[\$%#>] $/', + cmd_rm_mode => "auto", + dumplog => '', + eofile => 1, + errormode => "die", + errormsg => "", + fdmask => '', + host => "localhost", + inputlog => '', + last_line => "", + last_prompt => "", + maxbufsize => 1_048_576, + num_wrote => 0, + ofs => "", + opened => '', + opt_cback => '', + opt_log => '', + opts => {}, + ors => "\n", + outputlog => '', + pending_errormsg => "", + port => 23, + pushback_buf => "", + rs => "\n", + subopt_cback => '', + telnet_mode => 1, + time_out => 10, + timedout => '', + unsent_opts => "", + }; + + ## Indicate that we'll accept an offer from remote side for it to echo + ## and suppress go aheads. + &_opt_accept($self, + { option => &TELOPT_ECHO, + is_remote => 1, + is_enable => 1 }, + { option => &TELOPT_SGA, + is_remote => 1, + is_enable => 1 }, + ); + + ## Parse the args. + if (@_ == 2) { # one positional arg given + $host = $_[1]; + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse all other named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $self->binmode($args{$_}); + } + elsif (/^-?cmd_remove_mode$/i) { + $self->cmd_remove_mode($args{$_}); + } + elsif (/^-?dump_log$/i) { + $self->dump_log($args{$_}); + } + elsif (/^-?errmode$/i) { + $errmode = $args{$_}; + } + elsif (/^-?fhopen$/i) { + $fh_open = $args{$_}; + } + elsif (/^-?host$/i) { + $host = $args{$_}; + } + elsif (/^-?input_log$/i) { + $self->input_log($args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $self->input_record_separator($args{$_}); + } + elsif (/^-?option_log$/i) { + $self->option_log($args{$_}); + } + elsif (/^-?output_log$/i) { + $self->output_log($args{$_}); + } + elsif (/^-?output_record_separator$/i or /^-?ors$/i) { + $self->output_record_separator($args{$_}); + } + elsif (/^-?port$/i) { + $self->port($args{$_}); + } + elsif (/^-?prompt$/i) { + $self->prompt($args{$_}); + } + elsif (/^-?telnetmode$/i) { + $self->telnetmode($args{$_}); + } + elsif (/^-?timeout$/i) { + $self->timeout($args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::new()"); + } + } + } + + if (defined $errmode) { # user wants to set errmode + $self->errmode($errmode); + } + + if (defined $fh_open) { # user wants us to attach to existing filehandle + $self->fhopen($fh_open) + or return; + } + elsif (defined $host) { # user wants us to open a connection to host + $self->host($host); + $self->open + or return; + } + + $self; +} # end sub new + + +sub DESTROY { +} # end sub DESTROY + + +sub binmode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{bin_mode}; + + if (@_ >= 2) { + unless (defined $mode) { + $mode = 0; + } + + $s->{bin_mode} = $mode; + } + + $prev; +} # end sub binmode + + +sub break { + my ($self) = @_; + my $s = *$self->{net_telnet}; + my $break_cmd = "\xff\xf3"; + + $s->{timedout} = ''; + + &_put($self, \$break_cmd, "break"); +} # end sub break + + +sub buffer { + my ($self) = @_; + my $s = *$self->{net_telnet}; + + \$s->{buf}; +} # end sub buffer + + +sub buffer_empty { + my ($self) = @_; + my ( + $buffer, + ); + + $buffer = $self->buffer; + $$buffer = ""; +} # end sub buffer_empty + + +sub close { + my ($self) = @_; + my $s = *$self->{net_telnet}; + + $s->{eofile} = 1; + $s->{opened} = ''; + close $self + if defined fileno($self); + + 1; +} # end sub close + + +sub cmd { + my ($self, @args) = @_; + my ( + $cmd_remove_mode, + $errmode, + $firstpos, + $last_prompt, + $lastpos, + $lines, + $ors, + $output, + $output_ref, + $prompt, + $remove_echo, + $rs, + $rs_len, + $s, + $telopt_echo, + $timeout, + %args, + ); + my $cmd = ""; + local $_; + + ## Init. + $self->timed_out(''); + $self->last_prompt(""); + $s = *$self->{net_telnet}; + $output = []; + $cmd_remove_mode = $self->cmd_remove_mode; + $errmode = $self->errmode; + $ors = $self->output_record_separator; + $prompt = $self->prompt; + $rs = $self->input_record_separator; + $timeout = $self->timeout; + + ## Parse args. + if (@_ == 2) { # one positional arg given + $cmd = $_[1]; + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?cmd_remove/i) { + $cmd_remove_mode = &_parse_cmd_remove_mode($self, $args{$_}); + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $rs = &_parse_input_record_separator($self, $args{$_}); + } + elsif (/^-?output$/i) { + $output_ref = $args{$_}; + if (defined($output_ref) and ref($output_ref) eq "ARRAY") { + $output = $output_ref; + } + } + elsif (/^-?output_record_separator$/i or /^-?ors$/i) { + $ors = $self->output_record_separator($args{$_}); + } + elsif (/^-?prompt$/i) { + $prompt = &_parse_prompt($self, $args{$_}); + } + elsif (/^-?string$/i) { + $cmd = $args{$_}; + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::cmd()"); + } + } + } + + ## Override some user settings. + local $s->{errormode} = "return"; + local $s->{time_out} = &_endtime($timeout); + $self->errmsg(""); + + ## Send command and wait for the prompt. + $self->put($cmd . $ors) + and ($lines, $last_prompt) = $self->waitfor($prompt); + + ## Check for failure. + $s->{errormode} = $errmode; + return $self->error("command timed-out") if $self->timed_out; + return $self->error($self->errmsg) if $self->errmsg ne ""; + + ## Save the most recently matched prompt. + $self->last_prompt($last_prompt); + + ## Split lines into an array, keeping record separator at end of line. + $firstpos = 0; + $rs_len = length $rs; + while (($lastpos = index($lines, $rs, $firstpos)) > -1) { + push(@$output, + substr($lines, $firstpos, $lastpos - $firstpos + $rs_len)); + $firstpos = $lastpos + $rs_len; + } + + if ($firstpos < length $lines) { + push @$output, substr($lines, $firstpos); + } + + ## Determine if we should remove the first line of output based + ## on the assumption that it's an echoed back command. + if ($cmd_remove_mode eq "auto") { + ## See if remote side told us they'd echo. + $telopt_echo = $self->option_state(&TELOPT_ECHO); + $remove_echo = $telopt_echo->{remote_enabled}; + } + else { # user explicitly told us how many lines to remove. + $remove_echo = $cmd_remove_mode; + } + + ## Get rid of possible echo back command. + while ($remove_echo--) { + shift @$output; + } + + ## Ensure at least a null string when there's no command output - so + ## "true" is returned in a list context. + unless (@$output) { + @$output = (""); + } + + ## Return command output via named arg, if requested. + if (defined $output_ref) { + if (ref($output_ref) eq "SCALAR") { + $$output_ref = join "", @$output; + } + elsif (ref($output_ref) eq "HASH") { + %$output_ref = @$output; + } + } + + wantarray ? @$output : 1; +} # end sub cmd + + +sub cmd_remove_mode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{cmd_rm_mode}; + + if (@_ >= 2) { + $s->{cmd_rm_mode} = &_parse_cmd_remove_mode($self, $mode); + } + + $prev; +} # end sub cmd_remove_mode + + +sub dump_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{dumplog}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{dumplog} = $fh; + } + + $fh; +} # end sub dump_log + + +sub eof { + my ($self) = @_; + + *$self->{net_telnet}{eofile}; +} # end sub eof + + +sub errmode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{errormode}; + + if (@_ >= 2) { + $s->{errormode} = &_parse_errmode($self, $mode); + } + + $prev; +} # end sub errmode + + +sub errmsg { + my ($self, @errmsgs) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{errormsg}; + + if (@_ >= 2) { + $s->{errormsg} = join "", @errmsgs; + } + + $prev; +} # end sub errmsg + + +sub error { + my ($self, @errmsg) = @_; + my ( + $errmsg, + $func, + $mode, + $s, + @args, + ); + local $_; + + $s = *$self->{net_telnet}; + + if (@_ >= 2) { + ## Put error message in the object. + $errmsg = join "", @errmsg; + $s->{errormsg} = $errmsg; + + ## Do the error action as described by error mode. + $mode = $s->{errormode}; + if (ref($mode) eq "CODE") { + &$mode($errmsg); + return; + } + elsif (ref($mode) eq "ARRAY") { + ($func, @args) = @$mode; + &$func(@args); + return; + } + elsif ($mode =~ /^return$/i) { + return; + } + else { # die + if ($errmsg =~ /\n$/) { + die $errmsg; + } + else { + ## Die and append caller's line number to message. + &_croak($self, $errmsg); + } + } + } + else { + return $s->{errormsg} ne ""; + } +} # end sub error + + +sub fhopen { + my ($self, $fh) = @_; + my ( + $globref, + $s, + ); + + ## Convert given filehandle to a typeglob reference, if necessary. + $globref = &_qualify_fh($self, $fh); + + ## Ensure filehandle is already open. + return $self->error("fhopen filehandle isn't already open") + unless defined($globref) and defined(fileno $globref); + + ## Ensure we're closed. + $self->close; + + ## Save our private data. + $s = *$self->{net_telnet}; + + ## Switch ourself with the given filehandle. + *$self = *$globref; + + ## Restore our private data. + *$self->{net_telnet} = $s; + + ## Re-initialize ourself. + select((select($self), $|=1)[$[]); # don't buffer writes + $s = *$self->{net_telnet}; + $s->{blksize} = &_optimal_blksize((stat $self)[11]); + $s->{buf} = ""; + $s->{eofile} = ''; + $s->{errormsg} = ""; + vec($s->{fdmask}='', fileno($self), 1) = 1; + $s->{host} = ""; + $s->{last_line} = ""; + $s->{last_prompt} = ""; + $s->{num_wrote} = 0; + $s->{opened} = 1; + $s->{pending_errormsg} = ""; + $s->{port} = ''; + $s->{pushback_buf} = ""; + $s->{timedout} = ''; + $s->{unsent_opts} = ""; + &_reset_options($s->{opts}); + + 1; +} # end sub fhopen + + +sub get { + my ($self, %args) = @_; + my ( + $binmode, + $endtime, + $errmode, + $line, + $s, + $telnetmode, + $timeout, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $timeout = $s->{time_out}; + $s->{timedout} = ''; + return if $s->{eofile}; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::get()"); + } + } + + ## If any args given, override corresponding instance data. + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + + ## Set wall time when we time out. + $endtime = &_endtime($timeout); + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + ## Try to read just the waiting data using return error mode. + { + local $s->{errormode} = "return"; + $s->{errormsg} = ""; + &_fillbuf($self, $s, 0); + } + + ## We're done if we timed-out and timeout value is set to "poll". + return $self->error($s->{errormsg}) + if ($s->{timedout} and defined($timeout) and $timeout == 0 + and !length $s->{buf}); + + ## We're done if we hit an error other than timing out. + if ($s->{errormsg} and !$s->{timedout}) { + if (!length $s->{buf}) { + return $self->error($s->{errormsg}); + } + else { # error encountered but there's some data in buffer + $s->{pending_errormsg} = $s->{errormsg}; + } + } + + ## Clear time-out error from first read. + $s->{timedout} = ''; + $s->{errormsg} = ""; + + ## If buffer is still empty, try to read according to user's timeout. + if (!length $s->{buf}) { + &_fillbuf($self, $s, $endtime) + or do { + return if $s->{timedout}; + + ## We've reached end-of-file. + $self->close; + return; + }; + } + + ## Extract chars from buffer. + $line = $s->{buf}; + $s->{buf} = ""; + + $line; +} # end sub get + + +sub getline { + my ($self, %args) = @_; + my ( + $binmode, + $endtime, + $errmode, + $len, + $line, + $offset, + $pos, + $rs, + $s, + $telnetmode, + $timeout, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return if $s->{eofile}; + $rs = $s->{rs}; + $timeout = $s->{time_out}; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $rs = &_parse_input_record_separator($self, $args{$_}); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::getline()"); + } + } + + ## If any args given, override corresponding instance data. + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + + ## Set wall time when we time out. + $endtime = &_endtime($timeout); + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + ## Keep reading into buffer until end-of-line is read. + $offset = 0; + while (($pos = index($s->{buf}, $rs, $offset)) == -1) { + $offset = length $s->{buf}; + &_fillbuf($self, $s, $endtime) + or do { + return if $s->{timedout}; + + ## We've reached end-of-file. + $self->close; + if (length $s->{buf}) { + return $s->{buf}; + } + else { + return; + } + }; + } + + ## Extract line from buffer. + $len = $pos + length $rs; + $line = substr($s->{buf}, 0, $len); + substr($s->{buf}, 0, $len) = ""; + + $line; +} # end sub getline + + +sub getlines { + my ($self, %args) = @_; + my ( + $binmode, + $errmode, + $line, + $rs, + $s, + $telnetmode, + $timeout, + ); + my $all = 1; + my @lines = (); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return if $s->{eofile}; + $timeout = $s->{time_out}; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?all$/i) { + $all = $args{$_}; + unless (defined $all) { + $all = ''; + } + } + elsif (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?input_record_separator$/i or /^-?rs$/i) { + $rs = &_parse_input_record_separator($self, $args{$_}); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::getlines()"); + } + } + + ## If any args given, override corresponding instance data. + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{rs} = $rs + if defined $rs; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + local $s->{time_out} = &_endtime($timeout); + + ## User requested only the currently available lines. + if (! $all) { + return &_next_getlines($self, $s); + } + + ## Read lines until eof or error. + while (1) { + $line = $self->getline + or last; + push @lines, $line; + } + + ## Check for error. + return if ! $self->eof; + + @lines; +} # end sub getlines + + +sub host { + my ($self, $host) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{host}; + + if (@_ >= 2) { + unless (defined $host) { + $host = ""; + } + + $s->{host} = $host; + } + + $prev; +} # end sub host + + +sub input_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{inputlog}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{inputlog} = $fh; + } + + $fh; +} # end sub input_log + + +sub input_record_separator { + my ($self, $rs) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{rs}; + + if (@_ >= 2) { + $s->{rs} = &_parse_input_record_separator($self, $rs); + } + + $prev; +} # end sub input_record_separator + + +sub last_prompt { + my ($self, $string) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{last_prompt}; + + if (@_ >= 2) { + unless (defined $string) { + $string = ""; + } + + $s->{last_prompt} = $string; + } + + $prev; +} # end sub last_prompt + + +sub lastline { + my ($self, $line) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{last_line}; + + if (@_ >= 2) { + unless (defined $line) { + $line = ""; + } + + $s->{last_line} = $line; + } + + $prev; +} # end sub lastline + + +sub login { + my ($self) = @_; + my ( + $errmode, + $error, + $is_passwd_arg, + $is_username_arg, + $lastline, + $match, + $ors, + $passwd, + $prematch, + $prompt, + $s, + $timeout, + $username, + %args, + ); + local $_; + + ## Init. + $self->timed_out(''); + $self->last_prompt(""); + $s = *$self->{net_telnet}; + $timeout = $self->timeout; + $ors = $self->output_record_separator; + $prompt = $self->prompt; + + ## Parse args. + if (@_ == 3) { # just username and passwd given + $username = $_[1]; + $passwd = $_[2]; + + $is_username_arg = 1; + $is_passwd_arg = 1; + } + else { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?name$/i) { + $username = $args{$_}; + unless (defined $username) { + $username = ""; + } + + $is_username_arg = 1; + } + elsif (/^-?pass/i) { + $passwd = $args{$_}; + unless (defined $passwd) { + $passwd = ""; + } + + $is_passwd_arg = 1; + } + elsif (/^-?prompt$/i) { + $prompt = &_parse_prompt($self, $args{$_}); + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given ", + "to " . ref($self) . "::login()"); + } + } + } + + ## Ensure both username and password argument given. + &_croak($self,"Name argument not given to " . ref($self) . "::login()") + unless $is_username_arg; + &_croak($self,"Password argument not given to " . ref($self) . "::login()") + unless $is_passwd_arg; + + ## Override some user settings. + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{time_out} = &_endtime($timeout); + + ## Create a subroutine to generate an error. + $error + = sub { + my ($errmsg) = @_; + + if ($self->timed_out) { + return $self->error($errmsg); + } + elsif ($self->eof) { + ($lastline = $self->lastline) =~ s/\n+//; + return $self->error($errmsg, ": ", $lastline); + } + else { + return $self->error($self->errmsg); + } + }; + + + return $self->error("login failed: filehandle isn't open") + if $self->eof; + + ## Wait for login prompt. + $self->waitfor(Match => '/login[: ]*$/i', + Match => '/username[: ]*$/i', + Errmode => "return") + or do { + return &$error("eof read waiting for login prompt") + if $self->eof; + return &$error("timed-out waiting for login prompt"); + }; + + ## Delay sending response because of bug in Linux login program. + &_sleep(0.01); + + ## Send login name. + $self->put(String => $username . $ors, + Errmode => "return") + or return &$error("login disconnected"); + + ## Wait for password prompt. + $self->waitfor(Match => '/password[: ]*$/i', + Errmode => "return") + or do { + return &$error("eof read waiting for password prompt") + if $self->eof; + return &$error("timed-out waiting for password prompt"); + }; + + ## Delay sending response because of bug in Linux login program. + &_sleep(0.01); + + ## Send password. + $self->put(String => $passwd . $ors, + Errmode => "return") + or return &$error("login disconnected"); + + ## Wait for command prompt or another login prompt. + ($prematch, $match) = $self->waitfor(Match => '/login[: ]*$/i', + Match => '/username[: ]*$/i', + Match => $prompt, + Errmode => "return") + or do { + return &$error("eof read waiting for command prompt") + if $self->eof; + return &$error("timed-out waiting for command prompt"); + }; + + ## It's a bad login if we got another login prompt. + return $self->error("login failed: bad name or password") + if $match =~ /login[: ]*$/i or $match =~ /username[: ]*$/i; + + ## Save the most recently matched command prompt. + $self->last_prompt($match); + + 1; +} # end sub login + + +sub max_buffer_length { + my ($self, $maxbufsize) = @_; + my ( + $prev, + $s, + ); + my $minbufsize = 512; + + $s = *$self->{net_telnet}; + $prev = $s->{maxbufsize}; + + if (@_ >= 2) { + ## Ensure a positive integer value. + unless (defined $maxbufsize + and $maxbufsize =~ /^\d+$/ + and $maxbufsize) + { + &_carp($self, "ignoring bad Max_buffer_length " . + "argument \"$maxbufsize\": it's not a positive integer"); + $maxbufsize = $prev; + } + + ## Adjust up values that are too small. + if ($maxbufsize < $minbufsize) { + $maxbufsize = $minbufsize; + } + + $s->{maxbufsize} = $maxbufsize; + } + + $prev; +} # end sub max_buffer_length + + +## Make ofs() synonymous with output_field_separator(). +*ofs = \&output_field_separator; + + +sub open { + my ($self) = @_; + my ( + $errmode, + $errno, + $host, + $ip_addr, + $port, + $s, + $timeout, + %args, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $timeout = $s->{time_out}; + $s->{timedout} = ''; + + if (@_ == 2) { # one positional arg given + $self->host($_[1]); + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?host$/i) { + $self->host($args{$_}); + } + elsif (/^-?port$/i) { + $self->port($args{$_}) + or return; + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + } + else { + &_croak($self, "bad named parameter \"$_\" given ", + "to " . ref($self) . "::open()"); + } + } + } + + ## If any args given, override corresponding instance data. + local $s->{errormode} = $errmode + if defined $errmode; + + ## Get host and port. + $host = $self->host; + $port = $self->port; + + ## Ensure we're already closed. + $self->close; + + ## Connect with or without a timeout. + if (defined($timeout) and &_have_alarm) { # use a timeout + ## Convert possible absolute timeout to relative timeout. + if ($timeout >= $^T) { # it's an absolute time + $timeout = $timeout - time; + } + + ## Ensure a valid timeout value for alarm. + if ($timeout < 1) { + $timeout = 1; + } + $timeout = int($timeout + 1.5); + + ## Connect to server, timing out if it takes too long. + eval { + ## Turn on timer. + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{ALRM} = sub { die "timed-out\n" }; + alarm $timeout; + + ## Lookup server's IP address. + $ip_addr = inet_aton $host + or die "unknown remote host: $host\n"; + + ## Create a socket and attach the filehandle to it. + socket $self, AF_INET, SOCK_STREAM, 0 + or die "problem creating socket: $!\n"; + + ## Open connection to server. + connect $self, sockaddr_in($port, $ip_addr) + or die "problem connecting to \"$host\", port $port: $!\n"; + }; + alarm 0; + + ## Check for error. + if ($@ =~ /^timed-out$/) { # time out failure + $s->{timedout} = 1; + $self->close; + if (!$ip_addr) { + return $self->error("unknown remote host: $host: ", + "name lookup timed-out"); + } + else { + return $self->error("problem connecting to \"$host\", ", + "port $port: connect timed-out"); + } + } + elsif ($@) { # hostname lookup or connect failure + $self->close; + chomp $@; + return $self->error($@); + } + } + else { # don't use a timeout + $timeout = undef; + + ## Lookup server's IP address. + $ip_addr = inet_aton $host + or return $self->error("unknown remote host: $host"); + + ## Create a socket and attach the filehandle to it. + socket $self, AF_INET, SOCK_STREAM, 0 + or return $self->error("problem creating socket: $!"); + + ## Open connection to server. + connect $self, sockaddr_in($port, $ip_addr) + or do { + $errno = "$!"; + $self->close; + return $self->error("problem connecting to \"$host\", ", + "port $port: $errno"); + }; + } + + select((select($self), $|=1)[$[]); # don't buffer writes + $s->{blksize} = &_optimal_blksize((stat $self)[11]); + $s->{buf} = ""; + $s->{eofile} = ''; + $s->{errormsg} = ""; + vec($s->{fdmask}='', fileno($self), 1) = 1; + $s->{last_line} = ""; + $s->{num_wrote} = 0; + $s->{opened} = 1; + $s->{pending_errormsg} = ""; + $s->{pushback_buf} = ""; + $s->{timedout} = ''; + $s->{unsent_opts} = ""; + &_reset_options($s->{opts}); + + 1; +} # end sub open + + +sub option_accept { + my ($self, @args) = @_; + my ( + $arg, + $option, + $s, + @opt_args, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + + ## Parse the named args. + while (($_, $arg) = splice @args, 0, 2) { + ## Verify and save arguments. + if (/^-?do$/i) { + ## Make sure a callback is defined. + return $self->error("usage: an option callback must already ", + "be defined when enabling with $_") + unless $s->{opt_cback}; + + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => '', + is_enable => 1, + }; + } + elsif (/^-?dont$/i) { + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => '', + is_enable => '', + }; + } + elsif (/^-?will$/i) { + ## Make sure a callback is defined. + return $self->error("usage: an option callback must already ", + "be defined when enabling with $_") + unless $s->{opt_cback}; + + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => 1, + is_enable => 1, + }; + } + elsif (/^-?wont$/i) { + $option = &_verify_telopt_arg($self, $arg, $_); + return unless defined $option; + push @opt_args, { option => $option, + is_remote => 1, + is_enable => '', + }; + } + else { + return $self->error('usage: $obj->option_accept(' . + '[Do => $telopt,] ', + '[Dont => $telopt,] ', + '[Will => $telopt,] ', + '[Wont => $telopt,]'); + } + } + + ## Set "receive ok" for options specified. + &_opt_accept($self, @opt_args); +} # end sub option_accept + + +sub option_callback { + my ($self, $callback) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{opt_cback}; + + if (@_ >= 2) { + unless (defined $callback and ref($callback) eq "CODE") { + &_carp($self, "ignoring Option_callback argument because it's " . + "not a code ref"); + $callback = $prev; + } + + $s->{opt_cback} = $callback; + } + + $prev; +} # end sub option_callback + + +sub option_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{opt_log}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{opt_log} = $fh; + } + + $fh; +} # end sub option_log + + +sub option_state { + my ($self, $option) = @_; + my ( + $opt_state, + $s, + %opt_state, + ); + + ## Ensure telnet option is non-negative integer. + $option = &_verify_telopt_arg($self, $option); + return unless defined $option; + + ## Init. + $s = *$self->{net_telnet}; + unless (defined $s->{opts}{$option}) { + &_set_default_option($s, $option); + } + + ## Return hashref to a copy of the values. + $opt_state = $s->{opts}{$option}; + %opt_state = %$opt_state; + \%opt_state; +} # end sub option_state + + +## Make ors() synonymous with output_record_separator(). +*ors = \&output_record_separator; + + +sub output_field_separator { + my ($self, $ofs) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{ofs}; + + if (@_ >= 2) { + unless (defined $ofs) { + $ofs = ""; + } + + $s->{ofs} = $ofs; + } + + $prev; +} # end sub output_field_separator + + +sub output_log { + my ($self, $name) = @_; + my ( + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $fh = $s->{outputlog}; + + if (@_ >= 2) { + unless (defined $name) { + $name = ""; + } + + $fh = &_fname_to_handle($self, $name) + or return; + $s->{outputlog} = $fh; + } + + $fh; +} # end sub output_log + + +sub output_record_separator { + my ($self, $ors) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{ors}; + + if (@_ >= 2) { + unless (defined $ors) { + $ors = ""; + } + + $s->{ors} = $ors; + } + + $prev; +} # end sub output_record_separator + + +sub port { + my ($self, $port) = @_; + my ( + $prev, + $s, + $service, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{port}; + + if (@_ >= 2) { + unless (defined $port) { + $port = ""; + } + + if (!$port) { + &_carp($self, "ignoring bad Port argument \"$port\""); + $port = $prev; + } + elsif ($port !~ /^\d+$/) { # port isn't all digits + $service = $port; + $port = getservbyname($service, "tcp"); + unless ($port) { + &_carp($self, "ignoring bad Port argument \"$service\": " . + "it's an unknown TCP service"); + $port = $prev; + } + } + + $s->{port} = $port; + } + + $prev; +} # end sub port + + +sub print { + my ($self) = shift; + my ( + $buf, + $fh, + $s, + ); + + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return $self->error("write error: filehandle isn't open") + unless $s->{opened}; + + ## Add field and record separators. + $buf = join($s->{ofs}, @_) . $s->{ors}; + + ## Log the output if requested. + if ($s->{outputlog}) { + &_log_print($s->{outputlog}, $buf); + } + + ## Convert native newlines to CR LF. + if (!$s->{bin_mode}) { + $buf =~ s(\n)(\015\012)g; + } + + ## Escape TELNET IAC and also CR not followed by LF. + if ($s->{telnet_mode}) { + $buf =~ s(\377)(\377\377)g; + &_escape_cr(\$buf); + } + + &_put($self, \$buf, "print"); +} # end sub print + + +sub print_length { + my ($self) = @_; + + *$self->{net_telnet}{num_wrote}; +} # end sub print_length + + +sub prompt { + my ($self, $prompt) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{cmd_prompt}; + + ## Parse args. + if (@_ == 2) { + $s->{cmd_prompt} = &_parse_prompt($self, $prompt); + } + + $prev; +} # end sub prompt + + +sub put { + my ($self) = @_; + my ( + $binmode, + $buf, + $errmode, + $is_timeout_arg, + $s, + $telnetmode, + $timeout, + %args, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + + ## Parse args. + if (@_ == 2) { # one positional arg given + $buf = $_[1]; + } + elsif (@_ > 2) { # named args given + ## Get the named args. + (undef, %args) = @_; + + ## Parse the named args. + foreach (keys %args) { + if (/^-?binmode$/i) { + $binmode = $args{$_}; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $args{$_}); + } + elsif (/^-?string$/i) { + $buf = $args{$_}; + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $args{$_}; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $args{$_}); + $is_timeout_arg = 1; + } + else { + &_croak($self, "bad named parameter \"$_\" given ", + "to " . ref($self) . "::put()"); + } + } + } + + ## If any args given, override corresponding instance data. + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + local $s->{time_out} = $timeout + if defined $is_timeout_arg; + + ## Check for errors. + return $self->error("write error: filehandle isn't open") + unless $s->{opened}; + + ## Log the output if requested. + if ($s->{outputlog}) { + &_log_print($s->{outputlog}, $buf); + } + + ## Convert native newlines to CR LF. + if (!$s->{bin_mode}) { + $buf =~ s(\n)(\015\012)g; + } + + ## Escape TELNET IAC and also CR not followed by LF. + if ($s->{telnet_mode}) { + $buf =~ s(\377)(\377\377)g; + &_escape_cr(\$buf); + } + + &_put($self, \$buf, "print"); +} # end sub put + + +## Make rs() synonymous input_record_separator(). +*rs = \&input_record_separator; + + +sub suboption_callback { + my ($self, $callback) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{subopt_cback}; + + if (@_ >= 2) { + unless (defined $callback and ref($callback) eq "CODE") { + &_carp($self,"ignoring Suboption_callback argument because it's " . + "not a code ref"); + $callback = $prev; + } + + $s->{subopt_cback} = $callback; + } + + $prev; +} # end sub suboption_callback + + +sub telnetmode { + my ($self, $mode) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{telnet_mode}; + + if (@_ >= 2) { + unless (defined $mode) { + $mode = 0; + } + + $s->{telnet_mode} = $mode; + } + + $prev; +} # end sub telnetmode + + +sub timed_out { + my ($self, $value) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{timedout}; + + if (@_ >= 2) { + unless (defined $value) { + $value = ""; + } + + $s->{timedout} = $value; + } + + $prev; +} # end sub timed_out + + +sub timeout { + my ($self, $timeout) = @_; + my ( + $prev, + $s, + ); + + $s = *$self->{net_telnet}; + $prev = $s->{time_out}; + + if (@_ >= 2) { + $s->{time_out} = &_parse_timeout($self, $timeout); + } + + $prev; +} # end sub timeout + + +sub waitfor { + my ($self, @args) = @_; + my ( + $arg, + $binmode, + $endtime, + $errmode, + $len, + $match, + $match_op, + $pos, + $prematch, + $s, + $search, + $search_cond, + $telnetmode, + $timeout, + @match_cond, + @match_ops, + @search_cond, + @string_cond, + @warns, + ); + local $_; + + ## Init. + $s = *$self->{net_telnet}; + $s->{timedout} = ''; + return if $s->{eofile}; + return unless @args; + $timeout = $s->{time_out}; + + ## Code template used to build string match conditional. + ## Values between array elements must be supplied later. + @string_cond = + ('if (($pos = index $s->{buf}, ', ') > -1) { + $len = ', '; + $prematch = substr $s->{buf}, 0, $pos; + $match = substr $s->{buf}, $pos, $len; + substr($s->{buf}, 0, $pos + $len) = ""; + last; + }'); + + ## Code template used to build pattern match conditional. + ## Values between array elements must be supplied later. + @match_cond = + ('if ($s->{buf} =~ ', ') { + $prematch = $`; + $match = $&; + substr($s->{buf}, 0, length($`) + length($&)) = ""; + last; + }'); + + ## Parse args. + if (@_ == 2) { # one positional arg given + $arg = $_[1]; + + ## Fill in the blanks in the code template. + push @match_ops, $arg; + push @search_cond, join("", $match_cond[0], $arg, $match_cond[1]); + } + elsif (@_ > 2) { # named args given + ## Parse the named args. + while (($_, $arg) = splice @args, 0, 2) { + if (/^-?binmode$/i) { + $binmode = $arg; + unless (defined $binmode) { + $binmode = 0; + } + } + elsif (/^-?errmode$/i) { + $errmode = &_parse_errmode($self, $arg); + } + elsif (/^-?match$/i) { + ## Fill in the blanks in the code template. + push @match_ops, $arg; + push @search_cond, join("", + $match_cond[0], $arg, $match_cond[1]); + } + elsif (/^-?string$/i) { + ## Fill in the blanks in the code template. + $arg =~ s/'/\\'/g; # quote ticks + push @search_cond, join("", + $string_cond[0], "'$arg'", + $string_cond[1], length($arg), + $string_cond[2]); + } + elsif (/^-?telnetmode$/i) { + $telnetmode = $arg; + unless (defined $telnetmode) { + $telnetmode = 0; + } + } + elsif (/^-?timeout$/i) { + $timeout = &_parse_timeout($self, $arg); + } + else { + &_croak($self, "bad named parameter \"$_\" given " . + "to " . ref($self) . "::waitfor()"); + } + } + } + + ## If any args given, override corresponding instance data. + local $s->{errormode} = $errmode + if defined $errmode; + local $s->{bin_mode} = $binmode + if defined $binmode; + local $s->{telnet_mode} = $telnetmode + if defined $telnetmode; + + ## Check for bad match operator argument. + foreach $match_op (@match_ops) { + return $self->error("missing opening delimiter of match operator ", + "in argument \"$match_op\" given to ", + ref($self) . "::waitfor()") + unless $match_op =~ m(^\s*/) or $match_op =~ m(^\s*m\s*\W); + } + + ## Construct conditional to check for requested string and pattern matches. + ## Turn subsequent "if"s into "elsif". + $search_cond = join "\n\tels", @search_cond; + + ## Construct loop to fill buffer until string/pattern, timeout, or eof. + $search = join "", " + while (1) {\n\t", + $search_cond, ' + &_fillbuf($self, $s, $endtime) + or do { + last if $s->{timedout}; + $self->close; + last; + }; + }'; + + ## Set wall time when we timeout. + $endtime = &_endtime($timeout); + + ## Run the loop. + { + local $^W = 1; + local $SIG{"__WARN__"} = sub { push @warns, @_ }; + local $s->{errormode} = "return"; + $s->{errormsg} = ""; + eval $search; + } + + ## Check for failure. + return $self->error("pattern match timed-out") if $s->{timedout}; + return $self->error($s->{errormsg}) if $s->{errormsg} ne ""; + return $self->error("pattern match read eof") if $s->{eofile}; + + ## Check for Perl syntax errors or warnings. + if ($@ or @warns) { + foreach $match_op (@match_ops) { + &_match_check($self, $match_op) + or return; + } + return $self->error($@) if $@; + return $self->error(@warns) if @warns; + } + + wantarray ? ($prematch, $match) : 1; +} # end sub waitfor + + +######################## Private Subroutines ######################### + + +sub _append_lineno { + my ($obj, @msgs) = @_; + my ( + $file, + $line, + $pkg, + ); + + ## Find the caller that's not in object's class or one of its base classes. + ($pkg, $file , $line) = &_user_caller($obj); + join("", @msgs, " at ", $file, " line ", $line, "\n"); +} # end sub _append_lineno + + +sub _carp { + warn &_append_lineno(@_); +} # end sub _carp + + +sub _croak { + die &_append_lineno(@_); +} # end sub _croak + + +sub _endtime { + my ($interval) = @_; + + ## Compute wall time when timeout occurs. + if (defined $interval) { + if ($interval >= $^T) { # it's already an absolute time + return $interval; + } + elsif ($interval > 0) { # it's relative to the current time + return int(time + 1.5 + $interval); + } + else { # it's a one time poll + return 0; + } + } + else { # there's no timeout + return undef; + } +} # end sub _endtime + + +sub _escape_cr { + my ($string) = @_; + my ( + $nextchar, + ); + my $pos = 0; + + ## Convert all CR (not followed by LF) to CR NULL. + while (($pos = index($$string, "\015", $pos)) > -1) { + $nextchar = substr $$string, $pos + 1, 1; + + substr($$string, $pos, 1) = "\015\000" + unless $nextchar eq "\012"; + + $pos++; + } + + 1; +} # end sub _escape_cr + + +sub _fillbuf { + my ($self, $s, $endtime) = @_; + my ( + $msg, + $nfound, + $nread, + $pushback_len, + $read_pos, + $ready, + $timed_out, + $timeout, + $unparsed_pos, + ); + + ## If error from last read not yet reported then do it now. + if ($s->{pending_errormsg}) { + $msg = $s->{pending_errormsg}; + $s->{pending_errormsg} = ""; + return $self->error($msg); + } + + return unless $s->{opened}; + + while (1) { + ## Maximum buffer size exceeded? + return $self->error("maximum input buffer length exceeded: ", + $s->{maxbufsize}, " bytes") + unless length($s->{buf}) <= $s->{maxbufsize}; + + ## Determine how long to wait for input ready. + ($timed_out, $timeout) = &_timeout_interval($endtime); + if ($timed_out) { + $s->{timedout} = 1; + return $self->error("read timed-out"); + } + + ## Wait for input ready. + $nfound = select $ready=$s->{fdmask}, "", "", $timeout; + + ## Handle any errors while waiting. + if (!defined $nfound or $nfound <= 0) { # input not ready + if (defined $nfound and $nfound == 0) { # timed-out + $s->{timedout} = 1; + return $self->error("read timed-out"); + } + else { # error waiting for input ready + next if $! =~ /^interrupted/i; + + $s->{opened} = ''; + return $self->error("read error: $!"); + } + } + + ## Append to buffer any partially processed telnet or CR sequence. + $pushback_len = length $s->{pushback_buf}; + if ($pushback_len) { + $s->{buf} .= $s->{pushback_buf}; + $s->{pushback_buf} = ""; + } + + ## Read the waiting data. + $read_pos = length $s->{buf}; + $unparsed_pos = $read_pos - $pushback_len; + $nread = sysread $self, $s->{buf}, $s->{blksize}, $read_pos; + + ## Handle any read errors. + if (!defined $nread) { # read failed + next if $! =~ /^interrupted/i; # restart interrupted syscall + + $s->{opened} = ''; + return $self->error("read error: $!"); + } + + ## Handle eof. + if ($nread == 0) { # eof read + $s->{opened} = ''; + return; + } + + ## Display network traffic if requested. + if ($s->{dumplog}) { + &_log_dump('<', $s->{dumplog}, \$s->{buf}, $read_pos); + } + + ## Process any telnet commands in the data stream. + if ($s->{telnet_mode} and index($s->{buf},"\377",$unparsed_pos) > -1) { + &_interpret_tcmd($self, $s, $unparsed_pos); + } + + ## Process any carriage-return sequences in the data stream. + &_interpret_cr($s, $unparsed_pos); + + ## Read again if all chars read were consumed as telnet cmds. + next if $unparsed_pos >= length $s->{buf}; + + ## Log the input if requested. + if ($s->{inputlog}) { + &_log_print($s->{inputlog}, substr($s->{buf}, $unparsed_pos)); + } + + ## Save the last line read. + &_save_lastline($s); + + ## We've successfully read some data into the buffer. + last; + } # end while(1) + + 1; +} # end sub _fillbuf + + +sub _flush_opts { + my ($self) = @_; + my ( + $option_chars, + ); + my $s = *$self->{net_telnet}; + + ## Get option and clear the output buf. + $option_chars = $s->{unsent_opts}; + $s->{unsent_opts} = ""; + + ## Try to send options without waiting. + { + local $s->{errormode} = "return"; + local $s->{time_out} = 0; + &_put($self, \$option_chars, "telnet option negotiation") + or do { + ## Save chars not printed for later. + substr($option_chars, 0, $self->print_length) = ""; + $s->{unsent_opts} .= $option_chars; + }; + } + + 1; +} # end sub _flush_opts + + +sub _fname_to_handle { + my ($self, $fh) = @_; + my ( + $filename, + ); + + ## Ensure valid input. + return "" + unless defined $fh and (ref $fh or length $fh); + + ## Open a new filehandle if input is a filename. + no strict "refs"; + if (!ref($fh) and !defined(fileno $fh)) { # fh is a filename + $filename = $fh; + $fh = &_new_handle(); + CORE::open $fh, "> $filename" + or return $self->error("problem creating $filename: $!"); + } + + select((select($fh), $|=1)[$[]); # don't buffer writes + $fh; +} # end sub _fname_to_handle + + +sub _have_alarm { + eval { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{ALRM} = sub { die }; + alarm 0; + }; + + ! $@; +} # end sub _have_alarm + + +sub _interpret_cr { + my ($s, $pos) = @_; + my ( + $nextchar, + ); + + while (($pos = index($s->{buf}, "\015", $pos)) > -1) { + $nextchar = substr($s->{buf}, $pos + 1, 1); + if ($nextchar eq "\0") { + ## Convert CR NULL to CR when in telnet mode. + if ($s->{telnet_mode}) { + substr($s->{buf}, $pos + 1, 1) = ""; + } + } + elsif ($nextchar eq "\012") { + ## Convert CR LF to newline when not in binary mode. + if (!$s->{bin_mode}) { + substr($s->{buf}, $pos, 2) = "\n"; + } + } + elsif (!length($nextchar) and ($s->{telnet_mode} or !$s->{bin_mode})) { + ## Save CR in alt buffer for possible CR LF or CR NULL conversion. + $s->{pushback_buf} .= "\015"; + chop $s->{buf}; + } + + $pos++; + } + + 1; +} # end sub _interpret_cr + + +sub _interpret_tcmd { + my ($self, $s, $offset) = @_; + my ( + $callback, + $endpos, + $nextchar, + $option, + $parameters, + $pos, + $subcmd, + ); + local $_; + + ## Parse telnet commands in the data stream. + $pos = $offset; + while (($pos = index $s->{buf}, "\377", $pos) > -1) { # unprocessed IAC + $nextchar = substr $s->{buf}, $pos + 1, 1; + + ## Save command if it's only partially read. + if (!length $nextchar) { + $s->{pushback_buf} .= "\377"; + chop $s->{buf}; + last; + } + + if ($nextchar eq "\377") { # IAC is escaping "\377" char + ## Remove escape char from data stream. + substr($s->{buf}, $pos, 1) = ""; + $pos++; + } + elsif ($nextchar eq "\375" or $nextchar eq "\373" or + $nextchar eq "\374" or $nextchar eq "\376") { # opt negotiation + $option = substr $s->{buf}, $pos + 2, 1; + + ## Save command if it's only partially read. + if (!length $option) { + $s->{pushback_buf} .= "\377" . $nextchar; + chop $s->{buf}; + chop $s->{buf}; + last; + } + + ## Remove command from data stream. + substr($s->{buf}, $pos, 3) = ""; + + ## Handle option negotiation. + &_negotiate_recv($self, $s, $nextchar, ord($option), $pos); + } + elsif ($nextchar eq "\372") { # start of subnegotiation parameters + ## Save command if it's only partially read. + $endpos = index $s->{buf}, "\360", $pos; + if ($endpos == -1) { + $s->{pushback_buf} .= substr $s->{buf}, $pos; + substr($s->{buf}, $pos) = ""; + last; + } + + ## Remove subnegotiation cmd from buffer. + $subcmd = substr($s->{buf}, $pos, $endpos - $pos + 1); + substr($s->{buf}, $pos, $endpos - $pos + 1) = ""; + + ## Invoke subnegotiation callback. + if ($s->{subopt_cback} and length($subcmd) >= 5) { + $option = unpack "C", substr($subcmd, 2, 1); + if (length($subcmd) >= 6) { + $parameters = substr $subcmd, 3, length($subcmd) - 5; + } + else { + $parameters = ""; + } + + $callback = $s->{subopt_cback}; + &$callback($self, $option, $parameters); + } + } + else { # various two char telnet commands + ## Ignore and remove command from data stream. + substr($s->{buf}, $pos, 2) = ""; + } + } + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + 1; +} # end sub _interpret_tcmd + + +sub _io_socket_include { + local $SIG{"__DIE__"} = "DEFAULT"; + eval "require IO::Socket"; +} # end sub io_socket_include + + +sub _log_dump { + my ($direction, $fh, $data, $offset, $len) = @_; + my ( + $addr, + $hexvals, + $line, + ); + + $addr = 0; + $len = length($$data) - $offset + if !defined $len; + return 1 if $len <= 0; + + ## Print data in dump format. + while ($len > 0) { + ## Convert up to the next 16 chars to hex, padding w/ spaces. + if ($len >= 16) { + $line = substr $$data, $offset, 16; + } + else { + $line = substr $$data, $offset, $len; + } + $hexvals = unpack("H*", $line); + $hexvals .= ' ' x (32 - length $hexvals); + + ## Place in 16 columns, each containing two hex digits. + $hexvals = sprintf("%s %s %s %s " x 4, + unpack("a2" x 16, $hexvals)); + + ## For the ASCII column, change unprintable chars to a period. + $line =~ s/[\000-\037,\177-\237]/./g; + + ## Print the line in dump format. + &_log_print($fh, sprintf("%s 0x%5.5lx: %s%s\n", + $direction, $addr, $hexvals, $line)); + + $addr += 16; + $offset += 16; + $len -= 16; + } + + &_log_print($fh, "\n"); + + 1; +} # end sub _log_dump + + +sub _log_option { + my ($fh, $direction, $request, $option) = @_; + my ( + $name, + ); + + if ($option >= 0 and $option <= $#Telopts) { + $name = $Telopts[$option]; + } + else { + $name = $option; + } + + &_log_print($fh, "$direction $request $name\n"); +} # end sub _log_option + + +sub _log_print { + my ($fh, $buf) = @_; + local $\ = ''; + + if (ref($fh) and ref($fh) ne "GLOB") { # fh is blessed ref + $fh->print($buf); + } + else { # fh isn't blessed ref + print $fh $buf; + } +} # end sub _log_print + + +sub _match_check { + my ($self, $code) = @_; + my $error; + my @warns = (); + + ## Use eval to check for syntax errors or warnings. + { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{"__WARN__"} = sub { push @warns, @_ }; + local $^W = 1; + local $_ = ''; + eval "\$_ =~ $code;"; + } + if ($@) { + ## Remove useless lines numbers from message. + ($error = $@) =~ s/ at \(eval \d+\) line \d+.?//; + chomp $error; + return $self->error("bad match operator: $error"); + } + elsif (@warns) { + ## Remove useless lines numbers from message. + ($error = shift @warns) =~ s/ at \(eval \d+\) line \d+.?//; + $error =~ s/ while "strict subs" in use//; + chomp $error; + return $self->error("bad match operator: $error"); + } + + 1; +} # end sub _match_check + + +sub _negotiate_callback { + my ($self, $opt, $is_remote, $is_enabled, $was_enabled, $opt_bufpos) = @_; + my ( + $callback, + $s, + ); + local $_; + + ## Keep track of remote echo. + if ($is_remote and $opt == &TELOPT_ECHO) { # received WILL or WONT ECHO + $s = *$self->{net_telnet}; + + if ($is_enabled and !$was_enabled) { # received WILL ECHO + $s->{remote_echo} = 1; + } + elsif (!$is_enabled and $was_enabled) { # received WONT ECHO + $s->{remote_echo} = ''; + } + } + + ## Invoke callback, if there is one. + $callback = $self->option_callback; + if ($callback) { + &$callback($self, $opt, $is_remote, + $is_enabled, $was_enabled, $opt_bufpos); + } + + 1; +} # end sub _negotiate_callback + + +sub _negotiate_recv { + my ($self, $s, $opt_request, $opt, $opt_bufpos) = @_; + + ## Ensure data structure exists for this option. + unless (defined $s->{opts}{$opt}) { + &_set_default_option($s, $opt); + } + + ## Process the option. + if ($opt_request eq "\376") { # DONT + &_negotiate_recv_disable($self, $s, $opt, "dont", $opt_bufpos, + $s->{opts}{$opt}{local_enable_ok}, + \$s->{opts}{$opt}{local_enabled}, + \$s->{opts}{$opt}{local_state}); + } + elsif ($opt_request eq "\375") { # DO + &_negotiate_recv_enable($self, $s, $opt, "do", $opt_bufpos, + $s->{opts}{$opt}{local_enable_ok}, + \$s->{opts}{$opt}{local_enabled}, + \$s->{opts}{$opt}{local_state}); + } + elsif ($opt_request eq "\374") { # WONT + &_negotiate_recv_disable($self, $s, $opt, "wont", $opt_bufpos, + $s->{opts}{$opt}{remote_enable_ok}, + \$s->{opts}{$opt}{remote_enabled}, + \$s->{opts}{$opt}{remote_state}); + } + elsif ($opt_request eq "\373") { # WILL + &_negotiate_recv_enable($self, $s, $opt, "will", $opt_bufpos, + $s->{opts}{$opt}{remote_enable_ok}, + \$s->{opts}{$opt}{remote_enabled}, + \$s->{opts}{$opt}{remote_state}); + } + else { # internal error + die; + } + + 1; +} # end sub _negotiate_recv + + +sub _negotiate_recv_disable { + my ($self, $s, $opt, $opt_request, + $opt_bufpos, $enable_ok, $is_enabled, $state) = @_; + my ( + $ack, + $disable_cmd, + $enable_cmd, + $is_remote, + $nak, + $was_enabled, + ); + + ## What do we use to request enable/disable or respond with ack/nak. + if ($opt_request eq "wont") { + $enable_cmd = "\377\375" . pack("C", $opt); # do command + $disable_cmd = "\377\376" . pack("C", $opt); # dont command + $is_remote = 1; + $ack = "DO"; + $nak = "DONT"; + + &_log_option($s->{opt_log}, "RCVD", "WONT", $opt) + if $s->{opt_log}; + } + elsif ($opt_request eq "dont") { + $enable_cmd = "\377\373" . pack("C", $opt); # will command + $disable_cmd = "\377\374" . pack("C", $opt); # wont command + $is_remote = ''; + $ack = "WILL"; + $nak = "WONT"; + + &_log_option($s->{opt_log}, "RCVD", "DONT", $opt) + if $s->{opt_log}; + } + else { # internal error + die; + } + + ## Respond to WONT or DONT based on the current negotiation state. + if ($$state eq "no") { # state is already disabled + } + elsif ($$state eq "yes") { # they're initiating disable + $$is_enabled = ''; + $$state = "no"; + + ## Send positive acknowledgment. + $s->{unsent_opts} .= $disable_cmd; + &_log_option($s->{opt_log}, "SENT", $nak, $opt) + if $s->{opt_log}; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantno") { # they sent positive ack + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantno opposite") { # pos ack but we changed our mind + ## Indicate disabled but now we want to enable. + $$is_enabled = ''; + $$state = "wantyes"; + + ## Send queued request. + $s->{unsent_opts} .= $enable_cmd; + &_log_option($s->{opt_log}, "SENT", $ack, $opt) + if $s->{opt_log}; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes") { # they sent negative ack + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes opposite") { # nak but we changed our mind + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } +} # end sub _negotiate_recv_disable + + +sub _negotiate_recv_enable { + my ($self, $s, $opt, $opt_request, + $opt_bufpos, $enable_ok, $is_enabled, $state) = @_; + my ( + $ack, + $disable_cmd, + $enable_cmd, + $is_remote, + $nak, + $was_enabled, + ); + + ## What we use to send enable/disable request or send ack/nak response. + if ($opt_request eq "will") { + $enable_cmd = "\377\375" . pack("C", $opt); # do command + $disable_cmd = "\377\376" . pack("C", $opt); # dont command + $is_remote = 1; + $ack = "DO"; + $nak = "DONT"; + + &_log_option($s->{opt_log}, "RCVD", "WILL", $opt) + if $s->{opt_log}; + } + elsif ($opt_request eq "do") { + $enable_cmd = "\377\373" . pack("C", $opt); # will command + $disable_cmd = "\377\374" . pack("C", $opt); # wont command + $is_remote = ''; + $ack = "WILL"; + $nak = "WONT"; + + &_log_option($s->{opt_log}, "RCVD", "DO", $opt) + if $s->{opt_log}; + } + else { # internal error + die; + } + + ## Save current enabled state. + $was_enabled = $$is_enabled; + + ## Respond to WILL or DO based on the current negotiation state. + if ($$state eq "no") { # they're initiating enable + if ($enable_ok) { # we agree they/us should enable + $$is_enabled = 1; + $$state = "yes"; + + ## Send positive acknowledgment. + $s->{unsent_opts} .= $enable_cmd; + &_log_option($s->{opt_log}, "SENT", $ack, $opt) + if $s->{opt_log}; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + else { # we disagree they/us should enable + ## Send negative acknowledgment. + $s->{unsent_opts} .= $disable_cmd; + &_log_option($s->{opt_log}, "SENT", $nak, $opt) + if $s->{opt_log}; + } + } + elsif ($$state eq "yes") { # state is already enabled + } + elsif ($$state eq "wantno") { # error: our disable req answered by enable + $$is_enabled = ''; + $$state = "no"; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantno opposite") { # err: disable req answerd by enable + $$is_enabled = 1; + $$state = "yes"; + + ## Invoke callbacks. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes") { # they sent pos ack + $$is_enabled = 1; + $$state = "yes"; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + elsif ($$state eq "wantyes opposite") { # pos ack but we changed our mind + ## Indicate enabled but now we want to disable. + $$is_enabled = 1; + $$state = "wantno"; + + ## Inform other side we changed our mind. + $s->{unsent_opts} .= $disable_cmd; + &_log_option($s->{opt_log}, "SENT", $nak, $opt) + if $s->{opt_log}; + + ## Invoke callback. + &_negotiate_callback($self, $opt, $is_remote, + $$is_enabled, $was_enabled, $opt_bufpos); + } + + 1; +} # end sub _negotiate_recv_enable + + +sub _new_handle { + if ($INC{"IO/Handle.pm"}) { + return IO::Handle->new; + } + else { + require FileHandle; + return FileHandle->new; + } +} # end sub _new_handle + + +sub _next_getlines { + my ($self, $s) = @_; + my ( + $len, + $line, + $pos, + @lines, + ); + + ## Fill buffer and get first line. + $line = $self->getline + or return; + push @lines, $line; + + ## Extract subsequent lines from buffer. + while (($pos = index($s->{buf}, $s->{rs})) != -1) { + $len = $pos + length $s->{rs}; + push @lines, substr($s->{buf}, 0, $len); + substr($s->{buf}, 0, $len) = ""; + } + + @lines; +} # end sub _next_getlines + + +sub _opt_accept { + my ($self, @args) = @_; + my ( + $arg, + $option, + $s, + ); + + ## Init. + $s = *$self->{net_telnet}; + + foreach $arg (@args) { + ## Ensure data structure defined for this option. + $option = $arg->{option}; + if (!defined $s->{opts}{$option}) { + &_set_default_option($s, $option); + } + + ## Save whether we'll accept or reject this option. + if ($arg->{is_remote}) { + $s->{opts}{$option}{remote_enable_ok} = $arg->{is_enable}; + } + else { + $s->{opts}{$option}{local_enable_ok} = $arg->{is_enable}; + } + } + + 1; +} # end sub _opt_accept + + +sub _optimal_blksize { + my ($blksize) = @_; + local $^W = ''; # avoid non-numeric warning for ms-windows blksize of "" + + ## Use default when block size is invalid. + return 8192 + unless defined $blksize and $blksize >= 1 and $blksize <= 1_048_576; + + $blksize; +} # end sub _optimal_blksize + + +sub _parse_cmd_remove_mode { + my ($self, $mode) = @_; + + if (!defined $mode) { + $mode = 0; + } + elsif ($mode =~ /^\s*auto\s*$/i) { + $mode = "auto"; + } + elsif ($mode !~ /^\d+$/) { + &_carp($self, "ignoring bad Cmd_remove_mode " . + "argument \"$mode\": it's not \"auto\" or a " . + "non-negative integer"); + $mode = *$self->{net_telnet}{cmd_rm_mode}; + } + + $mode; +} # end sub _parse_cmd_remove_mode + + +sub _parse_errmode { + my ($self, $errmode) = @_; + + ## Set the error mode. + if (!defined $errmode) { + &_carp($self, "ignoring undefined Errmode argument"); + $errmode = *$self->{net_telnet}{errormode}; + } + elsif ($errmode =~ /^\s*return\s*$/i) { + $errmode = "return"; + } + elsif ($errmode =~ /^\s*die\s*$/i) { + $errmode = "die"; + } + elsif (ref($errmode) eq "CODE") { + } + elsif (ref($errmode) eq "ARRAY") { + unless (ref($errmode->[0]) eq "CODE") { + &_carp($self, "ignoring bad Errmode argument: " . + "first list item isn't a code ref"); + $errmode = *$self->{net_telnet}{errormode}; + } + } + else { + &_carp($self, "ignoring bad Errmode argument \"$errmode\""); + $errmode = *$self->{net_telnet}{errormode}; + } + + $errmode; +} # end sub _parse_errmode + + +sub _parse_input_record_separator { + my ($self, $rs) = @_; + + unless (defined $rs and length $rs) { + &_carp($self, "ignoring null Input_record_separator argument"); + $rs = *$self->{net_telnet}{rs}; + } + + $rs; +} # end sub _parse_input_record_separator + + +sub _parse_prompt { + my ($self, $prompt) = @_; + + unless (defined $prompt) { + $prompt = ""; + } + + unless ($prompt =~ m(^\s*/) or $prompt =~ m(^\s*m\s*\W)) { + &_carp($self, "ignoring bad Prompt argument \"$prompt\": " . + "missing opening delimiter of match operator"); + $prompt = *$self->{net_telnet}{cmd_prompt}; + } + + $prompt; +} # end sub _parse_prompt + + +sub _parse_timeout { + my ($self, $timeout) = @_; + + ## Ensure valid timeout. + if (defined $timeout) { + ## Test for non-numeric or negative values. + eval { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{"__WARN__"} = sub { die "non-numeric\n" }; + local $^W = 1; + $timeout *= 1; + }; + if ($@) { # timeout arg is non-numeric + &_carp($self, + "ignoring non-numeric Timeout argument \"$timeout\""); + $timeout = *$self->{net_telnet}{time_out}; + } + elsif ($timeout < 0) { # timeout arg is negative + &_carp($self, "ignoring negative Timeout argument \"$timeout\""); + $timeout = *$self->{net_telnet}{time_out}; + } + } + + $timeout; +} # end sub _parse_timeout + + +sub _put { + my ($self, $buf, $subname) = @_; + my ( + $endtime, + $len, + $nfound, + $nwrote, + $offset, + $ready, + $s, + $timed_out, + $timeout, + $zero_wrote_count, + ); + + ## Init. + $s = *$self->{net_telnet}; + $s->{num_wrote} = 0; + $zero_wrote_count = 0; + $offset = 0; + $len = length $$buf; + $endtime = &_endtime($s->{time_out}); + + return $self->error("write error: filehandle isn't open") + unless $s->{opened}; + + ## Try to send any waiting option negotiation. + if (length $s->{unsent_opts}) { + &_flush_opts($self); + } + + ## Write until all data blocks written. + while ($len) { + ## Determine how long to wait for output ready. + ($timed_out, $timeout) = &_timeout_interval($endtime); + if ($timed_out) { + $s->{timedout} = 1; + return $self->error("$subname timed-out"); + } + + ## Wait for output ready. + $nfound = select "", $ready=$s->{fdmask}, "", $timeout; + + ## Handle any errors while waiting. + if (!defined $nfound or $nfound <= 0) { # output not ready + if (defined $nfound and $nfound == 0) { # timed-out + $s->{timedout} = 1; + return $self->error("$subname timed-out"); + } + else { # error waiting for output ready + next if $! =~ /^interrupted/i; + + $s->{opened} = ''; + return $self->error("write error: $!"); + } + } + + ## Write the data. + $nwrote = syswrite $self, $$buf, $len, $offset; + + ## Handle any write errors. + if (!defined $nwrote) { # write failed + next if $! =~ /^interrupted/i; # restart interrupted syscall + + $s->{opened} = ''; + return $self->error("write error: $!"); + } + elsif ($nwrote == 0) { # zero chars written + ## Try ten more times to write the data. + if ($zero_wrote_count++ <= 10) { + &_sleep(0.01); + next; + } + + $s->{opened} = ''; + return $self->error("write error: zero length write: $!"); + } + + ## Display network traffic if requested. + if ($s->{dumplog}) { + &_log_dump('>', $s->{dumplog}, $buf, $offset, $nwrote); + } + + ## Increment. + $s->{num_wrote} += $nwrote; + $offset += $nwrote; + $len -= $nwrote; + } + + 1; +} # end sub _put + + +sub _qualify_fh { + my ($obj, $name) = @_; + my ( + $user_class, + ); + local $_; + + ## Get user's package name. + ($user_class) = &_user_caller($obj); + + ## Ensure name is qualified with a package name. + $name = qualify($name, $user_class); + + ## If it's not already, make it a typeglob ref. + if (!ref $name) { + no strict; + local $^W = 0; + + $name =~ s/^\*+//; + $name = eval "\\*$name"; + return unless ref $name; + } + + $name; +} # end sub _qualify_fh + + +sub _reset_options { + my ($opts) = @_; + my ( + $opt, + ); + + foreach $opt (keys %$opts) { + $opts->{$opt}{remote_enabled} = ''; + $opts->{$opt}{remote_state} = "no"; + $opts->{$opt}{local_enabled} = ''; + $opts->{$opt}{local_state} = "no"; + } + + 1; +} # end sub _reset_options + + +sub _save_lastline { + my ($s) = @_; + my ( + $firstpos, + $lastpos, + $len_w_sep, + $len_wo_sep, + $offset, + ); + my $rs = "\n"; + + if (($lastpos = rindex $s->{buf}, $rs) > -1) { # eol found + while (1) { + ## Find beginning of line. + $firstpos = rindex $s->{buf}, $rs, $lastpos - 1; + if ($firstpos == -1) { + $offset = 0; + } + else { + $offset = $firstpos + length $rs; + } + + ## Determine length of line with and without separator. + $len_wo_sep = $lastpos - $offset; + $len_w_sep = $len_wo_sep + length $rs; + + ## Save line if it's not blank. + if (substr($s->{buf}, $offset, $len_wo_sep) + !~ /^\s*$/) + { + $s->{last_line} = substr($s->{buf}, + $offset, + $len_w_sep); + last; + } + + last if $firstpos == -1; + + $lastpos = $firstpos; + } + } + + 1; +} # end sub _save_lastline + + +sub _set_default_option { + my ($s, $option) = @_; + + $s->{opts}{$option} = { + remote_enabled => '', + remote_state => "no", + remote_enable_ok => '', + local_enabled => '', + local_state => "no", + local_enable_ok => '', + }; +} # end sub _set_default_option + + +sub _sleep { + my ($secs) = @_; + my $bitmask = ""; + local *SOCK; + + socket SOCK, AF_INET, SOCK_STREAM, 0; + vec($bitmask, fileno(SOCK), 1) = 1; + select $bitmask, "", "", $secs; + CORE::close SOCK; + + 1; +} # end sub _sleep + + +sub _timeout_interval { + my ($endtime) = @_; + my ( + $timeout, + ); + + ## Return timed-out boolean and timeout interval. + if (defined $endtime) { + ## Is it a one-time poll. + return ('', 0) if $endtime == 0; + + ## Calculate the timeout interval. + $timeout = $endtime - time; + + ## Did we already timeout. + return (1, 0) unless $timeout > 0; + + return ('', $timeout); + } + else { # there is no timeout + return ('', undef); + } +} # end sub _timeout_interval + + +sub _user_caller { + my ($obj) = @_; + my ( + $class, + $curr_pkg, + $file, + $i, + $line, + $pkg, + %isa, + @isa, + ); + local $_; + + ## Create a boolean hash to test for isa. Make sure current + ## package and the object's class are members. + $class = ref $obj; + @isa = eval "\@${class}::ISA"; + push @isa, $class; + ($curr_pkg) = caller 1; + push @isa, $curr_pkg; + %isa = map { $_ => 1 } @isa; + + ## Search back in call frames for a package that's not in isa. + $i = 1; + while (($pkg, $file, $line) = caller ++$i) { + next if $isa{$pkg}; + + return ($pkg, $file, $line); + } + + ## If not found, choose outer most call frame. + ($pkg, $file, $line) = caller --$i; + return ($pkg, $file, $line); +} # end sub _user_caller + + +sub _verify_telopt_arg { + my ($self, $option, $argname) = @_; + + ## If provided, use argument name in error message. + if (defined $argname) { + $argname = "for arg $argname"; + } + else { + $argname = ""; + } + + ## Ensure telnet option is a non-negative integer. + eval { + local $SIG{"__DIE__"} = "DEFAULT"; + local $SIG{"__WARN__"} = sub { die "non-numeric\n" }; + local $^W = 1; + $option = abs(int $option); + }; + return $self->error("bad telnet option $argname: non-numeric") + if $@; + + return $self->error("bad telnet option $argname: option > 255") + unless $option <= 255; + + $option; +} # end sub _verify_telopt_arg + + +######################## Exported Constants ########################## + + +sub TELNET_IAC () {255}; # interpret as command: +sub TELNET_DONT () {254}; # you are not to use option +sub TELNET_DO () {253}; # please, you use option +sub TELNET_WONT () {252}; # I won't use option +sub TELNET_WILL () {251}; # I will use option +sub TELNET_SB () {250}; # interpret as subnegotiation +sub TELNET_GA () {249}; # you may reverse the line +sub TELNET_EL () {248}; # erase the current line +sub TELNET_EC () {247}; # erase the current character +sub TELNET_AYT () {246}; # are you there +sub TELNET_AO () {245}; # abort output--but let prog finish +sub TELNET_IP () {244}; # interrupt process--permanently +sub TELNET_BREAK () {243}; # break +sub TELNET_DM () {242}; # data mark--for connect. cleaning +sub TELNET_NOP () {241}; # nop +sub TELNET_SE () {240}; # end sub negotiation +sub TELNET_EOR () {239}; # end of record (transparent mode) +sub TELNET_ABORT () {238}; # Abort process +sub TELNET_SUSP () {237}; # Suspend process +sub TELNET_EOF () {236}; # End of file +sub TELNET_SYNCH () {242}; # for telfunc calls + +sub TELOPT_BINARY () {0}; # Binary Transmission +sub TELOPT_ECHO () {1}; # Echo +sub TELOPT_RCP () {2}; # Reconnection +sub TELOPT_SGA () {3}; # Suppress Go Ahead +sub TELOPT_NAMS () {4}; # Approx Message Size Negotiation +sub TELOPT_STATUS () {5}; # Status +sub TELOPT_TM () {6}; # Timing Mark +sub TELOPT_RCTE () {7}; # Remote Controlled Trans and Echo +sub TELOPT_NAOL () {8}; # Output Line Width +sub TELOPT_NAOP () {9}; # Output Page Size +sub TELOPT_NAOCRD () {10}; # Output Carriage-Return Disposition +sub TELOPT_NAOHTS () {11}; # Output Horizontal Tab Stops +sub TELOPT_NAOHTD () {12}; # Output Horizontal Tab Disposition +sub TELOPT_NAOFFD () {13}; # Output Formfeed Disposition +sub TELOPT_NAOVTS () {14}; # Output Vertical Tabstops +sub TELOPT_NAOVTD () {15}; # Output Vertical Tab Disposition +sub TELOPT_NAOLFD () {16}; # Output Linefeed Disposition +sub TELOPT_XASCII () {17}; # Extended ASCII +sub TELOPT_LOGOUT () {18}; # Logout +sub TELOPT_BM () {19}; # Byte Macro +sub TELOPT_DET () {20}; # Data Entry Terminal +sub TELOPT_SUPDUP () {21}; # SUPDUP +sub TELOPT_SUPDUPOUTPUT () {22}; # SUPDUP Output +sub TELOPT_SNDLOC () {23}; # Send Location +sub TELOPT_TTYPE () {24}; # Terminal Type +sub TELOPT_EOR () {25}; # End of Record +sub TELOPT_TUID () {26}; # TACACS User Identification +sub TELOPT_OUTMRK () {27}; # Output Marking +sub TELOPT_TTYLOC () {28}; # Terminal Location Number +sub TELOPT_3270REGIME () {29}; # Telnet 3270 Regime +sub TELOPT_X3PAD () {30}; # X.3 PAD +sub TELOPT_NAWS () {31}; # Negotiate About Window Size +sub TELOPT_TSPEED () {32}; # Terminal Speed +sub TELOPT_LFLOW () {33}; # Remote Flow Control +sub TELOPT_LINEMODE () {34}; # Linemode +sub TELOPT_XDISPLOC () {35}; # X Display Location +sub TELOPT_OLD_ENVIRON () {36}; # Environment Option +sub TELOPT_AUTHENTICATION () {37}; # Authentication Option +sub TELOPT_ENCRYPT () {38}; # Encryption Option +sub TELOPT_NEW_ENVIRON () {39}; # New Environment Option +sub TELOPT_EXOPL () {255}; # Extended-Options-List + + +1; +__END__; + + +######################## User Documentation ########################## + + +## To format the following documentation into a more readable format, +## use one of these programs: perldoc; pod2man; pod2html; pod2text. +## For example, to nicely format this documentation for printing, you +## may use pod2man and groff to convert to postscript: +## pod2man Net/Telnet.pm | groff -man -Tps > Net::Telnet.ps + +=head1 NAME + +Net::Telnet - interact with TELNET port or other TCP ports + +=head1 SYNOPSIS + +C + +see METHODS section below + +=head1 DESCRIPTION + +Net::Telnet allows you to make client connections to a TCP port and do +network I/O, especially to a port using the TELNET protocol. Simple +I/O methods such as print, get, and getline are provided. More +sophisticated interactive features are provided because connecting to +a TELNET port ultimately means communicating with a program designed +for human interaction. These interactive features include the ability +to specify a time-out and to wait for patterns to appear in the input +stream, such as the prompt from a shell. + +Other reasons to use this module than strictly with a TELNET port are: + +=over 2 + +=item * + +You're not familiar with sockets and you want a simple way to make +client connections to TCP services. + +=item * + +You want to be able to specify your own time-out while connecting, +reading, or writing. + +=item * + +You're communicating with an interactive program at the other end of +some socket or pipe and you want to wait for certain patterns to +appear. + +=back + +Here's an example that prints who's logged-on to the remote host +sparky. In addition to a username and password, you must also know +the user's shell prompt, which for this example is C + + use Net::Telnet (); + $t = new Net::Telnet (Timeout => 10, + Prompt => '/bash\$ $/'); + $t->open("sparky"); + $t->login($username, $passwd); + @lines = $t->cmd("who"); + print @lines; + +More examples are in the B section below. + +Usage questions should be directed to the Usenet newsgroup +comp.lang.perl.modules. + +Contact me, Jay Rogers , if you find any bugs or have +suggestions for improvement. + +=head2 What To Know Before Using + +=over 2 + +=item * + +All output is flushed while all input is buffered. Each object +contains its own input buffer. + +=item * + +The output record separator for C and C is set to +C<"\n"> by default, so that you don't have to append all your commands +with a newline. To avoid printing a trailing C<"\n"> use C or +set the I to C<"">. + +=item * + +The methods C and C use the I setting in the +object to determine when a login or remote command is complete. Those +methods will fail with a time-out if you don't set the prompt +correctly. + +=item * + +Use a combination of C and C as an alternative to +C or C when they don't do what you want. + +=item * + +Errors such as timing-out are handled according to the error mode +action. The default action is to print an error message to standard +error and have the program die. See the C method for more +information. + +=item * + +When constructing the match operator argument for C or +C, always use single quotes instead of double quotes to +avoid unexpected backslash interpretation (e.g. C<'/bash\$ $/'>). If +you're constructing a DOS like file path, you'll need to use four +backslashes to represent one (e.g. C<'/c:\\\\users\\\\billE$/i'>). + +Of course don't forget about regexp metacharacters like C<.>, C<[>, or +C<$>. You'll only need a single backslash to quote them. The anchor +metacharacters C<^> and C<$> refer to positions in the input buffer. +To avoid matching characters read that look like a prompt, it's a good +idea to end your prompt pattern with the C<$> anchor. That way the +prompt will only match if it's the last thing read. + +=item * + +In the input stream, each sequence of I and I (i.e. C<"\015\012"> or CR LF) is converted to C<"\n">. In the +output stream, each occurrence of C<"\n"> is converted to a sequence +of CR LF. See C to change the behavior. TCP protocols +typically use the ASCII sequence, carriage return and line feed to +designate a newline. + +=item * + +Timing-out while making a connection is disabled for machines that +don't support the C function. Most notably these include +MS-Windows machines. + +=item * + +You'll need to be running at least Perl version 5.002 to use this +module. This module does not require any libraries that don't already +come with a standard Perl distribution. + +If you have the IO:: libraries installed (they come standard with +perl5.004 and later) then IO::Socket::INET is used as a base class, +otherwise FileHandle is used. + +=item * + +Contact me, Jay Rogers , if you find any bugs or have +suggestions for improvement. + +=back + +=head2 Debugging + +The typical usage bug causes a time-out error because you've made +incorrect assumptions about what the remote side actually sends. The +easiest way to reconcile what the remote side sends with your +expectations is to use C or C. + +C allows you to see the data being sent from the remote +side before any translation is done, while C shows you +the results after translation. The translation includes converting +end of line characters, removing and responding to TELNET protocol +commands in the data stream. + +=head2 Style of Named Parameters + +Two different styles of named parameters are supported. This document +only shows the IO:: style: + + Net::Telnet->new(Timeout => 20); + +however the dash-option style is also allowed: + + Net::Telnet->new(-timeout => 20); + +=head2 Connecting to a Remote MS-Windows Machine + +By default MS-Windows doesn't come with a TELNET server. However +third party TELNET servers are available. Unfortunately many of these +servers falsely claim to be a TELNET server. This is especially true +of the so-called "Microsoft Telnet Server" that comes installed with +some newer versions MS-Windows. + +When a TELNET server first accepts a connection, it must use the ASCII +control characters carriage-return and line-feed to start a new line +(see RFC854). A server like the "Microsoft Telnet Server" that +doesn't do this, isn't a TELNET server. These servers send ANSI +terminal escape sequences to position to a column on a subsequent line +and to even position while writing characters that are adjacent to +each other. Worse, when sending output these servers resend +previously sent command output in a misguided attempt to display an +entire terminal screen. + +Connecting Net::Telnet to one of these false TELNET servers makes your +job of parsing command output very difficult. It's better to replace +a false TELNET server with a real TELNET server. The better TELNET +servers for MS-Windows allow you to avoid the ANSI escapes by turning +off something some of them call I. + + +=head1 METHODS + +In the calling sequences below, square brackets B<[]> represent +optional parameters. + +=over 4 + +=item B - create a new Net::Telnet object + + $obj = new Net::Telnet ([$host]); + + $obj = new Net::Telnet ([Binmode => $mode,] + [Cmd_remove_mode => $mode,] + [Dump_Log => $filename,] + [Errmode => $errmode,] + [Fhopen => $filehandle,] + [Host => $host,] + [Input_log => $file,] + [Input_record_separator => $chars,] + [Option_log => $file,] + [Ors => $chars,] + [Output_log => $file,] + [Output_record_separator => $chars,] + [Port => $port,] + [Prompt => $matchop,] + [Rs => $chars,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This is the constructor for Net::Telnet objects. A new object is +returned on success, the error mode action is performed on failure - +see C. The optional arguments are short-cuts to methods of +the same name. + +If the I<$host> argument is given then the object is opened by +connecting to TCP I<$port> on I<$host>. Also see C. The new +object returned is given the following defaults in the absence of +corresponding named parameters: + +=over 4 + +=item + +The default I is C<"localhost"> + +=item + +The default I is C<23> + +=item + +The default I is C<'/[\$%#E] $/'> + +=item + +The default I is C<10> + +=item + +The default I is C<"die"> + +=item + +The default I is C<"\n">. Note that I +is synonymous with I. + +=item + +The default I is C<"\n">. Note that I is +synonymous with I. + +=item + +The default I is C<0>, which means do newline translation. + +=item + +The default I is C<1>, which means respond to TELNET +commands in the data stream. + +=item + +The default I is C<"auto"> + +=item + +The defaults for I, I, I, and +I are C<"">, which means that logging is turned-off. + +=back + +=back + + +=over 4 + +=item B - toggle newline translation + + $mode = $obj->binmode; + + $prev = $obj->binmode($mode); + +This method controls whether or not sequences of carriage returns and +line feeds (CR LF or more specifically C<"\015\012">) are translated. +By default they are translated (i.e. binmode is C<0>). + +If no argument is given, the current mode is returned. + +If I<$mode> is C<1> then binmode is I and newline translation is +not done. + +If I<$mode> is C<0> then binmode is I and newline translation is +done. In the input stream, each sequence of CR LF is converted to +C<"\n"> and in the output stream, each occurrence of C<"\n"> is +converted to a sequence of CR LF. + +Note that input is always buffered. Changing binmode doesn't effect +what's already been read into the buffer. Output is not buffered and +changing binmode will have an immediate effect. + +=back + + +=over 4 + +=item B - send TELNET break character + + $ok = $obj->break; + +This method sends the TELNET break character. This character is +provided because it's a signal outside the ASCII character set which +is currently given local meaning within many systems. It's intended +to indicate that the Break Key or the Attention Key was hit. + +This method returns C<1> on success, or performs the error mode action +on failure. + +=back + + +=over 4 + +=item B - scalar reference to object's input buffer + + $ref = $obj->buffer; + +This method returns a scalar reference to the input buffer for +I<$obj>. Data in the input buffer is data that has been read from the +remote side but has yet to be read by the user. Modifications to the +input buffer are returned by a subsequent read. + +=back + + +=over 4 + +=item B - discard all data in object's input buffer + + $obj->buffer_empty; + +This method removes all data in the input buffer for I<$obj>. + +=back + + +=over 4 + +=item B - close object + + $ok = $obj->close; + +This method closes the socket, file, or pipe associated with the +object. It always returns a value of C<1>. + +=back + + +=over 4 + +=item B - issue command and retrieve output + + $ok = $obj->cmd($string); + $ok = $obj->cmd(String => $string, + [Output => $ref,] + [Cmd_remove_mode => $mode,] + [Errmode => $mode,] + [Input_record_separator => $chars,] + [Ors => $chars,] + [Output_record_separator => $chars,] + [Prompt => $match,] + [Rs => $chars,] + [Timeout => $secs,]); + + @output = $obj->cmd($string); + @output = $obj->cmd(String => $string, + [Output => $ref,] + [Cmd_remove_mode => $mode,] + [Errmode => $mode,] + [Input_record_separator => $chars,] + [Ors => $chars,] + [Output_record_separator => $chars,] + [Prompt => $match,] + [Rs => $chars,] + [Timeout => $secs,]); + +This method sends the command I<$string>, and reads the characters +sent back by the command up until and including the matching prompt. +It's assumed that the program to which you're sending is some kind of +command prompting interpreter such as a shell. + +The command I<$string> is automatically appended with the +output_record_separator, By default that's C<"\n">. This is similar +to someone typing a command and hitting the return key. Set the +output_record_separator to change this behavior. + +In a scalar context, the characters read from the remote side are +discarded and C<1> is returned on success. On time-out, eof, or other +failures, the error mode action is performed. See C. + +In a list context, just the output generated by the command is +returned, one line per element. In other words, all the characters in +between the echoed back command string and the prompt are returned. +If the command happens to return no output, a list containing one +element, the empty string is returned. This is so the list will +indicate true in a boolean context. On time-out, eof, or other +failures, the error mode action is performed. See C. + +The characters that matched the prompt may be retrieved using +C. + +Many command interpreters echo back the command sent. In most +situations, this method removes the first line returned from the +remote side (i.e. the echoed back command). See C +for more control over this feature. + +Use C to debug when this method keeps timing-out and you +don't think it should. + +Consider using a combination of C and C as an +alternative to this method when it doesn't do what you want, e.g. the +command you send prompts for input. + +The I named parameter provides an alternative method of +receiving command output. If you pass a scalar reference, all the +output (even if it contains multiple lines) is returned in the +referenced scalar. If you pass an array or hash reference, the lines +of output are returned in the referenced array or hash. You can use +C to change the notion of what separates a +line. + +Optional named parameters are provided to override the current +settings of cmd_remove_mode, errmode, input_record_separator, ors, +output_record_separator, prompt, rs, and timeout. Rs is synonymous +with input_record_separator and ors is synonymous with +output_record_separator. + +=back + + +=over 4 + +=item B - toggle removal of echoed commands + + $mode = $obj->cmd_remove_mode; + + $prev = $obj->cmd_remove_mode($mode); + +This method controls how to deal with echoed back commands in the +output returned by cmd(). Typically, when you send a command to the +remote side, the first line of output returned is the command echoed +back. Use this mode to remove the first line of output normally +returned by cmd(). + +If no argument is given, the current mode is returned. + +If I<$mode> is C<0> then the command output returned from cmd() has no +lines removed. If I<$mode> is a positive integer, then the first +I<$mode> lines of command output are stripped. + +By default, I<$mode> is set to C<"auto">. Auto means that whether or +not the first line of command output is stripped, depends on whether +or not the remote side offered to echo. By default, Net::Telnet +always accepts an offer to echo by the remote side. You can change +the default to reject such an offer using C. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not C<"auto"> or a non-negative integer. + +=back + + +=over 4 + +=item B - log all I/O in dump format + + $fh = $obj->dump_log; + + $fh = $obj->dump_log($fh); + + $fh = $obj->dump_log($filename); + +This method starts or stops dump format logging of all the object's +input and output. The dump format shows the blocks read and written +in a hexadecimal and printable character format. This method is +useful when debugging, however you might want to first try +C as it's more readable. + +If no argument is given, the current log filehandle is returned. An +empty string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened and a filehandle to it is returned. If the file can't be +opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - end of file indicator + + $eof = $obj->eof; + +This method returns C<1> if end of file has been read, otherwise it +returns an empty string. Because the input is buffered this isn't the +same thing as I<$obj> has closed. In other words I<$obj> can be +closed but there still can be stuff in the buffer to be read. Under +this condition you can still read but you won't be able to write. + +=back + + +=over 4 + +=item B - define action to be performed on error + + $mode = $obj->errmode; + + $prev = $obj->errmode($mode); + +This method gets or sets the action used when errors are encountered +using the object. The first calling sequence returns the current +error mode. The second calling sequence sets it to I<$mode> and +returns the previous mode. Valid values for I<$mode> are C<"die"> +(the default), C<"return">, a I, or an I. + +When mode is C<"die"> and an error is encountered using the object, +then an error message is printed to standard error and the program +dies. + +When mode is C<"return"> then the method generating the error places +an error message in the object and returns an undefined value in a +scalar context and an empty list in list context. The error message +may be obtained using C. + +When mode is a I, then when an error is encountered +I is called with the error message as its first argument. +Using this mode you may have your own subroutine handle errors. If +I itself returns then the method generating the error returns +undefined or an empty list depending on context. + +When mode is an I, the first element of the array must be a +I. Any elements that follow are the arguments to I. +When an error is encountered, the I is called with its +arguments. Using this mode you may have your own subroutine handle +errors. If the I itself returns then the method generating +the error returns undefined or an empty list depending on context. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not C<"die">, C<"return">, a I, or an +I whose first element isn't a I. + +=back + + +=over 4 + +=item B - most recent error message + + $msg = $obj->errmsg; + + $prev = $obj->errmsg(@msgs); + +The first calling sequence returns the error message associated with +the object. The empty string is returned if no error has been +encountered yet. The second calling sequence sets the error message +for the object to the concatenation of I<@msgs> and returns the +previous error message. Normally, error messages are set internally +by a method when an error is encountered. + +=back + + +=over 4 + +=item B - perform the error mode action + + $obj->error(@msgs); + +This method concatenates I<@msgs> into a string and places it in the +object as the error message. Also see C. It then performs +the error mode action. Also see C. + +If the error mode doesn't cause the program to die, then an undefined +value or an empty list is returned depending on the context. + +This method is primarily used by this class or a sub-class to perform +the user requested action when an error is encountered. + +=back + + +=over 4 + +=item B - use already open filehandle for I/O + + $ok = $obj->fhopen($fh); + +This method associates the open filehandle I<$fh> with I<$obj> for +further I/O. Filehandle I<$fh> must already be opened. + +Suppose you want to use the features of this module to do I/O to +something other than a TCP port, for example STDIN or a filehandle +opened to read from a process. Instead of opening the object for I/O +to a TCP port by using C or C, call this method +instead. + +The value C<1> is returned success, the error mode action is performed +on failure. + +=back + + +=over 4 + +=item B - read block of data + + $data = $obj->get([Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method reads a block of data from the object and returns it along +with any buffered data. If no buffered data is available to return, +it will wait for data to read using the timeout specified in the +object. You can override that timeout using I<$secs>. Also see +C. If buffered data is available to return, it also checks +for a block of data that can be immediately read. + +On eof an undefined value is returned. On time-out or other failures, +the error mode action is performed. To distinguish between eof or an +error occurring when the error mode is not set to C<"die">, use +C. + +Optional named parameters are provided to override the current +settings of binmode, errmode, telnetmode, and timeout. + +=back + + +=over 4 + +=item B - read next line + + $line = $obj->getline([Binmode => $mode,] + [Errmode => $errmode,] + [Input_record_separator => $chars,] + [Rs => $chars,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method reads and returns the next line of data from the object. +You can use C to change the notion of what +separates a line. The default is C<"\n">. If a line isn't +immediately available, this method blocks waiting for a line or a +time-out. + +On eof an undefined value is returned. On time-out or other failures, +the error mode action is performed. To distinguish between eof or an +error occurring when the error mode is not set to C<"die">, use +C. + +Optional named parameters are provided to override the current +settings of binmode, errmode, input_record_separator, rs, telnetmode, +and timeout. Rs is synonymous with input_record_separator. + +=back + + +=over 4 + +=item B - read next lines + + @lines = $obj->getlines([Binmode => $mode,] + [Errmode => $errmode,] + [Input_record_separator => $chars,] + [Rs => $chars,] + [Telnetmode => $mode,] + [Timeout => $secs,] + [All => $boolean,]); + +This method reads and returns all the lines of data from the object +until end of file is read. You can use C to +change the notion of what separates a line. The default is C<"\n">. +A time-out error occurs if all the lines can't be read within the +time-out interval. See C. + +The behavior of this method was changed in version 3.03. Prior to +version 3.03 this method returned just the lines available from the +next read. To get that old behavior, use the optional named parameter +I and set I<$boolean> to C<""> or C<0>. + +If only eof is read then an empty list is returned. On time-out or +other failures, the error mode action is performed. Use C to +distinguish between reading only eof or an error occurring when the +error mode is not set to C<"die">. + +Optional named parameters are provided to override the current +settings of binmode, errmode, input_record_separator, rs, telnetmode, +and timeout. Rs is synonymous with input_record_separator. + +=back + + +=over 4 + +=item B - name of remote host + + $host = $obj->host; + + $prev = $obj->host($host); + +This method designates the remote host for C. With no +argument it returns the current host name set in the object. With an +argument it sets the current host name to I<$host> and returns the +previous host name. You may indicate the remote host using either a +hostname or an IP address. + +The default value is C<"localhost">. It may also be set by C +or C. + +=back + + +=over 4 + +=item B - log all input + + $fh = $obj->input_log; + + $fh = $obj->input_log($fh); + + $fh = $obj->input_log($filename); + +This method starts or stops logging of input. This is useful when +debugging. Also see C. Because most command interpreters +echo back commands received, it's likely all your output will also be +in this log. Note that input logging occurs after newline +translation. See C for details on newline translation. + +If no argument is given, the log filehandle is returned. An empty +string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened for logging and a filehandle to it is returned. If the file +can't be opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - input line delimiter + + $chars = $obj->input_record_separator; + + $prev = $obj->input_record_separator($chars); + +This method designates the line delimiter for input. It's used with +C, C, and C to determine lines in the +input. + +With no argument this method returns the current input record +separator set in the object. With an argument it sets the input +record separator to I<$chars> and returns the previous value. Note +that I<$chars> must have length. + +A warning is printed to STDERR when attempting to set this attribute +to a string with no length. + +=back + + +=over 4 + +=item B - last prompt read + + $string = $obj->last_prompt; + + $prev = $obj->last_prompt($string); + +With no argument this method returns the last prompt read by cmd() or +login(). See C. With an argument it sets the last prompt +read to I<$string> and returns the previous value. Normally, only +internal methods set the last prompt. + +=back + + +=over 4 + +=item B - last line read + + $line = $obj->lastline; + + $prev = $obj->lastline($line); + +This method retrieves the last line read from the object. This may be +a useful error message when the remote side abnormally closes the +connection. Typically the remote side will print an error message +before closing. + +With no argument this method returns the last line read from the +object. With an argument it sets the last line read to I<$line> and +returns the previous value. Normally, only internal methods set the +last line. + +=back + + +=over 4 + +=item B - perform standard login + + $ok = $obj->login($username, $password); + + $ok = $obj->login(Name => $username, + Password => $password, + [Errmode => $mode,] + [Prompt => $match,] + [Timeout => $secs,]); + +This method performs a standard login by waiting for a login prompt +and responding with I<$username>, then waiting for the password prompt +and responding with I<$password>, and then waiting for the command +interpreter prompt. If any of those prompts sent by the remote side +don't match what's expected, this method will time-out, unless timeout +is turned off. + +Login prompt must match either of these case insensitive patterns: + + /login[: ]*$/i + /username[: ]*$/i + +Password prompt must match this case insensitive pattern: + + /password[: ]*$/i + +The command interpreter prompt must match the current setting of +prompt. See C. + +Use C to debug when this method keeps timing-out and you +don't think it should. + +Consider using a combination of C and C as an +alternative to this method when it doesn't do what you want, e.g. the +remote host doesn't prompt for a username. + +On success, C<1> is returned. On time out, eof, or other failures, +the error mode action is performed. See C. + +Optional named parameters are provided to override the current +settings of errmode, prompt, and timeout. + +=back + + +=over 4 + +=item B - maximum size of input buffer + + $len = $obj->max_buffer_length; + + $prev = $obj->max_buffer_length($len); + +This method designates the maximum size of the input buffer. An error +is generated when a read causes the buffer to exceed this limit. The +default value is 1,048,576 bytes (1MB). The input buffer can grow +much larger than the block size when you continuously read using +C or C and the data stream contains no newlines +or matching waitfor patterns. + +With no argument, this method returns the current maximum buffer +length set in the object. With an argument it sets the maximum buffer +length to I<$len> and returns the previous value. Values of I<$len> +smaller than 512 will be adjusted to 512. + +A warning is printed to STDERR when attempting to set this attribute +to something that isn't a positive integer. + +=back + + +=over 4 + +=item B - field separator for print + + $chars = $obj->ofs + + $prev = $obj->ofs($chars); + +This method is synonymous with C. + +=back + + +=over 4 + +=item B - connect to port on remote host + + $ok = $obj->open($host); + + $ok = $obj->open([Host => $host,] + [Port => $port,] + [Errmode => $mode,] + [Timeout => $secs,]); + +This method opens a TCP connection to I<$port> on I<$host>. If either +argument is missing then the current value of C or C +is used. Optional named parameters are provided to override the +current setting of errmode and timeout. + +On success C<1> is returned. On time-out or other connection +failures, the error mode action is performed. See C. + +Time-outs don't work for this method on machines that don't implement +SIGALRM - most notably MS-Windows machines. For those machines, an +error is returned when the system reaches its own time-out while +trying to connect. + +A side effect of this method is to reset the alarm interval associated +with SIGALRM. + +=back + + +=over 4 + +=item B - indicate willingness to accept a TELNET option + + $fh = $obj->option_accept([Do => $telopt,] + [Dont => $telopt,] + [Will => $telopt,] + [Wont => $telopt,]); + +This method is used to indicate whether to accept or reject an offer +to enable a TELNET option made by the remote side. If you're using +I or I to indicate a willingness to enable, then a +notification callback must have already been defined by a prior call +to C. See C for details on +receiving enable/disable notification of a TELNET option. + +You can give multiple I, I, I, or I arguments +for different TELNET options in the same call to this method. + +The following example describes the meaning of the named parameters. +A TELNET option, such as C used below, is an integer +constant that you can import from Net::Telnet. See the source in file +Telnet.pm for the complete list. + +=over 4 + +=item + +I => C + +=over 4 + +=item + +we'll accept an offer to enable the echo option on the local side + +=back + +=item + +I => C + +=over 4 + +=item + +we'll reject an offer to enable the echo option on the local side + +=back + +=item + +I => C + +=over 4 + +=item + +we'll accept an offer to enable the echo option on the remote side + +=back + +=item + +I => C + +=over 4 + +=item + +we'll reject an offer to enable the echo option on the remote side + +=back + +=back + +=item + +Use C to send a request to the remote side to enable or +disable a particular TELNET option. + +=back + + +=over 4 + +=item B - define the option negotiation callback + + $coderef = $obj->option_callback; + + $prev = $obj->option_callback($coderef); + +This method defines the callback subroutine that's called when a +TELNET option is enabled or disabled. Once defined, the +I may not be undefined. However, calling this method +with a different I<$coderef> changes it. + +A warning is printed to STDERR when attempting to set this attribute +to something that isn't a coderef. + +Here are the circumstances that invoke I<$coderef>: + +=over 4 + +=item + +An option becomes enabled because the remote side requested an enable +and C had been used to arrange that it be accepted. + +=item + +The remote side arbitrarily decides to disable an option that is +currently enabled. Note that Net::Telnet always accepts a request to +disable from the remote side. + +=item + +C was used to send a request to enable or disable an +option and the response from the remote side has just been received. +Note, that if a request to enable is rejected then I<$coderef> is +still invoked even though the option didn't change. + +=back + +=item + +Here are the arguments passed to I<&$coderef>: + + &$coderef($obj, $option, $is_remote, + $is_enabled, $was_enabled, $buf_position); + +=over 4 + +=item + +1. I<$obj> is the Net::Telnet object + +=item + +2. I<$option> is the TELNET option. Net::Telnet exports constants +for the various TELNET options which just equate to an integer. + +=item + +3. I<$is_remote> is a boolean indicating for which side the option +applies. + +=item + +4. I<$is_enabled> is a boolean indicating the option is enabled or +disabled + +=item + +5. I<$was_enabled> is a boolean indicating the option was previously +enabled or disabled + +=item + +6. I<$buf_position> is an integer indicating the position in the +object's input buffer where the option takes effect. See C +to access the object's input buffer. + +=back + +=back + + +=over 4 + +=item B - log all TELNET options sent or received + + $fh = $obj->option_log; + + $fh = $obj->option_log($fh); + + $fh = $obj->option_log($filename); + +This method starts or stops logging of all TELNET options being sent +or received. This is useful for debugging when you send options via +C or you arrange to accept option requests from the +remote side via C. Also see C. + +If no argument is given, the log filehandle is returned. An empty +string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened for logging and a filehandle to it is returned. If the file +can't be opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - send TELNET option negotiation request + + $ok = $obj->option_send([Do => $telopt,] + [Dont => $telopt,] + [Will => $telopt,] + [Wont => $telopt,] + [Async => $boolean,]); + +This method is not yet implemented. Look for it in a future version. + +=back + + +=over 4 + +=item B - get current state of a TELNET option + + $hashref = $obj->option_state($telopt); + +This method returns a hashref containing a copy of the current state +of TELNET option I<$telopt>. + +Here are the values returned in the hash: + +=over 4 + +=item + +I<$hashref>->{remote_enabled} + +=over 4 + +=item + +boolean that indicates if the option is enabled on the remote side. + +=back + +=item + +I<$hashref>->{remote_enable_ok} + +=over 4 + +=item + +boolean that indicates if it's ok to accept an offer to enable this +option on the remote side. + +=back + +=item + +I<$hashref>->{remote_state} + +=over 4 + +=item + +string used to hold the internal state of option negotiation for this +option on the remote side. + +=back + +=item + +I<$hashref>->{local_enabled} + +=over 4 + +=item + +boolean that indicates if the option is enabled on the local side. + +=back + +=item + +I<$hashref>->{local_enable_ok} + +=over 4 + +=item + +boolean that indicates if it's ok to accept an offer to enable this +option on the local side. + +=back + +=item + +I<$hashref>->{local_state} + +=over 4 + +=item + +string used to hold the internal state of option negotiation for this +option on the local side. + +=back + +=back + +=back + + +=over 4 + +=item B - output line delimiter + + $chars = $obj->ors; + + $prev = $obj->ors($chars); + +This method is synonymous with C. + +=back + + +=over 4 + +=item B - field separator for print + + $chars = $obj->output_field_separator; + + $prev = $obj->output_field_separator($chars); + +This method designates the output field separator for C. +Ordinarily the print method simply prints out the comma separated +fields you specify. Set this to specify what's printed between +fields. + +With no argument this method returns the current output field +separator set in the object. With an argument it sets the output +field separator to I<$chars> and returns the previous value. + +By default it's set to an empty string. + +=back + + +=over 4 + +=item B - log all output + + $fh = $obj->output_log; + + $fh = $obj->output_log($fh); + + $fh = $obj->output_log($filename); + +This method starts or stops logging of output. This is useful when +debugging. Also see C. Because most command interpreters +echo back commands received, it's likely all your output would also be +in an input log. See C. Note that output logging occurs +before newline translation. See C for details on newline +translation. + +If no argument is given, the log filehandle is returned. An empty +string indicates logging is off. + +To stop logging, use an empty string as an argument. + +If an open filehandle is given, it is used for logging and returned. +Otherwise, the argument is assumed to be the name of a file, the file +is opened for logging and a filehandle to it is returned. If the file +can't be opened for writing, the error mode action is performed. + +=back + + +=over 4 + +=item B - output line delimiter + + $chars = $obj->output_record_separator; + + $prev = $obj->output_record_separator($chars); + +This method designates the output line delimiter for C and +C. Set this to specify what's printed at the end of C +and C. + +The output record separator is set to C<"\n"> by default, so there's +no need to append all your commands with a newline. To avoid printing +the output_record_separator use C or set the +output_record_separator to an empty string. + +With no argument this method returns the current output record +separator set in the object. With an argument it sets the output +record separator to I<$chars> and returns the previous value. + +=back + + +=over 4 + +=item B - remote port + + $port = $obj->port; + + $prev = $obj->port($port); + +This method designates the remote TCP port. With no argument this +method returns the current port number. With an argument it sets the +current port number to I<$port> and returns the previous port. If +I<$port> is a TCP service name, then it's first converted to a port +number using the perl function C. + +The default value is C<23>. It may also be set by C or +C. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not a positive integer or a valid TCP service +name. + +=back + + +=over 4 + +=item B - write to object + + $ok = $obj->print(@list); + +This method writes I<@list> followed by the I +to the open object and returns C<1> if all data was successfully +written. On time-out or other failures, the error mode action is +performed. See C. + +By default, the C is set to C<"\n"> so all +your commands automatically end with a newline. In most cases your +output is being read by a command interpreter which won't accept a +command until newline is read. This is similar to someone typing a +command and hitting the return key. To avoid printing a trailing +C<"\n"> use C instead or set the output_record_separator to an +empty string. + +On failure, it's possible that some data was written. If you choose +to try and recover from a print timing-out, use C to +determine how much was written before the error occurred. + +You may also use the output field separator to print a string between +the list elements. See C. + +=back + + +=over 4 + +=item B - number of bytes written by print + + $num = $obj->print_length; + +This returns the number of bytes successfully written by the most +recent C or C. + +=back + + +=over 4 + +=item B - pattern to match a prompt + + $matchop = $obj->prompt; + + $prev = $obj->prompt($matchop); + +This method sets the pattern used to find a prompt in the input +stream. It must be a string representing a valid perl pattern match +operator. The methods C and C try to read until +matching the prompt. They will fail with a time-out error if the +pattern you've chosen doesn't match what the remote side sends. + +With no argument this method returns the prompt set in the object. +With an argument it sets the prompt to I<$matchop> and returns the +previous value. + +The default prompt is C<'/[\$%#E] $/'> + +Always use single quotes, instead of double quotes, to construct +I<$matchop> (e.g. C<'/bash\$ $/'>). If you're constructing a DOS like +file path, you'll need to use four backslashes to represent one +(e.g. C<'/c:\\\\users\\\\billE$/i'>). + +Of course don't forget about regexp metacharacters like C<.>, C<[>, or +C<$>. You'll only need a single backslash to quote them. The anchor +metacharacters C<^> and C<$> refer to positions in the input buffer. + +A warning is printed to STDERR when attempting to set this attribute +with a match operator missing its opening delimiter. + +=back + + +=over 4 + +=item B - write to object + + $ok = $obj->put($string); + + $ok = $obj->put(String => $string, + [Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method writes I<$string> to the opened object and returns C<1> if +all data was successfully written. This method is like C +except that it doesn't write the trailing output_record_separator +("\n" by default). On time-out or other failures, the error mode +action is performed. See C. + +On failure, it's possible that some data was written. If you choose +to try and recover from a put timing-out, use C to +determine how much was written before the error occurred. + +Optional named parameters are provided to override the current +settings of binmode, errmode, telnetmode, and timeout. + +=back + + +=over 4 + +=item B - input line delimiter + + $chars = $obj->rs; + + $prev = $obj->rs($chars); + +This method is synonymous with C. + +=back + + +=over 4 + +=item B - turn off/on telnet command interpretation + + $mode = $obj->telnetmode; + + $prev = $obj->telnetmode($mode); + +This method controls whether or not TELNET commands in the data stream +are recognized and handled. The TELNET protocol uses certain +character sequences sent in the data stream to control the session. +If the port you're connecting to isn't using the TELNET protocol, then +you should turn this mode off. The default is I. + +If no argument is given, the current mode is returned. + +If I<$mode> is C<0> then telnet mode is off. If I<$mode> is C<1> then +telnet mode is on. + +=back + + +=over 4 + +=item B - time-out indicator + + $boolean = $obj->timed_out; + + $prev = $obj->timed_out($boolean); + +This method indicates if a previous read, write, or open method +timed-out. Remember that timing-out is itself an error. To be able +to invoke C after a time-out error, you'd have to change +the default error mode to something other than C<"die">. See +C. + +With no argument this method returns C<1> if the previous method +timed-out. With an argument it sets the indicator. Normally, only +internal methods set this indicator. + +=back + + +=over 4 + +=item B - I/O time-out interval + + $secs = $obj->timeout; + + $prev = $obj->timeout($secs); + +This method sets the timeout interval that's used when performing I/O +or connecting to a port. When a method doesn't complete within the +timeout interval then it's an error and the error mode action is +performed. + +A timeout may be expressed as a relative or absolute value. If +I<$secs> is greater than or equal to the time the program started, as +determined by $^T, then it's an absolute time value for when time-out +occurs. The perl function C may be used to obtain an absolute +time value. For a relative time-out value less than $^T, time-out +happens I<$secs> from when the method begins. + +If I<$secs> is C<0> then time-out occurs if the data cannot be +immediately read or written. Use the undefined value to turn off +timing-out completely. + +With no argument this method returns the timeout set in the object. +With an argument it sets the timeout to I<$secs> and returns the +previous value. The default timeout value is C<10> seconds. + +A warning is printed to STDERR when attempting to set this attribute +to something that's not an C or a non-negative integer. + +=back + + +=over 4 + +=item B - wait for pattern in the input + + $ok = $obj->waitfor($matchop); + $ok = $obj->waitfor([Match => $matchop,] + [String => $string,] + [Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + + ($prematch, $match) = $obj->waitfor($matchop); + ($prematch, $match) = $obj->waitfor([Match => $matchop,] + [String => $string,] + [Binmode => $mode,] + [Errmode => $errmode,] + [Telnetmode => $mode,] + [Timeout => $secs,]); + +This method reads until a pattern match or string is found in the +input stream. All the characters before and including the match are +removed from the input stream. + +In a list context the characters before the match and the matched +characters are returned in I<$prematch> and I<$match>. In a scalar +context, the matched characters and all characters before it are +discarded and C<1> is returned on success. On time-out, eof, or other +failures, for both list and scalar context, the error mode action is +performed. See C. + +You can specify more than one pattern or string by simply providing +multiple I and/or I named parameters. A I<$matchop> +must be a string representing a valid Perl pattern match operator. +The I<$string> is just a substring to find in the input stream. + +Use C to debug when this method keeps timing-out and you +don't think it should. + +An optional named parameter is provided to override the current +setting of timeout. + +To avoid unexpected backslash interpretation, always use single quotes +instead of double quotes to construct a match operator argument for +C and C (e.g. C<'/bash\$ $/'>). If you're +constructing a DOS like file path, you'll need to use four backslashes +to represent one (e.g. C<'/c:\\\\users\\\\billE$/i'>). + +Of course don't forget about regexp metacharacters like C<.>, C<[>, or +C<$>. You'll only need a single backslash to quote them. The anchor +metacharacters C<^> and C<$> refer to positions in the input buffer. + +Optional named parameters are provided to override the current +settings of binmode, errmode, telnetmode, and timeout. + +=back + + +=head1 SEE ALSO + +=over 2 + +=item RFC 854 + +S + +S + +=item RFC 1143 + +S + +S + +=item TELNET Option Assignments + +S + +=back + + +=head1 EXAMPLES + +This example gets the current weather forecast for Brainerd, Minnesota. + + my ($forecast, $t); + + use Net::Telnet (); + $t = new Net::Telnet; + $t->open("rainmaker.wunderground.com"); + + ## Wait for first prompt and "hit return". + $t->waitfor('/continue:.*$/'); + $t->print(""); + + ## Wait for second prompt and respond with city code. + $t->waitfor('/city code.*$/'); + $t->print("BRD"); + + ## Read and print the first page of forecast. + ($forecast) = $t->waitfor('/[ \t]+press return to continue/i'); + print $forecast; + + exit; + + +This example checks a POP server to see if you have mail. + + my ($hostname, $line, $passwd, $pop, $username); + + $hostname = "your_destination_host_here"; + $username = "your_username_here"; + $passwd = "your_password_here"; + + use Net::Telnet (); + $pop = new Net::Telnet (Telnetmode => 0); + $pop->open(Host => $hostname, + Port => 110); + + + ## Read connection message. + $line = $pop->getline; + die $line unless $line =~ /^\+OK/; + + ## Send user name. + $pop->print("user $username"); + $line = $pop->getline; + die $line unless $line =~ /^\+OK/; + + ## Send password. + $pop->print("pass $passwd"); + $line = $pop->getline; + die $line unless $line =~ /^\+OK/; + + ## Request status of messages. + $pop->print("list"); + $line = $pop->getline; + print $line; + + exit; + + +Here's an example that uses the ssh program to connect to a remote +host. Because the ssh program reads and writes to its controlling +terminal, the IO::Pty module is used to create a new pseudo terminal +for use by ssh. A new Net::Telnet object is then created to read and +write to that pseudo terminal. To use the code below, substitute +"changeme" with the actual host, user, password, and command prompt. + + ## Main program. + { + my ($pty, $ssh, @lines); + my $host = "changeme"; + my $user = "changeme"; + my $password = "changeme"; + my $prompt = '/changeme:~> $/'; + + ## Start ssh program. + $pty = &spawn("ssh", "-l", $user, $host); # spawn() defined below + + ## Create a Net::Telnet object to perform I/O on ssh's tty. + use Net::Telnet; + $ssh = new Net::Telnet (-fhopen => $pty, + -prompt => $prompt, + -telnetmode => 0, + -cmd_remove_mode => 1, + -output_record_separator => "\r"); + + ## Login to remote host. + $ssh->waitfor(-match => '/password: ?$/i', + -errmode => "return") + or die "problem connecting to host: ", $ssh->lastline; + $ssh->print($password); + $ssh->waitfor(-match => $ssh->prompt, + -errmode => "return") + or die "login failed: ", $ssh->lastline; + + ## Send command, get and print its output. + @lines = $ssh->cmd("who"); + print @lines; + + exit; + } # end main program + + sub spawn { + my(@cmd) = @_; + my($pid, $pty, $tty, $tty_fd); + + ## Create a new pseudo terminal. + use IO::Pty (); + $pty = new IO::Pty + or die $!; + + ## Execute the program in another process. + unless ($pid = fork) { # child process + die "problem spawning program: $!\n" unless defined $pid; + + ## Disassociate process from existing controlling terminal. + use POSIX (); + POSIX::setsid + or die "setsid failed: $!"; + + ## Associate process with a new controlling terminal. + $tty = $pty->slave; + $tty_fd = $tty->fileno; + close $pty; + + ## Make stdio use the new controlling terminal. + open STDIN, "<&$tty_fd" or die $!; + open STDOUT, ">&$tty_fd" or die $!; + open STDERR, ">&STDOUT" or die $!; + close $tty; + + ## Execute requested program. + exec @cmd + or die "problem executing $cmd[0]\n"; + } # end child process + + $pty; + } # end sub spawn + + +Here's an example that changes a user's login password. Because the +passwd program always prompts for passwords on its controlling +terminal, the IO::Pty module is used to create a new pseudo terminal +for use by passwd. A new Net::Telnet object is then created to read +and write to that pseudo terminal. To use the code below, substitute +"changeme" with the actual old and new passwords. + + my ($pty, $passwd); + my $oldpw = "changeme"; + my $newpw = "changeme"; + + ## Start passwd program. + $pty = &spawn("passwd"); # spawn() defined above + + ## Create a Net::Telnet object to perform I/O on passwd's tty. + use Net::Telnet; + $passwd = new Net::Telnet (-fhopen => $pty, + -timeout => 2, + -output_record_separator => "\r", + -telnetmode => 0, + -cmd_remove_mode => 1); + $passwd->errmode("return"); + + ## Send existing password. + $passwd->waitfor('/password: ?$/i') + or die "no old password prompt: ", $passwd->lastline; + $passwd->print($oldpw); + + ## Send new password. + $passwd->waitfor('/new password: ?$/i') + or die "bad old password: ", $passwd->lastline; + $passwd->print($newpw); + + ## Send new password verification. + $passwd->waitfor('/new password: ?$/i') + or die "bad new password: ", $passwd->lastline; + $passwd->print($newpw); + + ## Display success or failure. + $passwd->waitfor('/changed/') + or die "bad new password: ", $passwd->lastline; + print $passwd->lastline; + + $passwd->close; + exit; + + +Here's an example you can use to down load a file of any type. The +file is read from the remote host's standard output using cat. To +prevent any output processing, the remote host's standard output is +put in raw mode using the Bourne shell. The Bourne shell is used +because some shells, notably tcsh, prevent changing tty modes. Upon +completion, FTP style statistics are printed to stderr. + + my ($block, $filename, $host, $hostname, $k_per_sec, $line, + $num_read, $passwd, $prevblock, $prompt, $size, $size_bsd, + $size_sysv, $start_time, $total_time, $username); + + $hostname = "your_destination_host_here"; + $username = "your_username_here"; + $passwd = "your_password_here"; + $filename = "your_download_file_here"; + + ## Connect and login. + use Net::Telnet (); + $host = new Net::Telnet (Timeout => 30, + Prompt => '/[%#>] $/'); + $host->open($hostname); + $host->login($username, $passwd); + + ## Make sure prompt won't match anything in send data. + $prompt = "_funkyPrompt_"; + $host->prompt("/$prompt\$/"); + $host->cmd("set prompt = '$prompt'"); + + ## Get size of file. + ($line) = $host->cmd("/bin/ls -l $filename"); + ($size_bsd, $size_sysv) = (split ' ', $line)[3,4]; + if ($size_sysv =~ /^\d+$/) { + $size = $size_sysv; + } + elsif ($size_bsd =~ /^\d+$/) { + $size = $size_bsd; + } + else { + die "$filename: no such file on $hostname"; + } + + ## Start sending the file. + binmode STDOUT; + $host->binmode(1); + $host->print("/bin/sh -c 'stty raw; cat $filename'"); + $host->getline; # discard echoed back line + + ## Read file a block at a time. + $num_read = 0; + $prevblock = ""; + $start_time = time; + while (($block = $host->get) and ($block !~ /$prompt$/o)) { + if (length $block >= length $prompt) { + print $prevblock; + $num_read += length $prevblock; + $prevblock = $block; + } + else { + $prevblock .= $block; + } + + } + $host->close; + + ## Print last block without trailing prompt. + $prevblock .= $block; + $prevblock =~ s/$prompt$//; + print $prevblock; + $num_read += length $prevblock; + die "error: expected size $size, received size $num_read\n" + unless $num_read == $size; + + ## Print totals. + $total_time = (time - $start_time) || 1; + $k_per_sec = ($size / 1024) / $total_time; + $k_per_sec = sprintf "%3.1f", $k_per_sec; + warn("$num_read bytes received in $total_time seconds ", + "($k_per_sec Kbytes/s)\n"); + + exit; + + +=head1 AUTHOR + +Jay Rogers + + +=head1 COPYRIGHT + +Copyright 1997, 2000, 2002 by Jay Rogers. All rights reserved. +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. diff --git a/agc_2-X/trunk/libs/Time/HiRes.1.59.pm b/agc_2-X/trunk/libs/Time/HiRes.1.59.pm new file mode 100644 index 00000000..98d31429 --- /dev/null +++ b/agc_2-X/trunk/libs/Time/HiRes.1.59.pm @@ -0,0 +1,359 @@ +package Time::HiRes; + +use strict; +use vars qw($VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); + +require Exporter; +require DynaLoader; + +@ISA = qw(Exporter DynaLoader); + +@EXPORT = qw( ); +@EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval + getitimer setitimer + ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF + d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer + d_nanosleep); + +$VERSION = '1.59'; +$XS_VERSION = $VERSION; +$VERSION = eval $VERSION; + +sub AUTOLOAD { + my $constname; + ($constname = $AUTOLOAD) =~ s/.*:://; + die "&Time::HiRes::constant not defined" if $constname eq 'constant'; + my ($error, $val) = constant($constname); + if ($error) { die $error; } + { + no strict 'refs'; + *$AUTOLOAD = sub { $val }; + } + goto &$AUTOLOAD; +} + +bootstrap Time::HiRes; + +# Preloaded methods go here. + +sub tv_interval { + # probably could have been done in C + my ($a, $b) = @_; + $b = [gettimeofday()] unless defined($b); + (${$b}[0] - ${$a}[0]) + ((${$b}[1] - ${$a}[1]) / 1_000_000); +} + +# Autoload methods go after =cut, and are processed by the autosplit program. + +1; +__END__ + +=head1 NAME + +Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers + +=head1 SYNOPSIS + + use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); + + usleep ($microseconds); + + ualarm ($microseconds); + ualarm ($microseconds, $interval_microseconds); + + $t0 = [gettimeofday]; + ($seconds, $microseconds) = gettimeofday; + + $elapsed = tv_interval ( $t0, [$seconds, $microseconds]); + $elapsed = tv_interval ( $t0, [gettimeofday]); + $elapsed = tv_interval ( $t0 ); + + use Time::HiRes qw ( time alarm sleep ); + + $now_fractions = time; + sleep ($floating_seconds); + alarm ($floating_seconds); + alarm ($floating_seconds, $floating_interval); + + use Time::HiRes qw( setitimer getitimer + ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF ); + + setitimer ($which, $floating_seconds, $floating_interval ); + getitimer ($which); + +=head1 DESCRIPTION + +The C module implements a Perl interface to the C, +C, C, and C/C system calls, in other +words, high resolution time and timers. See the L section below +and the test scripts for usage; see your system documentation for the +description of the underlying C or C, C, +C, and C/C calls. + +If your system lacks C or an emulation of it you don't +get C or the one-argument form of C. If your system lacks all of +C, C, and C, you don't get +C or C. If your system lacks both +C and C you don't get +C or C. + +If you try to import an unimplemented function in the C statement +it will fail at compile time. + +If your subsecond sleeping is implemented with C instead of +C, you can mix subsecond sleeping with signals since +C does not use signals. This, however is unportable, and you +should first check for the truth value of C<&Time::HiRes::d_nanosleep> to +see whether you have nanosleep, and then carefully read your +C C API documentation for any peculiarities. (There is no +separate interface to call C; just use C +or C with small enough values.) + +Unless using C for mixing sleeping with signals, give +some thought to whether Perl is the tool you should be using for work +requiring nanosecond accuracies. + +The following functions can be imported from this module. +No functions are exported by default. + +=over 4 + +=item gettimeofday () + +In array context returns a two-element array with the seconds and +microseconds since the epoch. In scalar context returns floating +seconds like C (see below). + +=item usleep ( $useconds ) + +Sleeps for the number of microseconds specified. Returns the number +of microseconds actually slept. Can sleep for more than one second, +unlike the C system call. See also C below. + +=item ualarm ( $useconds [, $interval_useconds ] ) + +Issues a C call; the C<$interval_useconds> is optional and +will be zero if unspecified, resulting in C-like behaviour. + +=item tv_interval + +tv_interval ( $ref_to_gettimeofday [, $ref_to_later_gettimeofday] ) + +Returns the floating seconds between the two times, which should have +been returned by C. If the second argument is omitted, +then the current time is used. + +=item time () + +Returns a floating seconds since the epoch. This function can be +imported, resulting in a nice drop-in replacement for the C below. + +B: This higher resolution timer can return values either less +or more than the core C, depending on whether your platform +rounds the higher resolution timer values up, down, or to the nearest second +to get the core C, but naturally the difference should be never +more than half a second. + +B: Since Sunday, September 9th, 2001 at 01:46:40 AM GMT, when +the C seconds since epoch rolled over to 1_000_000_000, the +default floating point format of Perl and the seconds since epoch have +conspired to produce an apparent bug: if you print the value of +C you seem to be getting only five decimals, not six +as promised (microseconds). Not to worry, the microseconds are there +(assuming your platform supports such granularity in first place). +What is going on is that the default floating point format of Perl +only outputs 15 digits. In this case that means ten digits before the +decimal separator and five after. To see the microseconds you can use +either C/C with C<"%.6f">, or the C function in +list context, which will give you the seconds and microseconds as two +separate values. + +=item sleep ( $floating_seconds ) + +Sleeps for the specified amount of seconds. Returns the number of +seconds actually slept (a floating point value). This function can be +imported, resulting in a nice drop-in replacement for the C +provided with perl, see the L below. + +=item alarm ( $floating_seconds [, $interval_floating_seconds ] ) + +The C signal is sent after the specified number of seconds. +Implemented using C. The C<$interval_floating_seconds> argument +is optional and will be zero if unspecified, resulting in C-like +behaviour. This function can be imported, resulting in a nice drop-in +replacement for the C provided with perl, see the L below. + +B: With some operating system and Perl release combinations +C restarts C, instead of interuping it. +This means that an C followed by a C +may together take the sum of the times specified for the the +C and the C, not just the time of the C. + +=item setitimer ( $which, $floating_seconds [, $interval_floating_seconds ] ) + +Start up an interval timer: after a certain time, a signal arrives, +and more signals may keep arriving at certain intervals. To disable a +timer, use C<$floating_seconds> of zero. If the C<$interval_floating_seconds> +is set to zero (or unspecified), the timer is disabled B the +next delivered signal. + +Use of interval timers may interfere with C, C, +and C. In standard-speak the "interaction is unspecified", +which means that I may happen: it may work, it may not. + +In scalar context, the remaining time in the timer is returned. + +In list context, both the remaining time and the interval are returned. + +There are usually three or four interval timers available: the C<$which> +can be C, C, C, or C. +Note that which ones are available depends: true UNIX platforms usually +have the first three, but (for example) Win32 and Cygwin have only +C, and only Solaris seems to have C (which is +used to profile multithreaded programs). + +C results in C-like behavior. Time is counted in +I; that is, wallclock time. C is delivered when +the timer expires. + +C counts time in (process) I; that is, only +when the process is running. In multiprocessor/user/CPU systems this +may be more or less than real or wallclock time. (This time is also +known as the I.) C is delivered when the timer expires. + +C counts time when either the process virtual time or when +the operating system is running on behalf of the process (such as I/O). +(This time is also known as the I.) (The sum of user +time and system time is known as the I.) C is +delivered when the timer expires. C can interrupt system calls. + +The semantics of interval timers for multithreaded programs are +system-specific, and some systems may support additional interval +timers. See your C documentation. + +=item getitimer ( $which ) + +Return the remaining time in the interval timer specified by C<$which>. + +In scalar context, the remaining time is returned. + +In list context, both the remaining time and the interval are returned. +The interval is always what you put in using C. + +=back + +=head1 EXAMPLES + + use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); + + $microseconds = 750_000; + usleep $microseconds; + + # signal alarm in 2.5s & every .1s thereafter + ualarm 2_500_000, 100_000; + + # get seconds and microseconds since the epoch + ($s, $usec) = gettimeofday; + + # measure elapsed time + # (could also do by subtracting 2 gettimeofday return values) + $t0 = [gettimeofday]; + # do bunch of stuff here + $t1 = [gettimeofday]; + # do more stuff here + $t0_t1 = tv_interval $t0, $t1; + + $elapsed = tv_interval ($t0, [gettimeofday]); + $elapsed = tv_interval ($t0); # equivalent code + + # + # replacements for time, alarm and sleep that know about + # floating seconds + # + use Time::HiRes; + $now_fractions = Time::HiRes::time; + Time::HiRes::sleep (2.5); + Time::HiRes::alarm (10.6666666); + + use Time::HiRes qw ( time alarm sleep ); + $now_fractions = time; + sleep (2.5); + alarm (10.6666666); + + # Arm an interval timer to go off first at 10 seconds and + # after that every 2.5 seconds, in process virtual time + + use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time ); + + $SIG{VTALRM} = sub { print time, "\n" }; + setitimer(ITIMER_VIRTUAL, 10, 2.5); + +=head1 C API + +In addition to the perl API described above, a C API is available for +extension writers. The following C functions are available in the +modglobal hash: + + name C prototype + --------------- ---------------------- + Time::NVtime double (*)() + Time::U2time void (*)(UV ret[2]) + +Both functions return equivalent information (like C) +but with different representations. The names C and C +were selected mainly because they are operating system independent. +(C is Unix-centric, though some platforms like VMS have +emulations for it.) + +Here is an example of using C from C: + + double (*myNVtime)(); + SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); + if (!svp) croak("Time::HiRes is required"); + if (!SvIOK(*svp)) croak("Time::NVtime isn't a function pointer"); + myNVtime = INT2PTR(double(*)(), SvIV(*svp)); + printf("The current time is: %f\n", (*myNVtime)()); + +=head1 DIAGNOSTICS + +=head2 negative time not invented yet + +You tried to use a negative time argument. + +=head2 internal error: useconds < 0 (unsigned ... signed ...) + +Something went horribly wrong-- the number of microseconds that cannot +become negative just became negative. Maybe your compiler is broken? + +=head1 CAVEATS + +Notice that the core C maybe rounding rather than truncating. +What this means is that the core C may be reporting the time +as one second later than C and C. + +Adjusting the system clock (either manually or by services like ntp) +may cause problems, especially for long running programs that assume +a monotonously increasing time (note that all platforms do not adjust +time as gracefully as UNIX ntp does). For example in Win32 (and derived +platforms like Cygwin and MinGW) the Time::HiRes::time() may temporarily +drift off from the system clock (and the original time()) by up to 0.5 +seconds. Time::HiRes will notice this eventually and recalibrate. + +=head1 AUTHORS + +D. Wegscheid +R. Schertler +J. Hietaniemi +G. Aas + +=head1 COPYRIGHT AND LICENSE + +Copyright (c) 1996-2002 Douglas E. Wegscheid. All rights reserved. + +Copyright (c) 2002,2003,2004 Jarkko Hietaniemi. All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/agc_2-X/trunk/libs/Time/HiRes.1.65.pm b/agc_2-X/trunk/libs/Time/HiRes.1.65.pm new file mode 100644 index 00000000..e47e09c7 --- /dev/null +++ b/agc_2-X/trunk/libs/Time/HiRes.1.65.pm @@ -0,0 +1,369 @@ +package Time::HiRes; + +use strict; +use vars qw($VERSION $XS_VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); + +require Exporter; +require DynaLoader; + +@ISA = qw(Exporter DynaLoader); + +@EXPORT = qw( ); +@EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval + getitimer setitimer + ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF + d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer + d_nanosleep); + +$VERSION = '1.65'; +$XS_VERSION = $VERSION; +$VERSION = eval $VERSION; + +sub AUTOLOAD { + my $constname; + ($constname = $AUTOLOAD) =~ s/.*:://; + die "&Time::HiRes::constant not defined" if $constname eq 'constant'; + my ($error, $val) = constant($constname); + if ($error) { die $error; } + { + no strict 'refs'; + *$AUTOLOAD = sub { $val }; + } + goto &$AUTOLOAD; +} + +bootstrap Time::HiRes; + +# Preloaded methods go here. + +sub tv_interval { + # probably could have been done in C + my ($a, $b) = @_; + $b = [gettimeofday()] unless defined($b); + (${$b}[0] - ${$a}[0]) + ((${$b}[1] - ${$a}[1]) / 1_000_000); +} + +# Autoload methods go after =cut, and are processed by the autosplit program. + +1; +__END__ + +=head1 NAME + +Time::HiRes - High resolution alarm, sleep, gettimeofday, interval timers + +=head1 SYNOPSIS + + use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); + + usleep ($microseconds); + + ualarm ($microseconds); + ualarm ($microseconds, $interval_microseconds); + + $t0 = [gettimeofday]; + ($seconds, $microseconds) = gettimeofday; + + $elapsed = tv_interval ( $t0, [$seconds, $microseconds]); + $elapsed = tv_interval ( $t0, [gettimeofday]); + $elapsed = tv_interval ( $t0 ); + + use Time::HiRes qw ( time alarm sleep ); + + $now_fractions = time; + sleep ($floating_seconds); + alarm ($floating_seconds); + alarm ($floating_seconds, $floating_interval); + + use Time::HiRes qw( setitimer getitimer + ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF ITIMER_REALPROF ); + + setitimer ($which, $floating_seconds, $floating_interval ); + getitimer ($which); + +=head1 DESCRIPTION + +The C module implements a Perl interface to the +C, C, C, and C/C +system calls, in other words, high resolution time and timers. See the +L section below and the test scripts for usage; see your +system documentation for the description of the underlying +C or C, C, C, and +C/C calls. + +If your system lacks C or an emulation of it you don't +get C or the one-argument form of C. +If your system lacks all of C, C, and +C, you don't get C or +C. If your system lacks both C and +C you don't get C or +C. + +If you try to import an unimplemented function in the C statement +it will fail at compile time. + +If your subsecond sleeping is implemented with C instead +of C, you can mix subsecond sleeping with signals since +C does not use signals. This, however, is not portable, +and you should first check for the truth value of +C<&Time::HiRes::d_nanosleep> to see whether you have nanosleep, and +then carefully read your C C API documentation for any +peculiarities. (There is no separate interface to call +C; just use C or +C with small enough values.) + +Unless using C for mixing sleeping with signals, give +some thought to whether Perl is the tool you should be using for +work requiring nanosecond accuracies. + +The following functions can be imported from this module. +No functions are exported by default. + +=over 4 + +=item gettimeofday () + +In array context returns a two-element array with the seconds and +microseconds since the epoch. In scalar context returns floating +seconds like C (see below). + +=item usleep ( $useconds ) + +Sleeps for the number of microseconds specified. Returns the number +of microseconds actually slept. Can sleep for more than one second, +unlike the C system call. See also C below. + +=item ualarm ( $useconds [, $interval_useconds ] ) + +Issues a C call; the C<$interval_useconds> is optional and +will be zero if unspecified, resulting in C-like behaviour. + +Note that the interaction between alarms and sleeps are unspecified. + +=item tv_interval + +tv_interval ( $ref_to_gettimeofday [, $ref_to_later_gettimeofday] ) + +Returns the floating seconds between the two times, which should have +been returned by C. If the second argument is omitted, +then the current time is used. + +=item time () + +Returns a floating seconds since the epoch. This function can be +imported, resulting in a nice drop-in replacement for the C
$lang_list_name $lang_list_name