1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257:
<?php
class PHPShopDebug {
var $value;
var $tollbar_height_closed = 150;
var $tollbar_height_opened = 500;
var $backgroundcolor = 'black';
var $textcolor = 'green';
var $tabcolor = '#337AB7';
var $texttabcolor = 'white';
function add($value, $desc = false) {
$this->value[$desc] = $value;
}
function timeon($desc = false) {
$this->start_time[$desc] = microtime(true);
}
function timeoff($desc = false) {
$time = microtime(true);
$seconds = ($time - $this->start_time[$desc]);
$this->seconds[$desc] = substr($seconds, 0, 6);
}
function disp($name, $content) {
global $PHPShopModules;
if ($_GET['debug'] == 'timer') {
$name['Total SQL'] = $this->total_sql;
$name['Total Seconds'] = $this->total_seconds;
$name['Total Memory'] = $this->total_memory;
}
ob_start();
print_r($name);
$disp = $content . ': ' . ob_get_clean();
echo '<pre class="debug-kit-pre">' . strip_tags($disp) . '</pre>';
}
function log() {
$disp = '';
$base = $GLOBALS['SysValue']['base']['errorlog']['errorlog_log'];
if (!empty($base)) {
$PHPShopOrm = new PHPShopOrm($base);
$data = $PHPShopOrm->select(array('*'), $where, array('order' => 'id DESC'), array('limit' => 100));
if (is_array($data))
foreach ($data as $val)
$disp.=PHPShopDate::dataV($val['date']) . ' ' . $val['error'] . '</br>';
}
else
$disp = __('');
echo $disp;
}
function compile($total_sql, $total_seconds, $total_memory) {
global $PHPShopNav, $PHPShopModules;
$this->total_sql = $total_sql;
$this->total_seconds = $total_seconds;
$this->total_memory = $total_memory;
if (!empty($_GET['debug'])) {
$height = $this->tollbar_height_closed . "px";
$height2 = ($this->tollbar_height_closed - 20) . "px";
} else {
$height = "25px";
$height2 = "0px";
}
$metod = '?';
if (is_array($PHPShopNav->objNav['query'])) {
foreach ($PHPShopNav->objNav['query'] as $k => $v)
if (is_array($v)) {
foreach ($v as $key => $val)
$metod.=$k . '[' . $key . ']=' . $val . '&';
} elseif ($k != 'debug')
$metod.=$k . '=' . $v . '&';
}
echo '
<script>
function debug_toolbar(toolbar,height){
height = toolbar.style.height;
if(height == "' . ($this->tollbar_height_closed - 20) . 'px") {
document.getElementById("debug-kit-toolbar").style.height="500px";
toolbar.style.height="500px";
}
else {
toolbar.style.height = "' . ($this->tollbar_height_closed - 20) . 'px";
document.getElementById("debug-kit-toolbar").style.height="' . $this->tollbar_height_closed . 'px";
}
}
</script>
<style>
.debug-kit-pre{
background-color: #000;
color: #FFF;
border: 0px;
}
#debug-kit-toolbar {
position: fixed;
top: 0px;
right:0px;
width: 100%;
height: ' . $height . ';
overflow: visible;
z-index:10000000;
font-family: helvetica, arial, sans-serif;
}
#debug-kit-nav{
background-color: ' . $this->tabcolor . ';
color: ' . $this->textcolor . ';
width: 500px;
padding: 3px;
padding-right:5px;
}
#debug-kit-nav a{
color: ' . $this->texttabcolor . ';
font-size: 12px;
}
#debug-kit-nav span{
color: white;
font-size: 12px;
}
#debug-kit-display {
background-color: ' . $this->backgroundcolor . ';
overflow: auto;
color: ' . $this->textcolor . ';
border: 0px;
border-style: inset;
height: ' . $height2 . ';
font-size: 11px;
text-align: left;
}
</style>
<div id="debug-kit-nav">
<a href="javascript:location.reload();" title="Reload"><span class="glyphicon glyphicon-refresh"></span></a>
<span>' . $total_seconds . '</span>
<a href="' . $metod . 'debug=session">Session</a>
<a href="' . $metod . 'debug=sysvalue">SysValue</a>
<a href="' . $metod . 'debug=request">Request</a>
<a href="' . $metod . 'debug=timer">Timer</a>
<a href="' . $metod . 'debug=variables">Variables</a>
<a href="' . $metod . 'debug=values">Values</a>
<a href="?" title="Exit"><span class=" glyphicon glyphicon-remove"></span></a>
<div id="debug-kit-display" onclick="debug_toolbar(this)">';
if (!empty($_GET['debug']))
switch ($_GET['debug']) {
case "session":
$this->disp($_SESSION, "_SESSION");
$this->disp($GLOBALS['Cache'], "GLOBALS['Cache']");
break;
case "sysvalue":
$SysValue = $GLOBALS['SysValue'];
$SysValue['connect'] = '******';
$SysValue['other'] = '******';
$this->disp($SysValue, "GLOBALS['SysValue']");
break;
case "request":
$this->disp($GLOBALS['SysValue']['nav'], "GLOBALS['SysValue']['nav']");
break;
case "log":
$this->log();
break;
case "variables":
$this->disp($GLOBALS['SysValue']['other'], "GLOBALS['SysValue']['other']");
break;
case "values":
$this->disp($this->value, "Values");
break;
case "timer":
$timer['Repsonal'] = $this->seconds;
$timer['Modules'] = $PHPShopModules->handlerDone;
$this->disp($timer, "Timer");
break;
}
echo '</div></div>';
}
}
function debug($value, $desc = false) {
global $PHPShopDebug;
$PHPShopDebug->add($value, $desc);
}
function timer($option = 'start', $desc = false) {
global $PHPShopDebug;
if ($option == 'start')
$PHPShopDebug->timeon($desc);
else
$PHPShopDebug->timeoff($desc);
}
?>