webui: make d_echo work in webui (#4432)

* webui: make d_echo work in webui
Remove d_print_r(), it is redundant to d_echo()
Remove d_echo calls in services.inc.php

* Switched debug check to work with nginx
This commit is contained in:
Tony Murray
2016-09-14 04:05:49 -05:00
committed by Neil Lathwood
parent ce95ceaa2b
commit 0351b54fb8
5 changed files with 11 additions and 25 deletions

View File

@@ -17,7 +17,6 @@ if (is_admin() !== false) {
if (file_exists($dir) && is_dir($dir)) {
$files = scandir($dir);
$dir .= DIRECTORY_SEPARATOR;
d_print_r($files);
foreach ($files as $file) {
if (is_executable($dir.$file) && is_file($dir.$file) && strstr($file, 'check_')) {
list(,$check_name) = explode('_', $file, 2);

View File

@@ -34,14 +34,16 @@ function catchFatal()
}
}
if (strpos($_SERVER['PATH_INFO'], "debug")) {
$debug = "1";
if (strpos($_SERVER['REQUEST_URI'], "debug")) {
$debug = true;
ini_set('display_errors', 0);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 1);
ini_set('error_reporting', E_ALL);
set_error_handler('logErrors');
register_shutdown_function('catchFatal');
$sql_debug = array();
$php_debug = array();
} else {
$debug = false;
ini_set('display_errors', 0);

View File

@@ -651,12 +651,12 @@ function is_valid_hostname($hostname)
*/
function d_echo($text, $no_debug_text = null)
{
global $debug;
global $debug, $php_debug;
if ($debug) {
if (is_array($text)) {
print_r($text);
if (isset($php_debug)) {
$php_debug[] = $text;
} else {
echo "$text";
print_r($text);
}
} elseif ($no_debug_text) {
echo "$no_debug_text";
@@ -684,19 +684,6 @@ function c_echo($string, $enabled = true)
}
}
/*
* convenience function - please use this instead of 'if ($debug) { print_r ...; }'
*/
function d_print_r($var, $no_debug_text = null)
{
global $debug;
if ($debug) {
print_r($var);
} elseif ($no_debug_text) {
echo "$no_debug_text";
}
} // d_print_r
/*
* @return true if the given graph type is a dynamic MIB graph

View File

@@ -18,7 +18,6 @@ function get_service_status($device = null)
$sql_query = substr($sql_query, 0, strlen($sql_query)-6);
}
$sql_query .= " GROUP BY service_status";
d_echo("SQL Query: ".$sql_query);
// $service is not null, get only what we want.
$result = dbFetchRows($sql_query, $sql_param);
@@ -30,7 +29,6 @@ function get_service_status($device = null)
$service_count[$v['service_status']] = $v['count'];
}
d_echo("Service Count by Status: ".print_r($service_count, true)."\n");
return $service_count;
}

View File

@@ -991,7 +991,7 @@ function snmp_mib_load($mib, $module, $included_by, $mibdir = null)
$mibs[$obj['object_type']] = $obj;
$mibs[$obj['object_type']]['included_by'] = $included_by;
}
d_print_r($mibs);
d_echo($mibs);
// NOTE: `last_modified` omitted due to being automatically maintained by MySQL
$columns = array('module', 'mib', 'object_type', 'oid', 'syntax', 'description', 'max_access', 'status', 'included_by');
update_db_table('mibdefs', $columns, 3, $mibs);
@@ -1202,7 +1202,7 @@ function load_mibdefs($module, $name)
}
}
d_print_r($result);
d_echo($result);
return $result;
} // load_mibdefs
@@ -1236,7 +1236,7 @@ function poll_mibs($device, &$graphs)
echo "$name ";
d_echo("\n");
$oids = snmpwalk_cache_oid($device, $name, array(), $module, null, "-OQUsb");
d_print_r($oids);
d_echo($oids);
save_mibs($device, $name, $oids, load_mibdefs($module, $name), $graphs);
}
echo "\n";