mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #484 from laf/issue-483
Updated the way debug=yes in url works to make it visually more appealing
This commit is contained in:
@@ -1600,3 +1600,6 @@ tr.search:nth-child(odd) {
|
|||||||
font-size: 2.5em;
|
font-size: 2.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-debug {
|
||||||
|
min-height: 25px;
|
||||||
|
}
|
||||||
|
|||||||
89
html/includes/print-debug.php
Normal file
89
html/includes/print-debug.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$total_queries = count($sql_debug);
|
||||||
|
$total_php_issues = count($php_debug);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal fade" id="sql_debug" tabindex="-1" role="dialog" aria-labelledby="sql_debug_label" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">SQL Debug</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<table class="table table-condensed table-hover">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach ($sql_debug as $sql_error) {
|
||||||
|
echo ("
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
$sql_error
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ("
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
$total_queries total SQL queries run.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
");
|
||||||
|
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal fade" id="php_debug" tabindex="-1" role="dialog" aria-labelledby="php_debug_label" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">SQL Debug</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<table class="table table-condensed table-hover">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach ($php_debug as $php_error) {
|
||||||
|
echo ("
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
");
|
||||||
|
print_r($php_error);
|
||||||
|
echo("
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ("
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
$total_php_issues total PHP issues / errors.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
");
|
||||||
|
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<nav class="navbar navbar-default navbar-fixed-bottom navbar-debug">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<p><strong>Debug options:</strong> <a href="#" data-toggle="modal" data-target="#sql_debug">Show SQL Debug</a> / <a href="#" data-toggle="modal" data-target="#php_debug">Show PHP Debug</a></p>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
@@ -12,6 +12,38 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$_SERVER['PATH_INFO'] = (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['ORIG_PATH_INFO']);
|
||||||
|
|
||||||
|
function logErrors($errno, $errstr, $errfile, $errline) {
|
||||||
|
global $php_debug;
|
||||||
|
$php_debug[] = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline);
|
||||||
|
}
|
||||||
|
|
||||||
|
function catchFatal() {
|
||||||
|
$last_error = error_get_last();
|
||||||
|
if ($last_error['type'] == 1) {
|
||||||
|
$log_error = array($last_error['type'],$last_error['message'],$last_error['file'],$last_error['line']);
|
||||||
|
print_r($log_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($_SERVER['PATH_INFO'], "debug"))
|
||||||
|
{
|
||||||
|
$debug = "1";
|
||||||
|
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');
|
||||||
|
} else {
|
||||||
|
$debug = FALSE;
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
ini_set('display_startup_errors', 0);
|
||||||
|
ini_set('log_errors', 0);
|
||||||
|
ini_set('error_reporting', 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
$msg_box = array();
|
$msg_box = array();
|
||||||
|
|
||||||
@@ -38,23 +70,6 @@ ob_start();
|
|||||||
ini_set('allow_url_fopen', 0);
|
ini_set('allow_url_fopen', 0);
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
|
|
||||||
$_SERVER['PATH_INFO'] = (isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['ORIG_PATH_INFO']);
|
|
||||||
|
|
||||||
if (strpos($_SERVER['PATH_INFO'], "debug"))
|
|
||||||
{
|
|
||||||
$debug = "1";
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
} else {
|
|
||||||
$debug = FALSE;
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('error_reporting', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($_GET as $key=>$get_var)
|
foreach ($_GET as $key=>$get_var)
|
||||||
{
|
{
|
||||||
if (strstr($key, "opt"))
|
if (strstr($key, "opt"))
|
||||||
@@ -318,6 +333,13 @@ toastr.options.extendedTimeOut = 20;
|
|||||||
echo("</script>");
|
echo("</script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_array($sql_debug) && is_array($php_debug)) {
|
||||||
|
|
||||||
|
include_once "includes/print-debug.php";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -22,10 +22,14 @@ Usage
|
|||||||
* Used by the other _query functions.
|
* Used by the other _query functions.
|
||||||
* */
|
* */
|
||||||
function dbQuery($sql, $parameters = array()) {
|
function dbQuery($sql, $parameters = array()) {
|
||||||
global $fullSql, $debug;
|
global $fullSql, $debug, $sql_debug;
|
||||||
$fullSql = dbMakeQuery($sql, $parameters);
|
$fullSql = dbMakeQuery($sql, $parameters);
|
||||||
if($debug) {
|
if($debug) {
|
||||||
print Console_Color::convert("\nSQL[%y".$fullSql."%n] ");
|
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
|
||||||
|
print Console_Color::convert("\nSQL[%y".$fullSql."%n] ");
|
||||||
|
} else {
|
||||||
|
$sql_debug[] = $fullSql;
|
||||||
|
}
|
||||||
#echo("\nSQL[".$fullSql."] ");
|
#echo("\nSQL[".$fullSql."] ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user