-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions-debug.php
69 lines (61 loc) · 1.76 KB
/
functions-debug.php
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
<?php
if (!function_exists('pp')) { //Pretty Print
function pp($obj,$label = '') {
if (!defined('PP_ENABLED') || !PP_ENABLED) { return false; }
$data = json_encode(print_r($obj,true));
?>
<style type="text/css">
#bsdLogger {
position: absolute;
top: 90px;
right: 20px;
border: 1px solid #bbb;
border-radius: 0.3rem;
background: rgba(255,255,255,0.5);
color: #444;
font-size: 14px;
height: 800px;
overflow: auto;
padding: 1rem;
transition: all 500ms ease;
width: 200px;
z-index: 999;
}
#bsdLogger:hover {
width: 90%;
right: 5%;
}
</style>
<script type="text/javascript">
var doStuff = function(){
var obj = <?php echo $data; ?>;
var logger = document.getElementById('bsdLogger');
if (!logger) {
logger = document.createElement('div');
logger.id = 'bsdLogger';
document.body.appendChild(logger);
}
////console.log(obj);
var pre = document.createElement('pre');
var h2 = document.createElement('h2');
pre.innerHTML = obj;
h2.innerHTML = '<?php echo addslashes($label); ?>';
logger.appendChild(h2);
logger.appendChild(pre);
};
window.addEventListener ("DOMContentLoaded", doStuff, false);
</script>
<?php
}
}
function pr($obj,$label = '') {
echo sprintf('%s: %s',$label,print_r($obj,true));
}
function cblog($msg,$label = '') {
$stamp = date('Y-m-d H:i:s');
$msg = sprintf('%s %s: %s',$stamp,$label, print_r($msg,true));
$filename = dirname(__FILE__) . '/data/cblog.txt';
$fp = fopen($filename, 'a') or exit("Can't open $filename");
fwrite($fp,$msg . "\n");
fclose($fp);
}