SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | if (extension_loaded('xhprof')) { | |
3 | - | if($_GET['_xhprof_xhr_'] == 1){ |
3 | + | if(isset($_GET['_xhprof_xhr_']) && $_GET['_xhprof_xhr_'] == 1){ |
4 | ||
5 | if(!session_id()){ | |
6 | session_start(); | |
7 | } | |
8 | ||
9 | if($_GET['doclear'] == 1){ | |
10 | unset($_SESSION['_xhprof_']); | |
11 | $_SESSION['_xhprof_'] = array(); | |
12 | echo 'xhprof session buffer cleared..\n'; | |
13 | $dir = '/var/tmp/xhprof'; | |
14 | $fp = opendir($dir); | |
15 | if ( $fp ) { | |
16 | while ($f = readdir($fp)) { | |
17 | $file = $dir . "/" . $f; | |
18 | if ($f == "." || $f == "..") { | |
19 | continue; | |
20 | } | |
21 | else if (is_dir($file) && !is_link($file)) { | |
22 | rrmdir($file); | |
23 | } | |
24 | else { | |
25 | unlink($file); | |
26 | } | |
27 | } | |
28 | closedir($fp); | |
29 | rmdir($dir); | |
30 | } | |
31 | echo 'xhprof files cleared..\n'; | |
32 | exit(); | |
33 | } | |
34 | rsort($_SESSION['_xhprof_']); | |
35 | echo json_encode($_SESSION['_xhprof_']); | |
36 | exit(); | |
37 | } | |
38 | else{ | |
39 | include_once '/usr/share/php/xhprof_lib/utils/xhprof_lib.php'; | |
40 | include_once '/usr/share/php/xhprof_lib/utils/xhprof_runs.php'; | |
41 | xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); | |
42 | } | |
43 | } | |
44 | ?> |