-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
84 lines (71 loc) · 3.33 KB
/
test.php
File metadata and controls
84 lines (71 loc) · 3.33 KB
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
<?php
/* Simple PHP test page for PHP Debugger.
* https://github.com/rorabr
* Copyright (C) 2019 Rodrigo Antunes - All Rights Reserved
* Permission to copy and modify is granted under the MIT license
* Last revised 2019-05-20 */
assert((require_once("debug.php")) || true);
session_start();
assert(debug_start("http://localhost:8080/debug.php", true)); // standalone httpd
ini_set('display_errors', 1);
$error_count = 0; // To show the number of events at the end
function my_log($msg) {
global $error_count;
/* This will generate a log entry with the line of my_log's caller */
assert(debug_log("Generated by my_log: $msg", 1)); // skip the first (1) stacklevel
$error_count ++;
}
?>
<html lang="en">
<head>
<meta name="description" content="PHP test page for PHPdebug at https://github.com/rorabr">
<?php
// Install Javascript error handler (inside <head>)
assert(debug_installJShandler());
// Demonstrate asset loading tracking
$asset_error = "";
assert(($asset_error = " onerror='debug_onloadhandler(this)'") || true);
$bootstrapcss = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css.err";
assert(($bootstrapcss = "assets/css/bootstrap.min.css.err") || true);
$bootstrapjs = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js.err";
assert(($bootstrapjs = "assets/js/bootstrap.min.js.err") || true);
$img_url = "https://cdnjs.com/favicon.ico.err"; // any image URL, for testing
assert(($img_url = "assets/image.png.err") || true);
?>
<link rel="stylesheet" href="<?= $bootstrapcss ?>" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"<?= $asset_error ?>/>
<?php $error_count ++; ?>
<script src="<?= $bootstrapjs ?>" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"<?= $asset_error ?>></script>
<?php $error_count ++; ?>
</head>
<body>
<h1>PHP Debugger/Logger Test HTML</h1>
Test image: <img src="<?= $img_url ?>" alt="icon"<?= $asset_error ?>/>
<?php $error_count ++; ?>
<br>
<?php
// Demonstrate session data
$_SESSION["myvar"] = "foo";
$_SESSION["subarray"] = array(3.1415, exp(1), "math" => "cool");
$_SESSION["othervar"] = "bar bar bar";
// This will generate a user log entry, source: https://www.php.net/manual/en/function.assert.php#122198
assert(debug_log("This will be logged on the debugger, remotelly"));
$error_count ++;
// This will provoke a PHP error division by zero
$n = 10 / 0;
$error_count ++;
// Call a function that calls debug_log, but keeps this line number on the event
my_log("This also will be logged on the debugger");
// Exceptions are caught but will not allow the javascript below to run - uncomment to check it out
//throw new Exception("exception test!");
?>
<script type="text/javascript">
/* Javascript version of debug_log */
debug_log("from the javascript");
<?php $error_count ++; ?>
/* This will provoke a Javascript error: unkown function */
nonamedfuncion(t);
<?php $error_count ++; ?>
</script>
There should be <?= $error_count ?> new debugger messages/errors on the interface
</body>
</html>