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.
This commit is contained in:
Harry G. Coin 2016-04-25 20:19:58 -05:00
parent b4c5c79a4d
commit 8abe003a71
21 changed files with 52 additions and 57 deletions

View File

@ -698,13 +698,11 @@ require_once "resources/require.php";
}
}
}
closedir($dh_sub);
}
echo "</optgroup>";
}
}
}
closedir($dh);
}
echo "</select>\n";
echo "<br />\n";

View File

@ -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 "</optgroup>";
}
}
}
closedir($dh);
}
echo "</select>\n";
echo " </td>\n";

View File

@ -235,9 +235,9 @@ else {
echo "<br><br>";
/* close the connection */
imap_close($inbox);
imap_close($connection);
//show the footer
require_once "resources/footer.php";
?>
?>

View File

@ -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."' ";

View File

@ -703,7 +703,7 @@ else {
echo " <td class='vncell' valign='top'>".$text['label-user_list']."</td>";
echo " <td class='vtable'>";
echo " <table width='52%'>\n";
foreach($ring_group_users as $field) {
if (isset($ring_group_users)) foreach($ring_group_users as $field) {
echo " <tr>\n";
echo " <td class='vtable'>".$field['username']."</td>\n";
echo " <td>\n";

View File

@ -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'];
}

View File

@ -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'];
}

View File

@ -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 "<tr ".$tr_link.">\n";

View File

@ -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

View File

@ -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) {

View File

@ -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 " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
}
}

View File

@ -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")) {

View File

@ -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"]));

View File

@ -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', '');
*/
?>
?>

View File

@ -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"] . "' ";

View File

@ -164,7 +164,7 @@ class event_socket {
public function close() {
if ($this->fp) {
fclose($fp);
fclose($fp->fp);
$this->fp = false;
}
}

View File

@ -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();

View File

@ -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')) {
}
}
?>
?>

View File

@ -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);
}
}

View File

@ -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'];
}
?>
?>

View File

@ -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'];
}