From 4ac06a919498431ce76ad83c47c406b8f8ad453f Mon Sep 17 00:00:00 2001 From: fusionate Date: Thu, 8 Jun 2023 19:32:39 +0000 Subject: [PATCH] Operator Panel: Updates for PHP 8.1 --- app/basic_operator_panel/autocomplete.php | 8 +++--- app/basic_operator_panel/exec.php | 27 +++++++++++-------- app/basic_operator_panel/index.php | 22 +++++++++------ .../classes/basic_operator_panel.php | 2 +- .../resources/content.php | 6 ++--- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/app/basic_operator_panel/autocomplete.php b/app/basic_operator_panel/autocomplete.php index 34397c2a14..58f7dc5533 100644 --- a/app/basic_operator_panel/autocomplete.php +++ b/app/basic_operator_panel/autocomplete.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -185,8 +185,8 @@ } //output suggestions, if any - if (sizeof($suggestions) > 0) { - $resp .= "[\n"; + if (!empty($suggestions) && is_array($suggestions) && @sizeof($suggestions) > 0) { + $resp = "[\n"; $resp .= implode(",\n", $suggestions)."\n"; $resp .= "]"; @@ -195,4 +195,4 @@ if (isset($_GET['debug'])) { echo ""; } } -?> +?> \ No newline at end of file diff --git a/app/basic_operator_panel/exec.php b/app/basic_operator_panel/exec.php index e0bc2b9f54..5ce188d441 100644 --- a/app/basic_operator_panel/exec.php +++ b/app/basic_operator_panel/exec.php @@ -2,7 +2,7 @@ /* $Id$ */ /* v_exec.php - Copyright (C) 2008-2019 Mark J Crane + Copyright (C) 2008-2023 Mark J Crane All rights reserved. Redistribution and use in source and binary forms, with or without @@ -55,10 +55,10 @@ //process the requests if (count($_GET) > 0) { //set the variables - $switch_cmd = trim($_GET["cmd"]); - $action = trim($_GET["action"]); - $data = trim($_GET["data"]); - $direction = trim($_GET["direction"]); + $switch_cmd = trim($_GET["cmd"] ?? ''); + $action = trim($_GET["action"] ?? ''); + $data = trim($_GET["data"] ?? ''); + $direction = trim($_GET["direction"] ?? ''); //setup the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); @@ -73,14 +73,17 @@ if (count($_GET) > 0) { $source = preg_replace($num_pattern,'',$_GET['source']); $destination = preg_replace($num_pattern,'',$_GET['destination']); $api_cmd = 'bgapi originate {sip_auto_answer=true,origination_caller_id_number=' . $source . ',sip_h_Call-Info=_undef_}user/' . $source . '@' . $_SESSION['domain_name'] . ' ' . $destination . ' XML ' . trim($_SESSION['user_context']); - } elseif ($switch_cmd == 'uuid_record') { + } + else if ($switch_cmd == 'uuid_record') { $uuid = preg_replace($uuid_pattern,'',$_GET['uuid']); $api_cmd = 'uuid_record ' . $uuid . ' start ' . $_SESSION['switch']['recordings']['dir'] . '/' . $_SESSION['domain_name'] . '/archive/' . date('Y/M/d') . '/' . $uuid . '.wav'; - } elseif ($switch_cmd == 'uuid_transfer') { + } + else if ($switch_cmd == 'uuid_transfer') { $uuid = preg_replace($uuid_pattern,'',$_GET['uuid']); $destination = preg_replace($num_pattern,'',$_GET['destination']); $api_cmd = 'uuid_transfer ' . $uuid . ' ' . $destination . ' XML ' . trim($_SESSION['user_context']); - } elseif ($switch_cmd == 'uuid_eavesdrop') { + } + else if ($switch_cmd == 'uuid_eavesdrop') { $chan_uuid = preg_replace($uuid_pattern,'',$_GET['chan_uuid']); $ext = preg_replace($num_pattern,'',$_GET['ext']); $destination = preg_replace($num_pattern,'',$_GET['destination']); @@ -89,10 +92,12 @@ if (count($_GET) > 0) { $text = $language->get(); $api_cmd = 'bgapi originate {origination_caller_id_name=' . $text['label-eavesdrop'] . ',origination_caller_id_number=' . $ext . '}user/' . $destination . '@' . $_SESSION['domain_name'] . ' &eavesdrop(' . $chan_uuid . ')'; - } elseif ($switch_cmd == 'uuid_kill') { + } + else if ($switch_cmd == 'uuid_kill') { $call_id = preg_replace($uuid_pattern,'',$_GET['call_id']); $api_cmd = 'uuid_kill ' . $call_id; - } else { + } + else { echo 'access denied'; return; } @@ -124,4 +129,4 @@ if (count($_GET) > 0) { } } -?> +?> \ No newline at end of file diff --git a/app/basic_operator_panel/index.php b/app/basic_operator_panel/index.php index 117b4e41ad..7bf75a21dd 100644 --- a/app/basic_operator_panel/index.php +++ b/app/basic_operator_panel/index.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -115,7 +115,7 @@ //update do not disturb if ($user_status == "Do Not Disturb") { $x = 0; - foreach($_SESSION['user']['extension'] as $row) { + foreach ($_SESSION['user']['extension'] as $row) { //build the array $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; $array['extensions'][$x]['dial_string'] = '!USER_BUSY'; @@ -123,8 +123,10 @@ //delete extension from the cache $cache = new cache; - $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); - if(!empty($number_alias)){ + if (!empty($row['extension'])) { + $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); + } + if (!empty($number_alias)) { $cache->delete("directory:".$row['number_alias']."@".$_SESSION['user']['domain_name']); } @@ -142,8 +144,10 @@ //delete extension from the cache $cache = new cache; - $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); - if(!empty($number_alias)){ + if (!empty($row['extension'])) { + $cache->delete("directory:".$row['extension']."@".$_SESSION['user']['domain_name']); + } + if (!empty($number_alias)) { $cache->delete("directory:".$row['number_alias']."@".$_SESSION['user']['domain_name']); } @@ -168,8 +172,10 @@ //delete extension from the cache $cache = new cache; - $cache->delete("directory:".$extension."@".$this->domain_name); - if(!empty($number_alias)){ + if (!empty($extension)) { + $cache->delete("directory:".$extension."@".$this->domain_name); + } + if (!empty($number_alias)) { $cache->delete("directory:".$number_alias."@".$this->domain_name); } } diff --git a/app/basic_operator_panel/resources/classes/basic_operator_panel.php b/app/basic_operator_panel/resources/classes/basic_operator_panel.php index f2da858a3b..0340fbef68 100644 --- a/app/basic_operator_panel/resources/classes/basic_operator_panel.php +++ b/app/basic_operator_panel/resources/classes/basic_operator_panel.php @@ -145,7 +145,7 @@ if (!class_exists('basic_operator_panel')) { $presence_id = $field['presence_id']; $presence = explode("@", $presence_id); $presence_id = $presence[0]; - $presence_domain = $presence[1]; + $presence_domain = $presence[1] ?? ''; if ($user == $presence_id) { if ($presence_domain == $_SESSION['domain_name']) { $found = true; diff --git a/app/basic_operator_panel/resources/content.php b/app/basic_operator_panel/resources/content.php index e8555e886e..6d145c5da9 100644 --- a/app/basic_operator_panel/resources/content.php +++ b/app/basic_operator_panel/resources/content.php @@ -274,7 +274,7 @@ if (is_array($activity)) { $call_number = $ext['dest']; } else { - $call_name = $activity[$ext['dest']]['effective_caller_id_name']; + $call_name = $activity[$ext['dest']]['effective_caller_id_name'] ?? null; $call_number = format_phone($ext['dest']); } $dir_icon = 'outbound'; @@ -391,7 +391,7 @@ if (is_array($activity)) { } else { //user extension - if ($ext['uuid'] != '' && $ext['uuid'] == $ext['call_uuid'] && $ext['variable_bridge_uuid'] == '') { + if ($ext['uuid'] != '' && $ext['uuid'] == $ext['call_uuid'] && empty($ext['variable_bridge_uuid'])) { $draggable = false; } else if (!empty($ext_state) && $ext_state == 'ringing' && $ext['variable_call_direction'] == 'local') { @@ -476,7 +476,7 @@ if (is_array($activity)) { } //hangup if (permission_exists('operator_panel_hangup') || in_array($extension, $_SESSION['user']['extensions'])) { - if ($ext['variable_bridge_uuid'] == '' && $ext_state == 'ringing') { + if (empty($ext['variable_bridge_uuid']) && $ext_state == 'ringing') { $call_identifier_hangup_uuid = $ext['uuid']; } else if ($dir_icon == 'outbound') {