PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.4.3
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.4.3
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.4.3, at lib/menu_log.php

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