PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.22
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.22
2.1.22 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 All 56 releases
booking-manager / core / wpbm-debug.php

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

249 lines 9.4 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 [email protected]
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 if (isset($EZSQL_ERROR[ (count($EZSQL_ERROR)-1)])) {
72
73 $last_db_error2 = $EZSQL_ERROR[ (count($EZSQL_ERROR)-1)];
74
75 if ( (isset($last_db_error2['query'])) && (isset($last_db_error2['error_str'])) ) {
76
77 $str = str_replace( array( '"', "'" ), '', $last_db_error2['error_str'] );
78 $query = str_replace( array( '"', "'" ), '', $last_db_error2['query'] );
79
80 $str = htmlspecialchars( $str, ENT_QUOTES );
81 $query = htmlspecialchars( $query , ENT_QUOTES );
82
83 $last_db_error = $str ;
84 $last_db_error .= '::<span style="color:#300;">'.$query.'</span>';
85 }
86 }
87 return $msg . '<br /><span style="font-size:11px;"> ['
88 . 'F:' . str_replace( dirname( $file_name ) , '' , $file_name )
89 . '| L:' . $line_num
90 . $ver_num
91 . '| DB:' . $last_db_error
92 . '] </span>' ;
93 }
94 }
95
96 /** Usage: if ( function_exists ('wpbm_check_post_key_max_number')) { wpbm_check_post_key_max_number(); } */
97 if ( ! function_exists( 'wpbm_check_post_key_max_number' ) ) {
98 function wpbm_check_post_key_max_number() {
99
100 /*
101 $post_max_totalname_length = intval( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : '9999999' );
102 $request_max_totalname_length = intval( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : '9999999' );
103 $post_max_name_length = intval( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : '9999999' );
104 $request_max_varname_length = intval( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : '9999999' );
105 */
106 $php_ini_vars = array(
107 'suhosin.post.max_totalname_length'
108 , 'suhosin.request.max_totalname_length'
109 , 'suhosin.post.max_name_length'
110 , 'suhosin.request.max_varname_length'
111 );
112
113 foreach ( $_POST as $key_name => $post_value ) {
114
115 $key_length = strlen( $key_name );
116
117 foreach ( $php_ini_vars as $php_ini_var ) {
118
119 $php_ini_var_length = intval( ( ini_get( $php_ini_var ) ) ? ini_get( $php_ini_var ) : '9999999' );
120
121 if ( $key_length > $php_ini_var_length ) {
122
123 wpbm_show_message_in_settings( 'Your php.ini configuration limited to '
124 . '<strong> '. $php_ini_var . ' = ' . $php_ini_var_length . '</strong>.'
125 . ' '
126 . 'Plugin require at least ' . ( intval( $key_length ) + 1 ). ', '
127 . 'for saving option: ' . '<strong>'. $key_name . '</strong>'
128 , 'error'
129 , __('Error' , 'booking-manager') . '.' );
130
131 }
132 }
133 }
134 }
135 }
136
137
138 /** Write debuge log to file ../wp-content/upload/wpbm_debug.log
139 *
140 * @param type $param
141 */
142 if ( ! function_exists( 'debuge_log' ) ) {
143 function debuge_log( $param ) {
144
145
146 $content = "\n---\n"
147 . 'Log: [' . date_i18n( 'Y-m-d H:m:s' ) . ']'
148 . "\n---\n"
149 . str_replace( ',', "\n,", json_encode( $param ) );
150
151
152 // Install files and folders for uploading files and prevent hotlinking
153 $upload_dir = wp_upload_dir();
154
155 $files = array(
156 array(
157 'base' => $upload_dir['basedir'],
158 'file' => 'wpbm_debug.log',
159 'content' => $content
160
161 )
162 );
163
164 foreach ( $files as $file ) {
165
166 if ( ( wp_mkdir_p( $file['base'] ) ) // Recursive directory creation based on full path.
167 //&& ( ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) // If file not exist
168 ) {
169
170 // Append new lines to bottom (if we need to rewrite, then use 'w'
171 if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'a' ) ) {
172
173 fwrite( $file_handle, $file['content'] );
174 fclose( $file_handle );
175 }
176 }
177 }
178
179 }
180 }
181
182
183
184 /** Show System debug log for Beta features.
185 *
186 * @param mixed $show_debug_info
187 *
188 * Example of usage:
189 *
190 $is_show_debug_info = ( ( get_bk_option( 'booking_is_show_system_debug_log' ) == 'On' ) ? true : false );
191 if ( $is_show_debug_info )
192 add_action( 'wpbm_show_debug', 'wpbm_start_showing_debug', 10, 1 );
193 ...
194 //-
195 do_action( 'wpbm_show_debug', array( 'after import' , $ics_array) );
196 ...
197 if ( $is_show_debug_info )
198 remove_action( 'wpbm_show_debug', 'wpbm_start_showing_debug', 10 );
199 */
200 function wpbm_start_showing_debug( $show_debug_info ) { //FixIn: 7.2.1.15
201
202 // Make first item as header - bold
203 if ( is_array( $show_debug_info ) )
204 $show_debug_info[0] = '<strong>' . $show_debug_info[0] . '</strong>';
205
206 // Get evrything in human redable view
207 $show_debug_info = print_r ( $show_debug_info, true );
208
209 // Remove unnecesary new lines
210 $show_debug_info = preg_replace( '/Array[\n\r\s]*\(/', 'array(', $show_debug_info );
211 $show_debug_info = preg_replace( '/\)\n/', ")", $show_debug_info );
212
213 // Show
214 echo "<div><pre class='prettyprint linenums'>";
215
216 echo( $show_debug_info );
217
218 echo "</pre></div>";
219
220 echo '<hr/>';
221
222 // For system debug log in Ajax request show it
223 ?><script type="text/javascript"> jQuery( '.wpbm_system_info_log' ).show(); </script><?php
224 }
225
226
227 /** Show Top Notice in Admin panel by writing in-line JS
228 *
229 * @param string $message
230 * @param string $message_type - (default notice) notice | error | warning | info | success
231 * @param int $seconds_to_show - (default 3000) - delay in microseconds
232 * @param bool $is_append - (default true) - append notice instead of replacing
233 */
234 function wpbm_admin_show_top_notice( $message, $message_type = 'info', $seconds_to_show = 3000, $is_append = true ) {
235
236 if ( ! is_admin() ) return;
237
238 // Show Notice in Admin header
239 ?><script type="text/javascript">
240 wpbm_admin_show_message( '<?php echo html_entity_decode( esc_js( $message ), ENT_QUOTES ); ?>'
241 , '<?php echo $message_type; ?>'
242 , <?php echo intval( $seconds_to_show ); ?>
243 , <?php echo ( $is_append ? 'true' : 'false' ); ?>
244 );
245 </script><?php
246 }
247 add_action( 'wpbm_admin_show_top_notice', 'wpbm_admin_show_top_notice', 10, 3 );
248
249