From 58d2a9d75423ed641257b2cf626b049ab36a0da4 Mon Sep 17 00:00:00 2001 From: fusionate Date: Thu, 2 May 2024 15:42:47 -0600 Subject: [PATCH] CDR - Details: Mitigate PHP 8.x errors. --- app/xml_cdr/resources/classes/xml_cdr.php | 70 ++++++++++++----------- app/xml_cdr/xml_cdr_details.php | 34 +++++------ 2 files changed, 55 insertions(+), 49 deletions(-) diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index c071490b35..2bedd7dcf7 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -1174,7 +1174,6 @@ if (!class_exists('xml_cdr')) { //clean up unset($new_row); } - $i++; } //format the times in the call flow array @@ -1182,7 +1181,7 @@ if (!class_exists('xml_cdr')) { foreach ($call_flow_array as $key => $row) { foreach ($row["times"] as $name => $value) { if ($value > 0) { - $call_flow_array[$i]["times"][$name.'stamp'] = date("Y-m-d H:i:s", (int) $value/1000000); + $call_flow_array[$i]["times"][$name.'stamp'] = date("Y-m-d H:i:s", round((float) $value / 1000000, 0)); } } $i++; @@ -1265,10 +1264,16 @@ if (!class_exists('xml_cdr')) { } //valet park - if (!empty($row["caller_profile"]["destination_number"]) - and (substr($row["caller_profile"]["destination_number"], 0, 4) == 'park' - or (substr($row["caller_profile"]["destination_number"], 0, 3) == '*59' - and strlen($row["caller_profile"]["destination_number"]) == 5))) { + if ( + !empty($row["caller_profile"]["destination_number"]) + && ( + substr($row["caller_profile"]["destination_number"], 0, 4) == 'park' + || ( + substr($row["caller_profile"]["destination_number"], 0, 3) == '*59' + && strlen($row["caller_profile"]["destination_number"]) > 3 + ) + ) + ) { //add items to the app array $app['application'] = 'dialplans'; $app['uuid'] = '46ae6d82-bb83-46a3-901d-33d0724347dd'; @@ -1359,25 +1364,26 @@ if (!class_exists('xml_cdr')) { $parameters['domain_uuid'] = $this->domain_uuid; $destinations = $this->database->select($sql, $parameters, 'all'); if (!empty($destinations)) { + $i = 0; foreach($destinations as $row) { - $destination_array['destinations'][$id]['application'] = 'destinations'; - $destination_array['destinations'][$id]['destination_uuid'] = $row["destination_uuid"]; - $destination_array['destinations'][$id]['uuid'] = $row["destination_uuid"]; - $destination_array['destinations'][$id]['dialplan_uuid'] = $row["dialplan_uuid"]; - $destination_array['destinations'][$id]['destination_type'] = $row["destination_type"]; - $destination_array['destinations'][$id]['destination_prefix'] = $row["destination_prefix"]; - $destination_array['destinations'][$id]['destination_number'] = $row["destination_number"]; - $destination_array['destinations'][$id]['extension'] = $row["destination_prefix"] . $row["destination_number"]; - $destination_array['destinations'][$id]['destination_trunk_prefix'] = $row["destination_trunk_prefix"]; - $destination_array['destinations'][$id]['destination_area_code'] = $row["destination_area_code"]; - $destination_array['destinations'][$id]['context'] = $row["destination_context"]; - $destination_array['destinations'][$id]['label'] = $row["destination_description"]; - $destination_array['destinations'][$id]['destination_enabled'] = $row["destination_enabled"]; - $destination_array['destinations'][$id]['name'] = $row["destination_description"]; - $destination_array['destinations'][$id]['description'] = $row["destination_description"]; - //$destination_array[$id]['destination_caller_id_name'] = $row["destination_caller_id_name"]; - //$destination_array[$id]['destination_caller_id_number'] = $row["destination_caller_id_number"]; - $id++; + $destination_array['destinations'][$i]['application'] = 'destinations'; + $destination_array['destinations'][$i]['destination_uuid'] = $row["destination_uuid"]; + $destination_array['destinations'][$i]['uuid'] = $row["destination_uuid"]; + $destination_array['destinations'][$i]['dialplan_uuid'] = $row["dialplan_uuid"]; + $destination_array['destinations'][$i]['destination_type'] = $row["destination_type"]; + $destination_array['destinations'][$i]['destination_prefix'] = $row["destination_prefix"]; + $destination_array['destinations'][$i]['destination_number'] = $row["destination_number"]; + $destination_array['destinations'][$i]['extension'] = $row["destination_prefix"] . $row["destination_number"]; + $destination_array['destinations'][$i]['destination_trunk_prefix'] = $row["destination_trunk_prefix"]; + $destination_array['destinations'][$i]['destination_area_code'] = $row["destination_area_code"]; + $destination_array['destinations'][$i]['context'] = $row["destination_context"]; + $destination_array['destinations'][$i]['label'] = $row["destination_description"]; + $destination_array['destinations'][$i]['destination_enabled'] = $row["destination_enabled"]; + $destination_array['destinations'][$i]['name'] = $row["destination_description"]; + $destination_array['destinations'][$i]['description'] = $row["destination_description"]; + //$destination_array[$i]['destination_caller_id_name'] = $row["destination_caller_id_name"]; + //$destination_array[$i]['destination_caller_id_number'] = $row["destination_caller_id_number"]; + $i++; } } unset($sql, $parameters, $row); @@ -1389,13 +1395,13 @@ if (!class_exists('xml_cdr')) { foreach ($row as $key => $value) { //find matching destinations if ($application == 'destinations') { - if ('+'.$value['destination_prefix'].$value['destination_number'] == $detail_action - or $value['destination_prefix'].$value['destination_number'] == $detail_action - or $value['destination_number'] == $detail_action - or $value['destination_trunk_prefix'].$value['destination_number'] == $detail_action - or '+'.$value['destination_prefix'].$value['destination_area_code'].$value['destination_number'] == $detail_action - or $value['destination_prefix'].$value['destination_area_code'].$value['destination_number'] == $detail_action - or $value['destination_area_code'].$value['destination_number'] == $detail_action) { + if ('+'.($value['destination_prefix'] ?? '').$value['destination_number'] == $detail_action + || ($value['destination_prefix'] ?? '').$value['destination_number'] == $detail_action + || $value['destination_number'] == $detail_action + || ($value['destination_trunk_prefix'] ?? '').$value['destination_number'] == $detail_action + || '+'.($value['destination_prefix'] ?? '').($value['destination_area_code'] ?? '').$value['destination_number'] == $detail_action + || ($value['destination_prefix'] ?? '').($value['destination_area_code'] ?? '').$value['destination_number'] == $detail_action + || ($value['destination_area_code'] ?? '').$value['destination_number'] == $detail_action) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$application."/app_languages.php")) { $value['application'] = $application; return $value; @@ -1404,7 +1410,7 @@ if (!class_exists('xml_cdr')) { } //find all other matching actions - if (!empty($value['extension']) && $value['extension'] == $detail_action or preg_match('/^'.preg_quote($value['extension']).'$/', $detail_action)) { + if (!empty($value['extension']) && $value['extension'] == $detail_action || preg_match('/^'.preg_quote($value['extension'] ?? '').'$/', $detail_action)) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$application."/app_languages.php")) { $value['application'] = $application; return $value; diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php index 7e7274c5cc..d49bca594f 100644 --- a/app/xml_cdr/xml_cdr_details.php +++ b/app/xml_cdr/xml_cdr_details.php @@ -60,19 +60,19 @@ $database = new database; $row = $database->select($sql, $parameters, 'row'); if (!empty($row) && is_array($row) && @sizeof($row) != 0) { - $caller_id_name = trim($row["caller_id_name"]); - $caller_id_number = trim($row["caller_id_number"]); - $caller_destination = trim($row["caller_destination"]); - $destination_number = trim($row["destination_number"]); - $duration = trim($row["billsec"]); - $missed_call = trim($row["missed_call"]); - $start_stamp = trim($row["start_stamp"]); + $caller_id_name = trim($row["caller_id_name"] ?? ''); + $caller_id_number = trim($row["caller_id_number"] ?? ''); + $caller_destination = trim($row["caller_destination"] ?? ''); + $destination_number = trim($row["destination_number"] ?? ''); + $duration = trim($row["billsec"] ?? ''); + $missed_call = trim($row["missed_call"] ?? ''); + $start_stamp = trim($row["start_stamp"] ?? ''); $xml_string = trim($row["xml"] ?? ''); - $json_string = trim($row["json"]); - $call_flow = trim($row["call_flow"]); - $direction = trim($row["direction"]); - $call_direction = trim($row["direction"]); - $status = trim($row["status"]); + $json_string = trim($row["json"] ?? ''); + $call_flow = trim($row["call_flow"] ?? ''); + $direction = trim($row["direction"] ?? ''); + $call_direction = trim($row["direction"] ?? ''); + $status = trim($row["status"] ?? ''); } unset($sql, $parameters, $row); @@ -91,7 +91,7 @@ $database = new database; $row = $database->select($sql, $parameters, 'row'); if (!empty($row) && is_array($row) && @sizeof($row) != 0) { - $json_string = trim($row["json"]); + $json_string = trim($row["json"] ?? ''); } unset($sql, $parameters, $row); } @@ -111,7 +111,7 @@ $database = new database; $row = $database->select($sql, $parameters, 'row'); if (!empty($row) && is_array($row) && @sizeof($row) != 0) { - $call_flow = trim($row["call_flow"]); + $call_flow = trim($row["call_flow"] ?? ''); } unset($sql, $parameters, $row); } @@ -200,9 +200,9 @@ $remote_media_ip = urldecode($array["variables"]["remote_media_ip"] ?? ''); $hangup_cause = urldecode($array["variables"]["hangup_cause"]); $hangup_cause_q850 = urldecode($array["variables"]["hangup_cause_q850"]); - $network_address = urldecode((string)$array["variables"]["network_address"]); - $outbound_caller_id_name = urldecode($array["variables"]["outbound_caller_id_name"]); - $outbound_caller_id_number = urldecode($array["variables"]["outbound_caller_id_number"]); + $network_address = urldecode($array["variables"]["network_address"] ?? ''); + $outbound_caller_id_name = urldecode($array["variables"]["outbound_caller_id_name"] ?? ''); + $outbound_caller_id_number = urldecode($array["variables"]["outbound_caller_id_number"] ?? ''); //set the time zone if (isset($_SESSION['domain']['time_zone']['name'])) {