diff --git a/bin/AST_conf_update_screen.pl b/bin/AST_conf_update_screen.pl index 059ef8e2..5973bb72 100644 --- a/bin/AST_conf_update_screen.pl +++ b/bin/AST_conf_update_screen.pl @@ -803,7 +803,7 @@ else # update internal process log $iLog_ct++; - if ($iLog_ct =~ /00$/) + if ($iLog_ct =~ /00$|50$/) { $stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;"; if($DB){print STDERR "|$stmtA|";} diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 0add18ce..552bb219 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2025-07-18 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2026-05-19 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -231,6 +231,10 @@ Changes: 241004-1518 - Added webform_one-three variables to the update_campaign function 241113-1600 - Added in_groups as input option for update_user function 250720-1841 - Added hopper_bulk_insert function +251205-1456 - Added ADAPT_PERCENTMAX dial_method +260123-1020 - pause_sec fix in agent_stats_export +260506-1525 - small fix for campaign changes +260519-1647 - Code updates for PHP8 compatibility, and json output format API Functions use the 'function' variable @@ -398,7 +402,7 @@ campaign_id - 2-8 characters ignore_agentdirect - Y or N, default is N. Exclude AGENTDIRECT in-groups from results or not SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header Example URL strings for API calls: @@ -431,7 +435,7 @@ OPTIONAL FIELDS- campaign_id - 2-8 characters, for all campaigns, leave blank SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header Example URL strings for API calls: @@ -460,7 +464,7 @@ source - description of what originated the API call (maximum 20 characters) campaign_id - 2-8 characters SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header OPTIONAL FIELDS- @@ -535,7 +539,7 @@ uniqueid - uniqueid of the call, works best included with another search field extension - 3-100 characters, the extension listed in the recording_log SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header duration - Y or N, default is N. Includes the duration of the recording in the output(in seconds), before the location @@ -571,7 +575,7 @@ phone_number - 2-20 characters, the DID that you want to pull logs for date - date of the calls to pull (must be in YYYY-MM-DD format) SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header NOTES- @@ -602,7 +606,7 @@ REQUIRED FIELDS- phone_number - the phone number(s) that you want to pull logs for. allows more than one, separated by commas SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header detail - (ALL) calls or only (LAST) call. default is (ALL) type - (IN)inbound, (OUT)outbound or (ALL) calls. defauls is (OUT) calls @@ -641,7 +645,7 @@ datetime_end - end date/time of the agent activity to pull (must be in "YYYY-MM SETTINGS FIELDS- agent_user - 2-20 characters, use only for one agent stats campaign_id - 2-8 characters, use only for one campaign stats -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header time_format - time format('H','HF','M','S') in hours, minutes or seconds: H = 1:23:45, M = 83:45, S = 5023 (default 'HF') * HF will force hour format even for zero seconds time "0:00:00" @@ -680,7 +684,7 @@ source - description of what originated the API call (maximum 20 characters) user_groups - pipe-delimited list of user groups to get status information for "ADMIN|AGENTS" SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header NOTES- @@ -711,7 +715,7 @@ source - description of what originated the API call (maximum 20 characters) in_groups - pipe-delimited list of inbound groups to get status information for "SALESLINE|SUPPORT" SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header NOTES- @@ -741,7 +745,7 @@ source - description of what originated the API call (maximum 20 characters) agent_user - 2-20 characters, use only for one agent status SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header include_ip - include computer_ip field(YES) or not(NO), the last ip address that the agent used to log in to the agent screen @@ -775,7 +779,7 @@ source - description of what originated the API call (maximum 20 characters) agent_user - 2-20 characters, use only for one user SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header Example URL strings for API calls: @@ -803,7 +807,7 @@ source - description of what originated the API call (maximum 20 characters) call_id - 16-40 characters SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header detail - if set to YES, more call info will be output. Default is NO, only callid and customer talk time will be output @@ -875,7 +879,7 @@ force_entry_list_id - 3-12 digits, will override the lead's assigned entry_list_ archived_lead - Y or N, Setting this to Y will query only the vicidial_list_archive leads for the leads details, default is N. SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, newline, pipe(default) +stage - the format of the exported data: csv, tab, newline, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header Example URL strings for API calls: @@ -992,7 +996,7 @@ source - description of what originated the API call (maximum 20 characters) call_id - 16-40 characters SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, newline, pipe(default) +stage - the format of the exported data: csv, tab, newline, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header Example URL strings for API calls: @@ -1022,7 +1026,7 @@ source - description of what originated the API call (maximum 20 characters) lead_id - 16-40 characters SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, newline, pipe(default) +stage - the format of the exported data: csv, tab, newline, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header search_location - Where to check for scheduled callback records in the system, can select only one(default is CURRENT): CURRENT - check for active scheduled callbacks @@ -2202,7 +2206,7 @@ source - description of what originated the API call (maximum 20 characters) SETTINGS FIELDS- (optional) leads_counts - Y or N, will include the counts of all leads and NEW status leads in the response, default is 'N' dialable_count - Y or N, will use the list's campaign settings to provide a count of how many are dialable right now, default is 'N' -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header archived_lead - Y or N, Setting this to Y will query only the vicidial_list_archive leads for the leads count, default is N. @@ -2239,7 +2243,7 @@ list_id - must be all numbers, 2-14 digits, OR use "---ALL---" for all lists source - description of what originated the API call (maximum 20 characters) SETTINGS FIELDS- (optional) -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header custom_order - the order to put the custom fields into: table_order, alpha_up, alpha_down (default is 'table_order') @@ -2331,7 +2335,7 @@ user_groups - pipe-delimited list of user groups to get status information for show_sub_status - show agent sub-status and pause_code, requires log lookup, (YES|NO) default is NO SETTINGS FIELDS- -stage - the format of the exported data: csv, tab, pipe(default) +stage - the format of the exported data: csv, tab, json, pipe(default) header - include a header(YES) or not(NO). This is optional, default is not to include a header Example URL strings for API calls: @@ -2552,7 +2556,7 @@ entry_type - One of these: 'campaign' url_type - One of these: 'dispo','start','addlead','noagent' alt_url_id - Digits only, 'NEW' or 'LIST'. Must be a valid alt URL ID for this campaign, or set to 'NEW' to add a new ALT URL NOTE: If only one Alt URL exists for this campaign and type, then this field can be left blank - NOTE: 'stage'(csv, tab, pipe[default]) and 'header'(YES, NO) options are available for an alt_url_id of 'LIST' + NOTE: 'stage'(csv, tab, json, pipe[default]) and 'header'(YES, NO) options are available for an alt_url_id of 'LIST' EDITABLE FIELDS- active - One of these: 'Y','N', default is 'N' @@ -2619,7 +2623,7 @@ source - description of what originated the API call (maximum 20 characters) preset_name - name of the preset in the system NOTE: If only one preset exists for this campaign, then this field can be left blank action - 'UPDATE', 'NEW', 'DELETE' or 'LIST' (default is 'UPDATE') - NOTE: 'stage'(csv, tab, pipe[default]) and 'header'(YES, NO) options are available for an action of 'LIST' + NOTE: 'stage'(csv, tab, json, pipe[default]) and 'header'(YES, NO) options are available for an action of 'LIST' EDITABLE FIELDS- preset_hide_number - One of these: 'Y','N', default is 'N' diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 97e4913d..8690c0a9 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -4542,6 +4542,9 @@ else $survey_fourth_exten = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$survey_fourth_exten); $preset_dtmf = preg_replace('/[^ \,\*\#0-9\p{L}]/u','',$preset_dtmf); + ### ALPHA-NUMERIC and underscore + $qc_statuses_id = preg_replace('/[^_0-9\p{L}]/u','',$qc_statuses_id); + ### ALPHA-NUMERIC and underscore and dash $agi_output = preg_replace('/[^-_0-9\p{L}]/u','',$agi_output); $ASTmgrSECRET = preg_replace('/[^-_0-9\p{L}]/u','',$ASTmgrSECRET); @@ -6338,12 +6341,13 @@ if ($SSscript_remove_js > 0) # 260410-1953 - Fix for max_inbound_auto_reenable feature in 4B admin screen # 260416-0909 - Added modify_settings_containers user setting # 260516-2350 - Added Internal Process Logs display page +# 260521-2044 - Fixes for input variable filtering # # 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-958a'; -$build = '260516-2350'; +$admin_version = '2.14-959a'; +$build = '260521-2044'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -9108,6 +9112,7 @@ if ($ADD==121) $p=0; $DNCadded=0; $DNCnotadded=0; $DNCdeleted=0; $DNCnotdeleted=0; while ($p < $PNct) { + $PN[$p] = preg_replace('/[^\,\:\+\*\#\.\_0-9\p{L}]/u','',$PN[$p]); if ( (preg_match('/delete/',$stage)) and ($LOGdelete_from_dnc > 0) ) { ##### BEGIN DELETE FROM DNC ##### @@ -9498,6 +9503,7 @@ if ($ADD==171) $p=0; while ($p < $PNct) { + $PN[$p] = preg_replace('/[^\,\:\+\*\#\.\_0-9\p{L}]/u','',$PN[$p]); if ( (preg_match('/delete/',$stage)) and ($LOGdelete_from_dnc > 0) ) { $stmt="SELECT count(*) from vicidial_filter_phone_numbers where phone_number='$PN[$p]' and filter_phone_group_id='$filter_phone_group_id';"; @@ -9617,6 +9623,7 @@ if ($ADD==3211) { if (strlen($PN[$p]) > 0) { + $PN[$p] = preg_replace('/[^\,\:\+\*\#\.\_0-9\p{L}]/u','',$PN[$p]); $ac_found=0; $vaf=0; while ($vaf_ct > $vaf) @@ -14951,6 +14958,7 @@ if ($ADD==231111111) $shift_weekdays_ct = count($shift_weekdays); while ($p <= $shift_weekdays_ct) { + $shift_weekdays[$p] = preg_replace('/[^0-9]/','',$shift_weekdays[$p]); $SHIFT_weekdays .= "$shift_weekdays[$p]"; $p++; } @@ -18362,6 +18370,7 @@ if ($ADD==48) $qc_statuses_ct = count($qc_statuses); while ($p < $qc_statuses_ct) { + $qc_statuses[$p] = preg_replace('/[^-_0-9\p{L}]/u','',$qc_statuses[$p]); $QC_statuses .= " $qc_statuses[$p]"; $p++; } @@ -19025,6 +19034,7 @@ if ($ADD==4111 || $ADD==4811 || $ADD==4911) $qc_statuses_ct = count($qc_statuses); while ($p < $qc_statuses_ct) { + $qc_statuses[$p] = preg_replace('/[^-_0-9\p{L}]/u','',$qc_statuses[$p]); $QC_statuses .= " $qc_statuses[$p]"; $p++; } @@ -19033,6 +19043,7 @@ if ($ADD==4111 || $ADD==4811 || $ADD==4911) $qc_lists_ct = count($qc_lists); while ($p < $qc_lists_ct) { + $qc_lists[$p] = preg_replace('/[^-_0-9\p{L}]/u','',$qc_lists[$p]); $QC_lists .= " $qc_lists[$p]"; $p++; } @@ -20143,6 +20154,7 @@ if ($ADD==431111111) $shift_weekdays_ct = count($shift_weekdays); while ($p <= $shift_weekdays_ct) { + $shift_weekdays[$p] = preg_replace('/[^0-9]/','',$shift_weekdays[$p]); $SHIFT_weekdays .= "$shift_weekdays[$p]"; $p++; } @@ -21276,6 +21288,7 @@ if ($ADD==494111111111) $report_weekdays_ct = count($report_weekdays); while ($p <= $report_weekdays_ct) { + $report_weekdays[$p] = preg_replace('/[^0-9]/','',$report_weekdays[$p]); $REPORT_weekdays .= "$report_weekdays[$p]"; $p++; } @@ -34066,6 +34079,7 @@ if ($ADD==431) $dl_weekdays_ct = count($dl_weekdays); while ($p <= $dl_weekdays_ct) { + $dl_weekdays[$p] = preg_replace('/[^0-9]/','',$dl_weekdays[$p]); $DL_weekdays .= "$dl_weekdays[$p]"; $p++; } @@ -34075,6 +34089,7 @@ if ($ADD==431) $p=0; while ($p < $group_ct) { + $groups[$p] = preg_replace('/[^-_0-9\p{L}]/u','',$groups[$p]); $groups_value .= " $groups[$p]"; $p++; } @@ -44283,6 +44298,7 @@ if ($ADD==395111111111) $p=0; $ip_added=0; $ip_removed=0; while ($p < $PNct) { + $PN[$p] = preg_replace('/[^\,\:\+\*\#\.\_0-9\p{L}]/u','',$PN[$p]); if (strlen($PN[$p]) > 0) { $PN[$p] = preg_replace("/\r|\n|\t/",'',$PN[$p]); diff --git a/www/vicidial/functions.php b/www/vicidial/functions.php index a540eda9..0a2d0b86 100644 --- a/www/vicidial/functions.php +++ b/www/vicidial/functions.php @@ -4,7 +4,7 @@ # # functions for administrative scripts and reports # -# Copyright (C) 2024 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2026 Matt Florell LICENSE: AGPLv2 # # # CHANGES: @@ -44,9 +44,10 @@ # 240401-1459 - Added check for vicidial_pending_ar entries in user_authorization # 240801-1130 - Code updates for PHP8 compatibility # 240805-2103 - Added PHP_error_reporting_OVERRIDE options +# 260521-1644 - Code updates for PHP8 compatibility, added ConvertToJSON function # -$PHP_error_reporting_OVERRIDE=0; +$PHP_error_reporting_OVERRIDE=0; $php_err_suppression_value=0; if (file_exists('options.php')) { require('options.php'); @@ -65,7 +66,7 @@ if ($PHP_error_reporting_OVERRIDE > 0) ##### BEGIN validate user login credentials, check for failed lock out ##### function user_authorization($user,$pass,$user_option,$user_update,$api_call) { - global $link,$php_script; + global $link,$php_script,$DB; # require("dbconnect_mysqli.php"); ############################################# @@ -103,6 +104,7 @@ function user_authorization($user,$pass,$user_option,$user_update,$api_call) $pass = preg_replace("/\||`|&|\'|\"|\\\\|;| /","",$pass); $passSQL = "pass='$pass'"; + $login_problem=0; if ($SSpass_hash_enabled > 0) { @@ -401,6 +403,7 @@ function array_group_count($array, $sort = false) ##### BEGIN bar chart using max stats data ##### function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$metric_name,$more_link,$END_DATE,$download_link,$chart_title) { + global $PHP_SELF; $stats_start_time = time(); if ($END_DATE) { @@ -501,7 +504,7 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met ##### BEGIN download max stats data ##### -function download_max_system_stats($campaign_id,$days_graph,$title,$metric,$metric_name,$END_DATE) +function download_max_system_stats($campaign_id,$days_graph,$title="",$metric,$metric_name,$END_DATE) { global $CSV_text, $link; $stats_start_time = time(); @@ -516,6 +519,7 @@ function download_max_system_stats($campaign_id,$days_graph,$title,$metric,$metr $Btotal_calls[0]=0; $link_text=''; $i=0; + $max_count=0; ### get stats for last X days $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]';"; @@ -576,7 +580,7 @@ function download_max_system_stats($campaign_id,$days_graph,$title,$metric,$metr $i=0; while($i < $days_graph) { - $bar_width = intval($max_multi * $Btotal_calls[$i]); + # $bar_width = intval($max_multi * $Btotal_calls[$i]); if ($Btotal_calls[$i] < 1) {$Btotal_calls[$i] = "-none-";} $CSV_text.="\"$Bstats_date[$i]\",\"$Btotal_calls[$i]\"\n"; $i++; @@ -592,7 +596,7 @@ function download_max_system_stats($campaign_id,$days_graph,$title,$metric,$metr function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code,$owner,$USprefix) { - global $link; + global $link, $DB, $DBX, $tz_method; $postalgmt_found=0; if ( (preg_match("/POSTAL/i",$postalgmt)) && (strlen($postal_code)>4) ) @@ -1393,9 +1397,11 @@ function lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$ } -function mysql_to_mysqli($stmt, $link) +function mysql_to_mysqli($stmt, $link, $debug=0) { + if ($debug) {print $stmt."\n";} $rslt=mysqli_query($link, $stmt); + if ($debug) {print " - ".mysqli_num_rows($rslt)."
\n";} return $rslt; } @@ -1632,7 +1638,7 @@ if (isset($camp_lists)) $g++; } - $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times FROM vicidial_call_times where call_time_id='$local_call_time';"; + $stmt="SELECT call_time_id,call_time_name,call_time_comments,ct_default_start,ct_default_stop,ct_sunday_start,ct_sunday_stop,ct_monday_start,ct_monday_stop,ct_tuesday_start,ct_tuesday_stop,ct_wednesday_start,ct_wednesday_stop,ct_thursday_start,ct_thursday_stop,ct_friday_start,ct_friday_stop,ct_saturday_start,ct_saturday_stop,ct_state_call_times,ct_holidays FROM vicidial_call_times where call_time_id='$local_call_time';"; if ($DB) {$dialable_output .= "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); $rowx=mysqli_fetch_row($rslt); @@ -1697,6 +1703,7 @@ if (isset($camp_lists)) $ct_state_gmt_SQL = ''; $ct_srs=0; $b=0; + $state_rules=array(); if (strlen($Gct_state_call_times)>2) { $state_rules = explode('|',$Gct_state_call_times); @@ -1704,7 +1711,7 @@ if (isset($camp_lists)) } while($ct_srs >= $b) { - if (strlen($state_rules[$b])>1) + if (isset($state_rules[$b]) && strlen($state_rules[$b])>1) { $stmt="SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; $rslt=mysql_to_mysqli($stmt, $link); @@ -1997,8 +2004,8 @@ if (isset($camp_lists)) $o=0; while ($Ds_to_print > $o) { - $o++; $Dsql .= "'$Dstatuses[$o]',"; + $o++; } $Dsql = preg_replace("/,$/","",$Dsql); if (strlen($Dsql) < 2) {$Dsql = "''";} @@ -2046,6 +2053,8 @@ if (isset($camp_lists)) if ($DB) {$dialable_output .= "$camplists_ct|$stmt\n";} $k=0; $camp_lists=''; + $list_id_sql=''; + $LCTlist_id_sql=''; while ($camplists_ct > $k) { $rowA = mysqli_fetch_row($rslt_list); @@ -2167,6 +2176,7 @@ if (isset($camp_lists)) $ct_state_gmt_SQL = ''; $ct_srs=0; $b=0; + $state_rules=array(); if (strlen($Gct_state_call_times)>2) { $state_rules = explode('|',$Gct_state_call_times); @@ -2174,7 +2184,7 @@ if (isset($camp_lists)) } while($ct_srs >= $b) { - if (strlen($state_rules[$b])>1) + if (isset($state_rules[$b]) && strlen($state_rules[$b])>1) { $stmt = "SELECT state_call_time_id,state_call_time_state,state_call_time_name,state_call_time_comments,sct_default_start,sct_default_stop,sct_sunday_start,sct_sunday_stop,sct_monday_start,sct_monday_stop,sct_tuesday_start,sct_tuesday_stop,sct_wednesday_start,sct_wednesday_stop,sct_thursday_start,sct_thursday_stop,sct_friday_start,sct_friday_stop,sct_saturday_start,sct_saturday_stop,ct_holidays from vicidial_state_call_times where state_call_time_id='$state_rules[$b]';"; $rslt=mysql_to_mysqli($stmt, $link); @@ -2565,4 +2575,49 @@ if ($only_return < 1) ##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### } + +function ConvertToJSON($result,$result_reason,$header="",$data="",$key="") + { + $json_output="{\n\"result\": \"$result\",\n\"result_reason\": \"$result_reason\",\n"; + $data=trim($data); + if (strlen($data)>0) + { + $json_output.="\n\"data\": [\n"; + $row_array=explode("\n", $data); + + if ($header=="YES") + { + $key_array=explode("|", $row_array[0]); + $i=1; + } + else + { + $key_array=array(); + $i=0; + } + + while ($i diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index 6c768a31..6bc6598b 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -228,10 +228,11 @@ # 251205-1456 - Added ADAPT_PERCENTMAX dial_method # 260123-1020 - pause_sec fix in agent_stats_export # 260506-1525 - small fix for campaign changes +# 260519-1647 - Code updates for PHP8 compatibility, and json output format # -$version = '2.14-203'; -$build = '260506-1525'; +$version = '2.14-204'; +$build = '260519-1647'; $php_script='non_agent_api.php'; $api_url_log = 0; $camp_lead_order_random=1; @@ -244,526 +245,779 @@ require("functions.php"); ### If you have globals turned off uncomment these lines if (isset($_GET["user"])) {$user=$_GET["user"];} elseif (isset($_POST["user"])) {$user=$_POST["user"];} + else {$user="";} if (isset($_GET["pass"])) {$pass=$_GET["pass"];} elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} + else {$pass="";} if (isset($_GET["function"])) {$function=$_GET["function"];} elseif (isset($_POST["function"])) {$function=$_POST["function"];} + else {$function="";} if (isset($_GET["format"])) {$format=$_GET["format"];} elseif (isset($_POST["format"])) {$format=$_POST["format"];} + else {$format="";} if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} + else {$list_id="";} if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} + else {$phone_code="";} if (isset($_GET["update_phone_number"])) {$update_phone_number=$_GET["update_phone_number"];} elseif (isset($_POST["update_phone_number"])) {$update_phone_number=$_POST["update_phone_number"];} + else {$update_phone_number="";} if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} + else {$phone_number="";} if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} + else {$vendor_lead_code="";} if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];} elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];} + else {$source_id="";} if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];} elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];} + else {$gmt_offset_now="";} if (isset($_GET["title"])) {$title=$_GET["title"];} elseif (isset($_POST["title"])) {$title=$_POST["title"];} + else {$title="";} if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} + else {$first_name="";} if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} + else {$middle_initial="";} if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} + else {$last_name="";} if (isset($_GET["address1"])) {$address1=$_GET["address1"];} elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} + else {$address1="";} if (isset($_GET["address2"])) {$address2=$_GET["address2"];} elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} + else {$address2="";} if (isset($_GET["address3"])) {$address3=$_GET["address3"];} elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} + else {$address3="";} if (isset($_GET["city"])) {$city=$_GET["city"];} elseif (isset($_POST["city"])) {$city=$_POST["city"];} + else {$city="";} if (isset($_GET["state"])) {$state=$_GET["state"];} elseif (isset($_POST["state"])) {$state=$_POST["state"];} + else {$state="";} if (isset($_GET["province"])) {$province=$_GET["province"];} elseif (isset($_POST["province"])) {$province=$_POST["province"];} + else {$province="";} if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} + else {$postal_code="";} if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} + else {$country_code="";} if (isset($_GET["gender"])) {$gender=$_GET["gender"];} elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} + else {$gender="";} if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} + else {$date_of_birth="";} if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} + else {$alt_phone="";} if (isset($_GET["email"])) {$email=$_GET["email"];} elseif (isset($_POST["email"])) {$email=$_POST["email"];} + else {$email="";} if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} + else {$security_phrase="";} if (isset($_GET["comments"])) {$comments=$_GET["comments"];} elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} + else {$comments="";} if (isset($_GET["dnc_check"])) {$dnc_check=$_GET["dnc_check"];} elseif (isset($_POST["dnc_check"])) {$dnc_check=$_POST["dnc_check"];} + else {$dnc_check="";} if (isset($_GET["campaign_dnc_check"])) {$campaign_dnc_check=$_GET["campaign_dnc_check"];} elseif (isset($_POST["campaign_dnc_check"])) {$campaign_dnc_check=$_POST["campaign_dnc_check"];} + else {$campaign_dnc_check="";} if (isset($_GET["add_to_hopper"])) {$add_to_hopper=$_GET["add_to_hopper"];} elseif (isset($_POST["add_to_hopper"])) {$add_to_hopper=$_POST["add_to_hopper"];} + else {$add_to_hopper="";} if (isset($_GET["hopper_priority"])) {$hopper_priority=$_GET["hopper_priority"];} elseif (isset($_POST["hopper_priority"])) {$hopper_priority=$_POST["hopper_priority"];} + else {$hopper_priority="";} if (isset($_GET["hopper_local_call_time_check"])) {$hopper_local_call_time_check=$_GET["hopper_local_call_time_check"];} elseif (isset($_POST["hopper_local_call_time_check"])) {$hopper_local_call_time_check=$_POST["hopper_local_call_time_check"];} + else {$hopper_local_call_time_check="";} if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];} elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];} + else {$campaign_id="";} if (isset($_GET["multi_alt_phones"])) {$multi_alt_phones=$_GET["multi_alt_phones"];} elseif (isset($_POST["multi_alt_phones"])) {$multi_alt_phones=$_POST["multi_alt_phones"];} + else {$multi_alt_phones="";} if (isset($_GET["source"])) {$source=$_GET["source"];} elseif (isset($_POST["source"])) {$source=$_POST["source"];} + else {$source="";} if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} + else {$phone_login="";} if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} + else {$session_id="";} if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} + else {$server_ip="";} if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} + else {$stage="";} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["rank"])) {$rank=$_GET["rank"];} elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} + else {$rank="";} if (isset($_GET["owner"])) {$owner=$_GET["owner"];} elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} + else {$owner="";} if (isset($_GET["agent_user"])) {$agent_user=$_GET["agent_user"];} elseif (isset($_POST["agent_user"])) {$agent_user=$_POST["agent_user"];} + else {$agent_user="";} if (isset($_GET["duplicate_check"])) {$duplicate_check=$_GET["duplicate_check"];} elseif (isset($_POST["duplicate_check"])) {$duplicate_check=$_POST["duplicate_check"];} + else {$duplicate_check="";} if (isset($_GET["custom_fields"])) {$custom_fields=$_GET["custom_fields"];} elseif (isset($_POST["custom_fields"])) {$custom_fields=$_POST["custom_fields"];} + else {$custom_fields="";} if (isset($_GET["search_method"])) {$search_method=$_GET["search_method"];} elseif (isset($_POST["search_method"])) {$search_method=$_POST["search_method"];} + else {$search_method="";} if (isset($_GET["insert_if_not_found"])) {$insert_if_not_found=$_GET["insert_if_not_found"];} elseif (isset($_POST["insert_if_not_found"])) {$insert_if_not_found=$_POST["insert_if_not_found"];} + else {$insert_if_not_found="";} if (isset($_GET["records"])) {$records=$_GET["records"];} elseif (isset($_POST["records"])) {$records=$_POST["records"];} + else {$records="";} if (isset($_GET["search_location"])) {$search_location=$_GET["search_location"];} elseif (isset($_POST["search_location"])) {$search_location=$_POST["search_location"];} + else {$search_location="";} if (isset($_GET["status"])) {$status=$_GET["status"];} elseif (isset($_POST["status"])) {$status=$_POST["status"];} + else {$status="";} if (isset($_GET["statuses"])) {$statuses=$_GET["statuses"];} elseif (isset($_POST["statuses"])) {$statuses=$_POST["statuses"];} + else {$statuses="";} if (isset($_GET["categories"])) {$categories=$_GET["categories"];} elseif (isset($_POST["categories"])) {$categories=$_POST["categories"];} + else {$categories="";} if (isset($_GET["user_field"])) {$user_field=$_GET["user_field"];} elseif (isset($_POST["user_field"])) {$user_field=$_POST["user_field"];} + else {$user_field="";} if (isset($_GET["list_id_field"])) {$list_id_field=$_GET["list_id_field"];} elseif (isset($_POST["list_id_field"])) {$list_id_field=$_POST["list_id_field"];} + else {$list_id_field="";} if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} + else {$lead_id="";} if (isset($_GET["no_update"])) {$no_update=$_GET["no_update"];} elseif (isset($_POST["no_update"])) {$no_update=$_POST["no_update"];} + else {$no_update="";} if (isset($_GET["delete_lead"])) {$delete_lead=$_GET["delete_lead"];} elseif (isset($_POST["delete_lead"])) {$delete_lead=$_POST["delete_lead"];} + else {$delete_lead="";} if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} + else {$called_count="";} if (isset($_GET["date"])) {$date=$_GET["date"];} elseif (isset($_POST["date"])) {$date=$_POST["date"];} + else {$date="";} if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} + else {$query_date="";} if (isset($_GET["query_time"])) {$query_time=$_GET["query_time"];} elseif (isset($_POST["query_time"])) {$query_time=$_POST["query_time"];} + else {$query_time="";} if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} + else {$end_date="";} if (isset($_GET["end_time"])) {$end_time=$_GET["end_time"];} elseif (isset($_POST["end_time"])) {$end_time=$_POST["end_time"];} + else {$end_time="";} if (isset($_GET["header"])) {$header=$_GET["header"];} elseif (isset($_POST["header"])) {$header=$_POST["header"];} + else {$header="";} if (isset($_GET["agent_pass"])) {$agent_pass=$_GET["agent_pass"];} elseif (isset($_POST["agent_pass"])) {$agent_pass=$_POST["agent_pass"];} + else {$agent_pass="";} if (isset($_GET["agent_user_level"])) {$agent_user_level=$_GET["agent_user_level"];} elseif (isset($_POST["agent_user_level"])) {$agent_user_level=$_POST["agent_user_level"];} + else {$agent_user_level="";} if (isset($_GET["agent_full_name"])) {$agent_full_name=$_GET["agent_full_name"];} elseif (isset($_POST["agent_full_name"])) {$agent_full_name=$_POST["agent_full_name"];} + else {$agent_full_name="";} if (isset($_GET["agent_user_group"])) {$agent_user_group=$_GET["agent_user_group"];} elseif (isset($_POST["agent_user_group"])) {$agent_user_group=$_POST["agent_user_group"];} + else {$agent_user_group="";} if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} + else {$phone_pass="";} if (isset($_GET["hotkeys_active"])) {$hotkeys_active=$_GET["hotkeys_active"];} elseif (isset($_POST["hotkeys_active"])) {$hotkeys_active=$_POST["hotkeys_active"];} + else {$hotkeys_active="";} if (isset($_GET["voicemail_id"])) {$voicemail_id=$_GET["voicemail_id"];} elseif (isset($_POST["voicemail_id"])) {$voicemail_id=$_POST["voicemail_id"];} -if (isset($_GET["email"])) {$email=$_GET["email"];} - elseif (isset($_POST["email"])) {$email=$_POST["email"];} + else {$voicemail_id="";} if (isset($_GET["custom_one"])) {$custom_one=$_GET["custom_one"];} elseif (isset($_POST["custom_one"])) {$custom_one=$_POST["custom_one"];} + else {$custom_one="";} if (isset($_GET["custom_two"])) {$custom_two=$_GET["custom_two"];} elseif (isset($_POST["custom_two"])) {$custom_two=$_POST["custom_two"];} + else {$custom_two="";} if (isset($_GET["custom_three"])) {$custom_three=$_GET["custom_three"];} elseif (isset($_POST["custom_three"])) {$custom_three=$_POST["custom_three"];} + else {$custom_three="";} if (isset($_GET["custom_four"])) {$custom_four=$_GET["custom_four"];} elseif (isset($_POST["custom_four"])) {$custom_four=$_POST["custom_four"];} + else {$custom_four="";} if (isset($_GET["custom_five"])) {$custom_five=$_GET["custom_five"];} elseif (isset($_POST["custom_five"])) {$custom_five=$_POST["custom_five"];} + else {$custom_five="";} if (isset($_GET["extension"])) {$extension=$_GET["extension"];} elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} + else {$extension="";} if (isset($_GET["dialplan_number"])) {$dialplan_number=$_GET["dialplan_number"];} elseif (isset($_POST["dialplan_number"])) {$dialplan_number=$_POST["dialplan_number"];} + else {$dialplan_number="";} if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + else {$protocol="";} if (isset($_GET["registration_password"])) {$registration_password=$_GET["registration_password"];} elseif (isset($_POST["registration_password"])) {$registration_password=$_POST["registration_password"];} + else {$registration_password="";} if (isset($_GET["phone_full_name"])) {$phone_full_name=$_GET["phone_full_name"];} elseif (isset($_POST["phone_full_name"])) {$phone_full_name=$_POST["phone_full_name"];} + else {$phone_full_name="";} if (isset($_GET["local_gmt"])) {$local_gmt=$_GET["local_gmt"];} elseif (isset($_POST["local_gmt"])) {$local_gmt=$_POST["local_gmt"];} + else {$local_gmt="";} if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} + else {$outbound_cid="";} if (isset($_GET["phone_context"])) {$phone_context=$_GET["phone_context"];} elseif (isset($_POST["phone_context"])) {$phone_context=$_POST["phone_context"];} + else {$phone_context="";} if (isset($_GET["list_name"])) {$list_name=$_GET["list_name"];} elseif (isset($_POST["list_name"])) {$list_name=$_POST["list_name"];} + else {$list_name="";} if (isset($_GET["active"])) {$active=$_GET["active"];} elseif (isset($_POST["active"])) {$active=$_POST["active"];} + else {$active="";} if (isset($_GET["script"])) {$script=$_GET["script"];} elseif (isset($_POST["script"])) {$script=$_POST["script"];} + else {$script="";} if (isset($_GET["am_message"])) {$am_message=$_GET["am_message"];} elseif (isset($_POST["am_message"])) {$am_message=$_POST["am_message"];} + else {$am_message="";} if (isset($_GET["drop_inbound_group"])) {$drop_inbound_group=$_GET["drop_inbound_group"];} elseif (isset($_POST["drop_inbound_group"])) {$drop_inbound_group=$_POST["drop_inbound_group"];} + else {$drop_inbound_group="";} if (isset($_GET["web_form_address"])) {$web_form_address=$_GET["web_form_address"];} elseif (isset($_POST["web_form_address"])) {$web_form_address=$_POST["web_form_address"];} + else {$web_form_address="";} if (isset($_GET["web_form_address_two"])) {$web_form_address_two=$_GET["web_form_address_two"];} elseif (isset($_POST["web_form_address_two"])) {$web_form_address_two=$_POST["web_form_address_two"];} + else {$web_form_address_two="";} if (isset($_GET["web_form_address_three"])) {$web_form_address_three=$_GET["web_form_address_three"];} elseif (isset($_POST["web_form_address_three"])) {$web_form_address_three=$_POST["web_form_address_three"];} + else {$web_form_address_three="";} if (isset($_GET["reset_list"])) {$reset_list=$_GET["reset_list"];} elseif (isset($_POST["reset_list"])) {$reset_list=$_POST["reset_list"];} + else {$reset_list="";} if (isset($_GET["delete_list"])) {$delete_list=$_GET["delete_list"];} elseif (isset($_POST["delete_list"])) {$delete_list=$_POST["delete_list"];} + else {$delete_list="";} if (isset($_GET["delete_leads"])) {$delete_leads=$_GET["delete_leads"];} elseif (isset($_POST["delete_leads"])) {$delete_leads=$_POST["delete_leads"];} + else {$delete_leads="";} if (isset($_GET["reset_time"])) {$reset_time=$_GET["reset_time"];} elseif (isset($_POST["reset_time"])) {$reset_time=$_POST["reset_time"];} + else {$reset_time="";} if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} + else {$uniqueid="";} if (isset($_GET["tz_method"])) {$tz_method=$_GET["tz_method"];} elseif (isset($_POST["tz_method"])) {$tz_method=$_POST["tz_method"];} + else {$tz_method="";} if (isset($_GET["reset_lead"])) {$reset_lead=$_GET["reset_lead"];} elseif (isset($_POST["reset_lead"])) {$reset_lead=$_POST["reset_lead"];} + else {$reset_lead="";} if (isset($_GET["usacan_areacode_check"])) {$usacan_areacode_check=$_GET["usacan_areacode_check"];} elseif (isset($_POST["usacan_areacode_check"])) {$usacan_areacode_check=$_POST["usacan_areacode_check"];} + else {$usacan_areacode_check="";} if (isset($_GET["usacan_prefix_check"])) {$usacan_prefix_check=$_GET["usacan_prefix_check"];} elseif (isset($_POST["usacan_prefix_check"])) {$usacan_prefix_check=$_POST["usacan_prefix_check"];} + else {$usacan_prefix_check="";} if (isset($_GET["delete_phone"])) {$delete_phone=$_GET["delete_phone"];} elseif (isset($_POST["delete_phone"])) {$delete_phone=$_POST["delete_phone"];} + else {$delete_phone="";} if (isset($_GET["alias_id"])) {$alias_id=$_GET["alias_id"];} elseif (isset($_POST["alias_id"])) {$alias_id=$_POST["alias_id"];} + else {$alias_id="";} if (isset($_GET["phone_logins"])) {$phone_logins=$_GET["phone_logins"];} elseif (isset($_POST["phone_logins"])) {$phone_logins=$_POST["phone_logins"];} + else {$phone_logins="";} if (isset($_GET["alias_name"])) {$alias_name=$_GET["alias_name"];} elseif (isset($_POST["alias_name"])) {$alias_name=$_POST["alias_name"];} + else {$alias_name="";} if (isset($_GET["delete_alias"])) {$delete_alias=$_GET["delete_alias"];} elseif (isset($_POST["delete_alias"])) {$delete_alias=$_POST["delete_alias"];} + else {$delete_alias="";} if (isset($_GET["callback"])) {$callback=$_GET["callback"];} elseif (isset($_POST["callback"])) {$callback=$_POST["callback"];} + else {$callback="";} if (isset($_GET["callback_status"])) {$callback_status=$_GET["callback_status"];} elseif (isset($_POST["callback_status"])) {$callback_status=$_POST["callback_status"];} + else {$callback_status="";} if (isset($_GET["callback_datetime"])) {$callback_datetime=$_GET["callback_datetime"];} elseif (isset($_POST["callback_datetime"])) {$callback_datetime=$_POST["callback_datetime"];} + else {$callback_datetime="";} if (isset($_GET["callback_type"])) {$callback_type=$_GET["callback_type"];} elseif (isset($_POST["callback_type"])) {$callback_type=$_POST["callback_type"];} + else {$callback_type="";} if (isset($_GET["callback_user"])) {$callback_user=$_GET["callback_user"];} elseif (isset($_POST["callback_user"])) {$callback_user=$_POST["callback_user"];} + else {$callback_user="";} if (isset($_GET["callback_comments"])) {$callback_comments=$_GET["callback_comments"];} elseif (isset($_POST["callback_comments"])) {$callback_comments=$_POST["callback_comments"];} + else {$callback_comments="";} if (isset($_GET["admin_user_group"])) {$admin_user_group=$_GET["admin_user_group"];} elseif (isset($_POST["admin_user_group"])) {$admin_user_group=$_POST["admin_user_group"];} + else {$admin_user_group="";} if (isset($_GET["datetime_start"])) {$datetime_start=$_GET["datetime_start"];} elseif (isset($_POST["datetime_start"])) {$datetime_start=$_POST["datetime_start"];} + else {$datetime_start="";} if (isset($_GET["datetime_end"])) {$datetime_end=$_GET["datetime_end"];} elseif (isset($_POST["datetime_end"])) {$datetime_end=$_POST["datetime_end"];} + else {$datetime_end="";} if (isset($_GET["time_format"])) {$time_format=$_GET["time_format"];} elseif (isset($_POST["time_format"])) {$time_format=$_POST["time_format"];} + else {$time_format="";} if (isset($_GET["group_alias_id"])) {$group_alias_id=$_GET["group_alias_id"];} elseif (isset($_POST["group_alias_id"])) {$group_alias_id=$_POST["group_alias_id"];} + else {$group_alias_id="";} if (isset($_GET["group_alias_name"])) {$group_alias_name=$_GET["group_alias_name"];} elseif (isset($_POST["group_alias_name"])) {$group_alias_name=$_POST["group_alias_name"];} + else {$group_alias_name="";} if (isset($_GET["caller_id_number"])) {$caller_id_number=$_GET["caller_id_number"];} elseif (isset($_POST["caller_id_number"])) {$caller_id_number=$_POST["caller_id_number"];} + else {$caller_id_number="";} if (isset($_GET["caller_id_name"])) {$caller_id_name=$_GET["caller_id_name"];} elseif (isset($_POST["caller_id_name"])) {$caller_id_name=$_POST["caller_id_name"];} + else {$caller_id_name="";} if (isset($_GET["user_groups"])) {$user_groups=$_GET["user_groups"];} elseif (isset($_POST["user_groups"])) {$user_groups=$_POST["user_groups"];} + else {$user_groups="";} if (isset($_GET["in_groups"])) {$in_groups=$_GET["in_groups"];} elseif (isset($_POST["in_groups"])) {$in_groups=$_POST["in_groups"];} + else {$in_groups="";} if (isset($_GET["did_ids"])) {$did_ids=$_GET["did_ids"];} elseif (isset($_POST["did_ids"])) {$did_ids=$_POST["did_ids"];} + else {$did_ids="";} if (isset($_GET["did_patterns"])) {$did_patterns=$_GET["did_patterns"];} elseif (isset($_POST["did_patterns"])) {$did_patterns=$_POST["did_patterns"];} + else {$did_patterns="";} if (isset($_GET["call_id"])) {$call_id=$_GET["call_id"];} elseif (isset($_POST["call_id"])) {$call_id=$_POST["call_id"];} + else {$call_id="";} if (isset($_GET["group"])) {$group=$_GET["group"];} elseif (isset($_POST["group"])) {$group=$_POST["group"];} + else {$group="";} if (isset($_GET["expiration_date"])) {$expiration_date=$_GET["expiration_date"];} elseif (isset($_POST["expiration_date"])) {$expiration_date=$_POST["expiration_date"];} + else {$expiration_date="";} if (isset($_GET["nanpa_ac_prefix_check"])) {$nanpa_ac_prefix_check=$_GET["nanpa_ac_prefix_check"];} elseif (isset($_POST["nanpa_ac_prefix_check"])) {$nanpa_ac_prefix_check=$_POST["nanpa_ac_prefix_check"];} + else {$nanpa_ac_prefix_check="";} if (isset($_GET["detail"])) {$detail=$_GET["detail"];} elseif (isset($_POST["detail"])) {$detail=$_POST["detail"];} + else {$detail="";} if (isset($_GET["delete_user"])) {$delete_user=$_GET["delete_user"];} elseif (isset($_POST["delete_user"])) {$delete_user=$_POST["delete_user"];} + else {$delete_user="";} if (isset($_GET["campaign_rank"])) {$campaign_rank=$_GET["campaign_rank"];} elseif (isset($_POST["campaign_rank"])) {$campaign_rank=$_POST["campaign_rank"];} + else {$campaign_rank="";} if (isset($_GET["campaign_grade"])) {$campaign_grade=$_GET["campaign_grade"];} elseif (isset($_POST["campaign_grade"])) {$campaign_grade=$_POST["campaign_grade"];} + else {$campaign_grade="";} if (isset($_GET["local_call_time"])) {$local_call_time=$_GET["local_call_time"];} elseif (isset($_POST["local_call_time"])) {$local_call_time=$_POST["local_call_time"];} + else {$local_call_time="";} if (isset($_GET["camp_rg_only"])) {$camp_rg_only=$_GET["camp_rg_only"];} elseif (isset($_POST["camp_rg_only"])) {$camp_rg_only=$_POST["camp_rg_only"];} + else {$camp_rg_only="";} if (isset($_GET["wrapup_seconds_override"])) {$wrapup_seconds_override=$_GET["wrapup_seconds_override"];} elseif (isset($_POST["wrapup_seconds_override"])) {$wrapup_seconds_override=$_POST["wrapup_seconds_override"];} + else {$wrapup_seconds_override="";} if (isset($_GET["entry_list_id"])) {$entry_list_id=$_GET["entry_list_id"];} elseif (isset($_POST["entry_list_id"])) {$entry_list_id=$_POST["entry_list_id"];} + else {$entry_list_id="";} if (isset($_GET["show_sub_status"])) {$show_sub_status=$_GET["show_sub_status"];} elseif (isset($_POST["show_sub_status"])) {$show_sub_status=$_POST["show_sub_status"];} + else {$show_sub_status="";} if (isset($_GET["campaigns"])) {$campaigns=$_GET["campaigns"];} elseif (isset($_POST["campaigns"])) {$campaigns=$_POST["campaigns"];} + else {$campaigns="";} if (isset($_GET["ingroups"])) {$ingroups=$_GET["ingroups"];} elseif (isset($_POST["ingroups"])) {$ingroups=$_POST["ingroups"];} + else {$ingroups="";} if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];} elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];} -if (isset($_GET["did_ids"])) {$did_ids=$_GET["did_ids"];} - elseif (isset($_POST["did_ids"])) {$did_ids=$_POST["did_ids"];} + else {$campaign_name="";} if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];} elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];} + else {$did_pattern="";} if (isset($_GET["users"])) {$users=$_GET["users"];} elseif (isset($_POST["users"])) {$users=$_POST["users"];} + else {$users="";} if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} + else {$auto_dial_level="";} if (isset($_GET["adaptive_maximum_level"])) {$adaptive_maximum_level=$_GET["adaptive_maximum_level"];} elseif (isset($_POST["adaptive_maximum_level"])) {$adaptive_maximum_level=$_POST["adaptive_maximum_level"];} + else {$adaptive_maximum_level="";} if (isset($_GET["campaign_vdad_exten"])) {$campaign_vdad_exten=$_GET["campaign_vdad_exten"];} elseif (isset($_POST["campaign_vdad_exten"])) {$campaign_vdad_exten=$_POST["campaign_vdad_exten"];} + else {$campaign_vdad_exten="";} if (isset($_GET["hopper_level"])) {$hopper_level=$_GET["hopper_level"];} elseif (isset($_POST["hopper_level"])) {$hopper_level=$_POST["hopper_level"];} + else {$hopper_level="";} if (isset($_GET["reset_hopper"])) {$reset_hopper=$_GET["reset_hopper"];} elseif (isset($_POST["reset_hopper"])) {$reset_hopper=$_POST["reset_hopper"];} + else {$reset_hopper="";} if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} + else {$dial_method="";} if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} -if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} - elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + else {$dial_timeout="";} if (isset($_GET["lookup_state"])) {$lookup_state=$_GET["lookup_state"];} elseif (isset($_POST["lookup_state"])) {$lookup_state=$_POST["lookup_state"];} + else {$lookup_state="";} if (isset($_GET["type"])) {$type=$_GET["type"];} elseif (isset($_POST["type"])) {$type=$_POST["type"];} + else {$type="";} if (isset($_GET["status_breakdown"])) {$status_breakdown=$_GET["status_breakdown"];} elseif (isset($_POST["status_breakdown"])) {$status_breakdown=$_POST["status_breakdown"];} + else {$status_breakdown="";} if (isset($_GET["show_percentages"])) {$show_percentages=$_GET["show_percentages"];} elseif (isset($_POST["show_percentages"])) {$show_percentages=$_POST["show_percentages"];} + else {$show_percentages="";} if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} + else {$file_download="";} if (isset($_GET["force_entry_list_id"])) {$force_entry_list_id=$_GET["force_entry_list_id"];} elseif (isset($_POST["force_entry_list_id"])) {$force_entry_list_id=$_POST["force_entry_list_id"];} + else {$force_entry_list_id="";} if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];} elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];} + else {$lead_filter_id="";} if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];} elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];} + else {$agent_choose_ingroups="";} if (isset($_GET["agent_choose_blended"])) {$agent_choose_blended=$_GET["agent_choose_blended"];} elseif (isset($_POST["agent_choose_blended"])) {$agent_choose_blended=$_POST["agent_choose_blended"];} + else {$agent_choose_blended="";} if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];} elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];} + else {$closer_default_blended="";} if (isset($_GET["outbound_alt_cid"])) {$outbound_alt_cid=$_GET["outbound_alt_cid"];} elseif (isset($_POST["outbound_alt_cid"])) {$outbound_alt_cid=$_POST["outbound_alt_cid"];} + else {$outbound_alt_cid="";} if (isset($_GET["phone_ring_timeout"])) {$phone_ring_timeout=$_GET["phone_ring_timeout"];} elseif (isset($_POST["phone_ring_timeout"])) {$phone_ring_timeout=$_POST["phone_ring_timeout"];} + else {$phone_ring_timeout="";} if (isset($_GET["delete_vm_after_email"])) {$delete_vm_after_email=$_GET["delete_vm_after_email"];} elseif (isset($_POST["delete_vm_after_email"])) {$delete_vm_after_email=$_POST["delete_vm_after_email"];} + else {$delete_vm_after_email="";} if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];} elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];} + else {$did_description="";} if (isset($_GET["did_route"])) {$did_route=$_GET["did_route"];} elseif (isset($_POST["did_route"])) {$did_route=$_POST["did_route"];} + else {$did_route="";} if (isset($_GET["record_call"])) {$record_call=$_GET["record_call"];} elseif (isset($_POST["record_call"])) {$record_call=$_POST["record_call"];} + else {$record_call="";} if (isset($_GET["exten_context"])) {$exten_context=$_GET["exten_context"];} elseif (isset($_POST["exten_context"])) {$exten_context=$_POST["exten_context"];} + else {$exten_context="";} if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];} elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];} + else {$voicemail_ext="";} if (isset($_GET["phone_extension"])) {$phone_extension=$_GET["phone_extension"];} elseif (isset($_POST["phone_extension"])) {$phone_extension=$_POST["phone_extension"];} + else {$phone_extension="";} if (isset($_GET["filter_clean_cid_number"])) {$filter_clean_cid_number=$_GET["filter_clean_cid_number"];} elseif (isset($_POST["filter_clean_cid_number"])) {$filter_clean_cid_number=$_POST["filter_clean_cid_number"];} + else {$filter_clean_cid_number="";} if (isset($_GET["ignore_agentdirect"])) {$ignore_agentdirect=$_GET["ignore_agentdirect"];} elseif (isset($_POST["ignore_agentdirect"])) {$ignore_agentdirect=$_POST["ignore_agentdirect"];} + else {$ignore_agentdirect="";} if (isset($_GET["areacode"])) {$areacode=$_GET["areacode"];} elseif (isset($_POST["areacode"])) {$areacode=$_POST["areacode"];} + else {$areacode="";} if (isset($_GET["cid_group_id"])) {$cid_group_id=$_GET["cid_group_id"];} elseif (isset($_POST["cid_group_id"])) {$cid_group_id=$_POST["cid_group_id"];} + else {$cid_group_id="";} if (isset($_GET["cid_description"])) {$cid_description=$_GET["cid_description"];} elseif (isset($_POST["cid_description"])) {$cid_description=$_POST["cid_description"];} + else {$cid_description="";} if (isset($_GET["custom_fields_copy"])) {$custom_fields_copy=$_GET["custom_fields_copy"];} elseif (isset($_POST["custom_fields_copy"])) {$custom_fields_copy=$_POST["custom_fields_copy"];} + else {$custom_fields_copy="";} if (isset($_GET["list_description"])) {$list_description=$_GET["list_description"];} elseif (isset($_POST["list_description"])) {$list_description=$_POST["list_description"];} + else {$list_description="";} if (isset($_GET["leads_counts"])) {$leads_counts=$_GET["leads_counts"];} elseif (isset($_POST["leads_counts"])) {$leads_counts=$_POST["leads_counts"];} + else {$leads_counts="";} if (isset($_GET["remove_from_hopper"])) {$remove_from_hopper=$_GET["remove_from_hopper"];} elseif (isset($_POST["remove_from_hopper"])) {$remove_from_hopper=$_POST["remove_from_hopper"];} + else {$remove_from_hopper="";} if (isset($_GET["custom_order"])) {$custom_order=$_GET["custom_order"];} elseif (isset($_POST["custom_order"])) {$custom_order=$_POST["custom_order"];} + else {$custom_order="";} if (isset($_GET["custom_copy_method"])) {$custom_copy_method=$_GET["custom_copy_method"];} elseif (isset($_POST["custom_copy_method"])) {$custom_copy_method=$_POST["custom_copy_method"];} + else {$custom_copy_method="";} if (isset($_GET["duration"])) {$duration=$_GET["duration"];} elseif (isset($_POST["duration"])) {$duration=$_POST["duration"];} + else {$duration="";} if (isset($_GET["is_webphone"])) {$is_webphone=$_GET["is_webphone"];} elseif (isset($_POST["is_webphone"])) {$is_webphone=$_POST["is_webphone"];} + else {$is_webphone="";} if (isset($_GET["webphone_auto_answer"])) {$webphone_auto_answer=$_GET["webphone_auto_answer"];} elseif (isset($_POST["webphone_auto_answer"])) {$webphone_auto_answer=$_POST["webphone_auto_answer"];} + else {$webphone_auto_answer="";} if (isset($_GET["use_external_server_ip"])) {$use_external_server_ip=$_GET["use_external_server_ip"];} elseif (isset($_POST["use_external_server_ip"])) {$use_external_server_ip=$_POST["use_external_server_ip"];} + else {$use_external_server_ip="";} if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];} elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];} + else {$template_id="";} if (isset($_GET["on_hook_agent"])) {$on_hook_agent=$_GET["on_hook_agent"];} elseif (isset($_POST["on_hook_agent"])) {$on_hook_agent=$_POST["on_hook_agent"];} + else {$on_hook_agent="";} if (isset($_GET["delete_did"])) {$delete_did=$_GET["delete_did"];} elseif (isset($_POST["delete_did"])) {$delete_did=$_POST["delete_did"];} + else {$delete_did="";} if (isset($_GET["group_by_campaign"])) {$group_by_campaign=$_GET["group_by_campaign"];} elseif (isset($_POST["group_by_campaign"])) {$group_by_campaign=$_POST["group_by_campaign"];} + else {$group_by_campaign="";} if (isset($_GET["source_user"])) {$source_user=$_GET["source_user"];} elseif (isset($_POST["source_user"])) {$source_user=$_POST["source_user"];} + else {$source_user="";} if (isset($_GET["list_exists_check"])) {$list_exists_check=$_GET["list_exists_check"];} elseif (isset($_POST["list_exists_check"])) {$list_exists_check=$_POST["list_exists_check"];} + else {$list_exists_check="";} if (isset($_GET["menu_id"])) {$menu_id=$_GET["menu_id"];} elseif (isset($_POST["menu_id"])) {$menu_id=$_POST["menu_id"];} + else {$menu_id="";} if (isset($_GET["xferconf_one"])) {$xferconf_one=$_GET["xferconf_one"];} elseif (isset($_POST["xferconf_one"])) {$xferconf_one=$_POST["xferconf_one"];} + else {$xferconf_one="";} if (isset($_GET["xferconf_two"])) {$xferconf_two=$_GET["xferconf_two"];} elseif (isset($_POST["xferconf_two"])) {$xferconf_two=$_POST["xferconf_two"];} + else {$xferconf_two="";} if (isset($_GET["xferconf_three"])) {$xferconf_three=$_GET["xferconf_three"];} elseif (isset($_POST["xferconf_three"])) {$xferconf_three=$_POST["xferconf_three"];} + else {$xferconf_three="";} if (isset($_GET["xferconf_four"])) {$xferconf_four=$_GET["xferconf_four"];} elseif (isset($_POST["xferconf_four"])) {$xferconf_four=$_POST["xferconf_four"];} + else {$xferconf_four="";} if (isset($_GET["xferconf_five"])) {$xferconf_five=$_GET["xferconf_five"];} elseif (isset($_POST["xferconf_five"])) {$xferconf_five=$_POST["xferconf_five"];} + else {$xferconf_five="";} if (isset($_GET["use_internal_webserver"])) {$use_internal_webserver=$_GET["use_internal_webserver"];} elseif (isset($_POST["use_internal_webserver"])) {$use_internal_webserver=$_POST["use_internal_webserver"];} + else {$use_internal_webserver="";} if (isset($_GET["field_label"])) {$field_label=$_GET["field_label"];} elseif (isset($_POST["field_label"])) {$field_label=$_POST["field_label"];} + else {$field_label="";} if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + else {$field_name="";} if (isset($_GET["field_description"])) {$field_description=$_GET["field_description"];} elseif (isset($_POST["field_description"])) {$field_description=$_POST["field_description"];} + else {$field_description="";} if (isset($_GET["field_rank"])) {$field_rank=$_GET["field_rank"];} elseif (isset($_POST["field_rank"])) {$field_rank=$_POST["field_rank"];} + else {$field_rank="";} if (isset($_GET["field_help"])) {$field_help=$_GET["field_help"];} elseif (isset($_POST["field_help"])) {$field_help=$_POST["field_help"];} + else {$field_help="";} if (isset($_GET["field_type"])) {$field_type=$_GET["field_type"];} elseif (isset($_POST["field_type"])) {$field_type=$_POST["field_type"];} + else {$field_type="";} if (isset($_GET["field_options"])) {$field_options=$_GET["field_options"];} elseif (isset($_POST["field_options"])) {$field_options=$_POST["field_options"];} + else {$field_options="";} if (isset($_GET["field_size"])) {$field_size=$_GET["field_size"];} elseif (isset($_POST["field_size"])) {$field_size=$_POST["field_size"];} + else {$field_size="";} if (isset($_GET["field_max"])) {$field_max=$_GET["field_max"];} elseif (isset($_POST["field_max"])) {$field_max=$_POST["field_max"];} + else {$field_max="";} if (isset($_GET["field_default"])) {$field_default=$_GET["field_default"];} elseif (isset($_POST["field_default"])) {$field_default=$_POST["field_default"];} + else {$field_default="";} if (isset($_GET["field_required"])) {$field_required=$_GET["field_required"];} elseif (isset($_POST["field_required"])) {$field_required=$_POST["field_required"];} + else {$field_required="";} if (isset($_GET["name_position"])) {$name_position=$_GET["name_position"];} elseif (isset($_POST["name_position"])) {$name_position=$_POST["name_position"];} + else {$name_position="";} if (isset($_GET["multi_position"])) {$multi_position=$_GET["multi_position"];} elseif (isset($_POST["multi_position"])) {$multi_position=$_POST["multi_position"];} + else {$multi_position="";} if (isset($_GET["field_order"])) {$field_order=$_GET["field_order"];} elseif (isset($_POST["field_order"])) {$field_order=$_POST["field_order"];} + else {$field_order="";} if (isset($_GET["field_encrypt"])) {$field_encrypt=$_GET["field_encrypt"];} elseif (isset($_POST["field_encrypt"])) {$field_encrypt=$_POST["field_encrypt"];} + else {$field_encrypt="";} if (isset($_GET["field_show_hide"])) {$field_show_hide=$_GET["field_show_hide"];} elseif (isset($_POST["field_show_hide"])) {$field_show_hide=$_POST["field_show_hide"];} + else {$field_show_hide="";} if (isset($_GET["field_duplicate"])) {$field_duplicate=$_GET["field_duplicate"];} elseif (isset($_POST["field_duplicate"])) {$field_duplicate=$_POST["field_duplicate"];} + else {$field_duplicate="";} if (isset($_GET["field_rerank"])) {$field_rerank=$_GET["field_rerank"];} elseif (isset($_POST["field_rerank"])) {$field_rerank=$_POST["field_rerank"];} + else {$field_rerank="";} if (isset($_GET["custom_fields_add"])) {$custom_fields_add=$_GET["custom_fields_add"];} elseif (isset($_POST["custom_fields_add"])) {$custom_fields_add=$_POST["custom_fields_add"];} + else {$custom_fields_add="";} if (isset($_GET["custom_fields_update"])) {$custom_fields_update=$_GET["custom_fields_update"];} elseif (isset($_POST["custom_fields_update"])) {$custom_fields_update=$_POST["custom_fields_update"];} + else {$custom_fields_update="";} if (isset($_GET["custom_fields_delete"])) {$custom_fields_delete=$_GET["custom_fields_delete"];} elseif (isset($_POST["custom_fields_delete"])) {$custom_fields_delete=$_POST["custom_fields_delete"];} + else {$custom_fields_delete="";} if (isset($_GET["dialable_count"])) {$dialable_count=$_GET["dialable_count"];} elseif (isset($_POST["dialable_count"])) {$dialable_count=$_POST["dialable_count"];} + else {$dialable_count="";} if (isset($_GET["call_handle_method"])) {$call_handle_method=$_GET["call_handle_method"];} elseif (isset($_POST["call_handle_method"])) {$call_handle_method=$_POST["call_handle_method"];} + else {$call_handle_method="";} if (isset($_GET["agent_search_method"])) {$agent_search_method=$_GET["agent_search_method"];} elseif (isset($_POST["agent_search_method"])) {$agent_search_method=$_POST["agent_search_method"];} + else {$agent_search_method="";} if (isset($_GET["ingroup_rank"])) {$ingroup_rank=$_GET["ingroup_rank"];} elseif (isset($_POST["ingroup_rank"])) {$ingroup_rank=$_POST["ingroup_rank"];} + else {$ingroup_rank="";} if (isset($_GET["ingroup_grade"])) {$ingroup_grade=$_GET["ingroup_grade"];} elseif (isset($_POST["ingroup_grade"])) {$ingroup_grade=$_POST["ingroup_grade"];} + else {$ingroup_grade="";} if (isset($_GET["ingrp_rg_only"])) {$ingrp_rg_only=$_GET["ingrp_rg_only"];} elseif (isset($_POST["ingrp_rg_only"])) {$ingrp_rg_only=$_POST["ingrp_rg_only"];} + else {$ingrp_rg_only="";} if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];} elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];} + else {$group_id="";} if (isset($_GET["lead_ids"])) {$lead_ids=$_GET["lead_ids"];} elseif (isset($_POST["lead_ids"])) {$lead_ids=$_POST["lead_ids"];} + else {$lead_ids="";} if (isset($_GET["delete_cf_data"])) {$delete_cf_data=$_GET["delete_cf_data"];} elseif (isset($_POST["delete_cf_data"])) {$delete_cf_data=$_POST["delete_cf_data"];} + else {$delete_cf_data="";} if (isset($_GET["dispo_call_url"])) {$dispo_call_url=$_GET["dispo_call_url"];} elseif (isset($_POST["dispo_call_url"])) {$dispo_call_url=$_POST["dispo_call_url"];} + else {$dispo_call_url="";} if (isset($_GET["entry_type"])) {$entry_type=$_GET["entry_type"];} elseif (isset($_POST["entry_type"])) {$entry_type=$_POST["entry_type"];} + else {$entry_type="";} if (isset($_GET["alt_url_id"])) {$alt_url_id=$_GET["alt_url_id"];} elseif (isset($_POST["alt_url_id"])) {$alt_url_id=$_POST["alt_url_id"];} + else {$alt_url_id="";} if (isset($_GET["url_address"])) {$url_address=$_GET["url_address"];} elseif (isset($_POST["url_address"])) {$url_address=$_POST["url_address"];} + else {$url_address="";} if (isset($_GET["url_type"])) {$url_type=$_GET["url_type"];} elseif (isset($_POST["url_type"])) {$url_type=$_POST["url_type"];} + else {$url_type="";} if (isset($_GET["url_rank"])) {$url_rank=$_GET["url_rank"];} elseif (isset($_POST["url_rank"])) {$url_rank=$_POST["url_rank"];} + else {$url_rank="";} if (isset($_GET["url_statuses"])) {$url_statuses=$_GET["url_statuses"];} elseif (isset($_POST["url_statuses"])) {$url_statuses=$_POST["url_statuses"];} + else {$url_statuses="";} if (isset($_GET["url_description"])) {$url_description=$_GET["url_description"];} elseif (isset($_POST["url_description"])) {$url_description=$_POST["url_description"];} + else {$url_description="";} if (isset($_GET["url_lists"])) {$url_lists=$_GET["url_lists"];} elseif (isset($_POST["url_lists"])) {$url_lists=$_POST["url_lists"];} + else {$url_lists="";} if (isset($_GET["url_call_length"])) {$url_call_length=$_GET["url_call_length"];} elseif (isset($_POST["url_call_length"])) {$url_call_length=$_POST["url_call_length"];} + else {$url_call_length="";} if (isset($_GET["preset_name"])) {$preset_name=$_GET["preset_name"];} elseif (isset($_POST["preset_name"])) {$preset_name=$_POST["preset_name"];} + else {$preset_name="";} if (isset($_GET["preset_number"])) {$preset_number=$_GET["preset_number"];} elseif (isset($_POST["preset_number"])) {$preset_number=$_POST["preset_number"];} + else {$preset_number="";} if (isset($_GET["preset_dtmf"])) {$preset_dtmf=$_GET["preset_dtmf"];} elseif (isset($_POST["preset_dtmf"])) {$preset_dtmf=$_POST["preset_dtmf"];} + else {$preset_dtmf="";} if (isset($_GET["preset_hide_number"])) {$preset_hide_number=$_GET["preset_hide_number"];} elseif (isset($_POST["preset_hide_number"])) {$preset_hide_number=$_POST["preset_hide_number"];} + else {$preset_hide_number="";} if (isset($_GET["action"])) {$action=$_GET["action"];} elseif (isset($_POST["action"])) {$action=$_POST["action"];} + else {$action="";} if (isset($_GET["dial_status_add"])) {$dial_status_add=$_GET["dial_status_add"];} elseif (isset($_POST["dial_status_add"])) {$dial_status_add=$_POST["dial_status_add"];} + else {$dial_status_add="";} if (isset($_GET["dial_status_remove"])) {$dial_status_remove=$_GET["dial_status_remove"];} elseif (isset($_POST["dial_status_remove"])) {$dial_status_remove=$_POST["dial_status_remove"];} + else {$dial_status_remove="";} if (isset($_GET["include_ip"])) {$include_ip=$_GET["include_ip"];} elseif (isset($_POST["include_ip"])) {$include_ip=$_POST["include_ip"];} + else {$include_ip="";} if (isset($_GET["reset_password"])) {$reset_password=$_GET["reset_password"];} elseif (isset($_POST["reset_password"])) {$reset_password=$_POST["reset_password"];} + else {$reset_password="";} if (isset($_GET["archived_lead"])) {$archived_lead=$_GET["archived_lead"];} elseif (isset($_POST["archived_lead"])) {$archived_lead=$_POST["archived_lead"];} + else {$archived_lead="";} if (isset($_GET["list_order"])) {$list_order=$_GET["list_order"];} elseif (isset($_POST["list_order"])) {$list_order=$_POST["list_order"];} + else {$list_order="";} if (isset($_GET["list_order_randomize"])) {$list_order_randomize=$_GET["list_order_randomize"];} elseif (isset($_POST["list_order_randomize"])) {$list_order_randomize=$_POST["list_order_randomize"];} + else {$list_order_randomize="";} if (isset($_GET["list_order_secondary"])) {$list_order_secondary=$_GET["list_order_secondary"];} elseif (isset($_POST["list_order_secondary"])) {$list_order_secondary=$_POST["list_order_secondary"];} + else {$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"];} + else {$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"];} + else {$source_did_pattern="";} if (isset($_GET["new_dids"])) {$new_dids=$_GET["new_dids"];} elseif (isset($_POST["new_dids"])) {$new_dids=$_POST["new_dids"];} + else {$new_dids="";} if (isset($_GET["webform_one"])) {$webform_one=$_GET["webform_one"];} elseif (isset($_POST["webform_one"])) {$webform_one=$_POST["webform_one"];} + else {$webform_one="";} if (isset($_GET["webform_two"])) {$webform_two=$_GET["webform_two"];} elseif (isset($_POST["webform_two"])) {$webform_two=$_POST["webform_two"];} + else {$webform_two="";} if (isset($_GET["webform_three"])) {$webform_three=$_GET["webform_three"];} elseif (isset($_POST["webform_three"])) {$webform_three=$_POST["webform_three"];} - -$DB=preg_replace('/[^0-9]/','',$DB); + else {$webform_three="";} +if (isset($_GET["forcephonecode"])) {$forcephonecode=$_GET["forcephonecode"];} + elseif (isset($_POST["forcephonecode"])) {$forcephonecode=$_POST["forcephonecode"];} + else {$forcephonecode="";} +if (isset($_GET["DBX"])) {$DBX=$_GET["DBX"];} + elseif (isset($_POST["DBX"])) {$DBX=$_POST["DBX"];} if (file_exists('options.php')) {require('options.php');} @@ -795,7 +1049,10 @@ if ($qm_conf_ct > 0) $SSallow_web_debug = $row[10]; $SSenhanced_agent_monitoring = $row[11]; } -if ($SSallow_web_debug < 1) {$DB=0;} +if ($SSallow_web_debug < 1 || !isset($DB)) {$DB=0;} +if ($SSallow_web_debug < 1 || !isset($DBX)) {$DBX=0;} +$DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); +$DBX=preg_replace("/[^0-9a-zA-Z]/","",$DBX); ##### END SETTINGS LOOKUP ##### ########################################### @@ -923,6 +1180,7 @@ $list_order = preg_replace('/[^ 0-9a-zA-Z]/','',$list_order); $list_order_randomize = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_randomize); $list_order_secondary = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_secondary); $number_of_lines = preg_replace('/[^0-9]/','',$number_of_lines); +$forcephonecode = preg_replace('/[^0-9]/','',$forcephonecode); if ($non_latin < 1) { @@ -934,7 +1192,7 @@ if ($non_latin < 1) $categories = preg_replace('/[^-\,\_0-9a-zA-Z]/','',$categories); $user=preg_replace('/[^-_0-9a-zA-Z]/','',$user); $pass=preg_replace('/[^-_0-9a-zA-Z]/','',$pass); - $agent_user=preg_replace('/[^-_0-9a-zA-Z]/','',$agent_user); + $agent_user=preg_replace('/[^-_0-9a-zA-Z\,]/','',$agent_user); $phone_number = preg_replace('/[^\,0-9]/','',$phone_number); $vendor_lead_code = preg_replace('/;|#|\"/','',$vendor_lead_code); $vendor_lead_code = preg_replace('/\+/',' ',$vendor_lead_code); @@ -1093,7 +1351,7 @@ else $categories = preg_replace('/[^-\,\_0-9\p{L}]/u','',$categories); $user=preg_replace('/[^-_0-9\p{L}]/u','',$user); $pass=preg_replace('/[^-_0-9\p{L}]/u','',$pass); - $agent_user=preg_replace('/[^-_0-9\p{L}]/u','',$agent_user); + $agent_user=preg_replace('/[^-_0-9\,\p{L}]/u','',$agent_user); $phone_number = preg_replace('/[^\,0-9]/','',$phone_number); $vendor_lead_code = preg_replace('/;|#|\"/','',$vendor_lead_code); $vendor_lead_code = preg_replace('/\+/',' ',$vendor_lead_code); @@ -1243,6 +1501,8 @@ else $dial_status_remove=preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_remove); } +if ($stage=="json") {$header="YES";} + $USarea = substr($phone_number, 0, 3); $USprefix = substr($phone_number, 3, 3); if (strlen($hopper_priority)<1) {$hopper_priority=0;} @@ -1324,8 +1584,8 @@ if ($archived_lead=="Y") {$vicidial_list_table="vicidial_list_archive";} else {$vicidial_list_table="vicidial_list"; $archived_lead="N";} - - +$result_reason=""; $data=""; +if (!isset($value)) {$value="";} ################################################################################ ### version - show version, date, time and time zone information for the API @@ -1474,6 +1734,9 @@ if ( ($api_list_restrict > 0) and ( ($function == 'add_lead') or ($function == ' ################################################################################ if ($function == 'sounds_list') { + if ($stage=="") {$stage="date";} + if ($format=="") {$format="tab";} + $stmt="SELECT count(*) from vicidial_users where user='$user' and user_level > 6 and active='Y';"; if ($DB>0) {echo "DEBUG: sounds_list query - $stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); @@ -2409,9 +2672,8 @@ if ($function == 'agent_ingroup_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -2740,9 +3002,13 @@ if ($function == 'agent_campaigns') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -2751,7 +3017,11 @@ if ($function == 'agent_campaigns') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -2764,7 +3034,11 @@ if ($function == 'agent_campaigns') { $result = 'ERROR'; $result_reason = "agent_campaigns USER DOES NOT HAVE PERMISSION TO GET AGENT INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -2802,7 +3076,11 @@ if ($function == 'agent_campaigns') $result = 'ERROR'; $result_reason = "agent_campaigns AGENT USER DOES NOT EXIST"; $data = "$agent_user"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -2837,6 +3115,7 @@ if ($function == 'agent_campaigns') $rslt=mysql_to_mysqli($stmt, $link); $li_recs = mysqli_num_rows($rslt); $L=0; + $campaigns_output_list=""; while ($li_recs > $L) { $row=mysqli_fetch_row($rslt); @@ -2859,7 +3138,11 @@ if ($function == 'agent_campaigns') $result = 'ERROR'; $result_reason = "agent_campaigns THIS AGENT USER HAS NO AVAILABLE CAMPAIGNS"; $data = "$agent_user|$user|"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"agent_user|user\n$agent_user|$user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -2891,6 +3174,8 @@ if ($function == 'agent_campaigns') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -2898,12 +3183,13 @@ if ($function == 'agent_campaigns') $output .= "$agent_user$DL$campaigns_output_list$DL$ingroup_output_list\n"; - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agent_user|$campaigns_output_list|$ingroup_output_list"; $result_reason = "agent_campaigns RESULTS FOUND: 1"; + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -2927,9 +3213,13 @@ if ($function == 'campaigns_list') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -2938,7 +3228,11 @@ if ($function == 'campaigns_list') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -2951,7 +3245,11 @@ if ($function == 'campaigns_list') { $result = 'ERROR'; $result_reason = "campaigns_list USER DOES NOT HAVE PERMISSION TO GET CAMPAIGN INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -2972,6 +3270,8 @@ if ($function == 'campaigns_list') $LOGadmin_viewable_groupsSQL=''; $whereLOGadmin_viewable_groupsSQL=''; + $LOGallowed_campaignsSQL=''; + $whereLOGallowed_campaignsSQL=''; if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) { $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); @@ -2998,6 +3298,8 @@ if ($function == 'campaigns_list') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -3023,18 +3325,23 @@ if ($function == 'campaigns_list') $result = 'ERROR'; $result_reason = "campaigns_list THIS USER HAS NO VIEWABLE CAMPAIGNS"; $data = "$user|"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user\n$user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { - echo "$CLoutput"; - $result = 'SUCCESS'; $data = "$user|$campaigns_list|"; $result_reason = "campaigns_list RESULTS FOUND: $L"; + if ($stage=="json") {$CLoutput=ConvertToJSON($result,$result_reason,$header,$CLoutput);} + echo "$CLoutput"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -3058,9 +3365,13 @@ if ($function == 'hopper_list') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -3069,7 +3380,11 @@ if ($function == 'hopper_list') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -3082,7 +3397,11 @@ if ($function == 'hopper_list') { $result = 'ERROR'; $result_reason = "hopper_list USER DOES NOT HAVE PERMISSION TO GET CAMPAIGN INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -3103,6 +3422,8 @@ if ($function == 'hopper_list') $LOGadmin_viewable_groupsSQL=''; $whereLOGadmin_viewable_groupsSQL=''; + $LOGallowed_campaignsSQL=''; + $whereLOGallowed_campaignsSQL=''; if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) { $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); @@ -3126,7 +3447,11 @@ if ($function == 'hopper_list') { $result = 'ERROR'; $result_reason = "hopper_list THIS CAMPAIGN DOES NOT EXIST"; - echo "$result: $result_reason: |$user|$campaign_id\n"; + $output="$result: $result_reason: |$user|$campaign_id\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|campaign_id\n$user|$campaign_id");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -3158,6 +3483,8 @@ if ($function == 'hopper_list') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -3243,7 +3570,11 @@ if ($function == 'hopper_list') $result = 'ERROR'; $result_reason = "hopper_list THERE ARE NO LEADS IN THE HOPPER FOR THIS CAMPAIGN"; $data = "$user|$campaign_id"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|campaign_id\n$user|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -3288,12 +3619,13 @@ if ($function == 'hopper_list') $L++; } - echo "$CLoutput"; - $result = 'SUCCESS'; $data = "$user|$hopper_list|"; $result_reason = "hopper_list RESULTS FOUND: $L"; + if ($stage=="json") {$CLoutput=ConvertToJSON($result,$result_reason,$header,$CLoutput);} + echo "$CLoutput"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -3318,9 +3650,8 @@ if ($function == 'hopper_bulk_insert') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -3443,6 +3774,7 @@ if ($function == 'hopper_bulk_insert') $lead_to_insert=0; $lead_hopper_add=0; $j=0; + $hopper_id=''; while ($find_lead_count > $j) { if ($DB>0) {echo "DEBUG: Checking requested lead_ids in order - $j|$find_lead_idARY[$j]| \n";} @@ -3574,9 +3906,8 @@ if ($function == 'blind_monitor') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -3607,9 +3938,13 @@ if ($function == 'blind_monitor') { $stmt ="SELECT conf_engine from servers where server_ip='$server_ip';"; $rslt=mysql_to_mysqli($stmt, $link); - $row=mysqli_fetch_row($rslt); - $conf_engine=$row[0]; - + $conf_engine=""; + if (mysqli_num_rows($rslt)>0) + { + $row=mysqli_fetch_row($rslt); + $conf_engine=$row[0]; + } + if($conf_engine == "CONFBRIDGE") { $conf_table = "vicidial_confbridges"; @@ -3820,9 +4155,8 @@ if ($function == 'add_user') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -4026,9 +4360,8 @@ if ($function == 'copy_user') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -4236,9 +4569,8 @@ if ($function == 'update_user') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -4731,6 +5063,7 @@ if ($function == 'update_user') $grade_END_SQL.="campaign_grade='$campaign_grade'"; } $camp_rg_onlySQL=''; + $camp_rg_only_andSQL=''; $camp_rg_onlyNOTE=''; if ($camp_rg_only=='1') { @@ -4972,9 +5305,8 @@ if ($function == 'update_remote_agent') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5205,9 +5537,8 @@ if ($function == 'add_group_alias') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5306,9 +5637,8 @@ if ($function == 'add_dnc_phone') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5365,31 +5695,42 @@ if ($function == 'add_dnc_phone') } else { - $stmtA="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$phone_number','$campaign_id');"; + $stmtA="INSERT IGNORE INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$phone_number','$campaign_id');"; if ($campaign_id == 'SYSTEM_INTERNAL') {$stmtA="INSERT INTO vicidial_dnc (phone_number) values('$phone_number');";} $rslt=mysql_to_mysqli($stmtA, $link); $affected_rowsA = mysqli_affected_rows($link); - $stmtB="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='$campaign_id', action='add', action_date=NOW(), user='$user';"; - if ($campaign_id == 'SYSTEM_INTERNAL') - {$stmtB="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$user';";} - $rslt=mysql_to_mysqli($stmtB, $link); - $affected_rowsB = mysqli_affected_rows($link); + if ($affected_rowsA>0) + { + $stmtB="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='$campaign_id', action='add', action_date=NOW(), user='$user';"; + if ($campaign_id == 'SYSTEM_INTERNAL') + {$stmtB="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$user';";} + $rslt=mysql_to_mysqli($stmtB, $link); + $affected_rowsB = mysqli_affected_rows($link); - ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmtA|$stmtB|"; - $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='LISTS', event_type='ADD', record_id='$phone_number', event_code='ADMIN API ADD DNC NUMBER', event_sql=\"$SQL_log\", event_notes='$phone_number|$campaign_id|$affected_rowsA|$affected_rowsB';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmtA|$stmtB|"; + $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='LISTS', event_type='ADD', record_id='$phone_number', event_code='ADMIN API ADD DNC NUMBER', event_sql=\"$SQL_log\", event_notes='$phone_number|$campaign_id|$affected_rowsA|$affected_rowsB';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); - $result = 'SUCCESS'; - $result_reason = "add_dnc_phone DNC NUMBER HAS BEEN ADDED"; - $data = "$phone_number|$campaign_id"; - echo "$result: $result_reason - $user|$data\n"; - api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + $result = 'SUCCESS'; + $result_reason = "add_dnc_phone DNC NUMBER HAS BEEN ADDED"; + $data = "$phone_number|$campaign_id"; + 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 = "add_dnc_phone DNC NUMBER NOT ADDED, CHECK FOR DUPLICATION"; + $data = "$phone_number|$campaign_id"; + echo "$result: $result_reason - $user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } } } } @@ -5410,9 +5751,8 @@ if ($function == 'delete_dnc_phone') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5514,9 +5854,8 @@ if ($function == 'add_fpg_phone') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5624,9 +5963,8 @@ if ($function == 'delete_fpg_phone') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5734,9 +6072,8 @@ if ($function == 'add_phone') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -5918,9 +6255,8 @@ if ($function == 'update_phone') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -6417,9 +6753,8 @@ if ($function == 'add_phone_alias') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -6535,9 +6870,8 @@ if ($function == 'update_phone_alias') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -6729,9 +7063,8 @@ if ($function == 'server_refresh') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -6813,9 +7146,8 @@ if ($function == 'update_list') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -6999,7 +7331,7 @@ if ($function == 'update_list') # Send the request & save response to $resp $resp = curl_exec($curl); - $temp_response = 'NONE'; + $temp_response = $resp; if (preg_match('/ERROR:/',$resp)) {$temp_response = 'ERROR: Field not added';} if (preg_match('/SUCCESS:/',$resp)) {$temp_response = 'SUCCESS: Field added';} @@ -7279,7 +7611,7 @@ if ($function == 'update_list') $result = 'NOTICE'; $result_reason = "update_list DELETE CUSTOM FIELD COMMAND SENT"; - $data = "$list_id|$field_label|$field_id|$temp_response|"; + $data = "$list_id|$field_label|$A_field_id|$temp_response|"; echo "$result: $result_reason - $user|$data\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } @@ -7728,7 +8060,7 @@ if ($function == 'update_list') $result = 'NOTICE'; $result_reason = "update_list LEADS IN LIST HAVE BEEN RESET"; - $data = "$list_id|$affected_rows"; + $data = "$list_id|$affected_rowsB"; echo "$result: $result_reason - $user|$data\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } @@ -7901,7 +8233,7 @@ if ($function == 'update_list') # Send the request & save response to $resp $resp = curl_exec($curl); - $temp_response = 'NONE'; + $temp_response = $resp; if (preg_match('/ERROR:/',$resp)) {$temp_response = 'ERROR: Fields not copied';} if (preg_match('/SUCCESS:/',$resp)) {$temp_response = 'SUCCESS: Fields copied';} @@ -7912,7 +8244,7 @@ if ($function == 'update_list') $result = 'NOTICE'; $result_reason = "update_list COPY CUSTOM FIELDS COMMAND SENT"; $data = "$list_id|$custom_fields_copy|$custom_copy_method|$temp_response|"; - echo "$result: $result_reason - $user|$data\n"; + echo "$result: $result_reason - $user|$data|$url\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -7940,9 +8272,9 @@ if ($function == 'list_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -8045,6 +8377,8 @@ if ($function == 'list_info') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -8140,9 +8474,12 @@ if ($function == 'list_custom_fields') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -8151,7 +8488,11 @@ if ($function == 'list_custom_fields') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -8160,7 +8501,11 @@ if ($function == 'list_custom_fields') { $result = 'ERROR'; $result_reason = "CUSTOM LIST FIELDS ARE NOT ENABLED ON THIS SYSTEM"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -8174,7 +8519,11 @@ if ($function == 'list_custom_fields') $result = 'ERROR'; $result_reason = "list_custom_fields USER DOES NOT HAVE PERMISSION TO MODIFY LISTS"; $data = "$allowed_user"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -8185,7 +8534,11 @@ if ($function == 'list_custom_fields') $result = 'ERROR'; $result_reason = "list_custom_fields YOU MUST USE ALL REQUIRED FIELDS"; $data = "$list_id|$list_name|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|list_id|list_name|campaign_id\n$user|$data");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -8198,7 +8551,11 @@ if ($function == 'list_custom_fields') $result = 'ERROR'; $result_reason = "list_custom_fields NOT AN ALLOWED LIST ID"; $data = "$list_id"; - echo "$result: $result_reason - $data\n"; + $output="$result: $result_reason - $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"list_id\n$list_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -8234,7 +8591,11 @@ if ($function == 'list_custom_fields') $result = 'ERROR'; $result_reason = "list_custom_fields LIST DOES NOT EXIST"; $data = "$list_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|list_id\n$user|$list_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -8285,6 +8646,8 @@ if ($function == 'list_custom_fields') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -8342,7 +8705,10 @@ if ($function == 'list_custom_fields') $result = 'SUCCESS'; $result_reason = "list_custom_fields LIST CUSTOM FIELDS INFORMATION SENT"; $data = "$list_id"; - echo $output; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -8368,9 +8734,9 @@ if ($function == 'add_list') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -8807,9 +9173,9 @@ if ($function == 'update_campaign') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -9426,13 +9792,14 @@ if ($function == 'update_campaign') { $stmt="DELETE from vicidial_hopper where campaign_id='$campaign_id' and campaign_id='$campaign_id';"; $rslt=mysql_to_mysqli($stmt, $link); + $affected_rows = mysqli_affected_rows($link); if ($DB) {echo "|$stmt|\n";} ### 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='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN API RESET HOPPER', event_sql=\"$SQL_log\", event_notes='campaign: $campaign_id';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN API RESET HOPPER', event_sql=\"$SQL_log\", event_notes='campaign: $campaign_id $affected_rows';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); @@ -9465,9 +9832,13 @@ if ($function == 'update_alt_url') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -9476,7 +9847,11 @@ if ($function == 'update_alt_url') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -9490,7 +9865,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url USER DOES NOT HAVE PERMISSION TO UPDATE CAMPAIGNS"; $data = "$allowed_user"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9501,7 +9880,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url YOU MUST USE ALL REQUIRED FIELDS"; $data = "$campaign_id|$campaign_name|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|campaign_id|campaign_name|campaign_id\n$user|$campaign_id|$campaign_name|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9533,7 +9916,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url CAMPAIGN DOES NOT EXIST"; $data = "$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|campaign_id\n$user|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9549,6 +9936,8 @@ if ($function == 'update_alt_url') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -9578,16 +9967,27 @@ if ($function == 'update_alt_url') $M++; } - if ($M < 1) - {echo "NOTICE: update_alt_url LIST, No Records Found - $user|$url_type|$entry_type|$campaign_id|0\n";} - else - {echo $output;} $result = 'SUCCESS'; $result_reason = "update_alt_url ALT URL LIST DISPLAYED"; $data = "$url_type|$entry_type|$campaign_id|$M"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + if ($M < 1) + { + if ($stage=="json") + { + $result_reason.="\", \"notice\": \"update_alt_url LIST, No Records Found - $user|$url_type|$entry_type|$campaign_id|0"; + } + else + { + echo "NOTICE: update_alt_url LIST, No Records Found - $user|$url_type|$entry_type|$campaign_id|0\n"; + } + } + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + exit; } if ($entry_type == 'campaign') @@ -9604,7 +10004,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url NO VALID URL TYPE DEFINED:"; $data = "$url_type|$entry_type|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_type|entry_type|campaign_id\n$user|$url_type|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9625,7 +10029,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url NO VALID URL TYPE DEFINED:"; $data = "$url_type|$entry_type|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_type|entry_type|campaign_id\n$user|$url_type|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9640,7 +10048,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url NO VALID URL TYPE DEFINED:"; $data = "$url_type|$entry_type|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_type|entry_type|campaign_id\n$user|$url_type|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9650,7 +10062,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url NO ENTRY TYPE DEFINED:"; $data = "$entry_type|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|entry_type|campaign_id\n$user|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9664,7 +10080,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url $event_section $url_type URL IS NOT SET TO ALT"; $data = "$url_type|$entry_type|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_type|entry_type|campaign_id\n$user|$url_type|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9680,7 +10100,7 @@ if ($function == 'update_alt_url') $stmt="SELECT url_id from vicidial_url_multi where campaign_id='$campaign_id' and entry_type='$entry_type' and url_type='$url_type' order by url_id limit 2;"; $rslt=mysql_to_mysqli($stmt, $link); $vum_recs = mysqli_num_rows($rslt); - if ($vum_recs < 2) + if ($vum_recs==1) { $row=mysqli_fetch_row($rslt); $alt_url_id = $row[0]; @@ -9690,7 +10110,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url ALT URL ID DOES NOT EXIST"; $data = "$alt_url_id|$url_type|$entry_type|$campaign_id|$vum_recs"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|alt_url_id|url_type|entry_type|campaign_id|vum_recs\n$user|$alt_url_id|$url_type|$entry_type|$campaign_id|$vum_recs");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9712,7 +10136,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD"; $data = "$active"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|active\n$user|$active");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9730,7 +10158,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url URL ADDRESS IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$url_address"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_address\n$user|$url_address");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9745,7 +10177,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url URL RANK IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$url_rank"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_rank\n$user|$url_rank");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9759,7 +10195,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url URL CAL LENGTH IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$url_call_length"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_call_length\n$user|$url_call_length");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9773,7 +10213,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url URL STATUSES IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$url_statuses"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_statuses\n$user|$url_statuses");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9791,7 +10235,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url URL DESCRIPTION IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$url_description"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_description\n$user|$url_description");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9810,7 +10258,11 @@ if ($function == 'update_alt_url') $result = 'ERROR'; $result_reason = "update_alt_url URL LISTS IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$url_lists"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|url_lists\n$user|$url_lists");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9826,7 +10278,11 @@ if ($function == 'update_alt_url') $result = 'NOTICE'; $result_reason = "update_alt_url NO UPDATES DEFINED"; $data = "$updateSQL"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|update\n$user|$data");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -9851,7 +10307,11 @@ if ($function == 'update_alt_url') $result = 'SUCCESS'; $result_reason = "update_alt_url ALT URL HAS BEEN ADDED"; $data = "NEW URL ID: $new_url_id|$url_type|$entry_type|$campaign_id"; - echo "$result: $result_reason - $user|$data\n"; + $output="$result: $result_reason - $user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"new_url_id|url_type|entry_type|campaign_id\n$new_url_id|$url_type|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -9872,7 +10332,11 @@ if ($function == 'update_alt_url') $result = 'SUCCESS'; $result_reason = "update_alt_url ALT URL HAS BEEN UPDATED"; $data = "$alt_url_id|$url_type|$entry_type|$campaign_id"; - echo "$result: $result_reason - $user|$data\n"; + $output="$result: $result_reason - $user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"alt_url_id|url_type|entry_type|campaign_id\n$alt_url_id|$url_type|$entry_type|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -9899,9 +10363,13 @@ if ($function == 'update_presets') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -9910,7 +10378,11 @@ if ($function == 'update_presets') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -9924,7 +10396,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets USER DOES NOT HAVE PERMISSION TO UPDATE CAMPAIGNS"; $data = "$allowed_user"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9935,7 +10411,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets YOU MUST USE ALL REQUIRED FIELDS"; $data = "$campaign_id|$campaign_name|$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|campaign_id|campaign_name|campaign_id\n$user|$campaign_id|$campaign_name|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9967,7 +10447,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets CAMPAIGN DOES NOT EXIST"; $data = "$campaign_id"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|campaign_id\n$user|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -9983,6 +10467,8 @@ if ($function == 'update_presets') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -10006,16 +10492,27 @@ if ($function == 'update_presets') $M++; } - if ($M < 1) - {echo "NOTICE: update_presets LIST, No Records Found - $user|$campaign_id|0\n";} - else - {echo $output;} $result = 'SUCCESS'; $result_reason = "update_presets PRESET LIST DISPLAYED"; $data = "$campaign_id|$M"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + if ($M < 1) + { + if ($stage=="json") + { + $result_reason.="\", \"notice\": \"update_presets LIST, No Records Found - $user|$campaign_id|0"; + } + else + { + echo "NOTICE: update_alt_url LIST, No Records Found - $user|$url_type|$entry_type|$campaign_id|0\n"; + } + } + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + exit; } @@ -10040,7 +10537,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets PRESET NAME DOES NOT EXIST"; $data = "$preset_name|$campaign_id|$vum_recs"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|preset_name|campaign_id|vum_recs\n$user|$preset_name|$campaign_id|$vum_recs");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -10058,7 +10559,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets PRESET HIDE NUMBER MUST BE Y OR N, THIS IS AN OPTIONAL FIELD"; $data = "$preset_hide_number"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|preset_hide_number\n$user|$preset_hide_number");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -10072,7 +10577,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets PRESET NUMBER IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$preset_number"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|preset_number\n$user|$preset_number");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -10090,7 +10599,11 @@ if ($function == 'update_presets') $result = 'ERROR'; $result_reason = "update_presets PRESET DTMF IS NOT VALID, THIS IS AN OPTIONAL FIELD"; $data = "$preset_dtmf"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|preset_dtmf\n$user|$preset_dtmf");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -10101,6 +10614,8 @@ if ($function == 'update_presets') $updateSQL = "$preset_numberSQL$preset_dtmfSQL$preset_hide_numberSQL"; + $event_section="CAMPAIGN_PRESETS"; + if ( (strlen($updateSQL)< 3) or ($action == 'DELETE') ) { if ($action == 'DELETE') @@ -10121,7 +10636,11 @@ if ($function == 'update_presets') $result = 'SUCCESS'; $result_reason = "update_presets PRESET HAS BEEN DELETED"; $data = "$preset_name|$campaign_id"; - echo "$result: $result_reason - $user|$data\n"; + $output="$result: $result_reason - $user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -10129,7 +10648,11 @@ if ($function == 'update_presets') $result = 'NOTICE'; $result_reason = "update_presets NO UPDATES DEFINED"; $data = "$updateSQL"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|update\n$user|$updateSQL");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -10154,7 +10677,11 @@ if ($function == 'update_presets') $result = 'SUCCESS'; $result_reason = "update_presets PRESET HAS BEEN ADDED"; $data = "NEW PRESET: $preset_name|$campaign_id"; - echo "$result: $result_reason - $user|$data\n"; + $output="$result: $result_reason - $user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -10175,7 +10702,11 @@ if ($function == 'update_presets') $result = 'SUCCESS'; $result_reason = "update_presets PRESET HAS BEEN UPDATED"; $data = "$preset_name|$campaign_id"; - echo "$result: $result_reason - $user|$data\n"; + $output="$result: $result_reason - $user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -10202,9 +10733,8 @@ if ($function == 'add_did') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -10607,9 +11137,8 @@ if ($function == 'copy_did') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -10803,9 +11332,8 @@ if ($function == 'update_did') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -11257,9 +11785,8 @@ if ($function == 'update_cid_group_entry') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -11615,9 +12142,13 @@ if ($function == 'recording_lookup') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -11626,7 +12157,11 @@ if ($function == 'recording_lookup') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -11639,7 +12174,11 @@ if ($function == 'recording_lookup') { $result = 'ERROR'; $result_reason = "recording_lookup USER DOES NOT HAVE PERMISSION TO GET RECORDING INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -11724,7 +12263,11 @@ if ($function == 'recording_lookup') $result = 'ERROR'; $result_reason = "recording_lookup INVALID SEARCH PARAMETERS"; $data = "$user|$agent_user|$lead_id|$date|$uniqueid"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user|lead_id|date|uniqueid\n$user|$agent_user|$lead_id|$date|$uniqueid");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -11739,7 +12282,11 @@ if ($function == 'recording_lookup') $result = 'ERROR'; $result_reason = "recording_lookup NO RECORDINGS FOUND"; $data = "$user|$agent_user|$lead_id|$date|$uniqueid"; - echo "$result: $result_reason - $data\n"; + $output="$result: $result_reason - $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user|lead_id|date|uniqueid\n$user|$agent_user|$lead_id|$date|$uniqueid");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -11754,6 +12301,8 @@ if ($function == 'recording_lookup') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|';} if ($header == 'YES') @@ -11791,11 +12340,12 @@ if ($function == 'recording_lookup') $k++; } - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agent_user|$lead_id|$date|$uniqueid|$stage"; $result_reason = "recording_lookup RECORDINGS FOUND: $rec_recs"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } @@ -11821,9 +12371,13 @@ if ($function == 'did_log_export') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -11832,7 +12386,11 @@ if ($function == 'did_log_export') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -11845,7 +12403,11 @@ if ($function == 'did_log_export') { $result = 'ERROR'; $result_reason = "did_log_export USER DOES NOT HAVE PERMISSION TO GET DID INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -11871,7 +12433,11 @@ if ($function == 'did_log_export') $result = 'ERROR'; $result_reason = "did_log_export INVALID SEARCH PARAMETERS"; $data = "$user|$phone_number|$date"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|phone_number|date\n$user|$phone_number|$date");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -11886,7 +12452,11 @@ if ($function == 'did_log_export') $result = 'ERROR'; $result_reason = "did_log_export NO RECORDS FOUND"; $data = "$user|$agent_user|$lead_id|$date"; - echo "$result: $result_reason - $data\n"; + $output="$result: $result_reason - $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user|lead_id|date\n$user|$agent_user|$lead_id|$date");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -11901,6 +12471,8 @@ if ($function == 'did_log_export') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if ($header == 'YES') @@ -11945,12 +12517,13 @@ if ($function == 'did_log_export') $k++; } - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agent_user|$lead_id|$date|$stage"; $result_reason = "did_log_export RECORDS FOUND: $rec_recs"; + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -11975,9 +12548,13 @@ if ($function == 'phone_number_log') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -11986,7 +12563,11 @@ if ($function == 'phone_number_log') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -11999,7 +12580,11 @@ if ($function == 'phone_number_log') { $result = 'ERROR'; $result_reason = "phone_number_log USER DOES NOT HAVE PERMISSION TO GET CALL LOG INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12041,7 +12626,11 @@ if ($function == 'phone_number_log') $result = 'ERROR'; $result_reason = "phone_number_log NO VALID PHONE NUMBERS DEFINED"; $data = "$user|$phone_number|$date"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|phone_number|date\n$user|$phone_number|$date");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -12063,6 +12652,8 @@ if ($function == 'phone_number_log') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} @@ -12159,6 +12750,7 @@ if ($function == 'phone_number_log') $p=0; while ($k > $p) { + if (!isset($DLepoch[$k])) {$DLepoch[$k]=0;} $DLlength_in_sec[$k]=0; $DLcloser_epoch[$k]=$DLepoch[$k]; $stmt="SELECT status,source_id from $vicidial_list_table where lead_id='$DLlead_id[$p]';"; @@ -12181,17 +12773,23 @@ if ($function == 'phone_number_log') $result = 'NOTICE'; $result_reason = "phone_number_log NO RECORDS FOUND FOR THIS PHONE NUMBER"; $data = "$user|$phone_number|$lead_id|$date"; - echo "$result: $result_reason - $data\n"; + $output="$result: $result_reason - $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|phone_number|lead_id|date\n$user|$phone_number|$lead_id|$date");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else { - echo "$output"; $result = 'SUCCESS'; $data = "$user|$agent_user|$lead_id|$date|$stage"; $result_reason = "phone_number_log RECORDS FOUND: $rec_recs"; + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -12216,9 +12814,13 @@ if ($function == 'agent_stats_export') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -12227,7 +12829,11 @@ if ($function == 'agent_stats_export') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12240,7 +12846,11 @@ if ($function == 'agent_stats_export') { $result = 'ERROR'; $result_reason = "agent_stats_export USER DOES NOT HAVE PERMISSION TO GET AGENT INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12252,7 +12862,15 @@ if ($function == 'agent_stats_export') if ( (strlen($agent_user)>0) and (strlen($agent_user)<21) ) { - $search_SQL .= "user='$agent_user'"; + $agent_user_array=explode(",", $agent_user); + if (count($agent_user_array)==1) + { + $search_SQL .= "user='$agent_user'"; + } + else + { + $search_SQL .= "user in ('".implode("', '", $agent_user_array)."')"; + } $search_ready++; } if ( (strlen($campaign_id)>0) and (strlen($campaign_id)<9) ) @@ -12278,7 +12896,11 @@ if ($function == 'agent_stats_export') $result = 'ERROR'; $result_reason = "agent_stats_export INVALID SEARCH PARAMETERS"; $data = "$user|$agent_user|$datetime_start|$datetime_end|$campaign_id"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user|datetime_start|datetime_end|campaign_id\n$user|$agent_user|$datetime_start|$datetime_end|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -12300,7 +12922,11 @@ if ($function == 'agent_stats_export') $result = 'ERROR'; $result_reason = "agent_stats_export NO RECORDS FOUND"; $data = "$user|$agent_user|$datetime_start|$datetime_end|$campaign_id"; - echo "$result: $result_reason - $data\n"; + $output="$result: $result_reason - $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user|datetime_start|datetime_end|campaign_id\n$user|$agent_user|$datetime_start|$datetime_end|$campaign_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -12315,6 +12941,8 @@ if ($function == 'agent_stats_export') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -12396,6 +13024,12 @@ if ($function == 'agent_stats_export') $ASpauses[$uc]++; } if (preg_match("/LOGIN/",$row[2])) {$ASsessions[$uc]++;} + if (!isset($ASpause_sec[$uc])) {$ASpause_sec[$uc]=0;} + if (!isset($ASwait_sec[$uc])) {$ASwait_sec[$uc]=0;} + if (!isset($AStalk_sec[$uc])) {$AStalk_sec[$uc]=0;} + if (!isset($ASdispo_sec[$uc])) {$ASdispo_sec[$uc]=0;} + if (!isset($ASdead_sec[$uc])) {$ASdead_sec[$uc]=0;} + if (!isset($ASend_sec[$uc])) {$ASend_sec[$uc]=0;} $ASpause_sec[$uc] = ($ASpause_sec[$uc] + $row[3]); $ASwait_sec[$uc] = ($ASwait_sec[$uc] + $row[4]); $AStalk_sec[$uc] = ($AStalk_sec[$uc] + $row[5]); @@ -12420,6 +13054,7 @@ if ($function == 'agent_stats_export') $ASuser_group[$k] = $row[1]; } $login_sec = ($ASpause_sec[$k] + $ASwait_sec[$k] + $AStalk_sec[$k] + $ASdispo_sec[$k]); + if (!isset($ASstart_epoch[$k])) {$ASstart_epoch[$k]=$ASend_epoch[$k];} # Or zero? $login_start_end_check = ( ($ASend_epoch[$k] - $ASstart_epoch[$k]) + $ASend_sec[$k]); if ($login_sec > $login_start_end_check) {$login_sec = $login_start_end_check;} if ($ASsessions[$k] < 1) {$ASsessions[$k] = 1;} @@ -12434,9 +13069,10 @@ if ($function == 'agent_stats_export') { $pct_pause = ( MathZDC($ASpause_sec[$k], $login_sec) * 100); } - $avg_cust_sec = MathZDC($cust_sec, $AScalls[$k]); - $avg_wait_sec = MathZDC($ASwait_sec[$k], $AScalls[$k]); - $pct_of_queue = ( MathZDC($AScalls[$k], $total_calls) * 100); + #if (!isset($cust_sec)) {$cust_sec=0;} + #$avg_cust_sec = MathZDC($cust_sec, $AScalls[$k]); + #$avg_wait_sec = MathZDC($ASwait_sec[$k], $AScalls[$k]); + #$pct_of_queue = ( MathZDC($AScalls[$k], $total_calls) * 100); if ($AScalls[$k] < 1) { $cust_sec = 0; @@ -12444,7 +13080,6 @@ if ($function == 'agent_stats_export') $talk_sec = 0; $dead_sec = 0; $dispo_sec = 0; - $pause_sec = 0; } else { @@ -12453,8 +13088,10 @@ if ($function == 'agent_stats_export') $talk_sec = $AStalk_sec[$k]; $dead_sec = $ASdead_sec[$k]; $dispo_sec = $ASdispo_sec[$k]; - $pause_sec = $ASpause_sec[$k]; } + $avg_cust_sec = MathZDC($cust_sec, $AScalls[$k]); + $avg_wait_sec = MathZDC($ASwait_sec[$k], $AScalls[$k]); + $pct_of_queue = ( MathZDC($AScalls[$k], $total_calls) * 100); $avg_session_sec = round($avg_session_sec); $avg_pause_sec = round($avg_pause_sec); $avg_pause_session = round($avg_pause_session); @@ -12470,27 +13107,29 @@ if ($function == 'agent_stats_export') $talk_sec = sec_convert($talk_sec,$time_format); $dead_sec = sec_convert($dead_sec,$time_format); $dispo_sec = sec_convert($dispo_sec,$time_format); - $pause_sec = sec_convert($pause_sec,$time_format); $avg_cust_sec = sec_convert($avg_cust_sec,$time_format); $avg_wait_sec = sec_convert($avg_wait_sec,$time_format); if ($group_by_campaign == 'YES') { - $output .= "$AScampaign[$k]$DL$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$pause_sec$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec$DL$talk_sec$DL$dispo_sec$DL$dead_sec\n"; + $output .= "$AScampaign[$k]$DL$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$ASpause_sec[$k]$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec$DL$talk_sec$DL$dispo_sec$DL$dead_sec\n"; } else { - $output .= "$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$pause_sec$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec$DL$talk_sec$DL$dispo_sec$DL$dead_sec\n"; + $output .= "$ASuser[$k]$DL$ASfull_name[$k]$DL$ASuser_group[$k]$DL$AScalls[$k]$DL$login_sec$DL$cust_sec$DL$avg_cust_sec$DL$avg_wait_sec$DL$pct_of_queue%$DL$ASpause_sec[$k]$DL$ASsessions[$k]$DL$avg_session_sec$DL$ASpauses[$k]$DL$avg_pause_sec$DL$pct_pause%$DL$avg_pause_session$DL$wait_sec$DL$talk_sec$DL$dispo_sec$DL$dead_sec\n"; } $k++; } - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agent_user|$lead_id|$date|$stage"; $result_reason = "agent_stats_export AGENTS FOUND: $k"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -12515,9 +13154,13 @@ if ($function == 'user_group_status') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -12526,7 +13169,11 @@ if ($function == 'user_group_status') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12539,7 +13186,11 @@ if ($function == 'user_group_status') { $result = 'ERROR'; $result_reason = "user_group_status USER DOES NOT HAVE PERMISSION TO GET USER GROUP INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12561,14 +13212,18 @@ if ($function == 'user_group_status') $result = 'ERROR'; $result_reason = "user_group_status INVALID SEARCH PARAMETERS"; $data = "$user|$user_groups"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|user_groups\n$user|$user_groups");} + echo "$output"; + 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) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; @@ -12616,6 +13271,8 @@ if ($function == 'user_group_status') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -12755,13 +13412,13 @@ if ($function == 'user_group_status') } } $output .= "$user_groupsOUTPUT$DL$total_calls_waiting$DL$total_agents$DL$total_agents_in_calls$DL$total_agents_waiting$DL$total_agents_paused$DL$total_agents_dead$DL$total_agents_dispo$DL$total_agents_in_dial\n"; - - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$user_groups|$stage"; $result_reason = "user_group_status AGENTS FOUND: $k"; + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -12785,9 +13442,13 @@ if ($function == 'in_group_status') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -12796,7 +13457,11 @@ if ($function == 'in_group_status') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12809,7 +13474,11 @@ if ($function == 'in_group_status') { $result = 'ERROR'; $result_reason = "in_group_status USER DOES NOT HAVE PERMISSION TO GET IN-GROUP INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -12818,7 +13487,7 @@ if ($function == 'in_group_status') { $search_SQL=''; $search_ready=0; - + $agent_search_SQL=""; if ( (strlen($in_groups)>0) and (strlen($in_groups)<10000) ) { $in_groupsOUTPUT = preg_replace("/\|/",' ',$in_groups); @@ -12832,14 +13501,18 @@ if ($function == 'in_group_status') $result = 'ERROR'; $result_reason = "in_group_status INVALID SEARCH PARAMETERS"; $data = "$user|$in_groups"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|in_groups\n$user|$in_groups");} + echo "$output"; + 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) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; @@ -12888,6 +13561,8 @@ if ($function == 'in_group_status') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -12980,13 +13655,13 @@ if ($function == 'in_group_status') } } $output .= "$in_groupsOUTPUT$DL$total_calls$DL$total_calls_waiting$DL$total_agents$DL$total_agents_in_calls$DL$total_agents_waiting$DL$total_agents_paused$DL$total_agents_dispo$DL$total_agents_in_dial\n"; - - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$in_groups|$stage|$total_agents_waiting"; $result_reason = "in_group_status CALLS FOUND: $k"; + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -13009,9 +13684,13 @@ if ($function == 'agent_status') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -13020,7 +13699,11 @@ if ($function == 'agent_status') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13033,7 +13716,11 @@ if ($function == 'agent_status') { $result = 'ERROR'; $result_reason = "agent_status USER DOES NOT HAVE PERMISSION TO GET AGENT INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13053,14 +13740,18 @@ if ($function == 'agent_status') $result = 'ERROR'; $result_reason = "agent_status INVALID SEARCH PARAMETERS"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { $stmt="SELECT admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -13084,6 +13775,8 @@ if ($function == 'agent_status') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -13273,13 +13966,13 @@ if ($function == 'agent_status') $output .= "$status$DL$callerid$DL$lead_id$DL$campaign_id$DL$calls_today$DL$full_name$DL$user_group$DL$user_level$DL$pause_code$DL$rtr_status$DL$phone_number$DL$vendor_lead_code$DL$conf_exten$computer_ipOUTPUT\n"; - - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agent_user|$stage"; $result_reason = "agent_status $output"; + if ($stage=="json") {$output=ConvertToJSON($result,"",$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -13287,7 +13980,11 @@ if ($function == 'agent_status') $result = 'ERROR'; $result_reason = "agent_status AGENT NOT LOGGED IN"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13297,7 +13994,11 @@ if ($function == 'agent_status') $result = 'ERROR'; $result_reason = "agent_status AGENT NOT FOUND"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13322,9 +14023,12 @@ if ($function == 'user_details') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -13333,7 +14037,11 @@ if ($function == 'user_details') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13346,7 +14054,11 @@ if ($function == 'user_details') { $result = 'ERROR'; $result_reason = "user_details USER DOES NOT HAVE PERMISSION TO GET USER DETAILS"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13366,14 +14078,18 @@ if ($function == 'user_details') $result = 'ERROR'; $result_reason = "user_details INVALID SEARCH PARAMETERS"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { $stmt="SELECT admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -13397,6 +14113,8 @@ if ($function == 'user_details') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -13420,13 +14138,13 @@ if ($function == 'user_details') $active = $row[3]; $output .= "$agent_user$DL$full_name$DL$user_group$DL$user_level$DL$active\n"; - - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agent_user|$stage"; $result_reason = "user_details $output"; + if ($stage=="json") {$output=ConvertToJSON($result,"",$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -13434,7 +14152,11 @@ if ($function == 'user_details') $result = 'ERROR'; $result_reason = "user_details USER NOT FOUND"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13459,9 +14181,12 @@ if ($function == 'callid_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -13470,7 +14195,11 @@ if ($function == 'callid_info') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13483,7 +14212,11 @@ if ($function == 'callid_info') { $result = 'ERROR'; $result_reason = "callid_info USER DOES NOT HAVE PERMISSION TO GET CALL INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13504,14 +14237,18 @@ if ($function == 'callid_info') $result = 'ERROR'; $result_reason = "callid_info INVALID SEARCH PARAMETERS"; $data = "$user|$call_id"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|call_id\n$user|$call_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { $stmt="SELECT admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -13535,6 +14272,8 @@ if ($function == 'callid_info') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -13621,12 +14360,13 @@ if ($function == 'callid_info') { $output .= "$call_id$DL$cust_sec\n"; } - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$call_id|$stage"; $result_reason = "callid_info $output"; + if ($stage=="json") {$output=ConvertToJSON($result,"",$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -13634,7 +14374,11 @@ if ($function == 'callid_info') $result = 'ERROR'; $result_reason = "callid_info CALL LOG NOT FOUND"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13644,7 +14388,11 @@ if ($function == 'callid_info') $result = 'ERROR'; $result_reason = "callid_info CALL NOT FOUND"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|call_id\n$user|$call_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13670,9 +14418,12 @@ if ($function == 'ccc_lead_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -13681,7 +14432,11 @@ if ($function == 'ccc_lead_info') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13694,7 +14449,11 @@ if ($function == 'ccc_lead_info') { $result = 'ERROR'; $result_reason = "ccc_lead_info USER DOES NOT HAVE PERMISSION TO GET LEAD INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13716,14 +14475,18 @@ if ($function == 'ccc_lead_info') $result = 'ERROR'; $result_reason = "ccc_lead_info INVALID SEARCH PARAMETERS"; $data = "$user|$call_id"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|call_id\n$user|$call_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { $stmt="SELECT admin_viewable_groups,allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -13748,6 +14511,8 @@ if ($function == 'ccc_lead_info') {$DL = "\n"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -13818,7 +14583,11 @@ if ($function == 'ccc_lead_info') { $result = 'ERROR'; $result_reason = "ccc_lead_info LEAD NOT FOUND"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13826,13 +14595,13 @@ if ($function == 'ccc_lead_info') } $output .= "$LEADstatus$DL$LEADuser$DL$LEADvendor_lead_code$DL$LEADsource_id$DL$LEADlist_id$DL$LEADgmt_offset_now$DL$LEADphone_code$DL$LEADphone_number$DL$LEADtitle$DL$LEADfirst_name$DL$LEADmiddle_initial$DL$LEADlast_name$DL$LEADaddress1$DL$LEADaddress2$DL$LEADaddress3$DL$LEADcity$DL$LEADstate$DL$LEADprovince$DL$LEADpostal_code$DL$LEADcountry_code$DL$LEADgender$DL$LEADdate_of_birth$DL$LEADalt_phone$DL$LEADemail$DL$LEADsecurity_phrase$DL$LEADcomments$DL$LEADcalled_count$DL$LEADlast_local_call_time$DL$LEADrank$DL$LEADowner\n"; - - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$call_id|$stage"; $result_reason = "ccc_lead_info $output"; + if ($stage=="json") {$output=ConvertToJSON($result,"",$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -13840,7 +14609,11 @@ if ($function == 'ccc_lead_info') $result = 'ERROR'; $result_reason = "ccc_lead_info LEAD NOT FOUND"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13850,7 +14623,11 @@ if ($function == 'ccc_lead_info') $result = 'ERROR'; $result_reason = "ccc_lead_info CALL NOT FOUND"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -13876,9 +14653,12 @@ if ($function == 'lead_callback_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -13887,7 +14667,11 @@ if ($function == 'lead_callback_info') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13900,7 +14684,11 @@ if ($function == 'lead_callback_info') { $result = 'ERROR'; $result_reason = "lead_callback_info USER DOES NOT HAVE PERMISSION TO GET LEAD INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -13920,14 +14708,18 @@ if ($function == 'lead_callback_info') $result = 'ERROR'; $result_reason = "lead_callback_info INVALID SEARCH PARAMETERS"; $data = "$user|$lead_id"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|lead_id\n$user|$lead_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { $stmt="SELECT admin_viewable_groups,allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -13952,6 +14744,8 @@ if ($function == 'lead_callback_info') {$DL = "\n"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -14045,7 +14839,11 @@ if ($function == 'lead_callback_info') { $result = 'ERROR'; $result_reason = "lead_callback_info LEAD NOT FOUND"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -14059,12 +14857,13 @@ if ($function == 'lead_callback_info') if ( ( ( ($header == 'NO') or ($header == '') ) and (strlen($output) > 10) ) or ( ($header == 'YES') and (strlen($output) > 170) ) ) { - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$lead_id|$stage|$search_location"; $result_reason = "lead_callback_info $output"; + if ($stage=="json") {$output=ConvertToJSON($result,"",$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -14072,7 +14871,11 @@ if ($function == 'lead_callback_info') $result = 'ERROR'; $result_reason = "lead_callback_info CALLBACK NOT FOUND"; $data = "$user|$lead_id|$stage|$search_location"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|lead_id|search_location\n$user|$lead_id|$search_location");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -14098,9 +14901,8 @@ if ($function == 'lead_dearchive') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -14149,7 +14951,7 @@ if ($function == 'lead_dearchive') else { $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; @@ -14196,7 +14998,7 @@ if ($function == 'lead_dearchive') $lead_entry_list_id = $row[1]; $stmt="SELECT list_id,entry_list_id from vicidial_list $lead_search_SQL limit 1"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $lead_exists = mysqli_num_rows($rslt); @@ -14271,9 +15073,8 @@ if ($function == 'lead_field_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -14322,7 +15123,7 @@ if ($function == 'lead_field_info') else { $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; @@ -14349,84 +15150,95 @@ if ($function == 'lead_field_info') $lead_entry_list_id = $row[1]; $stmt="SELECT count(*) from vicidial_lists where list_id='$lead_list_id' $LOGallowed_campaignsSQL;"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $list_exists = $row[0]; + $table_exists=1; + $enc_fields=0; + $hide_list=''; + $LOGadmin_hide_lead_data=0; if ($list_exists > 0) { if ($custom_fields == 'Y') { - $stmt="SELECT admin_hide_lead_data,admin_hide_phone_data,admin_cf_show_hidden from vicidial_users where user='$user';"; - $rslt=mysql_to_mysqli($stmt, $link); - $row=mysqli_fetch_row($rslt); - $LOGadmin_hide_lead_data = $row[0]; - $LOGadmin_hide_phone_data = $row[1]; - $LOGadmin_cf_show_hidden = $row[2]; - if ($DB) {echo "CF user: |$LOGadmin_hide_lead_data|$LOGadmin_hide_phone_data|$LOGadmin_cf_show_hidden|\n";} - - if (strlen($list_id)>1) - {$lead_entry_list_id = $list_id;} - - if (preg_match("/cf_encrypt/",$active_modules)) + $show_stmt="show tables like 'custom_".$lead_entry_list_id."'"; + $show_rslt=mysql_to_mysqli($show_stmt, $link); + $table_exists=mysqli_num_rows($show_rslt); + if ($table_exists>0) { - $enc_fields=0; - $stmt = "SELECT count(*) from vicidial_lists_fields where field_encrypt='Y' and list_id='$lead_entry_list_id';"; + + $stmt="SELECT admin_hide_lead_data,admin_hide_phone_data,admin_cf_show_hidden from vicidial_users where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($DB) {echo "$stmt\n";} - $enc_field_ct = mysqli_num_rows($rslt); - if ($enc_field_ct > 0) + $row=mysqli_fetch_row($rslt); + $LOGadmin_hide_lead_data = $row[0]; + $LOGadmin_hide_phone_data = $row[1]; + $LOGadmin_cf_show_hidden = $row[2]; + if ($DB) {echo "CF user: |$LOGadmin_hide_lead_data|$LOGadmin_hide_phone_data|$LOGadmin_cf_show_hidden|\n";} + + if (strlen($list_id)>1) + {$lead_entry_list_id = $list_id;} + + if (preg_match("/cf_encrypt/",$active_modules)) { - $row=mysqli_fetch_row($rslt); - $enc_fields = $row[0]; - } - if ($enc_fields > 0) - { - $stmt = "SELECT field_label from vicidial_lists_fields where field_encrypt='Y' and list_id='$lead_entry_list_id';"; + $enc_fields=0; + $stmt = "SELECT count(*) from vicidial_lists_fields where field_encrypt='Y' and list_id='$lead_entry_list_id';"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $enc_field_ct = mysqli_num_rows($rslt); - $r=0; - while ($enc_field_ct > $r) + if ($enc_field_ct > 0) { $row=mysqli_fetch_row($rslt); - $encrypt_list .= "$row[0],"; - $r++; + $enc_fields = $row[0]; } - $encrypt_list = ",$encrypt_list"; - } - if ($LOGadmin_cf_show_hidden < 1) - { - $hide_fields=0; - $stmt = "SELECT count(*) from vicidial_lists_fields where field_show_hide!='DISABLED' and list_id='$lead_entry_list_id';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($DB) {echo "$stmt\n";} - $hide_field_ct = mysqli_num_rows($rslt); - if ($hide_field_ct > 0) + if ($enc_fields > 0) { - $row=mysqli_fetch_row($rslt); - $hide_fields = $row[0]; + $stmt = "SELECT field_label from vicidial_lists_fields where field_encrypt='Y' and list_id='$lead_entry_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $enc_field_ct = mysqli_num_rows($rslt); + $r=0; + while ($enc_field_ct > $r) + { + $row=mysqli_fetch_row($rslt); + $encrypt_list .= "$row[0],"; + $r++; + } + $encrypt_list = ",$encrypt_list"; } - if ($hide_fields > 0) + if ($LOGadmin_cf_show_hidden < 1) { - $stmt = "SELECT field_label from vicidial_lists_fields where field_show_hide!='DISABLED' and list_id='$lead_entry_list_id';"; + $hide_fields=0; + $stmt = "SELECT count(*) from vicidial_lists_fields where field_show_hide!='DISABLED' and list_id='$lead_entry_list_id';"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $hide_field_ct = mysqli_num_rows($rslt); - $r=0; - while ($hide_field_ct > $r) + if ($hide_field_ct > 0) { $row=mysqli_fetch_row($rslt); - $hide_list .= "$row[0],"; - $r++; + $hide_fields = $row[0]; + } + if ($hide_fields > 0) + { + $stmt = "SELECT field_label from vicidial_lists_fields where field_show_hide!='DISABLED' and list_id='$lead_entry_list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $hide_field_ct = mysqli_num_rows($rslt); + $r=0; + while ($hide_field_ct > $r) + { + $row=mysqli_fetch_row($rslt); + $hide_list .= "$row[0],"; + $r++; + } + $hide_list = ",$hide_list"; } - $hide_list = ",$hide_list"; } } - } - $stmt="SELECT $field_name from custom_$lead_entry_list_id $lead_search_SQL;"; + $stmt="SELECT $field_name from custom_$lead_entry_list_id $lead_search_SQL;"; + } } else { @@ -14436,7 +15248,7 @@ if ($function == 'lead_field_info') if ($DB) {echo "$stmt\n";} $field_exists = mysqli_num_rows($rslt); - if ($field_exists > 0) + if ($field_exists > 0 && $table_exists > 0) { $row=mysqli_fetch_row($rslt); $output = $row[0]; @@ -14524,9 +15336,12 @@ if ($function == 'lead_all_info') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -14535,7 +15350,11 @@ if ($function == 'lead_all_info') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -14548,7 +15367,11 @@ if ($function == 'lead_all_info') { $result = 'ERROR'; $result_reason = "lead_all_info USER DOES NOT HAVE PERMISSION TO GET LEAD INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -14566,14 +15389,18 @@ if ($function == 'lead_all_info') $result = 'ERROR'; $result_reason = "lead_all_info LEAD NOT FOUND"; $data = "$user|$lead_id|$phone_number"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|lead_id|phone_number\n$user|$lead_id|$phone_number");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } else { $stmt="SELECT admin_viewable_groups,allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -14603,6 +15430,8 @@ if ($function == 'lead_all_info') {$DL = "\n"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} @@ -14624,7 +15453,7 @@ if ($function == 'lead_all_info') $lead_loop_ct++; } - $lead_loop_ct=0; + $lead_loop_ct=0; $header_printed=0; while ($lead_exists > $lead_loop_ct) { $lead_list_id = $ARY_lead_list_id[$lead_loop_ct]; @@ -14645,6 +15474,7 @@ if ($function == 'lead_all_info') { $CF_data_output=''; $CF_header_output=''; + $hide_list=''; if ($custom_fields == 'Y') { $stmt="SELECT admin_hide_lead_data,admin_hide_phone_data,admin_cf_show_hidden from vicidial_users where user='$user';"; @@ -14726,52 +15556,59 @@ if ($function == 'lead_all_info') $r++; } - $stmt="SELECT $custom_fields_list from custom_$lead_entry_list_id where lead_id='$lead_lead_id';"; - $rslt=mysql_to_mysqli($stmt, $link); - $custom_fields_found = mysqli_num_rows($rslt); - if ($DB) {echo "$custom_fields_found|$stmt\n";} - if ($custom_fields_found > 0) + $cust_stmt="show tables like 'custom_$lead_entry_list_id'"; + if ($DB) {echo "$cust_stmt\n";} + $cust_rslt=mysql_to_mysqli($cust_stmt, $link); + if (mysqli_num_rows($cust_rslt)>0) { - $row=mysqli_fetch_row($rslt); - $rc=0; - while ($r > $rc) + $stmt="SELECT $custom_fields_list from custom_$lead_entry_list_id where lead_id='$lead_lead_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + $custom_fields_found = mysqli_num_rows($rslt); + if ($DB) {echo "$custom_fields_found|$stmt\n";} + if ($custom_fields_found > 0) { - $temp_CF_value = $row[$rc]; - $temp_CP_label = $custom_fields_ARY[$rc]; + $row=mysqli_fetch_row($rslt); + $rc=0; + while ($r > $rc) + { + $temp_CF_value = $row[$rc]; + $temp_CP_label = $custom_fields_ARY[$rc]; - if ($enc_fields > 0) - { - $field_enc=''; $field_enc_all=''; - if ($DB) {echo "|$temp_CP_label|$encrypt_list|$hide_list|\n";} - if ( (preg_match("/,$temp_CP_label,/",$encrypt_list)) and (strlen($temp_CF_value) > 0) ) + if (isset($enc_fields) && $enc_fields > 0) { - if ($DB) {echo "DECRYPTING $temp_CP_label\n";} - exec("../agc/aes.pl --decrypt --text=$temp_CF_value", $field_enc); - $field_enc_ct = count($field_enc); - $k=0; - while ($field_enc_ct > $k) + $field_enc=''; $field_enc_all=''; + if ($DB) {echo "|$temp_CP_label|$encrypt_list|$hide_list|\n";} + if ( (preg_match("/,$temp_CP_label,/",$encrypt_list)) and (strlen($temp_CF_value) > 0) ) { - $field_enc_all .= $field_enc[$k]; - $k++; + if ($DB) {echo "DECRYPTING $temp_CP_label\n";} + exec("../agc/aes.pl --decrypt --text=$temp_CF_value", $field_enc); + $field_enc_ct = count($field_enc); + $k=0; + while ($field_enc_ct > $k) + { + $field_enc_all .= $field_enc[$k]; + $k++; + } + $field_enc_all = preg_replace("/CRYPT: |\n|\r|\t/",'',$field_enc_all); + $temp_CF_value = base64_decode($field_enc_all); } - $field_enc_all = preg_replace("/CRYPT: |\n|\r|\t/",'',$field_enc_all); - $temp_CF_value = base64_decode($field_enc_all); } + if ( ( (preg_match("/,$temp_CP_label,/",$hide_list)) or ($LOGadmin_hide_lead_data > 0) ) and (strlen($temp_CF_value) > 0) ) + { + $field_temp_val = $temp_CF_value; + $temp_CF_value = preg_replace("/./",'X',$field_temp_val); + } + $CF_data_output .= "$DL$temp_CF_value"; + $CF_header_output .= "$DL$temp_CP_label"; + $rc++; } - if ( ( (preg_match("/,$temp_CP_label,/",$hide_list)) or ($LOGadmin_hide_lead_data > 0) ) and (strlen($temp_CF_value) > 0) ) - { - $field_temp_val = $temp_CF_value; - $temp_CF_value = preg_replace("/./",'X',$field_temp_val); - } - $CF_data_output .= "$DL$temp_CF_value"; - $CF_header_output .= "$DL$temp_CP_label"; - $rc++; } } } - if ($header == 'YES') + if ($header == 'YES' && $header_printed==0) { $output .= 'status' . $DL . 'user' . $DL . 'vendor_lead_code' . $DL . 'source_id' . $DL . 'list_id' . $DL . 'gmt_offset_now' . $DL . 'phone_code' . $DL . 'phone_number' . $DL . 'title' . $DL . 'first_name' . $DL . 'middle_initial' . $DL . 'last_name' . $DL . 'address1' . $DL . 'address2' . $DL . 'address3' . $DL . 'city' . $DL . 'state' . $DL . 'province' . $DL . 'postal_code' . $DL . 'country_code' . $DL . 'gender' . $DL . 'date_of_birth' . $DL . 'alt_phone' . $DL . 'email' . $DL . 'security_phrase' . $DL . 'comments' . $DL . 'called_count' . $DL . 'last_local_call_time' . $DL . 'rank' . $DL . 'owner' . $DL . 'entry_list_id' . $DL . 'lead_id' . $CF_header_output . "\n"; + $header_printed++; } $stmt="SELECT status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from $vicidial_list_table where lead_id='$lead_lead_id';"; @@ -14828,7 +15665,7 @@ if ($function == 'lead_all_info') $result = 'ERROR'; $result_reason = "lead_all_info LEAD NOT FOUND"; $data = "$user|$lead_id|$phone_number"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -14843,7 +15680,7 @@ if ($function == 'lead_all_info') $result = 'ERROR'; $result_reason = "lead_all_info LIST NOT FOUND"; $data = "$user|$lead_id|$phone_number"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); # exit; } @@ -14854,12 +15691,23 @@ if ($function == 'lead_all_info') $result = 'ERROR'; $result_reason = "lead_all_info LEAD NOT FOUND"; $data = "$user|$lead_id|$phone_number"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|lead_id|phone_number\n$user|$lead_id|$phone_number");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } if (strlen($output) > 10) - {echo "$output";} + { + if ($stage=="json") + { + $result_reason=($result=="SUCCESS" ? "" : $result_reason); + $output=ConvertToJSON($result,$result_reason,$header,$output); + } + echo "$output"; + } else { if ($no_list_counter > 0) @@ -14867,7 +15715,11 @@ if ($function == 'lead_all_info') $result = 'ERROR'; $result_reason = "lead_all_info LIST NOT FOUND"; $data = "$user|$lead_id|$phone_number|$no_list_output"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|lead_id|phone_number|no_list_output\n$user|$lead_id|$phone_number|$no_list_output");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -14894,9 +15746,8 @@ if ($function == 'lead_status_search') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -14956,7 +15807,7 @@ if ($function == 'lead_status_search') else { $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; @@ -15137,6 +15988,7 @@ if ($function == 'lead_status_search') $column_list = preg_replace("/lead_id,/",'',$column_list); $column_list = preg_replace("/,$/",'',$column_list); $column_list_array = explode(',',$column_list); + $columns_ct = count($column_list_array); # need a recount after removing lead_id if (preg_match("/cf_encrypt/",$active_modules)) { $enc_fields=0; @@ -15201,9 +16053,9 @@ if ($function == 'lead_status_search') { $row=mysqli_fetch_row($rslt); $t=0; - while ($columns_ct >= $t) + while ($columns_ct > $t) { - if ($enc_fields > 0) + if (isset($enc_fields) && $enc_fields > 0) { $field_enc=''; $field_enc_all=''; if ($DB) {echo "|$column_list|$encrypt_list|\n";} @@ -15248,7 +16100,7 @@ if ($function == 'lead_status_search') { $result = 'ERROR'; $result_reason = "lead_status_search NO RESULTS FOUND"; - $data = "$user|$lead_id|$status|$call_date"; + $data = "$user|$lead_id|$status"; echo "$result: $result_reason: $data\n"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -15286,9 +16138,12 @@ if ($function == 'lead_search') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -15297,8 +16152,12 @@ if ($function == 'lead_search') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; $data = "$allowed_user"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -15311,8 +16170,12 @@ if ($function == 'lead_search') { $result = 'ERROR'; $result_reason = "lead_search USER DOES NOT HAVE PERMISSION TO SEARCH FOR LEADS"; - echo "$result: $result_reason: |$user|$modify_leads|\n"; + $output="$result: $result_reason: |$user|$modify_leads|\n"; $data = "$modify_leads"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|modify_leads\n$user|$modify_leads");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -15399,7 +16262,11 @@ if ($function == 'lead_search') $result = 'ERROR'; $result_reason = "lead_search NO VALID SEARCH METHOD"; $data = "$search_method|$lead_id($find_lead_id)|$vendor_lead_code($find_vendor_lead_code)|$phone_number($find_phone_number)"; - echo "$result: $result_reason - $user|$data\n"; + $output="$result: $result_reason - $user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"search_method|lead_id|vendor_lead_code|phone_number\n$search_method|$lead_id($find_lead_id)|$vendor_lead_code($find_vendor_lead_code)|$phone_number($find_phone_number)");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -15412,7 +16279,11 @@ if ($function == 'lead_search') $result = 'ERROR'; $result_reason = "lead_search NOT AN ALLOWED LIST ID"; $data = "$phone_number|$list_id"; - echo "$result: $result_reason - $data\n"; + $output="$result: $result_reason - $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"phone_number|list_id\n$phone_number|$list_id");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -15530,7 +16401,7 @@ if ($function == 'lead_search') $output=''; if ($header == 'YES') { - $output .= 'search_key' . $DL . 'records_found' . $DL . 'lead_ids' . "\n"; + $output .= 'search_key|records_found|lead_ids' . "\n"; } $PH_search = count($find_phone_numberARYx); $SK_count = count($search_key); @@ -15580,7 +16451,10 @@ if ($function == 'lead_search') $result = 'SUCCESS'; $result_reason = "lead_search LEADS FOUND IN THE SYSTEM"; $data = "$lead_id|$vendor_lead_code|$phone_number|$search_found"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,$output);} echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } else @@ -15588,7 +16462,11 @@ if ($function == 'lead_search') $result = 'ERROR'; $result_reason = "lead_search NO MATCHES FOUND IN THE SYSTEM"; $data = "$lead_id|$vendor_lead_code|$phone_number"; - echo "$result: $result_reason: |$user|$data\n"; + $output="$result: $result_reason: |$user|$data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|lead_id|vendor_lead_code|phone_number\n$user|$lead_id|$vendor_lead_code|$phone_number");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -15615,9 +16493,8 @@ if ($function == 'update_log_entry') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -15720,7 +16597,7 @@ if ($function == 'update_log_entry') { $result = 'SUCCESS'; $result_reason = "update_log_entry RECORD HAS BEEN UPDATED"; - $data = "$user|$group|$call_id|$status|$old_status|$uniqueid|$affected_rows"; + $data = "$user|$group|$call_id|$status|$old_status|$uniqueid|$update_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); } @@ -15766,9 +16643,8 @@ if ($function == 'add_lead') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -16376,6 +17252,7 @@ if ($function == 'add_lead') $data = "$phone_number|$list_id|$lead_id|$gmt_offset"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + $g=0; if (strlen($multi_alt_phones) > 5) { $map=$MT; $ALTm_phone_code=$MT; $ALTm_phone_number=$MT; $ALTm_phone_note=$MT; @@ -16981,9 +17858,8 @@ if ($function == 'update_lead') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -17298,6 +18174,7 @@ if ($function == 'update_lead') api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } + $VCBAaffected_rows=""; if ( (strlen($VL_update_SQL)>6) or ($delete_lead=='Y') ) { if (strlen($VL_update_SQL)>6) @@ -18049,9 +18926,8 @@ if ($function == 'batch_update_lead') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -18133,6 +19009,7 @@ if ($function == 'batch_update_lead') $search_found=0; $found_lead_ids=''; + if (!isset($allowed_listsSQL)) {$allowed_listsSQL='';} # if api_list_restrict is not set, this isn't either at this point. if (strlen($lead_ids) > 0) # search for the lead_id { if (strlen($allowed_listsSQL) > 3) @@ -18238,9 +19115,8 @@ if ($function == 'check_phone_number') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + 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 @@ -18302,7 +19178,7 @@ if ($function == 'check_phone_number') $result = 'ERROR'; $result_reason = "check_phone_number NANPA options disabled, NANPA prefix data not loaded"; echo "$result: $result_reason - $vicidial_nanpa_prefix_codes_count|$user\n"; - $data = "$inserted_alt_phones|$lead_id"; + $data = "$vicidial_nanpa_prefix_codes_count|$lead_id"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -18513,9 +19389,13 @@ if ($function == 'logged_in_agents') { $result = 'ERROR'; $result_reason = "Invalid Source"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -18524,7 +19404,11 @@ if ($function == 'logged_in_agents') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -18537,7 +19421,11 @@ if ($function == 'logged_in_agents') { $result = 'ERROR'; $result_reason = "logged_in_agents USER DOES NOT HAVE PERMISSION TO GET AGENT INFO"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -18545,7 +19433,7 @@ if ($function == 'logged_in_agents') else { $stmt="SELECT admin_viewable_groups,allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; - if ($DB) {$MAIN.="|$stmt|\n";} + if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGadmin_viewable_groups = $row[0]; @@ -18595,6 +19483,8 @@ if ($function == 'logged_in_agents') {$DL = "\t"; $DLset++;} if ($stage == 'pipe') {$DL = '|'; $DLset++;} + if ($stage == 'json') + {$DL = '|'; $DLset++;} if ($DLset < 1) {$DL='|'; $stage='pipe';} if (strlen($time_format) < 1) @@ -18770,12 +19660,13 @@ if ($function == 'logged_in_agents') } if ($printed_agents > 0) { - echo "$output"; - $result = 'SUCCESS'; $data = "$user|$agents_to_list|$stage"; $result_reason = "logged_in_agents $output"; + if ($stage=="json") {$output=ConvertToJSON($result,"",$header,$output);} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } } @@ -18784,7 +19675,11 @@ if ($function == 'logged_in_agents') $result = 'ERROR'; $result_reason = "logged_in_agents NO LOGGED IN AGENTS"; $data = "$user|$agent_user"; - echo "$result: $result_reason: $data\n"; + $output="$result: $result_reason: $data\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|agent_user\n$user|$agent_user");} + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } @@ -18807,9 +19702,13 @@ if ($function == 'call_status_stats') { $result = 'ERROR'; $result_reason = "call_status_stats INVALID OR MISSING CAMPAIGNS"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"source\n$source");} + echo "$output"; + 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 @@ -18818,7 +19717,11 @@ if ($function == 'call_status_stats') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -18831,7 +19734,11 @@ if ($function == 'call_status_stats') { $result = 'ERROR'; $result_reason = "call_status_stats USER DOES NOT HAVE PERMISSION TO VIEW STATS"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -18851,7 +19758,8 @@ if ($function == 'call_status_stats') $total_hr_array=array(); $total_stat_array=array(); */ - + + $output=""; $campaign_array=explode("-", $campaigns); $campaign_SQL=" and campaign_id in ('".implode("', '", $campaign_array)."') "; if (in_array("ALLCAMPAIGNS", $campaign_array) || preg_match('/\-\-\-ALL\-\-\-/', $campaigns)) @@ -18937,6 +19845,10 @@ if ($function == 'call_status_stats') while($outb_row=mysqli_fetch_row($outb_rslt)) { + if (!isset($outbound_array["$outb_row[0]"][0])) {$outbound_array["$outb_row[0]"][0]=0;} + if (!isset($temp_stat_array["$outb_row[0]"]["$outb_row[1]"])) {$temp_stat_array["$outb_row[0]"]["$outb_row[1]"]=0;} + if (!isset($temp_hour_array["$outb_row[0]"]["$outb_row[2]"])) {$temp_hour_array["$outb_row[0]"]["$outb_row[2]"]=0;} + $outbound_array["$outb_row[0]"][0]+=$outb_row[3]; if (in_array($outb_row[1], $human_ans_array)) { @@ -18968,12 +19880,12 @@ if ($function == 'call_status_stats') for ($i=0; $i<24; $i++) { $hrkey=substr("0$i", -2); - $hrs=$temp_hour_array["$key"]["$hrkey"]+=0; + $hrs=(isset($temp_hour_array["$key"]["$hrkey"]) ? $temp_hour_array["$key"]["$hrkey"] : 0); $hour_str.="$hrkey-$hrs,"; } $hour_str=substr($hour_str, 0, -1); - if (!is_array($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); + if (!isset($temp_stat_array["$key"]) || !is_array($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); $temp_ary_ct = count($temp_stat_array["$key"]); if ($temp_ary_ct > 0) { @@ -18987,7 +19899,7 @@ if ($function == 'call_status_stats') } $status_str=substr($status_str, 0, -1); - echo $key."|".$outbound_array[$key][0]."|".$outbound_array[$key][1]."|".$hour_str."|".$status_str."|\n"; + $output.=$key."|OUTBOUND|".$outbound_array[$key][0]."|".$outbound_array[$key][1]."|".$hour_str."|".$status_str."\n"; } # while(list($key, $val)=each($inbound_array)) { @@ -18997,12 +19909,12 @@ if ($function == 'call_status_stats') for ($i=0; $i<24; $i++) { $hrkey=substr("0$i", -2); - $hrs=$temp_hour_array["$key"]["$hrkey"]+=0; + $hrs=(isset($temp_hour_array["$key"]["$hrkey"]) ? $temp_hour_array["$key"]["$hrkey"] : 0); $hour_str.="$hrkey-$hrs,"; } $hour_str=substr($hour_str, 0, -1); - if (!is_array($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); + if (!isset($temp_stat_array["$key"]) || !is_array($temp_stat_array["$key"])) $temp_stat_array["$key"] = array(); $temp_ary_ct = count($temp_stat_array["$key"]); if ($temp_ary_ct > 0) { @@ -19016,12 +19928,21 @@ if ($function == 'call_status_stats') } $status_str=substr($status_str, 0, -1); - echo $key."|".$inbound_array[$key][0]."|".$inbound_array[$key][1]."|".$hour_str."|".$status_str."|\n"; + $output.=$key."|INBOUND|".$inbound_array[$key][0]."|".$inbound_array[$key][1]."|".$hour_str."|".$status_str."\n"; } $result = 'SUCCESS'; $data = "$user|$stage"; $result_reason = "call_status_stats"; + + if ($stage=="json") + { + # Report doesn't have a header - adding one + $output="campaign|direction|total_calls|human_answered|hour_counts|status_counts\n".$output; + $output=ConvertToJSON($result,"",$header,$output); + } + echo "$output"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); } exit; @@ -19040,9 +19961,13 @@ if ($function == 'call_dispo_report') { $result = 'ERROR'; $result_reason = "call_dispo_report INVALID OR MISSING CAMPAIGNS, INGROUPS, OR DIDS"; - echo "$result: $result_reason - $source\n"; + $output="$result: $result_reason: |$source|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"");} + echo "$output"; + 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 @@ -19051,7 +19976,11 @@ if ($function == 'call_dispo_report') { $result = 'ERROR'; $result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION"; - echo "$result: $result_reason: |$user|$function|\n"; + $output="$result: $result_reason: |$user|$function|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|function\n$user|$function");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -19065,7 +19994,11 @@ if ($function == 'call_dispo_report') { $result = 'ERROR'; $result_reason = "call_status_stats USER DOES NOT HAVE PERMISSION TO VIEW STATS"; - echo "$result: $result_reason: |$user|$allowed_user|\n"; + $output="$result: $result_reason: |$user|$allowed_user|\n"; + + if ($stage=="json") {$output=ConvertToJSON($result,$result_reason,$header,"user|allowed_user\n$user|$allowed_user");} + echo "$output"; + $data = "$allowed_user"; api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; @@ -19077,6 +20010,7 @@ if ($function == 'call_dispo_report') if (!$end_date) {$end_date=$query_date;} if (!$end_time) {$end_time="23:59:59";} if ($show_percentages && !$status_breakdown) {$show_percentages="";} + $rpt_str=""; # COMPILE INBOUND CAMPAIGN CLAUSE $skip_inbound=0; @@ -19132,7 +20066,7 @@ if ($function == 'call_dispo_report') } } - if (!is_array($did_id_array)) $did_id_array = array(); + if (!isset($did_id_array) || !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)."')"; @@ -19164,7 +20098,8 @@ if ($function == 'call_dispo_report') } } - if (!is_array($status_array)) $status_array = array(); + if (!isset($status_array) || !is_array($status_array)) $status_array = array(); + $status_SQL=""; if ($status_array && count($status_array)>0) { $status_SQL=" and status in ('".implode("', '", $status_array)."') "; @@ -19191,7 +20126,8 @@ if ($function == 'call_dispo_report') } } } - if (!is_array($user_array)) $user_array = array(); + if (!isset($user_array) || !is_array($user_array)) $user_array = array(); + $user_SQL=""; if ($user_array && count($user_array)>0) { $user_SQL=" and user in ('".implode("', '", $user_array)."') "; @@ -19215,10 +20151,14 @@ if ($function == 'call_dispo_report') $rslt=mysql_to_mysqli($stmt, $link); while ($row=mysqli_fetch_row($rslt)) { + if (!isset($outbound_ct_array["$row[0]"]["TOTAL CALLS"])) {$outbound_ct_array["$row[0]"]["TOTAL CALLS"]=0;} $outbound_ct_array["$row[0]"]["TOTAL CALLS"]+=$row[2]; $grand_total_calls+=$row[2]; if ($status_breakdown) { + if (!isset($outbound_ct_array["$row[0]"]["$row[1]"])) {$outbound_ct_array["$row[0]"]["$row[1]"]=0;} + if (!isset($grand_total_array["$row[1]"])) {$grand_total_array["$row[1]"]=0;} + if (!in_array("$row[1]", $status_ct_array)) { array_push($status_ct_array, "$row[1]"); @@ -19235,6 +20175,7 @@ if ($function == 'call_dispo_report') $rslt=mysql_to_mysqli($stmt, $link); while ($row=mysqli_fetch_row($rslt)) { + if (!isset($inbound_ct_array["$row[0]"]["TOTAL CALLS"])) {$inbound_ct_array["$row[0]"]["TOTAL CALLS"]=0;} $inbound_ct_array["$row[0]"]["TOTAL CALLS"]+=$row[2]; $grand_total_calls+=$row[2]; if ($status_breakdown) @@ -19243,6 +20184,8 @@ if ($function == 'call_dispo_report') { array_push($status_ct_array, "$row[1]"); } + if (!isset($inbound_ct_array["$row[0]"]["$row[1]"])) {$inbound_ct_array["$row[0]"]["$row[1]"]=0;} + if (!isset($grand_total_array["$row[1]"])) {$grand_total_array["$row[1]"]=0;} $inbound_ct_array["$row[0]"]["$row[1]"]+=$row[2]; $grand_total_array["$row[1]"]+=$row[2]; } @@ -19255,6 +20198,7 @@ if ($function == 'call_dispo_report') $rslt=mysql_to_mysqli($stmt, $link); while ($row=mysqli_fetch_row($rslt)) { + if (!isset($did_ct_array["$row[1]"]["TOTAL CALLS"])) {$did_ct_array["$row[1]"]["TOTAL CALLS"]=0;} $did_ct_array["$row[1]"]["TOTAL CALLS"]+=$row[4]; $grand_total_calls+=$row[4]; if ($status_breakdown) @@ -19263,13 +20207,16 @@ if ($function == 'call_dispo_report') { array_push($status_ct_array, "$row[3]"); } + if (!isset($did_ct_array["$row[1]"]["$row[3]"])) {$did_ct_array["$row[1]"]["$row[3]"]=0;} + if (!isset($grand_total_array["$row[3]"])) {$grand_total_array["$row[3]"]=0;} $did_ct_array["$row[1]"]["$row[3]"]+=$row[4]; $grand_total_array["$row[3]"]+=$row[4]; } } } - if (!is_array($status_ct_array)) $status_ct_array = array(); + if (!isset($status_ct_array) || !is_array($status_ct_array)) $status_ct_array = array(); + sort($status_ct_array); $rpt_str.="CAMPAIGN,TOTAL CALLS"; if ($status_breakdown) { @@ -19289,7 +20236,7 @@ if ($function == 'call_dispo_report') { for ($i=0; $i4) ) @@ -20262,7 +21217,7 @@ function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) $pmin=(gmdate("i", time() + $pzone)); $phour=( (gmdate("G", time() + $pzone)) * 100); $pday=gmdate("w", time() + $pzone); - $tz = sprintf("%.2f", $p); + $tz = sprintf("%.2f", $gmt_offset); $GMT_gmt = "$tz"; $GMT_day = "$pday"; $GMT_hour = ($phour + $pmin); @@ -20431,6 +21386,7 @@ function dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state) ##### Logging ##### function api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data) { + global $DB; if ($api_logging > 0) { global $startMS, $query_string, $ip;