PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.7.1
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.7.1
1.9.5 1.9.4 1.9.3 trunk 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 All 40 releases
code-profiler / lib / menu_log.php

menu_log.php in Code Profiler – WordPress Performance Profiling and Debugging Made Easy 1.7.1, at lib/menu_log.php

146 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +=====================================================================+
4 | ____ _ ____ __ _ _ |
5 | / ___|___ __| | ___ | _ \ _ __ ___ / _(_) | ___ _ __ |
6 | | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| |
7 | | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | |
8 | \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| |
9 | |
10 | (c) Jerome Bruandet ~ https://nintechnet.com/codeprofiler/ |
11 +=====================================================================+
12 */
13
14 if (! defined('ABSPATH') ) {
15 die('Forbidden');
16 }
17
18 // =====================================================================
19 // Display the profiler's log.
20
21 // Delete the log?
22 if (! empty( $_POST['cp-delete-log'] ) ) {
23 if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log') ) {
24 printf(
25 CODE_PROFILER_ERROR_NOTICE,
26 esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler')
27 );
28
29 } else {
30 $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n");
31 if ( $res !== false ) {
32 printf(
33 CODE_PROFILER_UPDATE_NOTICE,
34 esc_html__('The log was deleted.', 'code-profiler')
35 );
36 } else {
37 printf(
38 CODE_PROFILER_ERROR_NOTICE,
39 esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler')
40 );
41 }
42 }
43 }
44 ?>
45 <script>
46 'use strict';
47 var cplog_array = new Array();
48 <?php
49 $info = 0; $warn = 0; $error = 0; $debug = 0; $logline = '';
50 if ( file_exists( CODE_PROFILER_LOG ) ) {
51
52 $lines = array();
53 $lines = file( CODE_PROFILER_LOG, FILE_SKIP_EMPTY_LINES );
54 $i = 0;
55 $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR', 8 => 'DEBUG');
56 foreach( $lines as $line ) {
57 if ( $line[0] == '<') { continue; }
58 list( $date, $level, $string ) = explode('~~', $line, 3 );
59 if (! isset( $facility[$level] ) ) {
60 continue;
61 }
62 $date = date('d-M-y H:i:s', $date );
63 echo 'cplog_array[' . $i . '] = "' .
64 rawurlencode( "$level~~$date {$facility[$level]} $string" ) ."\";\n";
65 ++$i;
66 if ( $level == 1 ) {
67 $info = 1;
68 } elseif ( $level == 2 ) {
69 $warn = 1;
70 } elseif ( $level == 4 ) {
71 $error = 1;
72 } elseif ( $level == 8 ) {
73 $debug = 1;
74 continue;
75 }
76 $logline .= "$date {$facility[$level]} $string";
77 }
78 }
79 ?>
80 </script>
81 <?php
82
83 if ( defined('CODE_PROFILER_TEXTAREA_HEIGHT') ) {
84 $th = (int) CODE_PROFILER_TEXTAREA_HEIGHT;
85 } else {
86 $th = '450';
87 }
88
89 echo code_profiler_display_tabs( 4 );
90 ?>
91 <form name="cplogform" method="post">
92 <table class="form-table">
93 <tr>
94 <td width="100%">
95 <textarea dir="auto" name="cptxtlog" class="large-text code" style="height:<?php echo (int)$th; ?>px;" wrap="off" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><?php
96 if (! empty( $logline ) ) {
97 echo esc_textarea( $logline );
98 $disabled = '';
99 } else {
100 echo "\n\n > " . esc_html__("Code Profiler's log is empty.", 'code-profiler');
101 $disabled = ' disabled';
102 }
103 if (! $error ) {
104 $error_checked = '';
105 } else {
106 $error_checked = ' checked';
107 }
108 if (! $warn ) {
109 $warn_checked = '';
110 } else {
111 $warn_checked = ' checked';
112 }
113 ?></textarea>
114 <p style="text-align:center">
115 <label for="cxinfo">
116 <input id="cxinfo" type="checkbox" name="info" checked="checked"<?php disabled( $info, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
117 <span style="display: inline-block"><?php esc_html_e('Info', 'code-profiler') ?></span>&nbsp;
118 </label>
119 &nbsp;&nbsp;&nbsp;&nbsp;
120 <label for="cxwarn">
121 <input id="cxwarn" type="checkbox" name="warn"<?php echo $warn_checked ?><?php disabled( $warn, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
122 <span style="display: inline-block"><?php esc_html_e('Warning', 'code-profiler') ?></span>&nbsp;
123 </label>
124 &nbsp;&nbsp;&nbsp;&nbsp;
125 <label for="cxerror">
126 <input id="cxerror" type="checkbox" name="error"<?php echo $error_checked ?><?php disabled( $error, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
127 <span style="display: inline-block"><?php esc_html_e('Error', 'code-profiler') ?></span>&nbsp;
128 </label>
129 &nbsp;&nbsp;&nbsp;&nbsp;
130 <label for="cxdebug">
131 <input id="cxdebug" type="checkbox" name="debug"<?php disabled( $debug, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
132 <span style="display: inline-block"><?php esc_html_e('Debug', 'code-profiler') ?></span>&nbsp;
133 </label>
134 </p>
135 <input type="submit" onclick="return cpjs_delete_log();" name="cp-delete-log" class="button button-primary" value="<?php esc_attr_e('Delete log', 'code-profiler') ?>"<?php disabled( $logline, '') ?> />
136 <?php wp_nonce_field('cp_delete_log', 'cp_nonce', 0); ?>
137 <p class="description"><?php esc_html_e('The log is deleted automatically when it reaches 100KB.', 'code-profiler') ?></p>
138 </td>
139 </tr>
140 </table>
141 </form>
142 <?php
143
144 // =====================================================================
145 // EOF
146