Added Khomp campaign settings option

Added experimental stereo recording testing code

git-svn-id: svn://192.168.202.10@3880 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-10-22 02:15:09 +00:00
parent a0b526484f
commit d53bbc1a5d
10 changed files with 1015 additions and 286 deletions
+52 -8
View File
@@ -263,6 +263,7 @@
# 240420-2242 - Added ConfBridge code
# 240415-1701 - Fix for ConfBridge code
# 240723-1632 - Small fix for ConfBridge
# 240906-1032 - Added testing for stereo_recording in-group option *NOT PRODUCTION READY*
#
$script = 'agi-VDAD_ALL_inbound.agi';
@@ -402,7 +403,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database
$stmtA = "SELECT agi_output,local_gmt FROM servers where server_ip = '$VARserver_ip';";
$stmtA = "SELECT agi_output,local_gmt,conf_engine 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;
@@ -415,6 +416,7 @@ while ($sthArows > $rec_count)
@aryA = $sthA->fetchrow_array;
$DBagi_output = $aryA[0];
$local_gmt = $aryA[1];
$conf_engine = $aryA[2];
if ($isdst) {$local_gmt++;}
if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';}
if ($DBagi_output =~ /FILE/) {$AGILOG = '2';}
@@ -894,7 +896,7 @@ $affected_rows = $dbhA->do($stmtA);
### Grab inbound groups values from the database
$cbc=0;
$stmtA = "SELECT call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,drop_call_seconds,drop_action,drop_exten,next_agent_call,voicemail_ext,queue_priority,drop_inbound_group,afterhours_xfer_group,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,no_agent_no_queue,no_agent_action,no_agent_action_value,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,active,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,ingroup_recording_override,ingroup_rec_filename,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,max_calls_method,max_calls_count,max_calls_action,populate_lead_ingroup,na_call_url,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,routing_initiated_recordings,on_hook_cid_number,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,add_lead_timezone,populate_lead_source,populate_lead_vendor,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,answer_signal,no_agent_delay,agent_search_method,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only FROM vicidial_inbound_groups where group_id = '$channel_group';";
$stmtA = "SELECT call_time_id,after_hours_action,after_hours_message_filename,after_hours_exten,after_hours_voicemail,welcome_message_filename,moh_context,onhold_prompt_filename,prompt_interval,agent_alert_exten,agent_alert_delay,drop_call_seconds,drop_action,drop_exten,next_agent_call,voicemail_ext,queue_priority,drop_inbound_group,afterhours_xfer_group,play_place_in_line,play_estimate_hold_time,hold_time_option,hold_time_option_seconds,hold_time_option_exten,hold_time_option_voicemail,hold_time_option_xfer_group,hold_time_option_callback_filename,hold_time_option_callback_list_id,hold_recall_xfer_group,no_delay_call_route,play_welcome_message,no_agent_no_queue,no_agent_action,no_agent_action_value,extension_appended_cidname,uniqueid_status_display,uniqueid_status_prefix,hold_time_option_minimum,hold_time_option_press_filename,hold_time_option_callmenu,onhold_prompt_no_block,onhold_prompt_seconds,hold_time_option_no_block,hold_time_option_prompt_seconds,hold_time_second_option,hold_time_third_option,wait_hold_option_priority,wait_time_option,wait_time_second_option,wait_time_third_option,wait_time_option_seconds,wait_time_option_exten,wait_time_option_voicemail,wait_time_option_xfer_group,wait_time_option_callmenu,wait_time_option_callback_filename,wait_time_option_callback_list_id,wait_time_option_press_filename,wait_time_option_no_block,wait_time_option_prompt_seconds,active,calculate_estimated_hold_seconds,add_lead_url,eht_minimum_prompt_filename,eht_minimum_prompt_no_block,eht_minimum_prompt_seconds,on_hook_ring_time,ingroup_recording_override,ingroup_rec_filename,on_hook_cid,action_xfer_cid,drop_callmenu,after_hours_callmenu,max_calls_method,max_calls_count,max_calls_action,populate_lead_ingroup,na_call_url,drop_lead_reset,after_hours_lead_reset,nanq_lead_reset,wait_time_lead_reset,hold_time_lead_reset,routing_initiated_recordings,on_hook_cid_number,populate_lead_province,areacode_filter,areacode_filter_seconds,areacode_filter_action,areacode_filter_action_value,populate_state_areacode,inbound_survey,inbound_survey_filename,inbound_survey_accept_digit,closing_time_action,closing_time_now_trigger,closing_time_filename,closing_time_end_filename,closing_time_lead_reset,closing_time_option_exten,closing_time_option_callmenu,closing_time_option_voicemail,closing_time_option_xfer_group,closing_time_option_callback_list_id,add_lead_timezone,populate_lead_source,populate_lead_vendor,enter_ingroup_url,cid_cb_confirm_number,cid_cb_invalid_filter_phone_group,cid_cb_valid_length,cid_cb_valid_filename,cid_cb_confirmed_filename,cid_cb_enter_filename,cid_cb_you_entered_filename,cid_cb_press_to_confirm_filename,cid_cb_invalid_filename,cid_cb_reenter_filename,cid_cb_error_filename,place_in_line_caller_number_filename,place_in_line_you_next_filename,answer_signal,no_agent_delay,agent_search_method,populate_lead_comments,drop_call_seconds_override,populate_lead_owner,in_queue_nanque,in_queue_nanque_exceptions,second_alert_trigger,second_alert_trigger_seconds,second_alert_filename,second_alert_delay,second_alert_container,second_alert_only,third_alert_trigger,third_alert_trigger_seconds,third_alert_filename,third_alert_delay,third_alert_container,third_alert_only,stereo_recording FROM vicidial_inbound_groups where group_id = '$channel_group';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1050,6 +1052,7 @@ if ($sthArows > 0)
$third_alert_delay = $aryA[138];
$third_alert_container = $aryA[139];
$third_alert_only = $aryA[140];
$stereo_recording = $aryA[141];
if ( (length($place_in_line_caller_number_filename) < 1) || ($place_in_line_caller_number_filename =~ /^NULL$/i) )
{$place_in_line_caller_number_filename='queue-thereare';}
@@ -3430,6 +3433,18 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override
$dbhP=$dbhA; $mysql_count='02214'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
}
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$retval_stop = $AGI->exec("StopMixMonitor","");
$retval = $AGI->exec("MixMonitor",",r(/var/spool/asterisk/monitorS/$campaign_rec_filename-in.wav)t(/var/spool/asterisk/monitorS/$campaign_rec_filename-out.wav)");
### insert record into recording_log_stereo table ###
$stmtA = "INSERT INTO recording_log_stereo (recording_id,server_ip,start_time,length_in_sec,filename,lead_id,options,processing_log) values('$recording_id','$VDADserver_ip','$now_date','0','$campaign_rec_filename','$insert_lead_id','$stereo_recording $channel_group','start: $now_date|vicidial_id: $insert_close_id|user: $VDADuser|channel: $channel|');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE STEREO RECORDING STARTED : |$retval|$retval_stop|$SRaffected_rows|$recording_id|$stmtA|"; &agi_output;}
}
$vmgr_callerid = substr($campaign_rec_filename, 0, 17) . '...';
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$VDADserver_ip','','Originate','$vmgr_callerid','Channel: $channelrec','Context: $ext_context','Exten: $recording_exten','Priority: 1','Callerid: $campaign_rec_filename','','','','','');";
$affected_rows = $dbhA->do($stmtA);
@@ -3901,7 +3916,7 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_engine = $aryA[0];
$conf_engine = $aryA[0];
$rec_count++;
}
$sthA->finish();
@@ -4670,21 +4685,50 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override
$campaign_rec_filename =~ s/CALLID/$callerid/gi;
$campaign_rec_filename =~ s/\"|\'//gi;
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
$retval_stop = $AGI->exec("StopMixMonitor","");
$retval = $AGI->exec("MixMonitor",",r(/var/spool/asterisk/monitorS/$campaign_rec_filename-in.wav)t(/var/spool/asterisk/monitorS/$campaign_rec_filename-out.wav)");
}
else
{
$AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
{
$retval = $AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
}
else
{
$retval = $AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
}
}
### insert record into recording_log table ###
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$phone_number','$now_date','$now_date_epoch','0','$campaign_rec_filename','$insert_lead_id','$VDADuser','$campaign_rec_filename','$insert_close_id');";
$RLRAaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01173'; $MEL_aff_rows=$RLRAaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE RECORDING STARTED : |$RLRAaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- REMOTE RECORDING STARTED : |$retval|$RLRAaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$stmtB = "SELECT LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$recording_id = $aryA[0];
}
$sthA->finish();
### insert record into recording_log_stereo table ###
$stmtA = "INSERT INTO recording_log_stereo (recording_id,server_ip,start_time,length_in_sec,filename,lead_id,options,processing_log) values('$recording_id','$VDADserver_ip','$now_date','0','$campaign_rec_filename','$insert_lead_id','$stereo_recording $channel_group','start: $now_date|vicidial_id: $insert_close_id|user: $VDADuser|channel: $channel|');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE STEREO RECORDING STARTED : |$retval|$SRaffected_rows|$recording_id|$stmtA|"; &agi_output;}
}
}
}
### END REMOTE AGENT SECTION
+170 -57
View File
@@ -129,7 +129,9 @@
# 220524-1746 - Changed SHARED_ campaign in-group transfers to use 'SRDROP' log status instead of 'DROP'
# 230309-0952 - Added abandon_check_queue feature
# 240804-1218 - Remove ding and sleep for dropped calls going to an extension(message)
# 240906-1021 - Added testing for stereo_recording campaign option *NOT PRODUCTION READY*
# 241001-2222 - Fixes for Khomp call processing
# 241020-1928 - Added khomp campaign settings options
#
$script = 'agi-VDAD_ALL_outbound.agi';
@@ -299,7 +301,7 @@ $sthA->finish();
### Grab Server values from the database
$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks,agi_output,voicemail_dump_exten_no_inst,external_server_ip FROM servers where server_ip = '$VARserver_ip';";
$stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks,agi_output,voicemail_dump_exten_no_inst,external_server_ip,conf_engine 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;
@@ -317,6 +319,7 @@ while ($sthArows > $rec_count)
$DBagi_output = $aryA[6];
$voicemail_dump_exten_no_inst = $aryA[7];
$external_server_ip = $aryA[8];
$conf_engine = $aryA[9];
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;}
@@ -825,7 +828,7 @@ if ($VDACaffected_rows > 0)
##### END - Max call stats
### Grab campaign values from the database
$stmtA = "SELECT drop_call_seconds,drop_action,safe_harbor_exten,concurrent_transfers,next_agent_call,voicemail_ext,drop_inbound_group,use_internal_dnc,use_campaign_dnc,cpd_amd_action,am_message_exten,three_way_call_cid,campaign_cid,survey_first_audio_file,survey_opt_in_audio_file,survey_ni_audio_file,survey_third_audio_file,survey_fourth_audio_file,extension_appended_cidname,queue_priority,closer_campaigns,queuemetrics_phone_environment,campaign_recording,campaign_rec_filename,safe_harbor_audio,safe_harbor_menu_id,survey_recording,safe_harbor_audio_field,use_other_campaign_dnc,cpd_unknown_action,routing_initiated_recordings,campaign_rec_exten,call_quota_lead_ranking,sip_event_logging,amd_type,agent_search_method,dial_method FROM vicidial_campaigns where campaign_id = '$VDADcampaign';";
$stmtA = "SELECT drop_call_seconds,drop_action,safe_harbor_exten,concurrent_transfers,next_agent_call,voicemail_ext,drop_inbound_group,use_internal_dnc,use_campaign_dnc,cpd_amd_action,am_message_exten,three_way_call_cid,campaign_cid,survey_first_audio_file,survey_opt_in_audio_file,survey_ni_audio_file,survey_third_audio_file,survey_fourth_audio_file,extension_appended_cidname,queue_priority,closer_campaigns,queuemetrics_phone_environment,campaign_recording,campaign_rec_filename,safe_harbor_audio,safe_harbor_menu_id,survey_recording,safe_harbor_audio_field,use_other_campaign_dnc,cpd_unknown_action,routing_initiated_recordings,campaign_rec_exten,call_quota_lead_ranking,sip_event_logging,amd_type,agent_search_method,dial_method,stereo_recording,khomp_settings_container FROM vicidial_campaigns where campaign_id = '$VDADcampaign';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -873,6 +876,8 @@ if ($VDACaffected_rows > 0)
$amd_type = $aryA[34];
$agent_search_method_OVERRIDE = $aryA[35];
$campaign_dial_method = $aryA[36];
$stereo_recording = $aryA[37];
$khomp_settings_container = $aryA[38];
if (length($closer_campaigns) > 2)
{
$closer_campaigns =~ s/^ | -$//gi;
@@ -891,12 +896,15 @@ if ($VDACaffected_rows > 0)
$khomp_api_login_url = '';
$khomp_api_user = '';
$khomp_api_pass = '';
$khomp_api_check_ssl = '';
$khomp_header = '';
$khomp_id_format = '';
$khomp_api_token = '';
$khomp_api_token_expire = '';
$khomp_api_token_expire = 0;
$stmtA = "SELECT container_entry FROM vicidial_settings_containers WHERE container_id = 'KHOMPSETTINGS';";
$agi_string = "-- KHOMP: Using settings container $khomp_settings_container"; &agi_output;
$stmtA = "SELECT container_entry FROM vicidial_settings_containers WHERE container_id = '$khomp_settings_container';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -930,6 +938,7 @@ if ($VDACaffected_rows > 0)
if ( $key eq 'khomp_api_proxied' ) { $khomp_api_proxied = $value; }
if ( $key eq 'khomp_api_user' ) { $khomp_api_user = $value; }
if ( $key eq 'khomp_api_pass' ) { $khomp_api_pass = $value; }
if ( $key eq 'khomp_api_check_ssl' ) { $khomp_api_check_ssl = $value; }
if ( $key eq 'khomp_header' ) { $khomp_header = $value; }
if ( $key eq 'khomp_id_format' ) { $khomp_id_format = $value; }
if ( $key eq 'khomp_api_login_url' ) { $khomp_api_login_url = $value; }
@@ -938,7 +947,7 @@ if ($VDACaffected_rows > 0)
}
}
$agi_string = "KHOMP Settings: url-$khomp_api_url|proxied-$khomp_api_proxied|login_url-$khomp_api_login_url|user-$khomp_api_user|pass-$khomp_api_pass|header-$khomp_header|format-$khomp_id_format";
$agi_string = "KHOMP Settings: url-$khomp_api_url|proxied-$khomp_api_proxied|login_url-$khomp_api_login_url|user-$khomp_api_user|pass-$khomp_api_pass|ssl-check-$khomp_api_check_ssl|header-$khomp_header|format-$khomp_id_format|api-token-$khomp_api_token|token-expire-$khomp_api_token_expire|";
&agi_output;
}
@@ -1647,11 +1656,11 @@ if ($call_handle_method =~ /REMIND/)
$khomp_api_proxied,
$khomp_api_login_url,
$khomp_api_user,
$khomp_api_pass,
$khomp_api_pass,
$khomp_api_check_ssl,
$khomp_header,
$khomp_id_format,
$khomp_api_token,
$khomp_api_token_expire,
$khomp_settings_container,
$external_server_ip,
$VDADcampaign,
$callerid,
@@ -1754,11 +1763,11 @@ if ($call_handle_method =~ /SURVEY/)
$khomp_api_proxied,
$khomp_api_login_url,
$khomp_api_user,
$khomp_api_pass,
$khomp_api_pass,
$khomp_api_check_ssl,
$khomp_header,
$khomp_id_format,
$khomp_api_token,
$khomp_api_token_expire,
$khomp_settings_container,
$external_server_ip,
$VDADcampaign,
$callerid,
@@ -2641,10 +2650,10 @@ if (( $amd_type eq 'KHOMP' ) && ( $khomp_enabled ) )
$khomp_api_login_url,
$khomp_api_user,
$khomp_api_pass,
$khomp_api_check_ssl,
$khomp_header,
$khomp_id_format,
$khomp_api_token,
$khomp_api_token_expire,
$khomp_settings_container,
$external_server_ip,
$VDADcampaign,
$callerid,
@@ -3165,21 +3174,49 @@ while ($drop_timer <= $DROP_TIME)
$campaign_rec_filename =~ s/CALLID/$callerid/gi;
$campaign_rec_filename =~ s/\"|\'//gi;
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
$retval = $AGI->exec("MixMonitor",",r(/var/spool/asterisk/monitorS/$campaign_rec_filename-in.wav)t(/var/spool/asterisk/monitorS/$campaign_rec_filename-out.wav)");
}
else
{
$AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
{
$retval = $AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
}
else
{
$retval = $AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
}
}
### insert record into recording_log table ###
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$VDADphone','$now_date','$now_date_epoch','0','$campaign_rec_filename','$CIDlead_id','$VDADuser','$campaign_rec_filename','$uniqueid');";
$RLRAaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01074'; $MEL_aff_rows=$RLRAaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE RECORDING STARTED : |$RLRAaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- REMOTE RECORDING STARTED : |$retval|$RLRAaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$stmtB = "SELECT LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$recording_id = $aryA[0];
}
$sthA->finish();
### insert record into recording_log_stereo table ###
$stmtA = "INSERT INTO recording_log_stereo (recording_id,server_ip,start_time,length_in_sec,filename,lead_id,options,processing_log) values('$recording_id','$VARserver_ip','$now_date','0','$campaign_rec_filename','$CIDlead_id','$stereo_recording $VDADcampaign','start: $now_date|vicidial_id: $uniqueid|user: $VDADuser|channel: $channel|');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE STEREO RECORDING STARTED : |$retval|$SRaffected_rows|$recording_id|$stmtA|"; &agi_output;}
}
}
}
### END REMOTE AGENT SECTION
@@ -3278,6 +3315,17 @@ while ($drop_timer <= $DROP_TIME)
$dbhP=$dbhA; $mysql_count='02125'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
}
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$retval = $AGI->exec("MixMonitor",",r(/var/spool/asterisk/monitorS/$campaign_rec_filename-in.wav)t(/var/spool/asterisk/monitorS/$campaign_rec_filename-out.wav)");
### insert record into recording_log_stereo table ###
$stmtA = "INSERT INTO recording_log_stereo (recording_id,server_ip,start_time,length_in_sec,filename,lead_id,options,processing_log) values('$recording_id','$VARserver_ip','$now_date','0','$campaign_rec_filename','$CIDlead_id','$stereo_recording $VDADcampaign','start: $now_date|vicidial_id: $uniqueid|user: $VDADuser|channel: $channel|');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE STEREO RECORDING STARTED : |$retval|$SRaffected_rows|$recording_id|$stmtA|"; &agi_output;}
}
$vmgr_callerid = substr($campaign_rec_filename, 0, 17) . '...';
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$VDADserver_ip','','Originate','$vmgr_callerid','Channel: $channelrec','Context: $ext_context','Exten: $campaign_rec_exten','Priority: 1','Callerid: $campaign_rec_filename','','','','','');";
$affected_rows = $dbhA->do($stmtA);
@@ -3906,21 +3954,50 @@ while ($drop_timer <= $DROP_TIME)
$campaign_rec_filename =~ s/CALLID/$callerid/gi;
$campaign_rec_filename =~ s/\"|\'//gi;
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
$retval = $AGI->exec("MixMonitor",",r(/var/spool/asterisk/monitorS/$campaign_rec_filename-in.wav)t(/var/spool/asterisk/monitorS/$campaign_rec_filename-out.wav)");
}
else
{
$AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
{
$retval = $AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
}
else
{
$retval = $AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
}
}
### insert record into recording_log table ###
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$VDADphone','$now_date','$now_date_epoch','0','$campaign_rec_filename','$CIDlead_id','$VDADuser','$campaign_rec_filename','$uniqueid');";
$RLRAaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01076'; $MEL_aff_rows=$RLRAaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE RECORDING STARTED : |$RLRAaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- REMOTE RECORDING STARTED : |$retval|$RLRAaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$stmtB = "SELECT LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$recording_id = $aryA[0];
}
$sthA->finish();
### insert record into recording_log_stereo table ###
$stmtA = "INSERT INTO recording_log_stereo (recording_id,server_ip,start_time,length_in_sec,filename,lead_id,options,processing_log) values('$recording_id','$VARserver_ip','$now_date','0','$campaign_rec_filename','$CIDlead_id','$stereo_recording $VDADcampaign','start: $now_date|vicidial_id: $uniqueid|channel: $channel|');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE2 STEREO RECORDING STARTED : |$retval|$SRaffected_rows|$recording_id|$stmtA|"; &agi_output;}
}
}
}
### END REMOTE AGENT SECTION
@@ -4019,6 +4096,17 @@ while ($drop_timer <= $DROP_TIME)
$dbhP=$dbhA; $mysql_count='02133'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
}
if ( ($stereo_recording =~ /CUSTOMER/i) && ($conf_engine eq "CONFBRIDGE") )
{
$retval = $AGI->exec("MixMonitor",",r(/var/spool/asterisk/monitorS/$campaign_rec_filename-in.wav)t(/var/spool/asterisk/monitorS/$campaign_rec_filename-out.wav)");
### insert record into recording_log_stereo table ###
$stmtA = "INSERT INTO recording_log_stereo (recording_id,server_ip,start_time,length_in_sec,filename,lead_id,options,processing_log) values('$recording_id','$VARserver_ip','$now_date','0','$campaign_rec_filename','$CIDlead_id','$stereo_recording $VDADcampaign','start: $now_date|vicidial_id: $uniqueid|user: $VDADuser|channel: $channel|');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- REMOTE STEREO RECORDING STARTED : |$retval|$SRaffected_rows|$recording_id|$stmtA|"; &agi_output;}
}
$vmgr_callerid = substr($campaign_rec_filename, 0, 17) . '...';
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$VDADserver_ip','','Originate','$vmgr_callerid','Channel: $channelrec','Context: $ext_context','Exten: $campaign_rec_exten','Priority: 1','Callerid: $campaign_rec_filename','','','','','');";
$affected_rows = $dbhA->do($stmtA);
@@ -5267,11 +5355,11 @@ sub process_khomp_analytics
$khomp_api_proxied,
$khomp_api_login_url,
$khomp_api_user,
$khomp_api_pass,
$khomp_api_pass,
$khomp_api_check_ssl,
$khomp_header,
$khomp_id_format,
$khomp_api_token,
$khomp_api_token_expire,
$khomp_id_format,
$khomp_settings_container,
$external_server_ip,
$campaign_id,
$callerid,
@@ -5292,8 +5380,7 @@ sub process_khomp_analytics
{ $khomp_id = $callerid . '_' . $campaign_id . '_' . $external_server_ip; }
my $api_auth_time = 0;
if ( ( !( $khomp_api_token_expire ) ) and ( $khomp_api_token_expire != 0 ) ) { $khomp_api_token_expire = 0; }
if ( ( $khomp_api_token_expire < time() ) or ( $khomp_api_token eq 'TOKENTOKENTOKEN' ))
if ( ($khomp_api_token_expire < time() ) or ( $khomp_api_token eq 'TOKENTOKENTOKEN' ))
{
if ($AGILOG) {$agi_string = "-- KHOMP API Token $khomp_api_token has expired at $khomp_api_token_expire"; &agi_output;}
@@ -5301,34 +5388,38 @@ sub process_khomp_analytics
my $new_khomp_api_token = '';
if ( $khomp_api_proxied eq 'false' )
{
($new_khomp_api_token, $api_auth_time) = khomp_api_login( $khomp_api_login_url, $khomp_api_user, $khomp_api_pass );
($new_khomp_api_token, $api_auth_time) = khomp_api_login( $khomp_api_login_url, $khomp_api_user, $khomp_api_pass, $khomp_api_check_ssl );
}
# update the settings container
my $old_token_string = "khomp_api_token => $khomp_api_token";
my $new_token_string = "khomp_api_token => $new_khomp_api_token";
my $new_token_expire_time = time() + 3600;
my $old_token_expire_string = "khomp_api_token_expire => $khomp_api_token_expire";
my $new_token_expire_string = "khomp_api_token_expire => $new_token_expire_time";
if ( $new_khomp_api_token ne '0' )
{
# LOCK vicidial_settings_containers
$stmtA = "LOCK TABLES vicidial_settings_containers WRITE";
$dbhA->do($stmtA);
# UPDATE the Token
$stmtToken = "UPDATE vicidial_settings_containers SET container_entry = REGEXP_REPLACE(container_entry, '$old_token_string', '$new_token_string') WHERE container_id = 'KHOMPSETTINGS';";
$affected_rows = $dbhA->do($stmtToken);
# UPDATE the Expire time
$stmtExpire = "UPDATE vicidial_settings_containers SET container_entry = REGEXP_REPLACE(container_entry, '$old_token_expire_string', '$new_token_expire_string') WHERE container_id = 'KHOMPSETTINGS';";
$affected_rows = $dbhA->do($stmtExpire);
# Unlock vicidial_settings_containers
$stmtA = "UNLOCK TABLES";
$dbhA->do($stmtA);
# update the settings container
my $old_token_string = "khomp_api_token => $khomp_api_token";
my $new_token_string = "khomp_api_token => $new_khomp_api_token";
my $new_token_expire_time = time() + 3600;
my $old_token_expire_string = "khomp_api_token_expire => $khomp_api_token_expire";
my $new_token_expire_string = "khomp_api_token_expire => $new_token_expire_time";
if ($AGILOG) {$agi_string = "-- KHOMP SC TOKEN UPDATE|$affected_rows|$stmtToken|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- KHOMP SC TOKEN EXPIRE UPDATE|$affected_rows|$stmtExpire|"; &agi_output;}
# LOCK vicidial_settings_containers
$stmtA = "LOCK TABLES vicidial_settings_containers WRITE";
$dbhA->do($stmtA);
# UPDATE the Token
$stmtToken = "UPDATE vicidial_settings_containers SET container_entry = REGEXP_REPLACE(container_entry, '$old_token_string', '$new_token_string') WHERE container_id = '$khomp_settings_container';";
$affected_rows = $dbhA->do($stmtToken);
# UPDATE the Expire time
$stmtExpire = "UPDATE vicidial_settings_containers SET container_entry = REGEXP_REPLACE(container_entry, '$old_token_expire_string', '$new_token_expire_string') WHERE container_id = '$khomp_settings_container';";
$affected_rows = $dbhA->do($stmtExpire);
# Unlock vicidial_settings_containers
$stmtA = "UNLOCK TABLES";
$dbhA->do($stmtA);
# over write the old with the new
$khomp_api_token = $new_khomp_api_token;
if ($AGILOG) {$agi_string = "-- KHOMP SC TOKEN UPDATE|$affected_rows|$stmtToken|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- KHOMP SC TOKEN EXPIRE UPDATE|$affected_rows|$stmtExpire|"; &agi_output;}
# over write the old with the new
$khomp_api_token = $new_khomp_api_token;
}
}
else
{
@@ -5357,7 +5448,7 @@ sub process_khomp_analytics
#UC# $khomp_json = encode_json( $khomp_request );
# call the API
($result, $api_query_time) = khomp_json_api( $khomp_json, $khomp_api_url );
($result, $api_query_time) = khomp_json_api( $khomp_json, $khomp_api_url, $khomp_api_check_ssl );
# check the result
if ( $result =~ /^ERROR/ )
@@ -5653,7 +5744,8 @@ sub khomp_api_login
(
$khomp_api_login_url,
$khomp_api_user,
$khomp_api_pass
$khomp_api_pass,
$khomp_api_check_ssl
) = @_;
my $token = 'login';
@@ -5681,7 +5773,17 @@ sub khomp_api_login
# encode it as JSON
#UC# $login_json = encode_json( $login_json );
my $curl_cmd = "$curlbin -sS --data \'$login_json\' $khomp_api_login_url";
my $curl_cmd = "";
if ($khomp_api_check_ssl == 0)
{
$agi_string = "-- KHOMP SSL VERIFICATION DISABLE!"; &agi_output;
$curl_cmd = "$curlbin --insecure -sS --data \'$login_json\' $khomp_api_login_url";
}
else
{
$curl_cmd = "$curlbin -sS --data \'$login_json\' $khomp_api_login_url";
}
$agi_string = "-- KHOMP CURL COMMAND: $curl_cmd"; &agi_output;
@@ -5701,6 +5803,8 @@ sub khomp_api_login
$token = $result->{'result'}->{'token'};
if ( $token eq '' ) { $token = '0'; }
($auth_end_sec, $auth_end_usec) = gettimeofday();
$api_auth_time = tv_interval ( [$auth_start_sec, $auth_start_usec], [$auth_end_sec, $auth_end_usec]);
@@ -5711,7 +5815,7 @@ sub khomp_api_login
### code for connecting to KHOMP api and passing JSON
sub khomp_json_api
{
( $khomp_json, $khomp_api_url ) = @_;
( $khomp_json, $khomp_api_url, $khomp_api_check_ssl ) = @_;
my $query_start_sec;
my $query_start_usec;
@@ -5723,7 +5827,16 @@ sub khomp_json_api
($query_start_sec, $query_start_usec) = gettimeofday();
my $curl_cmd = "$curlbin -sS --data \'$khomp_json\' $khomp_api_url";
my $curl_cmd = "";
if ($khomp_api_check_ssl == 0)
{
$agi_string = "-- KHOMP SSL VERIFICATION DISABLE!"; &agi_output;
$curl_cmd = "$curlbin --insecure -sS --data \'$khomp_json\' $khomp_api_url";
}
else
{
$curl_cmd = "$curlbin -sS --data \'$khomp_json\' $khomp_api_url";
}
$agi_string = "-- KHOMP CURL COMMAND: $curl_cmd"; &agi_output;