From 10645fd231c58ae0e3107c68ae526315224208b6 Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 31 Jul 2024 03:40:36 +0000 Subject: [PATCH] Changes for PHP8 compatibility, Added copy_did Non-Agent API function git-svn-id: svn://192.168.202.10@3857 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/www/vicidial/admin.php | 72 +++--- agc_2-X/trunk/www/vicidial/non_agent_api.php | 221 ++++++++++++++++++- 2 files changed, 258 insertions(+), 35 deletions(-) diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 034fc52d..2078908c 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -131,7 +131,7 @@ $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summa $Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; -$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list call_dispo_report agent_campaigns park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel update_remote_agent'; +$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list call_dispo_report agent_campaigns park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did copy_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel update_remote_agent'; $browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone'; @@ -6184,12 +6184,13 @@ if ($SSscript_remove_js > 0) # 240704-0944 - Added coldstorage database connection fields to system_settings # 240706-2332 - Added DB Schema Compare Utility # 240716-1453 - Small header fixes +# 240730-1829 - Changes for PHP8 compatibility, added copy_did Non-Agent API function # # 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.14-924a'; -$build = '240716-1453'; +$admin_version = '2.14-925a'; +$build = '240730-1829'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -7580,7 +7581,7 @@ if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($AD if ($ADD==41) { $p=0; - if (is_null($XFERgroups)) $XFERgroups = array(); + if (!is_array($XFERgroups)) $XFERgroups = array(); $XFERgroup_ct = count($XFERgroups); while ($p < $XFERgroup_ct) { @@ -14748,6 +14749,8 @@ if ($ADD==231111111) $row=mysqli_fetch_row($rslt); if ($row[0] > 0) {echo "
"._QXZ("SHIFT DEFINITION NOT ADDED - there is already a shift entry with this ID")."\n";} + else if (!is_array($shift_weekdays)) + {echo "
"._QXZ("SHIFT DEFINITION NOT ADDED - you have to select at least one weekday")."\n";} else { $shift_length_test = preg_replace('/:/i', '',$shift_length); @@ -15852,6 +15855,7 @@ if ($ADD==298111111111) if ( ($LOGmodify_statuses!=1) or ($add_copy_disabled > 0) ) { echo "
"._QXZ("You do not have permission to add records on this system")." -system_settings-\n"; + $ADD=198111111111; } else { @@ -15860,11 +15864,17 @@ if ($ADD==298111111111) $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); if ($row[0] > 0) - {echo "
"._QXZ("VM MESSAGE GROUP NOT ADDED - there is already a VM MESSAGE GROUP in the system with this ID")."\n";} + { + echo "
"._QXZ("VM MESSAGE GROUP NOT ADDED - there is already a VM MESSAGE GROUP in the system with this ID")."\n"; + $ADD=198111111111; + } else { - if ( (strlen($queue_group) < 2) or (strlen($queue_group_name) < 2) or (strlen($active) < 1) ) - {echo "
"._QXZ("VM MESSAGE GROUP NOT ADDED - Please go back and look at the data you entered")."\n";} + if ( (strlen($queue_group) < 2) or (strlen($queue_group_name) < 5) or (strlen($active) < 1) ) + { + echo "
"._QXZ("VM MESSAGE GROUP NOT ADDED - Please go back and look at the data you entered")."\n"; + $ADD=198111111111; + } else { echo "
"._QXZ("VM MESSAGE GROUP ADDED")."\n"; @@ -16178,7 +16188,7 @@ if ($ADD=="4A") } $k=0; $new_field_value=''; - $multi_count = count($api_allowed_functions); + if (is_array($api_allowed_functions)) {$multi_count = count($api_allowed_functions);} else {$multi_count=0;} $multi_array = $api_allowed_functions; while ($k < $multi_count) { @@ -17207,6 +17217,7 @@ if ($ADD==41) { $p=0; echo "
"._QXZ("ACTIVE LISTS CHANGED"); + if(!is_array($list_active_change)) {$list_active_change=array();} $list_active_change_ct = count($list_active_change); while ($p < $list_active_change_ct) { @@ -17592,6 +17603,7 @@ if ($ADD==44) { $p=0; echo "
"._QXZ("ACTIVE LISTS CHANGED"); + if (!is_array($list_active_change)) {$list_active_change=array();} $list_active_change_ct = count($list_active_change); while ($p < $list_active_change_ct) { @@ -17794,7 +17806,7 @@ if ($ADD==48) else { $p=0; - if (is_null($qc_statuses)) $qc_statuses = array(); + if (!is_array($qc_statuses)) $qc_statuses = array(); $qc_statuses_ct = count($qc_statuses); while ($p < $qc_statuses_ct) { @@ -17802,7 +17814,7 @@ if ($ADD==48) $p++; } $p=0; - if (is_null($qc_lists)) $qc_lists = array(); + if (!is_array($qc_lists)) $qc_lists = array(); $qc_lists_ct = count($qc_lists); while ($p < $qc_lists_ct) { @@ -18206,6 +18218,7 @@ if ($ADD==411) { $p=0; echo "
"._QXZ("TERRITORIES RESET"); + if (!is_array($territory_reset)) $territory_reset = array(); $territory_reset_ct = count($territory_reset); while ($p < $territory_reset_ct) { @@ -18410,7 +18423,7 @@ if ($ADD==4111 || $ADD==4811 || $ADD==4911) else { $p=0; - if (is_null($qc_statuses)) $qc_statuses = array(); + if (!is_array($qc_statuses)) $qc_statuses = array(); $qc_statuses_ct = count($qc_statuses); while ($p < $qc_statuses_ct) { @@ -18418,7 +18431,7 @@ if ($ADD==4111 || $ADD==4811 || $ADD==4911) $p++; } $p=0; - if (is_null($qc_lists)) $qc_lists = array(); + if (!is_array($qc_lists)) $qc_lists = array(); $qc_lists_ct = count($qc_lists); while ($p < $qc_lists_ct) { @@ -18967,7 +18980,7 @@ if ($ADD==411111) { $p=0; $GROUP_shifts=' '; - $group_shifts_ct = count($group_shifts); + $group_shifts_ct = (is_array($group_shifts) ? count($group_shifts) : -1); while ($p <= $group_shifts_ct) { if ($non_latin < 1) @@ -18983,7 +18996,7 @@ if ($ADD==411111) } $p=0; $VGROUP_vgroups=' '; - $vgroup_vgroups_ct = count($agent_status_viewable_groups); + $vgroup_vgroups_ct = (is_array($agent_status_viewable_groups) ? count($agent_status_viewable_groups) : -1); while ($p <= $vgroup_vgroups_ct) { if ($non_latin < 1) @@ -18999,7 +19012,7 @@ if ($ADD==411111) } $p=0; $VGROUP_chatgroups=' '; - $vgroup_chatgroups_ct = count($agent_allowed_chat_groups); + $vgroup_chatgroups_ct = (is_array($agent_allowed_chat_groups) ? count($agent_allowed_chat_groups) : -1); while ($p <= $vgroup_chatgroups_ct) { if ($non_latin < 1) @@ -19015,7 +19028,7 @@ if ($ADD==411111) } $p=0; $Vadmin_viewable_groups=' '; - $admin_viewable_groups_ct = count($admin_viewable_groups); + $admin_viewable_groups_ct = (is_array($admin_viewable_groups) ? count($admin_viewable_groups) : -1); while ($p <= $admin_viewable_groups_ct) { if ($non_latin < 1) @@ -19031,7 +19044,7 @@ if ($ADD==411111) } $p=0; $Vadmin_viewable_call_times=' '; - $admin_viewable_call_times_ct = count($admin_viewable_call_times); + $admin_viewable_call_times_ct = (is_array($admin_viewable_call_times) ? count($admin_viewable_call_times) : -1); while ($p <= $admin_viewable_call_times_ct) { if ($non_latin < 1) @@ -19046,7 +19059,7 @@ if ($ADD==411111) $p++; } $k=0; - $multi_count = count($allowed_reports); + $multi_count = (is_array($allowed_reports) ? count($allowed_reports) : -1); $multi_array = $allowed_reports; while ($k < $multi_count) { @@ -19096,7 +19109,7 @@ if ($ADD==411111) { $custom_report_str=""; - if (count($allowed_custom_reports)>0) + if (is_array($allowed_custom_reports) && count($allowed_custom_reports)>0) { for ($q=0; $q"; $shift_length_test = preg_replace('/:/i', '',$shift_length); - if ( (strlen($shift_id) < 2) or (strlen($shift_name) < 2) or (strlen($shift_start_time) < 4) or (strlen($shift_start_time) > 4) or (strlen($shift_length) < 5) or (strlen($shift_length) > 5) or ($shift_start_time > 2359) or ($shift_length_test > 2400) ) + if ( (strlen($shift_id) < 2) or (strlen($shift_name) < 2) or (strlen($shift_start_time) < 4) or (strlen($shift_start_time) > 4) or (strlen($shift_length) < 5) or (strlen($shift_length) > 5) or ($shift_start_time > 2359) or ($shift_length_test > 2400) or (!is_array($shift_weekdays)) ) { echo "
"._QXZ("SHIFT DEFINITION NOT MODIFIED - Please go back and look at the data you entered")."\n"; echo "
"._QXZ("Shift ID and name must be at least 2 characters in length")."\n"; echo "
"._QXZ("Shift Start Time must be 4 digits in length and be a valid time")."\n"; echo "
"._QXZ("Shift Length must be 5 characters in length and be 24 hours or less")."\n"; + echo "
"._QXZ("At least one weekday must be selected")."\n"; } else { @@ -20609,6 +20623,7 @@ if ($ADD==494111111111) { $p=0; $REPORT_weekdays=''; + if(!is_array($report_weekdays)) {$report_weekdays=array();} $report_weekdays_ct = count($report_weekdays); while ($p <= $report_weekdays_ct) { @@ -23870,7 +23885,7 @@ if ($ADD==6211111111) $stmtB="UPDATE vicidial_call_times set ct_holidays='$hct_holidays[$o]' where call_time_id='$hct_ids[$o]';"; $rslt=mysql_to_mysqli($stmtB, $link); if ($DB) {echo "|$stmtB|\n";} - echo "Holiday Rule Removed: $hct_ids[$o]
\n"; + echo "Holiday Rule Removed: $hct_ids[$o]
\n"; $o++; } @@ -23882,7 +23897,7 @@ if ($ADD==6211111111) if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); - echo "
"._QXZ("HOLIDAY DELETION COMPLETED").": $holiday_id\n"; + echo "
"._QXZ("HOLIDAY DELETION COMPLETED").": $holiday_id\n"; echo "

\n"; } } @@ -33184,6 +33199,7 @@ if ($ADD==431) $p=0; $DL_weekdays=''; + if (!is_array($dl_weekdays)) {$dl_weekdays=array();} $dl_weekdays_ct = count($dl_weekdays); while ($p <= $dl_weekdays_ct) { @@ -33192,7 +33208,7 @@ if ($ADD==431) } $groups_value=''; - $group_ct = count($groups); + if (is_array($groups)) {$group_ct = count($groups);} else {$group_ct=0;} $p=0; while ($p < $group_ct) { @@ -46030,7 +46046,7 @@ if ($ADD==130) echo " $list_id_ary[$o]"; echo " $ingroups_ct"; echo "".(preg_match('/\-\-ALL\-\-/', $group_group_ary[$o]) ? _QXZ("$group_group_ary[$o]") : $group_group_ary[$o]).""; - echo ""._QXZ("MODIFY")."\n"; + echo ""._QXZ("MODIFY")."\n"; $o++; } @@ -51785,7 +51801,7 @@ if ($ADD==999988) while ($zones_to_print > $o) { $rowx=mysqli_fetch_row($rslt); - date_default_timezone_set($rowx[7]); + date_default_timezone_set("$rowx[7]"); $tz_time = date("Y-m-d H:i:s"); if ($rowx[3] != "$last_country") {$row_color++; $last_country = $rowx[3];} @@ -51804,8 +51820,9 @@ if ($ADD==999988) $o++; } echo "\n"; + date_default_timezone_set($orig_zone); } -date_default_timezone_set($orig_zone); +# JCJ - date_default_timezone_set($orig_zone); ##### END available timezones display page ##### @@ -51876,8 +51893,9 @@ if ($ADD==999987) $o++; } echo "\n"; + date_default_timezone_set($orig_zone); } -date_default_timezone_set($orig_zone); +#JCJ - date_default_timezone_set($orig_zone); ##### END available phone_codes display page ##### diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index 5c7fb41a..d20eab28 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -214,10 +214,11 @@ # 240703-1657 - Added update_remote_agent function # 240718-0942 - Fixes for inconsistencies in documentation and permissions for some functions # 240718-1716 - Added fields to campaigns_list function output +# 240730-1832 - Changes for PHP8 compatibility, Added copy_did function # -$version = '2.14-191'; -$build = '240718-1716'; +$version = '2.14-192'; +$build = '240730-1832'; $php_script='non_agent_api.php'; $api_url_log = 0; $camp_lead_order_random=1; @@ -738,6 +739,10 @@ if (isset($_GET["list_order_secondary"])) {$list_order_secondary=$_GET["list_o elseif (isset($_POST["list_order_secondary"])) {$list_order_secondary=$_POST["list_order_secondary"];} 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["source_did_pattern"])) {$source_did_pattern=$_GET["source_did_pattern"];} + elseif (isset($_POST["source_did_pattern"])) {$source_did_pattern=$_POST["source_did_pattern"];} +if (isset($_GET["new_dids"])) {$new_dids=$_GET["new_dids"];} + elseif (isset($_POST["new_dids"])) {$new_dids=$_POST["new_dids"];} $DB=preg_replace('/[^0-9]/','',$DB); @@ -1001,6 +1006,8 @@ if ($non_latin < 1) $lead_filter_id = preg_replace('/[^-_0-9a-zA-Z]/','',$lead_filter_id); $outbound_alt_cid = preg_replace('/[^0-9a-zA-Z]/','',$outbound_alt_cid); $did_pattern = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$did_pattern); + $source_did_pattern = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$source_did_pattern); + $new_dids = preg_replace('/[^:\+\,\*\#\.\_0-9a-zA-Z]/','',$new_dids); $did_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$did_description); $did_route = preg_replace('/[^-_0-9a-zA-Z]/','',$did_route); $record_call = preg_replace('/[^-_0-9a-zA-Z]/','',$record_call); @@ -1155,6 +1162,8 @@ else $lead_filter_id = preg_replace('/[^-_0-9\p{L}]/u','',$lead_filter_id); $outbound_alt_cid = preg_replace('/[^0-9\p{L}]/u','',$outbound_alt_cid); $did_pattern = preg_replace('/[^:\+\*\#\.\_0-9\p{L}]/u','',$did_pattern); + $source_did_pattern = preg_replace('/[^:\+\*\#\.\_0-9\p{L}]/u','',$source_did_pattern); + $new_dids = preg_replace('/[^:\+\,\*\#\.\_0-9\p{L}]/u','',$new_dids); $did_description = preg_replace('/[^- \.\,\_0-9\p{L}]/u','',$did_description); $did_route = preg_replace('/[^-_0-9\p{L}]/u','',$did_route); $record_call = preg_replace('/[^-_0-9\p{L}]/u','',$record_call); @@ -10227,6 +10236,202 @@ if ($function == 'add_did') +################################################################################ +### copy_did - adds new Inbound DID entries to the system, copied from an existing DID entry +################################################################################ +if ($function == 'copy_did') + { + if(strlen($source)<2) + { + $result = 'ERROR'; + $result_reason = "Invalid Source"; + echo "$result: $result_reason - $source\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + echo "ERROR: Invalid Source: |$source|\n"; + exit; + } + else + { + if ( (!preg_match("/ $function /",$api_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$api_allowed_functions)) ) + { + $result = 'ERROR'; + $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; + echo "$result: $result_reason: |$user|$function|\n"; + $data = "$allowed_user"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + $stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and modify_inbound_dids='1' and user_level >= 8 and active='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $allowed_user=$row[0]; + if ($allowed_user < 1) + { + $result = 'ERROR'; + $result_reason = "copy_did USER DOES NOT HAVE PERMISSION TO ADD DIDS"; + $data = "$allowed_user"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + if ( (strlen($source_did_pattern)<2) or (strlen($source_did_pattern)>50) or (strlen($new_dids)<2) or (strlen($new_dids)>2000) ) + { + $result = 'ERROR'; + $result_reason = "copy_did YOU MUST USE ALL REQUIRED FIELDS"; + $data = "$source_did_pattern|$new_dids"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $stmt="SELECT allowed_campaigns,admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGallowed_campaigns = $row[0]; + $LOGadmin_viewable_groups = $row[1]; + + $admin_viewable_groupsSQL=''; + $WHEREadmin_viewable_groupsSQL=''; + if (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $admin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $WHEREadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + + $stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$source_did_pattern' $admin_viewable_groupsSQL;"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $did_exists=$row[0]; + if ($did_exists < 1) + { + $result = 'ERROR'; + $result_reason = "copy_did SOURCE DID DOES NOT EXIST"; + $data = "$source_did_pattern"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + # loop through all new_dids and insert them + $new_dids_ct=0; + $new_dids_ARY=array(); + if (preg_match("/,/",$new_dids)) + { + $new_dids_ARY = explode(',',$new_dids); + $new_dids_ct = count($new_dids_ARY); + } + else + { + $new_dids_ARY[0] = $new_dids; + $new_dids_ct=1; + } + + $did_inserts=0; + $did_insert_errors=0; + $did_insert_log=''; + $i=0; + while ($i < $new_dids_ct) + { + $stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$new_dids_ARY[$i]';"; + if ($DB>0) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $did_exists=$row[0]; + if ($did_exists > 0) + { + $result = 'NOTICE'; + $result_reason = "copy_did DID ALREADY EXISTS"; + $data = "$new_dids_ARY[$i]"; + echo "$result: $result_reason - $user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + $did_insert_errors++; + $did_insert_log .= "$new_dids_ARY[$i] ALREADY EXISTS\n"; + } + else + { + $did_patternSQL = "did_pattern='$did_pattern'"; + $did_descriptionSQL=''; + + if (strlen($did_description) > 0) + { + if ( (strlen($did_description) > 50) or (strlen($did_description) < 6) ) + { + $result = 'ERROR'; + $result_reason = "copy_did DID DESCRIPTION MUST BE EITHER BLANK OR FROM 6 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$did_description"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$did_descriptionSQL = "'$did_description'";} + } + else + {$did_descriptionSQL = "did_description";} + + $stmt = "INSERT IGNORE INTO vicidial_inbound_dids (did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id,record_call,filter_inbound_number,filter_phone_group_id,filter_url,filter_action,filter_extension,filter_exten_context,filter_voicemail_ext,filter_phone,filter_server_ip,filter_user,filter_user_unavailable_action,filter_user_route_settings_ingroup,filter_group_id,filter_call_handle_method,filter_agent_search_method,filter_list_id,filter_campaign_id,filter_phone_code,filter_menu_id,filter_clean_cid_number,custom_one,custom_two,custom_three,custom_four,custom_five,user_group,filter_dnc_campaign,filter_url_did_redirect,no_agent_ingroup_redirect,no_agent_ingroup_id,no_agent_ingroup_extension,pre_filter_phone_group_id,pre_filter_extension,entry_list_id,filter_entry_list_id,max_queue_ingroup_calls,max_queue_ingroup_id,max_queue_ingroup_extension,did_carrier_description) SELECT '$new_dids_ARY[$i]',$did_descriptionSQL,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,group_id,call_handle_method,agent_search_method,list_id,campaign_id,phone_code,menu_id,record_call,filter_inbound_number,filter_phone_group_id,filter_url,filter_action,filter_extension,filter_exten_context,filter_voicemail_ext,filter_phone,filter_server_ip,filter_user,filter_user_unavailable_action,filter_user_route_settings_ingroup,filter_group_id,filter_call_handle_method,filter_agent_search_method,filter_list_id,filter_campaign_id,filter_phone_code,filter_menu_id,filter_clean_cid_number,custom_one,custom_two,custom_three,custom_four,custom_five,user_group,filter_dnc_campaign,filter_url_did_redirect,no_agent_ingroup_redirect,no_agent_ingroup_id,no_agent_ingroup_extension,pre_filter_phone_group_id,pre_filter_extension,entry_list_id,filter_entry_list_id,max_queue_ingroup_calls,max_queue_ingroup_id,max_queue_ingroup_extension,did_carrier_description from vicidial_inbound_dids where did_pattern='$source_did_pattern';"; + $rslt=mysql_to_mysqli($stmt, $link); + $add_count = mysqli_affected_rows($link); + $did_id = mysqli_insert_id($link); + if ($DB) {echo "$add_count|$did_id|$stmt|\n";} + $did_insert_log .= "$new_dids_ARY[$i] ADDED, did_id: $did_id\n"; + $did_inserts = ($did_inserts + $add_count); + + $result = 'NOTICE'; + $result_reason = "copy_did DID HAS BEEN ADDED"; + $data = "$new_dids_ARY[$i]|$source_did_pattern|$did_id|$add_count"; + echo "$result: $result_reason - $user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + $i++; + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = preg_replace('/;/', '', $SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='DIDS', event_type='COPY', record_id='$did_id', event_code='ADMIN API COPY DIDS', event_sql=\"$SQL_log\", event_notes='DID Source: $source_did_pattern Inserts: $did_inserts Insert Errors: $did_insert_errors Copy Log:\n$did_insert_log';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + if ($did_inserts > 0) + { + $result = 'SUCCESS'; + $result_reason = "copy_did DIDS HAVE BEEN ADDED"; + $data = "$source_did_pattern|$did_inserts|$did_insert_errors"; + echo "$result: $result_reason - $user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + else + { + $result = 'ERROR'; + $result_reason = "copy_did NO DIDS ADDED"; + $data = "$source_did_pattern|$did_inserts|$did_insert_errors"; + echo "$result: $result_reason - $user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + } + } + exit; + } +################################################################################ +### END copy_did +################################################################################ + + + + + ################################################################################ ### update_did - updates Inbound DID information in the vicidial_inbound_dids table ################################################################################ @@ -17996,7 +18201,7 @@ if ($function == 'call_status_stats') } $hour_str=substr($hour_str, 0, -1); - if (is_null($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); + if (!is_array($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); $temp_ary_ct = count($temp_stat_array["$key"]); if ($temp_ary_ct > 0) { @@ -18024,7 +18229,7 @@ if ($function == 'call_status_stats') } $hour_str=substr($hour_str, 0, -1); - if (is_null($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); + if (!is_array($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); $temp_ary_ct = count($temp_stat_array["$key"]); if ($temp_ary_ct > 0) { @@ -18153,7 +18358,7 @@ if ($function == 'call_dispo_report') } } - if (is_null($did_id_array)) $did_id_array = array(); + if (!is_array($did_id_array)) $did_id_array = array(); if (count($did_id_array)>0 && $skip_inbound) # DON'T DO A REPORT FOR INGROUPS AND DIDS YET. { $did_SQL="and did_id in ('".implode("', '", $did_id_array)."')"; @@ -18185,7 +18390,7 @@ if ($function == 'call_dispo_report') } } - if (is_null($status_array)) $status_array = array(); + if (!is_array($status_array)) $status_array = array(); if ($status_array && count($status_array)>0) { $status_SQL=" and status in ('".implode("', '", $status_array)."') "; @@ -18212,7 +18417,7 @@ if ($function == 'call_dispo_report') } } } - if (is_null($user_array)) $user_array = array(); + if (!is_array($user_array)) $user_array = array(); if ($user_array && count($user_array)>0) { $user_SQL=" and user in ('".implode("', '", $user_array)."') "; @@ -18290,7 +18495,7 @@ if ($function == 'call_dispo_report') } } - if (is_null($status_ct_array)) $status_ct_array = array(); + if (!is_array($status_ct_array)) $status_ct_array = array(); $rpt_str.="CAMPAIGN,TOTAL CALLS"; if ($status_breakdown) {