Files
magic-map/server/debug.php

143 lines
3.6 KiB
PHP
Raw Permalink Normal View History

2019-06-06 17:15:12 +02:00
<?php
/**
* debug.php
*
* Debug-Data Collection And Window Display
*
* @category Debug
* @author Victor Giers <vgiers@web.de>
* @copyright 2019 Victor Giers
* @license https://www.gnu.org/licenses/gpl.txt GPLv3
* @version Permanent Beta
* @link https://www.victorgiers.com/
*/
if(!isset($_SESSION)) session_start();
?>
<style>
.debug{
padding:20px;
position: fixed;
background-color: rgba(0,0,0,0.7);
color:rgba(255,255,255,1);
text-shadow: 1px 1px rgba(0,0,0,1);
font-size: 11px;
font-family: 'Lucida Grande', Verdana, Helvetica, sans-serif;
max-height:700px;
overflow: hidden;
right:40px;
top:85px;
z-index: 1000;
/*pointer-events: none;*/
border-radius: 7px;
}
.debug hr{
color:white;
box-shadow: 1px 1px rgba(0,0,0,1);
}
.debug span{
display: block;
white-space: nowrap;
}
.debug.m{
min-width:4em;
}
.debug table{
padding-top:10px;
border:none;
}
.debug table td{
padding:20px;
vertical-align:top;
border-right: 1px solid #dedede;
box-shadow: 1px 0px #333;
max-height: 600px;
}
.debugcell{
max-height:inherit;
max-width:400px;
overflow: auto;
}
</style>
<script>
var maxed = <?=(isset($_SESSION['debugMaxed']))? $_SESSION['debugMaxed'] : 'false' ?>;
function minimDebug(){
$(".debug").prop("hidden", (_, val) => !val);
$.ajax({url:'server/server.php',method:'POST',data:{debugMaxed:!maxed}});
maxed = !maxed;
}
(function () {
"use strict";
var baseLogFunction = console.log;
console.log = function(){
baseLogFunction.apply(console, arguments);
var args = Array.prototype.slice.call(arguments);
for(var i=0;i<args.length;i++){
var node = createLogNode(args[i]);
document.querySelector("#jsdebug").appendChild(node);
}
}
function createLogNode(message){
var node = document.createElement("div");
var textNode = document.createTextNode(message);
node.appendChild(textNode);
return node;
}
window.onerror = function(message, url, linenumber) {
console.log("JavaScript error: " + message + " on line " +
linenumber + " for " + url);
};
})();
</script>
<div class="debug"<?=(($_SESSION['debugMaxed'] == 'true') ? '' : ' hidden') ?>>
<h2>Debug</h2><div><a style="position:absolute;right:25px;color:white;top:1em;" href="#" onClick="minimDebug()">Minimieren</a></div><hr>
<table>
<tr>
<td>
<div id="jsdebug"></div>
</td>
</tr>
<tr>
<?php
if($GLOBALS['phpErrors'] != null || $GLOBALS['sqlErrors'] != null){
echo ("<td><div class='debugcell'>");
if($GLOBALS['sqlErrors'] != null) echo ("<b>SQL-Errors:</b><br>".$GLOBALS['sqlErrors']);
if($GLOBALS['phpErrors'] != null) echo ("<b>PHP-Errors:</b><br>".$GLOBALS['phpErrors']);
echo ("</div></td>");
}
if($GLOBALS['debugData'] != null){
echo ("<td><div class='debugcell'><b>Variables:</b><br/>".$GLOBALS['debugData']."</div></td>");
}
?>
<td>
<div class='debugcell'>
<b>$_SESSION:</b> <pre><?php echo(print_r($_SESSION));?></pre>
</div>
</td>
<td style="border:none;box-shadow: none;">
<div class='debugcell'>
<b>$_GET:</b> <pre><?php echo(print_r($_GET));?></pre>
<b>$_POST:</b> <pre><?php echo(print_r($_POST));?></pre>
<b>$GLOBALS:</b> <pre><?php echo(print_r($GLOBALS));?></pre>
</div>
</td>
</tr>
</table>
</div>
<div class="debug m"<?=(($_SESSION['debugMaxed'] == 'true') ? ' hidden' : '') ?>>
<div id="debugMaxLink"><a style="position:absolute;right:25px;color:white;top:1em;" href="#" onClick="minimDebug()">Debug</a></div>
</div>