From 89e5ecbcdf42f1cee0441adddb2cad86d6c3dad8 Mon Sep 17 00:00:00 2001 From: "Harry G. Coin" Date: Mon, 25 Apr 2016 20:19:58 -0500 Subject: [PATCH] The goal is to increase confidence in fusionpbx, one step is to run by default with error_reporting (E_ALL ^ E_NOTICE); So, please find in this set numerous small changes which eliminate numerous php warning messages. Also, a small bug fix in an sql statistics routine, naming a count(*) field as count, so displaying correct detail. If any of the proposed changes are omitted, the relevant page will experience php warnings. There are no doubt fusionpbx pages I've yet to visit that still generate warnings, this set is nearly certainly not comprehensive. --- app/devices/device_edit.php | 2 -- app/extensions/extension_edit.php | 4 +-- app/fax/fax_files_remote.php | 4 +-- app/provision/index.php | 2 +- app/ring_groups/ring_group_edit.php | 2 +- .../resources/classes/voicemail.php | 4 +-- app/voicemails/voicemails.php | 4 +-- app/xml_cdr/xml_cdr_extension_summary.php | 8 +++--- app/xml_cdr/xml_cdr_statistics_inc.php | 28 +++++++++---------- core/menu/menu_item_list.php | 2 +- core/users/usersupdate.php | 2 +- index.php | 2 +- logout.php | 2 +- resources/classes/destinations.php | 4 +-- resources/classes/domains.php | 2 +- resources/classes/event_socket.php | 2 +- resources/classes/menu.php | 4 +-- resources/classes/switch_settings.php | 15 +++++----- resources/functions.php | 4 +-- resources/require.php | 6 ++-- themes/default/template.php | 6 ++-- 21 files changed, 52 insertions(+), 57 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 5085986ab5..3ee1c1e8fe 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -698,13 +698,11 @@ require_once "resources/require.php"; } } } - closedir($dh_sub); } echo ""; } } } - closedir($dh); } echo "\n"; echo "
\n"; diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index 82c710b0c8..ea66278745 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -926,7 +926,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //get the users $sql = "SELECT * FROM v_users "; $sql .= "where domain_uuid = '".$domain_uuid."' "; - foreach($assigned_user_uuids as $assigned_user_uuid) { + if (isset($assigned_user_uuids)) foreach($assigned_user_uuids as $assigned_user_uuid) { $sql .= "and user_uuid <> '".$assigned_user_uuid."' "; } unset($assigned_user_uuids); @@ -1289,13 +1289,11 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } } } - closedir($dh_sub); } echo ""; } } } - closedir($dh); } echo "\n"; echo " \n"; diff --git a/app/fax/fax_files_remote.php b/app/fax/fax_files_remote.php index 28c5d76b83..23d4b1b731 100644 --- a/app/fax/fax_files_remote.php +++ b/app/fax/fax_files_remote.php @@ -235,9 +235,9 @@ else { echo "

