PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / trunk
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar vtrunk
2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 2.0.22 All 55 releases
booking-manager / core / wpbm-debug.php

wpbm-debug.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar trunk, at core/wpbm-debug.php

255 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.1
4 * @package Any
5 * @category Dubug info showing
6 * @author wpdevelop
7 *
8 * @web-site https://oplugins.com/
9 * @email info@oplugins.com
10 *
11 * @modified 09.09.2015
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16
17
18 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19 // D e b u g f u n c t i o n s ///////////////////////////////////////////////////////////////////////////////////////////////////
20 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
21
22 /** Show values of the arguments list */
23 if ( ! function_exists( 'debuge' ) ) {
24 function debuge() {
25 $numargs = func_num_args();
26 $var = func_get_args();
27 $makeexit = is_bool( $var[count($var)-1] ) ? $var[ count($var) - 1 ]:false;
28 echo "<div><pre class='prettyprint linenums'>";
29 //print_r($var);
30 foreach ( $var as $ind => $item ) {
31
32 echo "\n<strong> [$ind] " . gettype( $item ) . "</strong>\n";
33
34 if ( 'string' === gettype( $item ) ) {
35 echo( htmlentities( $item ) );
36 } else {
37 print_r( $item );
38 }
39 }
40 echo "</pre></div>";
41 echo '<script type="text/javascript"> jQuery(".ajax_respond_insert, .ajax_respond").show(); </script>';
42 if ( $makeexit ) {
43 echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>';
44 exit;
45 }
46 }
47 }
48
49 /** Show Speed of the execution and number of queries. */
50 if ( ! function_exists( 'debuge_speed' ) ) {
51 function debuge_speed() {
52 echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>';
53 }
54 }
55
56 /** Show error info
57 */
58 if ( ! function_exists( 'debuge_error' ) ) {
59 function debuge_error( $msg , $file_name='', $line_num=''){
60 echo get_debuge_error( $msg , $file_name , $line_num );
61 }
62 }
63
64 if ( ! function_exists( 'get_debuge_error' ) ) {
65 function get_debuge_error( $msg , $file_name='', $line_num=''){
66
67 $ver_num = ( ! defined('WPBM_VERSION') ) ? '' : '|V:' . WPBM_VERSION ;
68
69 $last_db_error = '';
70 global $EZSQL_ERROR;
71
72 //FixIn: 2.0.31.1
73 if (
74 ( ! empty( $EZSQL_ERROR ) )
75 && ( is_array( $EZSQL_ERROR ) )
76 && ( isset( $EZSQL_ERROR[ ( count( $EZSQL_ERROR ) - 1 ) ] ) )
77 ){
78
79 $last_db_error2 = $EZSQL_ERROR[ (count($EZSQL_ERROR)-1)];
80
81 if ( (isset($last_db_error2['query'])) && (isset($last_db_error2['error_str'])) ) {
82
83 $str = str_replace( array( '"', "'" ), '', $last_db_error2['error_str'] );
84 $query = str_replace( array( '"', "'" ), '', $last_db_error2['query'] );
85
86 $str = htmlspecialchars( $str, ENT_QUOTES );
87 $query = htmlspecialchars( $query , ENT_QUOTES );
88
89 $last_db_error = $str ;
90 $last_db_error .= '::<span style="color:#300;">'.$query.'</span>';
91 }
92 }
93 return $msg . '<br /><span style="font-size:11px;"> ['
94 . 'F:' . str_replace( dirname( $file_name ) , '' , $file_name )
95 . '| L:' . $line_num
96 . $ver_num
97 . '| DB:' . $last_db_error
98 . '] </span>' ;
99 }
100 }
101
102 /** Usage: if ( function_exists ('wpbm_check_post_key_max_number')) { wpbm_check_post_key_max_number(); } */
103 if ( ! function_exists( 'wpbm_check_post_key_max_number' ) ) {
104 function wpbm_check_post_key_max_number() {
105
106 /*
107 $post_max_totalname_length = intval( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : '9999999' );
108 $request_max_totalname_length = intval( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : '9999999' );
109 $post_max_name_length = intval( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : '9999999' );
110 $request_max_varname_length = intval( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : '9999999' );
111 */
112 $php_ini_vars = array(
113 'suhosin.post.max_totalname_length'
114 , 'suhosin.request.max_totalname_length'
115 , 'suhosin.post.max_name_length'
116 , 'suhosin.request.max_varname_length'
117 );
118
119 foreach ( $_POST as $key_name => $post_value ) {
120
121 $key_length = strlen( $key_name );
122
123 foreach ( $php_ini_vars as $php_ini_var ) {
124
125 $php_ini_var_length = intval( ( ini_get( $php_ini_var ) ) ? ini_get( $php_ini_var ) : '9999999' );
126
127 if ( $key_length > $php_ini_var_length ) {
128
129 wpbm_show_message_in_settings( 'Your php.ini configuration limited to '
130 . '<strong> '. $php_ini_var . ' = ' . $php_ini_var_length . '</strong>.'
131 . ' '
132 . 'Plugin require at least ' . ( intval( $key_length ) + 1 ). ', '
133 . 'for saving option: ' . '<strong>'. $key_name . '</strong>'
134 , 'error'
135 , __('Error' , 'booking-manager') . '.' );
136
137 }
138 }
139 }
140 }
141 }
142
143
144 /** Write debuge log to file ../wp-content/upload/wpbm_debug.log
145 *
146 * @param type $param
147 */
148 if ( ! function_exists( 'debuge_log' ) ) {
149 function debuge_log( $param ) {
150
151
152 $content = "\n---\n"
153 . 'Log: [' . date_i18n( 'Y-m-d H:m:s' ) . ']'
154 . "\n---\n"
155 . str_replace( ',', "\n,", json_encode( $param ) );
156
157
158 // Install files and folders for uploading files and prevent hotlinking
159 $upload_dir = wp_upload_dir();
160
161 $files = array(
162 array(
163 'base' => $upload_dir['basedir'],
164 'file' => 'wpbm_debug.log',
165 'content' => $content
166
167 )
168 );
169
170 foreach ( $files as $file ) {
171
172 if ( ( wp_mkdir_p( $file['base'] ) ) // Recursive directory creation based on full path.
173 //&& ( ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) // If file not exist
174 ) {
175
176 // Append new lines to bottom (if we need to rewrite, then use 'w'
177 if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'a' ) ) {
178
179 fwrite( $file_handle, $file['content'] );
180 fclose( $file_handle );
181 }
182 }
183 }
184
185 }
186 }
187
188
189
190 /** Show System debug log for Beta features.
191 *
192 * @param mixed $show_debug_info
193 *
194 * Example of usage:
195 *
196 $is_show_debug_info = ( ( get_bk_option( 'booking_is_show_system_debug_log' ) == 'On' ) ? true : false );
197 if ( $is_show_debug_info )
198 add_action( 'wpbm_show_debug', 'wpbm_start_showing_debug', 10, 1 );
199 ...
200 //-
201 do_action( 'wpbm_show_debug', array( 'after import' , $ics_array) );
202 ...
203 if ( $is_show_debug_info )
204 remove_action( 'wpbm_show_debug', 'wpbm_start_showing_debug', 10 );
205 */
206 function wpbm_start_showing_debug( $show_debug_info ) { //FixIn: 7.2.1.15
207
208 // Make first item as header - bold
209 if ( is_array( $show_debug_info ) )
210 $show_debug_info[0] = '<strong>' . $show_debug_info[0] . '</strong>';
211
212 // Get evrything in human redable view
213 $show_debug_info = print_r ( $show_debug_info, true );
214
215 // Remove unnecesary new lines
216 $show_debug_info = preg_replace( '/Array[\n\r\s]*\(/', 'array(', $show_debug_info );
217 $show_debug_info = preg_replace( '/\)\n/', ")", $show_debug_info );
218
219 // Show
220 echo "<div><pre class='prettyprint linenums'>";
221
222 echo( $show_debug_info );
223
224 echo "</pre></div>";
225
226 echo '<hr/>';
227
228 // For system debug log in Ajax request show it
229 ?><script type="text/javascript"> jQuery( '.wpbm_system_info_log' ).show(); </script><?php
230 }
231
232
233 /** Show Top Notice in Admin panel by writing in-line JS
234 *
235 * @param string $message
236 * @param string $message_type - (default notice) notice | error | warning | info | success
237 * @param int $seconds_to_show - (default 3000) - delay in microseconds
238 * @param bool $is_append - (default true) - append notice instead of replacing
239 */
240 function wpbm_admin_show_top_notice( $message, $message_type = 'info', $seconds_to_show = 3000, $is_append = true ) {
241
242 if ( ! is_admin() ) return;
243
244 // Show Notice in Admin header
245 ?><script type="text/javascript">
246 wpbm_admin_show_message( '<?php echo html_entity_decode( esc_js( $message ), ENT_QUOTES ); ?>'
247 , '<?php echo $message_type; ?>'
248 , <?php echo intval( $seconds_to_show ); ?>
249 , <?php echo ( $is_append ? 'true' : 'false' ); ?>
250 );
251 </script><?php
252 }
253 add_action( 'wpbm_admin_show_top_notice', 'wpbm_admin_show_top_notice', 10, 3 );
254
255