PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0
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 2.0, at core/wpbm-debug.php

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