"; /* close the connection */ -imap_close($inbox); +imap_close($connection); //show the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?> diff --git a/app/provision/index.php b/app/provision/index.php index 89ed9fa6ef..22956c2bac 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -80,7 +80,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); } //get the domain_name and domain_uuid - if ($_SESSION['provision']['http_domain_filter']['text'] == "false") { + if ((!isset($_SESSION['provision']['http_domain_filter'])) or $_SESSION['provision']['http_domain_filter']['text'] == "false") { //get the domain_uuid $sql = "SELECT domain_uuid FROM v_devices "; $sql .= "WHERE device_mac_address = '".$mac."' "; diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 7c096e33f1..05e1c58cd6 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -703,7 +703,7 @@ else { echo " ".$text['label-user_list'].""; echo " "; echo " \n"; - foreach($ring_group_users as $field) { + if (isset($ring_group_users)) foreach($ring_group_users as $field) { echo " \n"; echo " \n"; echo " \n"; diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php index a5f4869b35..826a1aa036 100644 --- a/app/xml_cdr/xml_cdr_statistics_inc.php +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -326,8 +326,8 @@ else { $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $sql_where); $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; - $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; - $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / 60; + $stats[$i]['avg_sec'] = ($stats[$i]['volume']==0) ? 0 : $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_min'] = (($stats[$i]['volume']==0) ? 0 : $stats[$i]['volume'] - $stats[$i]['missed']) / 60; //answer / seizure ratio if ($_GET['showall'] && permission_exists('xml_cdr_all')) { @@ -338,10 +338,10 @@ else { $where .= " billsec = '0' and "; $where .= " direction = 'inbound' and "; $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); - $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['asr'] = ($stats[$i]['volume']==0) ? 0 : (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); //average length of call - $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $stats[$i]['aloc'] = ($stats[$i]['volume']==0) ? 0 : $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); } //call info for a day @@ -356,7 +356,7 @@ else { $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $sql_where); $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; - $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_sec'] = ($stats[$i]['volume']==0) ? 0 : $stats[$i]['seconds'] / $stats[$i]['volume']; $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24); if ($_GET['showall'] && permission_exists('xml_cdr_all')) { $where = "where "; @@ -366,8 +366,8 @@ else { $where .= " billsec = '0' and "; $where .= " direction = 'inbound' and "; $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); - $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); - $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $stats[$i]['asr'] = ($stats[$i]['volume']==0) ? 0 :(($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['aloc'] = ($stats[$i]['volume']==0) ? 0 :$stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); $i++; //call info for a week @@ -381,8 +381,8 @@ else { $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $sql_where); $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; - $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; - $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*7); + $stats[$i]['avg_sec'] = ($stats[$i]['volume']==0) ? 0 :$stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_min'] = ($stats[$i]['volume']==0) ? 0 :($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*7); if ($_GET['showall'] && permission_exists('xml_cdr_all')) { $where = "where "; } else { @@ -391,8 +391,8 @@ else { $where .= " billsec = '0' and "; $where .= " direction = 'inbound' and "; $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); - $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); - $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $stats[$i]['asr'] = ($stats[$i]['volume']==0) ? 0 :(($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['aloc'] = ($stats[$i]['volume']==0) ? 0 :$stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); $i++; //call info for a month @@ -406,7 +406,7 @@ else { $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $sql_where); $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; - $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_sec'] = ($stats[$i]['volume']==0) ? 0 :$stats[$i]['seconds'] / $stats[$i]['volume']; $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*30); if ($_GET['showall'] && permission_exists('xml_cdr_all')) { $where = "where "; @@ -416,8 +416,8 @@ else { $where .= " billsec = '0' and "; $where .= " direction = 'inbound' and "; $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); - $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); - $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $stats[$i]['asr'] = ($stats[$i]['volume']==0) ? 0 :(($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['aloc'] =($stats[$i]['volume']==0) ? 0 : $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); $i++; //show the graph diff --git a/core/menu/menu_item_list.php b/core/menu/menu_item_list.php index fde3bc658a..4f852bf0c9 100644 --- a/core/menu/menu_item_list.php +++ b/core/menu/menu_item_list.php @@ -84,7 +84,7 @@ function build_db_child_menu_list ($db, $menu_item_level, $menu_item_uuid, $c) { foreach ($sub_result as &$sub_row) { $group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null); } - $group_list = implode(', ', $group_list); + $group_list = isset($group_list) ? implode(', ', $group_list) : ''; unset ($sub_prep_statement); //display the main body of the list switch ($menu_item_category) { diff --git a/core/users/usersupdate.php b/core/users/usersupdate.php index da6688c2a7..1fb80137d1 100644 --- a/core/users/usersupdate.php +++ b/core/users/usersupdate.php @@ -565,7 +565,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") { foreach($result as $field) { if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins - if (!in_array($field["group_uuid"], $assigned_groups)) { + if (isset($assigned_groups) && !in_array($field["group_uuid"], $assigned_groups)) { echo " \n"; } } diff --git a/index.php b/index.php index 3e0ca555b9..60c11d0be7 100644 --- a/index.php +++ b/index.php @@ -56,7 +56,7 @@ include "root.php"; require_once "resources/require.php"; // if logged in, redirect to login destination - if (strlen($_SESSION["username"]) > 0) { + if (isset($_SESSION["username"]) and (strlen($_SESSION["username"]) > 0)) { if (strlen($_SESSION['login']['destination']['url']) > 0) { header("Location: ".$_SESSION['login']['destination']['url']); } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/user_settings/user_dashboard.php")) { diff --git a/logout.php b/logout.php index ae24d59e9e..a8012b741f 100644 --- a/logout.php +++ b/logout.php @@ -29,7 +29,7 @@ require_once "resources/require.php"; //check for login return preference if ($_SESSION["user_uuid"] != '') { - if ($_SESSION['login']['destination_last']['boolean'] == 'true') { + if (isset($_SESSION['login']['destination_last']) && ($_SESSION['login']['destination_last']['boolean'] == 'true')) { if ($_SERVER['HTTP_REFERER'] != '') { //convert to relative path $referrer = substr($_SERVER['HTTP_REFERER'], strpos($_SERVER['HTTP_REFERER'], $_SERVER["HTTP_HOST"]) + strlen($_SERVER["HTTP_HOST"])); diff --git a/resources/classes/destinations.php b/resources/classes/destinations.php index f2657972b0..88c70cb76e 100644 --- a/resources/classes/destinations.php +++ b/resources/classes/destinations.php @@ -29,7 +29,7 @@ class destinations { } $i = 0; foreach ($apps as $x => &$app) { - foreach ($app['destinations'] as &$row) { + if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) { $this->destinations[] = $row; } } @@ -277,4 +277,4 @@ echo $obj->select('ivr', 'example5', ''); echo $obj->select('ivr', 'example6', ''); */ -?> \ No newline at end of file +?> diff --git a/resources/classes/domains.php b/resources/classes/domains.php index 1bf9a9663e..a5c745fc15 100644 --- a/resources/classes/domains.php +++ b/resources/classes/domains.php @@ -138,7 +138,7 @@ if (!class_exists('domains')) { } //get the user settings - if (strlen($_SESSION["domain_uuid"]) > 0 && strlen($_SESSION["user_uuid"]) > 0) { + if (array_key_exists("domain_uuid",$_SESSION) and array_key_exists("user_uuid",$_SESSION) and strlen($_SESSION["domain_uuid"]) > 0 && strlen($_SESSION["user_uuid"]) > 0) { $sql = "select * from v_user_settings "; $sql .= "where domain_uuid = '" . $_SESSION["domain_uuid"] . "' "; $sql .= "and user_uuid = '" . $_SESSION["user_uuid"] . "' "; diff --git a/resources/classes/event_socket.php b/resources/classes/event_socket.php index 54a5e4d208..13ad5048ad 100644 --- a/resources/classes/event_socket.php +++ b/resources/classes/event_socket.php @@ -164,7 +164,7 @@ class event_socket { public function close() { if ($this->fp) { - fclose($fp); + fclose($fp->fp); $this->fp = false; } } diff --git a/resources/classes/menu.php b/resources/classes/menu.php index 6852450c5c..73f219d05d 100644 --- a/resources/classes/menu.php +++ b/resources/classes/menu.php @@ -203,7 +203,7 @@ if (!class_exists('menu')) { //if there are no groups listed in v_menu_item_groups under menu_item_uuid then add the default groups foreach($apps as $app) { foreach ($app['menu'] as $sub_row) { - foreach ($sub_row['groups'] as $group) { + if (isset($sub_row['groups'])) foreach ($sub_row['groups'] as $group) { $sql = "select count(*) as count from v_menu_item_groups "; $sql .= "where menu_item_uuid = '".$sub_row['uuid']."' "; $sql .= "and menu_uuid = '".$this->menu_uuid."' "; @@ -547,7 +547,7 @@ if (!class_exists('menu')) { //set the default menu_uuid $this->menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286'; //check to see if any menu exists - $sql = "select count(*) from v_menus "; + $sql = "select count(*) as count from v_menus "; $sql .= "where menu_uuid = '".$this->menu_uuid."' "; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); diff --git a/resources/classes/switch_settings.php b/resources/classes/switch_settings.php index c536d79422..c0bd743708 100644 --- a/resources/classes/switch_settings.php +++ b/resources/classes/switch_settings.php @@ -67,15 +67,14 @@ if (!class_exists('switch_settings')) { } } - //connect to event socket - $esl = new event_socket; - $esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password); + { //connect to event socket + $esl = new event_socket; + $esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password); - //run the api command - $result = $esl->request('api global_getvar'); + //run the api command + $result = $esl->request('api global_getvar'); + } //close event socket - //close event socket - fclose($fp); //set the result as a named array $vars = array(); @@ -284,4 +283,4 @@ if (!class_exists('switch_settings')) { } } -?> \ No newline at end of file +?> diff --git a/resources/functions.php b/resources/functions.php index f04f3dfd7a..8816a36bb1 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -843,7 +843,7 @@ function format_string ($format, $data) { function format_phone($phone_number) { $phone_number = trim($phone_number, "+"); if (is_numeric($phone_number)) { - foreach ($_SESSION["format"]["phone"] as &$format) { + if (isset($_SESSION["format"]["phone"])) foreach ($_SESSION["format"]["phone"] as &$format) { $format_count = substr_count($format, 'x'); $format_count = $format_count + substr_count($format, 'R'); $format_count = $format_count + substr_count($format, 'r'); @@ -1148,7 +1148,7 @@ function number_pad($number,$n) { } } } - ksort($dir_array, SORT_STRING); + if (isset($dir_array)) ksort($dir_array, SORT_STRING); closedir($dir_list); } } diff --git a/resources/require.php b/resources/require.php index 19a5a8edcc..c384b55482 100644 --- a/resources/require.php +++ b/resources/require.php @@ -42,7 +42,7 @@ } //class auto loader - if (!class_exists(auto_loader)) { + if (!class_exists('auto_loader')) { class auto_loader { public function __construct() { spl_autoload_register(array($this, 'loader')); @@ -76,7 +76,7 @@ require_once "resources/switch.php"; //change language on the fly - for translate tool (if available) - if ($_REQUEST['view_lang_code'] != '') { + if (isset($_REQUEST['view_lang_code']) && ($_REQUEST['view_lang_code']) != '') { $_SESSION['domain']['language']['code'] = $_REQUEST['view_lang_code']; } -?> \ No newline at end of file +?> diff --git a/themes/default/template.php b/themes/default/template.php index 558d15a5f8..65b746ec43 100644 --- a/themes/default/template.php +++ b/themes/default/template.php @@ -57,7 +57,7 @@ $background_images_enabled = false; if ($default_login) { //try using login background images/colors - if ($_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) { + if (isset($_SESSION['theme']) && $_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) { $background_images_enabled = true; $background_images = $_SESSION['theme']['login_background_image']; } @@ -79,7 +79,7 @@ } else { //use standard background images/colors - if ($_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) { + if (isset($_SESSION['theme']) && isset($_SESSION['theme']['background_image_enabled']) && $_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) { $background_images_enabled = true; $background_images = $_SESSION['theme']['background_image']; } @@ -96,7 +96,7 @@ if (count($background_images) > 0) { - if (strlen($_SESSION['background_image']) == 0) { + if ((!isset($_SESSION['background_image'])) or strlen($_SESSION['background_image']) == 0) { $_SESSION['background_image'] = $background_images[array_rand($background_images)]; $background_image = $_SESSION['background_image']; }
".$field['username']."\n"; diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index 4b25157061..664b5f7559 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -42,7 +42,7 @@ } //set the voicemail id and voicemail uuid arrays - foreach ($_SESSION['user']['extension'] as $index => $row) { + if (isset($_SESSION['user']['extension'])) foreach ($_SESSION['user']['extension'] as $index => $row) { if (strlen($row['number_alias']) > 0) { $voicemail_ids[$index]['voicemail_id'] = $row['number_alias']; } @@ -50,7 +50,7 @@ $voicemail_ids[$index]['voicemail_id'] = $row['user']; } } - foreach ($_SESSION['user']['voicemail'] as $row) { + if (isset($_SESSION['user']['voicemail'])) foreach ($_SESSION['user']['voicemail'] as $row) { if (strlen($row['voicemail_uuid']) > 0) { $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index a420938e17..2383c31834 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -43,7 +43,7 @@ else { $order = check_str($_GET["order"]); //set the voicemail id and voicemail uuid arrays - foreach ($_SESSION['user']['extension'] as $index => $row) { + if (isset($_SESSION['user']['extension'])) foreach ($_SESSION['user']['extension'] as $index => $row) { if (strlen($row['number_alias']) > 0) { $voicemail_ids[$index]['voicemail_id'] = $row['number_alias']; } @@ -51,7 +51,7 @@ else { $voicemail_ids[$index]['voicemail_id'] = $row['user']; } } - foreach ($_SESSION['user']['voicemail'] as $row) { + if (isset($_SESSION['user']['voicemail'])) foreach ($_SESSION['user']['voicemail'] as $row) { if (strlen($row['voicemail_uuid']) > 0) { $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } diff --git a/app/xml_cdr/xml_cdr_extension_summary.php b/app/xml_cdr/xml_cdr_extension_summary.php index 1102707aea..d96f11714d 100644 --- a/app/xml_cdr/xml_cdr_extension_summary.php +++ b/app/xml_cdr/xml_cdr_extension_summary.php @@ -105,10 +105,10 @@ } unset ($sql, $prep_statement, $result, $row_count); // create list of extensions for query below - foreach ($extensions as $extension => $blah) { + if (isset($extensions)) foreach ($extensions as $extension => $blah) { $ext_array[] = $extension; } - $ext_list = implode("','", $ext_array); + $ext_list = (isset($ext_array)) ? implode("','", $ext_array) : ""; //calculate the summary data $sql = "select "; @@ -300,7 +300,7 @@ $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - foreach ($extensions as $extension => $ext) { + if (isset($extensions)) foreach ($extensions as $extension => $ext) { $seconds['inbound'] = $summary[$extension]['inbound']['seconds']; $seconds['outbound'] = $summary[$extension]['outbound']['seconds']; if ($summary[$extension]['missed'] == null) { @@ -320,7 +320,7 @@ $volume = $summary[$extension]['inbound']['count'] + $summary[$extension]['outbound']['count']; //average length of call - $summary[$extension]['aloc'] = ($seconds['inbound'] + $seconds['outbound']) / ($volume - $missed); + $summary[$extension]['aloc'] = $volume==0 ? 0 : ($seconds['inbound'] + $seconds['outbound']) / ($volume - $missed); $tr_link = "xhref='xml_cdr.php?'"; echo "