initial commit
This commit is contained in:
142
server/debug.php
Normal file
142
server/debug.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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>
|
||||
84
server/debugfunctions.php
Normal file
84
server/debugfunctions.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
function errorhandler($errno, $errstr, $errfile, $errline, $errcontext){
|
||||
$fp = explode(dirname(__DIR__, 1), $errfile);
|
||||
$constants = array(
|
||||
"E_ERROR",
|
||||
"E_WARNING",
|
||||
"E_PARSE",
|
||||
"E_NOTICE",
|
||||
"E_CORE_ERROR",
|
||||
"E_CORE_WARNING",
|
||||
"E_COMPILE_ERROR",
|
||||
"E_COMPILE_WARNING",
|
||||
"E_USER_ERROR",
|
||||
"E_USER_WARNING",
|
||||
"E_USER_NOTICE",
|
||||
"E_STRICT",
|
||||
"E_RECOVERABLE_ERROR",
|
||||
"E_DEPRECATED",
|
||||
"E_USER_DEPRECATED",
|
||||
"E_ALL"
|
||||
);
|
||||
$included = array();
|
||||
foreach ($constants as $constant) {
|
||||
$value = constant($constant);
|
||||
if (($errno & $value) === $value) {
|
||||
$included[] = $constant;
|
||||
}
|
||||
}
|
||||
$description = implode(", ", $included);
|
||||
if(strpos($errstr, "sql")){
|
||||
$GLOBALS['sqlErrors'].="<span>[$description] in <b>".$fp[1]."</b> line <b>$errline</b></span>$errstr<br><br>";
|
||||
} else {
|
||||
$GLOBALS['phpErrors'].="<span>[$description] in <b>".$fp[1]."</b> line <b>$errline</b></span>$errstr<br><br>";
|
||||
}
|
||||
}
|
||||
|
||||
function alert($string){
|
||||
echo("<script>alert('" .((isset($string)) ? addslashes($string) : 'parameter not set') . "');</script>");
|
||||
}
|
||||
|
||||
function debug($var, $mode = null){
|
||||
$bt = debug_backtrace();
|
||||
$file = file($bt[0]['file']);
|
||||
$src = $file[$bt[0]['line']-1];
|
||||
$pat = '#(.*)'.__FUNCTION__.' *?\( *?(.*) *?\)(.*)#i';
|
||||
$varName = preg_replace($pat, '$2', $src);
|
||||
if($mode == null){
|
||||
$mode = "print_r";
|
||||
$varName .= ', "'.$mode.'" ';
|
||||
}
|
||||
switch($mode){
|
||||
case "print_r":
|
||||
ob_start();
|
||||
print_r($var);
|
||||
$result = ob_get_clean();
|
||||
if($result == strip_tags($result)){
|
||||
if(strpos($result, ('(')) !== false)
|
||||
$result = strstr($result, "(");
|
||||
} else {
|
||||
$result = htmlspecialchars($result);
|
||||
}
|
||||
$GLOBALS['debugData'] .= '<b>' . $varName . '</b>:<pre>'.$result.'</pre>';
|
||||
break;
|
||||
case "var_dump":
|
||||
ob_start();
|
||||
var_dump($var);
|
||||
$result = ob_get_clean();
|
||||
$result = ($result != strip_tags($result))? htmlspecialchars($result) : $result;
|
||||
$GLOBALS['debugString'] .= '<b>' . $varName . '</b>:<pre>'.$result.'</pre>';
|
||||
break;
|
||||
case "var_export":
|
||||
ob_start();
|
||||
var_export($var);
|
||||
$result = ob_get_clean();
|
||||
$result = ($result != strip_tags($result))? htmlspecialchars($result) : $result;
|
||||
$GLOBALS['debugString'] .= '<b>' . $varName . '</b>:<pre>'.$result.'</pre>';
|
||||
break;
|
||||
case "alert":
|
||||
$result = print_r($var, true);
|
||||
$GLOBALS['debugString'] .= alert(json_encode($result));
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
0
server/functions.php
Normal file
0
server/functions.php
Normal file
7
server/server.php
Normal file
7
server/server.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
if(!isset($_SESSION)) session_start();
|
||||
|
||||
if(isset($_POST['debugMaxed'])){
|
||||
$_SESSION['debugMaxed'] = $_POST['debugMaxed'];
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user