diff --git a/agi/agi-record_prompts.agi b/agi/agi-record_prompts.agi index 05d980dd..a7158bd5 100644 --- a/agi/agi-record_prompts.agi +++ b/agi/agi-record_prompts.agi @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# agi-record_prompts.agi version 2.6 +# agi-record_prompts.agi version 2.12 # # for recording prompts to GSM file over the phone # Saves recordings with 8-digit filenames to be played when exten is dialed @@ -29,19 +29,87 @@ # - vm-msgsaved # - vm-goodbye # -# Copyright (C) 2013 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2016 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # 71226-1303 - Added option to change format GSM/WAV and timeout through flags # 90519-1019 - Changed formatting to conform to other scripts # 130108-1815 - Changes for Asterisk 1.8 compatibility +# 161029-2239 - Changed to database storage for prompt count # +$script = 'agi-record_prompts.agi'; +&get_time_now; $US='_'; + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +if (!$VARDB_port) {$VARDB_port='3306';} +if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";} + +use DBI; use Asterisk::AGI; $AGI = new Asterisk::AGI; +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + +### Grab Server values from the database +$stmtA = "SELECT agi_output FROM servers where server_ip = '$VARserver_ip';"; +$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) + { + $AGILOG = '0'; + @aryA = $sthA->fetchrow_array; + $DBagi_output = $aryA[0]; + if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';} + if ($DBagi_output =~ /FILE/) {$AGILOG = '2';} + if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';} + $rec_count++; + } +$sthA->finish(); + + ### begin parsing run-time options ### if (length($ARGV[0])>1) { @@ -90,6 +158,22 @@ $quit_program=0; $loop_counter=0; $REC_id = 85100000; $REC_next = 0; +$rec_prompt_count=1; +$rec_prompt_count_next=0; + +### Gather current rec_prompt_count from system_settings ### +$stmtA= "SELECT rec_prompt_count from system_settings;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; + if ($AGILOG) {$agi_string = "$sthArows|$stmtA|"; &agi_output;} +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $rec_prompt_count = $aryA[0]; + $rec_prompt_count_next = ($rec_prompt_count + 1); + } +$sthA->finish(); if (-e "/prompt_count.txt") { @@ -97,19 +181,26 @@ if (-e "/prompt_count.txt") @test = ; close(test); + $test[0] = ($test[0] + 0); + if ($rec_prompt_count > $test[0]) + {$test[0] = $rec_prompt_count;} + if ($rec_prompt_count < $test[0]) + { + $rec_prompt_count = $test[0]; + ### update the rec_prompt_count in system_settings + $stmtA = "UPDATE system_settings SET rec_prompt_count='$rec_prompt_count';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + } $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"; + print test "$rec_prompt_count"; close(test); - $REC_id = ($REC_id + 1); + $REC_id = ($REC_id + $rec_prompt_count); } $session_recording = "$REC_id"; @@ -169,6 +260,15 @@ sub welcome_1 exit; } + ### update the rec_prompt_count in system_settings + $stmtA = "UPDATE system_settings SET rec_prompt_count='$REC_next';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + + open(test, ">/prompt_count.txt") || die "can't open /prompt_count.txt: $!\n"; + print test "$REC_next"; + close(test); + &record_prompts; } @@ -278,11 +378,12 @@ sub verify_recording { if ($pin == '1') { - $AGI->stream_file('auth-thankyou'); + $AGI->stream_file('auth-thankyou'); $AGI->say_digits("$REC_id"); - $AGI->stream_file('beep'); + $AGI->stream_file('beep'); $AGI->say_digits("$REC_id"); - $AGI->stream_file('vm-goodbye'); + $AGI->stream_file('vm-goodbye'); + $AGI->stream_file('silence'); exit; } if ($pin == '2') @@ -294,7 +395,6 @@ sub verify_recording { &record_prompts; } - } } @@ -342,6 +442,10 @@ sub enter_pin_number { # please enter the pin number followed by the pound key + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); + $interrupt_digit=''; $interrupt_digit = $AGI->stream_file('ld_welcome_pin_number','123456789'); @@ -417,3 +521,19 @@ sub checkresult $fail++; } } + +sub agi_output +{ +if ($AGILOG >=2) + { + ### open the log file for writing ### + open(Lout, ">>$AGILOGfile") + || die "Can't open $AGILOGfile: $!\n"; + print Lout "$now_date|$script|$agi_string\n"; + close(Lout); + } + ### send to STDERR writing ### +if ( ($AGILOG == '1') || ($AGILOG == '3') ) + {print STDERR "$now_date|$script|$agi_string\n";} +$agi_string=''; +} diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index c0fcf194..27f7195f 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -1675,7 +1675,8 @@ agent_screen_colors VARCHAR(20) default 'default', script_remove_js ENUM('1','0') default '1', manual_auto_next ENUM('1','0') default '0', user_new_lead_limit ENUM('1','0') default '0', -agent_xfer_park_3way ENUM('1','0') default '0' +agent_xfer_park_3way ENUM('1','0') default '0', +rec_prompt_count INT(9) UNSIGNED default '0' ) ENGINE=MyISAM; CREATE TABLE vicidial_campaigns_list_mix ( @@ -3805,4 +3806,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1472',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1473',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/extras/upgrade_2.12.sql b/extras/upgrade_2.12.sql index ab98fb29..fabfa66f 100644 --- a/extras/upgrade_2.12.sql +++ b/extras/upgrade_2.12.sql @@ -726,3 +726,7 @@ ALTER TABLE vicidial_user_groups ADD agent_xfer_park_3way ENUM('Y','N') default ALTER TABLE system_settings ADD agent_xfer_park_3way ENUM('1','0') default '0'; UPDATE system_settings SET db_schema_version='1472',db_schema_update_date=NOW() where db_schema_version < 1472; + +ALTER TABLE system_settings ADD rec_prompt_count INT(9) UNSIGNED default '0'; + +UPDATE system_settings SET db_schema_version='1473',db_schema_update_date=NOW() where db_schema_version < 1473; diff --git a/www/agc/conf_exten_check.php b/www/agc/conf_exten_check.php index 81632908..d1ddfb4b 100644 --- a/www/agc/conf_exten_check.php +++ b/www/agc/conf_exten_check.php @@ -73,10 +73,11 @@ # 160227-1007 - Fixed XSS security issue, issue #929 # 160303-2354 - Added code for chat transfers # 160326-0942 - Fixed issue #933, variables +# 161029-2216 - Formatting and additional agent debug logging # -$version = '2.12-48'; -$build = '160326-0942'; +$version = '2.12-49'; +$build = '161029-2216'; $php_script = 'conf_exten_check.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=44; @@ -247,6 +248,10 @@ if ($format=='debug') echo "\n"; } + +################################################################################ +### refresh - sends agent session data to agent screen every second +################################################################################ if ($ACTION == 'refresh') { $MT[0]=''; @@ -882,8 +887,13 @@ if ($ACTION == 'refresh') } echo "$countecho\n"; + $stage = "$Astatus|$Aagent_log_id"; } + +################################################################################ +### register - registers a conference to a phone +################################################################################ if ($ACTION == 'register') { $MT[0]=''; @@ -907,6 +917,9 @@ if ($ACTION == 'register') +################################################################################ +### DEBUG OUTPUT AND LOGGING +################################################################################ if ($format=='debug') { $ENDtime = date("U"); diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index aec1d393..fa685aa6 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -1490,6 +1490,7 @@ if ($ACTION == 'regCLOSER') } echo _QXZ("Closer In Group Choice %1s has been registered to user %2s",0,'',$closer_choice,$user)."\n"; + $stage = "$vla_autodial|$closer_choice"; } @@ -1549,6 +1550,7 @@ if ($ACTION == 'regTERRITORY') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00256',$user,$server_ip,$session_name,$one_mysql_log);} } echo _QXZ("Territory Choice %1s has been registered to user %2s",0,'',$agent_territories,$user)."\n"; + $stage = $agent_territories; } diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index a85671e1..96c0ba8b 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -3877,12 +3877,13 @@ else # 161018-2249 - Added allow_required_fields campaign option # 161021-1320 - Added Fronter - Closer Detail Report, Fixed admin logging bug # 161028-1539 - Added agent_xfer_park_3way option to system settings and user groups +# 161029-2304 - Added rec_prompt_count display to system settings # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.12-569a'; -$build = '161028-1539'; +$admin_version = '2.12-570a'; +$build = '161029-2304'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -32600,7 +32601,7 @@ if ($ADD==311111111111111) $ALLagent_count = $rowx[2]; } - $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled,usacan_phone_dialcode_fix,cache_carrier_stats_realtime,oldest_logs_date,log_recording_access,report_default_format,alt_ivr_logging,default_phone_code,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way from system_settings;"; + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled,usacan_phone_dialcode_fix,cache_carrier_stats_realtime,oldest_logs_date,log_recording_access,report_default_format,alt_ivr_logging,default_phone_code,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,rec_prompt_count from system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $version = $row[0]; @@ -32755,6 +32756,7 @@ if ($ADD==311111111111111) $manual_auto_next = $row[149]; $user_new_lead_limit = $row[150]; $agent_xfer_park_3way = $row[151]; + $rec_prompt_count = $row[152]; if ($pass_hash_enabled > 0) {$pass_hash_enabled = 'ENABLED';} else {$pass_hash_enabled = 'DISABLED';} @@ -32780,6 +32782,7 @@ if ($ADD==311111111111111) echo ""._QXZ("DB Schema Update Date").": $db_schema_update_date\n"; echo ""._QXZ("Password Encryption").": $pass_hash_enabled - $pass_key - $pass_cost\n"; echo ""._QXZ("Auto User-add Value").": $auto_user_add_value\n"; + echo ""._QXZ("Recording Prompt Count").": $rec_prompt_count\n"; echo ""._QXZ("Install Date").": $install_date\n"; $pcblinkB=''; $pcblinkE=''; if ($vicidial_phone_codes_count < 1000) {$pcblinkB=''; $pcblinkE='';}