From 5fad68e911de585215339a95eb87bd51f2f3a8c6 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 3 Sep 2018 20:16:09 +0000 Subject: [PATCH] Fixed URL encoding in Agent script display added email count to Agent API calls_in_queue_count function git-svn-id: svn://192.168.202.10@3022 3d104415-ff17-0410-8863-d5cf3c621b8a --- extras/MySQL_AST_CREATE_tables.sql | 3 +- extras/upgrade_2.14.sql | 4 + www/agc/api.php | 16 +- www/agc/vdc_script_display.php | 397 ++++++++++++++++------------- 4 files changed, 235 insertions(+), 185 deletions(-) diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 67e1fbd0..4dee520e 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -3137,6 +3137,7 @@ PRIMARY KEY (email_row_id), KEY email_list_account_key (email_account_id), KEY email_list_user_key (user), KEY vicidial_email_lead_id_key (lead_id) +KEY vicidial_email_group_key (group_id) ) ENGINE=MyISAM; CREATE TABLE vicidial_email_accounts ( @@ -4294,4 +4295,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1554',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1555',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/extras/upgrade_2.14.sql b/extras/upgrade_2.14.sql index 2d7e6486..da38ccf9 100644 --- a/extras/upgrade_2.14.sql +++ b/extras/upgrade_2.14.sql @@ -743,3 +743,7 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('TIMEZONES_AUSTRALIA','Australian Timezone List','TIMEZONE_LIST','---ALL---','AUS,AEST,Y,Eastern Australia Time Zone\nAUS,AEST,N,Queensland Time Zone\nAUS,ACST,Y,Central Australia Time Zone\nAUS,ACST,N,Northern Territory Time Zone\nAUS,AWST,N,Western Australia Time Zone\n'); UPDATE system_settings SET db_schema_version='1554',db_schema_update_date=NOW() where db_schema_version < 1554; + +CREATE INDEX vicidial_email_group_key on vicidial_email_list(group_id); + +UPDATE system_settings SET db_schema_version='1555',db_schema_update_date=NOW() where db_schema_version < 1555; diff --git a/www/agc/api.php b/www/agc/api.php index 0094d246..7d86ce34 100644 --- a/www/agc/api.php +++ b/www/agc/api.php @@ -95,10 +95,11 @@ # 180204-2350 - Added dial_ingroup external_dial option # 180301-2302 - Added GET-AND-POST URL logging # 180323-2227 - Fix for dial_ingroup error message on external_dial function +# 180903-1606 - Added count for waiting emails to calls_in_queue_count function # -$version = '2.14-61'; -$build = '180323-2227'; +$version = '2.14-62'; +$build = '180903-1606'; $startMS = microtime(); @@ -4153,8 +4154,17 @@ if ($function == 'calls_in_queue_count') $row=mysqli_fetch_row($rslt); $calls_in_queue_count=$row[0]; + ### grab the number of emails waiting in queue that could be routed to this agent + $stmt="SELECT count(*) from vicidial_email_list where status IN('NEW','QUEUE') and (group_id IN('$AccampSQL'));"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $emails_in_queue_count=$row[0]; + + $total_in_queue_count = ($calls_in_queue_count + $emails_in_queue_count); + $result = _QXZ("SUCCESS"); - $result_reason = _QXZ("SUCCESS: calls_in_queue_count") . " - " . $calls_in_queue_count; + $result_reason = _QXZ("SUCCESS: calls_in_queue_count") . " - " . $total_in_queue_count; echo "$result_reason"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } diff --git a/www/agc/vdc_script_display.php b/www/agc/vdc_script_display.php index 3480ba98..ac4bf4e5 100644 --- a/www/agc/vdc_script_display.php +++ b/www/agc/vdc_script_display.php @@ -39,10 +39,11 @@ # 171126-1124 - Added email message display from inbound emails only # 180224-1406 - Added LOGINvar variables, and options.php $INSERT_ variables # 180327-1356 - Added code for LOCALFQDN conversion to browser-used server URL for script iframes +# 180628-2200 - Patch for proper url encoding of variables replaced when within href and src attributes # -$version = '2.14-33'; -$build = '180224-1406'; +$version = '2.14-34'; +$build = '180628-2200'; require_once("dbconnect_mysqli.php"); require_once("functions.php"); @@ -418,187 +419,221 @@ $script_name = $row[0]; $script_text = stripslashes($row[1]); $script_color = $row[2]; -if (preg_match("/iframe\ssrc/i",$script_text)) - { - $IFRAME=1; - $user = preg_replace('/\s/i','+',$user); - $pass = preg_replace('/\s/i','+',$orig_pass); +# ADD NEW PATTERNS/ATTRIBUTES TO MATCH HERE AS NEEDED. +# PATTERN ENTRY MUST MATCH CORRESPONDING INDEX IN ATTRIBUTE ARRAY TO WORK PROPERLY. +# FOR EXAMPLE, an IFRAME SRC or A HREF tag +$pattern_array=array("/\]+)\>/i", "/\]+)\>/i"); +$attribute_array=array("/src=[\"|\']([^\"\']+)[\"|\']/i", "/href=[\"|\']([^\"\']+)[\"|\']/i"); - if ($IFRAMEencode=='1') +for($x=0; $x0) { - $lead_id = urlencode(trim($lead_id)); - $vendor_id = urlencode(trim($vendor_id)); - $vendor_lead_code = urlencode(trim($vendor_lead_code)); - $list_id = urlencode(trim($list_id)); - $list_name = urlencode(trim($list_name)); - $list_description = urlencode(trim($list_description)); - $gmt_offset_now = urlencode(trim($gmt_offset_now)); - $phone_code = urlencode(trim($phone_code)); - $phone_number = urlencode(trim($phone_number)); - $title = urlencode(trim($title)); - $first_name = urlencode(trim($first_name)); - $middle_initial = urlencode(trim($middle_initial)); - $last_name = urlencode(trim($last_name)); - $address1 = urlencode(trim($address1)); - $address2 = urlencode(trim($address2)); - $address3 = urlencode(trim($address3)); - $city = urlencode(trim($city)); - $state = urlencode(trim($state)); - $province = urlencode(trim($province)); - $postal_code = urlencode(trim($postal_code)); - $country_code = urlencode(trim($country_code)); - $gender = urlencode(trim($gender)); - $date_of_birth = urlencode(trim($date_of_birth)); - $alt_phone = urlencode(trim($alt_phone)); - $email = urlencode(trim($email)); - $security_phrase = urlencode(trim($security_phrase)); - $comments = urlencode(trim($comments)); - $campaign = urlencode(trim($campaign)); - $phone_login = urlencode(trim($phone_login)); - $original_phone_login = urlencode(trim($original_phone_login)); - $phone_pass = urlencode(trim($phone_pass)); - $fronter = urlencode(trim($fronter)); - $closer = urlencode(trim($closer)); - $group = urlencode(trim($group)); - $channel_group = urlencode(trim($channel_group)); - $SQLdate = urlencode(trim($SQLdate)); - $epoch = urlencode(trim($epoch)); - $uniqueid = urlencode(trim($uniqueid)); - $customer_zap_channel = urlencode(trim($customer_zap_channel)); - $customer_server_ip = urlencode(trim($customer_server_ip)); - $server_ip = urlencode(trim($server_ip)); - $SIPexten = urlencode(trim($SIPexten)); - $session_id = urlencode(trim($session_id)); - $phone = urlencode(trim($phone)); - $parked_by = urlencode(trim($parked_by)); - $dispo = urlencode(trim($dispo)); - $dialed_number = urlencode(trim($dialed_number)); - $dialed_label = urlencode(trim($dialed_label)); - $source_id = urlencode(trim($source_id)); - $rank = urlencode(trim($rank)); - $owner = urlencode(trim($owner)); - $camp_script = urlencode(trim($camp_script)); - $in_script = urlencode(trim($in_script)); - $script_width = urlencode(trim($script_width)); - $script_height = urlencode(trim($script_height)); - $fullname = urlencode(trim($fullname)); - $agent_email = urlencode(trim($agent_email)); - $recording_filename = urlencode(trim($recording_filename)); - $recording_id = urlencode(trim($recording_id)); - $user_custom_one = urlencode(trim($user_custom_one)); - $user_custom_two = urlencode(trim($user_custom_two)); - $user_custom_three = urlencode(trim($user_custom_three)); - $user_custom_four = urlencode(trim($user_custom_four)); - $user_custom_five = urlencode(trim($user_custom_five)); - $preset_number_a = urlencode(trim($preset_number_a)); - $preset_number_b = urlencode(trim($preset_number_b)); - $preset_number_c = urlencode(trim($preset_number_c)); - $preset_number_d = urlencode(trim($preset_number_d)); - $preset_number_e = urlencode(trim($preset_number_e)); - $preset_number_f = urlencode(trim($preset_number_f)); - $preset_dtmf_a = urlencode(trim($preset_dtmf_a)); - $preset_dtmf_b = urlencode(trim($preset_dtmf_b)); - $did_id = urlencode(trim($did_id)); - $did_extension = urlencode(trim($did_extension)); - $did_pattern = urlencode(trim($did_pattern)); - $did_description = urlencode(trim($did_description)); - $called_count = urlencode(trim($called_count)); - $session_name = urlencode(trim($session_name)); - $entry_date = urlencode(trim($entry_date)); - $did_custom_one = urlencode(trim($did_custom_one)); - $did_custom_two = urlencode(trim($did_custom_two)); - $did_custom_three = urlencode(trim($did_custom_three)); - $did_custom_four = urlencode(trim($did_custom_four)); - $did_custom_five = urlencode(trim($did_custom_five)); - $web_vars = urlencode(trim($web_vars)); - } - else - { - $lead_id = preg_replace('/\s/i','+',$lead_id); - $vendor_id = preg_replace('/\s/i','+',$vendor_id); - $vendor_lead_code = preg_replace('/\s/i','+',$vendor_lead_code); - $list_id = preg_replace('/\s/i','+',$list_id); - $list_name = preg_replace('/\s/i','+',$list_name); - $list_description = preg_replace('/\s/i','+',$list_description); - $gmt_offset_now = preg_replace('/\s/i','+',$gmt_offset_now); - $phone_code = preg_replace('/\s/i','+',$phone_code); - $phone_number = preg_replace('/\s/i','+',$phone_number); - $title = preg_replace('/\s/i','+',$title); - $first_name = preg_replace('/\s/i','+',$first_name); - $middle_initial = preg_replace('/\s/i','+',$middle_initial); - $last_name = preg_replace('/\s/i','+',$last_name); - $address1 = preg_replace('/\s/i','+',$address1); - $address2 = preg_replace('/\s/i','+',$address2); - $address3 = preg_replace('/\s/i','+',$address3); - $city = preg_replace('/\s/i','+',$city); - $state = preg_replace('/\s/i','+',$state); - $province = preg_replace('/\s/i','+',$province); - $postal_code = preg_replace('/\s/i','+',$postal_code); - $country_code = preg_replace('/\s/i','+',$country_code); - $gender = preg_replace('/\s/i','+',$gender); - $date_of_birth = preg_replace('/\s/i','+',$date_of_birth); - $alt_phone = preg_replace('/\s/i','+',$alt_phone); - $email = preg_replace('/\s/i','+',$email); - $security_phrase = preg_replace('/\s/i','+',$security_phrase); - $comments = preg_replace('/\s/i','+',$comments); - $campaign = preg_replace('/\s/i','+',$campaign); - $phone_login = preg_replace('/\s/i','+',$phone_login); - $original_phone_login = preg_replace('/\s/i','+',$original_phone_login); - $phone_pass = preg_replace('/\s/i','+',$phone_pass); - $fronter = preg_replace('/\s/i','+',$fronter); - $closer = preg_replace('/\s/i','+',$closer); - $group = preg_replace('/\s/i','+',$group); - $channel_group = preg_replace('/\s/i','+',$channel_group); - $SQLdate = preg_replace('/\s/i','+',$SQLdate); - $epoch = preg_replace('/\s/i','+',$epoch); - $uniqueid = preg_replace('/\s/i','+',$uniqueid); - $customer_zap_channel = preg_replace('/\s/i','+',$customer_zap_channel); - $customer_server_ip = preg_replace('/\s/i','+',$customer_server_ip); - $server_ip = preg_replace('/\s/i','+',$server_ip); - $SIPexten = preg_replace('/\s/i','+',$SIPexten); - $session_id = preg_replace('/\s/i','+',$session_id); - $phone = preg_replace('/\s/i','+',$phone); - $parked_by = preg_replace('/\s/i','+',$parked_by); - $dispo = preg_replace('/\s/i','+',$dispo); - $dialed_number = preg_replace('/\s/i','+',$dialed_number); - $dialed_label = preg_replace('/\s/i','+',$dialed_label); - $source_id = preg_replace('/\s/i','+',$source_id); - $rank = preg_replace('/\s/i','+',$rank); - $owner = preg_replace('/\s/i','+',$owner); - $camp_script = preg_replace('/\s/i','+',$camp_script); - $in_script = preg_replace('/\s/i','+',$in_script); - $script_width = preg_replace('/\s/i','+',$script_width); - $script_height = preg_replace('/\s/i','+',$script_height); - $fullname = preg_replace('/\s/i','+',$fullname); - $agent_email = preg_replace('/\s/i','+',$agent_email); - $recording_filename = preg_replace('/\s/i','+',$recording_filename); - $recording_id = preg_replace('/\s/i','+',$recording_id); - $user_custom_one = preg_replace('/\s/i','+',$user_custom_one); - $user_custom_two = preg_replace('/\s/i','+',$user_custom_two); - $user_custom_three = preg_replace('/\s/i','+',$user_custom_three); - $user_custom_four = preg_replace('/\s/i','+',$user_custom_four); - $user_custom_five = preg_replace('/\s/i','+',$user_custom_five); - $preset_number_a = preg_replace('/\s/i','+',$preset_number_a); - $preset_number_b = preg_replace('/\s/i','+',$preset_number_b); - $preset_number_c = preg_replace('/\s/i','+',$preset_number_c); - $preset_number_d = preg_replace('/\s/i','+',$preset_number_d); - $preset_number_e = preg_replace('/\s/i','+',$preset_number_e); - $preset_number_f = preg_replace('/\s/i','+',$preset_number_f); - $preset_dtmf_a = preg_replace('/\s/i','+',$preset_dtmf_a); - $preset_dtmf_b = preg_replace('/\s/i','+',$preset_dtmf_b); - $did_id = preg_replace('/\s/i','+',$did_id); - $did_extension = preg_replace('/\s/i','+',$did_extension); - $did_pattern = preg_replace('/\s/i','+',$did_pattern); - $did_description = preg_replace('/\s/i','+',$did_description); - $called_count = preg_replace('/\s/i','+',$called_count); - $session_name = preg_replace('/\s/i','+',$session_name); - $entry_date = preg_replace('/\s/i','+',$entry_date); - $did_custom_one = preg_replace('/\s/i','+',$did_custom_one); - $did_custom_two = preg_replace('/\s/i','+',$did_custom_two); - $did_custom_three = preg_replace('/\s/i','+',$did_custom_three); - $did_custom_four = preg_replace('/\s/i','+',$did_custom_four); - $did_custom_five = preg_replace('/\s/i','+',$did_custom_five); - $web_vars = preg_replace('/\s/i','+',$web_vars); + $user = preg_replace('/\s/i','+',$user); + $pass = preg_replace('/\s/i','+',$orig_pass); + $lead_id_URL = urlencode(trim($lead_id)); + $vendor_id_URL = urlencode(trim($vendor_id)); + $vendor_lead_code_URL = urlencode(trim($vendor_lead_code)); + $list_id_URL = urlencode(trim($list_id)); + $list_name_URL = urlencode(trim($list_name)); + $list_description_URL = urlencode(trim($list_description)); + $gmt_offset_now_URL = urlencode(trim($gmt_offset_now)); + $phone_code_URL = urlencode(trim($phone_code)); + $phone_number_URL = urlencode(trim($phone_number)); + $title_URL = urlencode(trim($title)); + $first_name_URL = urlencode(trim($first_name)); + $middle_initial_URL = urlencode(trim($middle_initial)); + $last_name_URL = urlencode(trim($last_name)); + $address1_URL = urlencode(trim($address1)); + $address2_URL = urlencode(trim($address2)); + $address3_URL = urlencode(trim($address3)); + $city_URL = urlencode(trim($city)); + $state_URL = urlencode(trim($state)); + $province_URL = urlencode(trim($province)); + $postal_code_URL = urlencode(trim($postal_code)); + $country_code_URL = urlencode(trim($country_code)); + $gender_URL = urlencode(trim($gender)); + $date_of_birth_URL = urlencode(trim($date_of_birth)); + $alt_phone_URL = urlencode(trim($alt_phone)); + $email_URL = urlencode(trim($email)); + $security_phrase_URL = urlencode(trim($security_phrase)); + $comments_URL = urlencode(trim($comments)); + $campaign_URL = urlencode(trim($campaign)); + $phone_login_URL = urlencode(trim($phone_login)); + $original_phone_login_URL = urlencode(trim($original_phone_login)); + $phone_pass_URL = urlencode(trim($phone_pass)); + $fronter_URL = urlencode(trim($fronter)); + $closer_URL = urlencode(trim($closer)); + $group_URL = urlencode(trim($group)); + $channel_group_URL = urlencode(trim($channel_group)); + $SQLdate_URL = urlencode(trim($SQLdate)); + $epoch_URL = urlencode(trim($epoch)); + $uniqueid_URL = urlencode(trim($uniqueid)); + $customer_zap_channel_URL = urlencode(trim($customer_zap_channel)); + $customer_server_ip_URL = urlencode(trim($customer_server_ip)); + $server_ip_URL = urlencode(trim($server_ip)); + $SIPexten_URL = urlencode(trim($SIPexten)); + $session_id_URL = urlencode(trim($session_id)); + $phone_URL = urlencode(trim($phone)); + $parked_by_URL = urlencode(trim($parked_by)); + $dispo_URL = urlencode(trim($dispo)); + $dialed_number_URL = urlencode(trim($dialed_number)); + $dialed_label_URL = urlencode(trim($dialed_label)); + $source_id_URL = urlencode(trim($source_id)); + $rank_URL = urlencode(trim($rank)); + $owner_URL = urlencode(trim($owner)); + $camp_script_URL = urlencode(trim($camp_script)); + $in_script_URL = urlencode(trim($in_script)); + $script_width_URL = urlencode(trim($script_width)); + $script_height_URL = urlencode(trim($script_height)); + $fullname_URL = urlencode(trim($fullname)); + $agent_email_URL = urlencode(trim($agent_email)); + $recording_filename_URL = urlencode(trim($recording_filename)); + $recording_id_URL = urlencode(trim($recording_id)); + $user_custom_one_URL = urlencode(trim($user_custom_one)); + $user_custom_two_URL = urlencode(trim($user_custom_two)); + $user_custom_three_URL = urlencode(trim($user_custom_three)); + $user_custom_four_URL = urlencode(trim($user_custom_four)); + $user_custom_five_URL = urlencode(trim($user_custom_five)); + $preset_number_a_URL = urlencode(trim($preset_number_a)); + $preset_number_b_URL = urlencode(trim($preset_number_b)); + $preset_number_c_URL = urlencode(trim($preset_number_c)); + $preset_number_d_URL = urlencode(trim($preset_number_d)); + $preset_number_e_URL = urlencode(trim($preset_number_e)); + $preset_number_f_URL = urlencode(trim($preset_number_f)); + $preset_dtmf_a_URL = urlencode(trim($preset_dtmf_a)); + $preset_dtmf_b_URL = urlencode(trim($preset_dtmf_b)); + $did_id_URL = urlencode(trim($did_id)); + $did_extension_URL = urlencode(trim($did_extension)); + $did_pattern_URL = urlencode(trim($did_pattern)); + $did_description_URL = urlencode(trim($did_description)); + $called_count_URL = urlencode(trim($called_count)); + $session_name_URL = urlencode(trim($session_name)); + $entry_date_URL = urlencode(trim($entry_date)); + $did_custom_one_URL = urlencode(trim($did_custom_one)); + $did_custom_two_URL = urlencode(trim($did_custom_two)); + $did_custom_three_URL = urlencode(trim($did_custom_three)); + $did_custom_four_URL = urlencode(trim($did_custom_four)); + $did_custom_five_URL = urlencode(trim($did_custom_five)); + $web_vars_URL = urlencode(trim($web_vars)); + + $iframe_replace=$iframe_matches[1]; + + for ($q=0; $q