| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | * @subpackage Support Functions |
| 6 | 6 | * @category Functions |
| 7 | 7 | * |
| 8 | 8 | * @author wpdevelop |
| 9 | - * @link http://oplugins.com/ | |
| 9 | + * @link https://oplugins.com/ | |
| 10 | 10 | * @email info@oplugins.com |
| 11 | 11 | * |
| 12 | 12 | * @modified 29.09.2015 |
| 13 | 13 | */ |
| @@ -61,9 +61,9 @@ | ||
| 61 | 61 | function wpbm_up_link() { |
| 62 | 62 | if ( ! wpbm_is_this_demo() ) |
| 63 | 63 | $v = wpbm_get_ver_sufix(); |
| 64 | 64 | else $v = ''; |
| 65 | - return 'http://oplugins.com/plugins/booking-manager/' . ( ( empty($v) ) ? '' : 'upgrade-' . $v . '/' ) ; | |
| 65 | + return 'https://oplugins.com/plugins/booking-manager/' . ( ( empty($v) ) ? '' : 'upgrade-' . $v . '/' ) ; | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** Check if this demo website |
| 69 | 69 | * |
| @@ -71,10 +71,10 @@ | ||
| 71 | 71 | */ |
| 72 | 72 | function wpbm_is_this_demo() { |
| 73 | 73 | //return ! true; //TODO: comment it. 2016-09-27 // Replaced! |
| 74 | 74 | if ( |
| 75 | - ( ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'oplugins.com' ) !== false ) ) | |
| 76 | - || ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( strpos( $_SERVER['HTTP_HOST'], 'oplugins.com' ) !== false ) ) | |
| 75 | + ( ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) && ( strpos( sanitize_text_field( wp_unslash($_SERVER['SCRIPT_FILENAME']) ), 'oplugins.com' ) !== false ) ) | |
| 76 | + || ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( strpos( sanitize_text_field( wp_unslash($_SERVER['HTTP_HOST'])), 'oplugins.com' ) !== false ) ) | |
| 77 | 77 | ) |
| 78 | 78 | return true; |
| 79 | 79 | else |
| 80 | 80 | return false; |
| @@ -89,191 +89,9 @@ | ||
| 89 | 89 | /** Show System Info (status) at item > Settings General page |
| 90 | 90 | * Link: http://server.com/wp-admin/admin.php?page=wpbm-settings&system_info=show#wpbm_general_settings_system_info_metabox |
| 91 | 91 | */ |
| 92 | 92 | function wpbm_system_info() { |
| 93 | - | |
| 94 | - if ( wpbm_is_this_demo() ) return; | |
| 95 | - | |
| 96 | - if ( current_user_can( 'activate_plugins' ) ) { // Only for Administrator or Super admin. More here: https://codex.wordpress.org/Roles_and_Capabilities | |
| 97 | - | |
| 98 | - global $wpdb, $wp_version; | |
| 99 | - | |
| 100 | - $all_plugins = get_plugins(); | |
| 101 | - $active_plugins = get_option( 'active_plugins' ); | |
| 102 | - | |
| 103 | - $mysql_info = $wpdb->get_results( "SHOW VARIABLES LIKE 'sql_mode'" ); | |
| 104 | - if ( is_array( $mysql_info ) ) $sql_mode = $mysql_info[0]->Value; | |
| 105 | - if ( empty( $sql_mode ) ) $sql_mode = 'Not set'; | |
| 106 | - | |
| 107 | - $safe_mode = ( ini_get( 'safe_mode' ) ) ? 'On' : 'Off'; | |
| 108 | - $allow_url_fopen = ( ini_get( 'allow_url_fopen' ) ) ? 'On' : 'Off'; | |
| 109 | - $upload_max_filesize = ( ini_get( 'upload_max_filesize' ) ) ? ini_get( 'upload_max_filesize' ) : 'N/A'; | |
| 110 | - $post_max_size = ( ini_get( 'post_max_size' ) ) ? ini_get( 'post_max_size' ) : 'N/A'; | |
| 111 | - $max_execution_time = ( ini_get( 'max_execution_time' ) ) ? ini_get( 'max_execution_time' ) : 'N/A'; | |
| 112 | - $memory_limit = ( ini_get( 'memory_limit' ) ) ? ini_get( 'memory_limit' ) : 'N/A'; | |
| 113 | - $memory_usage = ( function_exists( 'memory_get_usage' ) ) ? round( memory_get_usage() / 1024 / 1024, 2 ) . ' Mb' : 'N/A'; | |
| 114 | - $exif_read_data = ( is_callable( 'exif_read_data' ) ) ? 'Yes' . " ( V" . substr( phpversion( 'exif' ), 0, 4 ) . ")" : 'No'; | |
| 115 | - $iptcparse = ( is_callable( 'iptcparse' ) ) ? 'Yes' : 'No'; | |
| 116 | - $xml_parser_create = ( is_callable( 'xml_parser_create' ) ) ? 'Yes' : 'No'; | |
| 117 | - $theme = ( function_exists( 'wp_get_theme' ) ) ? wp_get_theme() : get_theme( get_current_theme() ); | |
| 118 | - | |
| 119 | - if ( function_exists( 'is_multisite' ) ) { | |
| 120 | - if ( is_multisite() ) $multisite = 'Yes'; | |
| 121 | - else $multisite = 'No'; | |
| 122 | - } else { $multisite = 'N/A'; | |
| 123 | - } | |
| 124 | - | |
| 125 | - $system_info = array( | |
| 126 | - 'system_info' => '', | |
| 127 | - 'php_info' => '', | |
| 128 | - 'active_plugins' => '', | |
| 129 | - 'inactive_plugins' => '' | |
| 130 | - ); | |
| 131 | - | |
| 132 | - $ver_small_name = get_wpbm_version(); | |
| 133 | - if ( class_exists( 'wpbm_multiuser' ) ) $ver_small_name = 'multiuser'; | |
| 134 | - | |
| 135 | - $system_info['system_info'] = array( | |
| 136 | - 'Plugin Update' => ( defined( 'WPBM_VERSION' ) ) ? WPBM_VERSION : 'N/A', | |
| 137 | - 'Plugin Version' => ucwords( $ver_small_name ), | |
| 138 | - 'Plugin Update Date' => date( "Y-m-d", filemtime( WPBM_FILE ) ), | |
| 139 | - | |
| 140 | - 'WP Version' => $wp_version, | |
| 141 | - 'WP DEBUG' => ( ( defined('WP_DEBUG') ) && ( WP_DEBUG ) ) ? 'On' : 'Off', | |
| 142 | - 'WP DB Version' => get_option( 'db_version' ), | |
| 143 | - 'Operating System' => PHP_OS, | |
| 144 | - 'Server' => $_SERVER["SERVER_SOFTWARE"], | |
| 145 | - 'PHP Version' => PHP_VERSION, | |
| 146 | - 'PHP Safe Mode' => $safe_mode, | |
| 147 | - 'MYSQL Version' => $wpdb->get_var( "SELECT VERSION() AS version" ), | |
| 148 | - 'SQL Mode' => $sql_mode, | |
| 149 | - 'Memory usage' => $memory_usage, | |
| 150 | - 'Site URL' => get_option( 'siteurl' ), | |
| 151 | - 'Home URL' => home_url(), | |
| 152 | - 'SERVER[HTTP_HOST]' => $_SERVER['HTTP_HOST'], | |
| 153 | - 'SERVER[SERVER_NAME]' => $_SERVER['SERVER_NAME'], | |
| 154 | - 'Multisite' => $multisite, | |
| 155 | - 'Active Theme' => $theme['Name'] . ' ' . $theme['Version'] | |
| 156 | - ); | |
| 157 | - | |
| 158 | - $system_info['php_info'] = array( | |
| 159 | - 'PHP Version' => PHP_VERSION, | |
| 160 | - 'PHP Safe Mode' => $safe_mode, | |
| 161 | - 'PHP Memory Limit' => '<strong>' . $memory_limit . '</strong>', | |
| 162 | - 'PHP Max Script Execute Time' => '<strong>' . $max_execution_time . '</strong>', | |
| 163 | - | |
| 164 | - 'PHP Max Post Size' => '<strong>' . $post_max_size . '</strong>', | |
| 165 | - 'PHP MAX Input Vars' => '<strong>' . ( ( ini_get( 'max_input_vars' ) ) ? ini_get( 'max_input_vars' ) : 'N/A' ) . '</strong>', //How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). | |
| 166 | - | |
| 167 | - 'PHP Max Upload Size' => $upload_max_filesize, | |
| 168 | - 'PHP Allow URL fopen' => $allow_url_fopen, | |
| 169 | - 'PHP Exif support' => $exif_read_data, | |
| 170 | - 'PHP IPTC support' => $iptcparse, | |
| 171 | - 'PHP XML support' => $xml_parser_create | |
| 172 | - ); | |
| 173 | - | |
| 174 | - $system_info['php_info']['PHP cURL'] = ( function_exists('curl_init') ) ? 'On' : 'Off'; | |
| 175 | - $system_info['php_info']['Max Nesting Level'] = ( ( ini_get( 'max_input_nesting_level' ) ) ? ini_get( 'max_input_nesting_level' ) : 'N/A' ); | |
| 176 | - $system_info['php_info']['Max Time 4 script'] = ( ( ini_get( 'max_input_time' ) ) ? ini_get( 'max_input_time' ) : 'N/A' ); //Maximum amount of time each script may spend parsing request data | |
| 177 | - $system_info['php_info']['Log'] = ( ( ini_get( 'error_log' ) ) ? ini_get( 'error_log' ) : 'N/A' ); | |
| 178 | - | |
| 179 | - if ( ini_get( "suhosin.get.max_value_length" ) ) { | |
| 180 | - | |
| 181 | - $system_info['suhosin_info'] = array(); | |
| 182 | - $system_info['suhosin_info']['POST max_array_index_length'] = ( ( ini_get( 'suhosin.post.max_array_index_length' ) ) ? ini_get( 'suhosin.post.max_array_index_length' ) : 'N/A' ); | |
| 183 | - $system_info['suhosin_info']['REQUEST max_array_index_length'] = ( ( ini_get( 'suhosin.request.max_array_index_length' ) ) ? ini_get( 'suhosin.request.max_array_index_length' ) : 'N/A' ); | |
| 184 | - | |
| 185 | - $system_info['suhosin_info']['POST max_totalname_length'] = ( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : 'N/A' ); | |
| 186 | - $system_info['suhosin_info']['REQUEST max_totalname_length'] = ( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : 'N/A' ); | |
| 187 | - | |
| 188 | - $system_info['suhosin_info']['POST max_vars'] = ( ( ini_get( 'suhosin.post.max_vars' ) ) ? ini_get( 'suhosin.post.max_vars' ) : 'N/A' ); | |
| 189 | - $system_info['suhosin_info']['REQUEST max_vars'] = ( ( ini_get( 'suhosin.request.max_vars' ) ) ? ini_get( 'suhosin.request.max_vars' ) : 'N/A' ); | |
| 190 | - | |
| 191 | - $system_info['suhosin_info']['POST max_value_length'] = ( ( ini_get( 'suhosin.post.max_value_length' ) ) ? ini_get( 'suhosin.post.max_value_length' ) : 'N/A' ); | |
| 192 | - $system_info['suhosin_info']['REQUEST max_value_length'] = ( ( ini_get( 'suhosin.request.max_value_length' ) ) ? ini_get( 'suhosin.request.max_value_length' ) : 'N/A' ); | |
| 193 | - | |
| 194 | - $system_info['suhosin_info']['POST max_name_length'] = ( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : 'N/A' ); | |
| 195 | - $system_info['suhosin_info']['REQUEST max_varname_length'] = ( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : 'N/A' ); | |
| 196 | - | |
| 197 | - $system_info['suhosin_info']['POST max_array_depth'] = ( ( ini_get( 'suhosin.post.max_array_depth' ) ) ? ini_get( 'suhosin.post.max_array_depth' ) : 'N/A' ); | |
| 198 | - $system_info['suhosin_info']['REQUEST max_array_depth'] = ( ( ini_get( 'suhosin.request.max_array_depth' ) ) ? ini_get( 'suhosin.request.max_array_depth' ) : 'N/A' ); | |
| 199 | - } | |
| 200 | - | |
| 201 | - | |
| 202 | - if ( function_exists('gd_info') ) { | |
| 203 | - $gd_info = gd_info(); | |
| 204 | - if ( isset( $gd_info['GD Version'] ) ) | |
| 205 | - $gd_info = $gd_info['GD Version']; | |
| 206 | - else | |
| 207 | - $gd_info = json_encode( $gd_info ); | |
| 208 | - } else { | |
| 209 | - $gd_info = 'Off'; | |
| 210 | - } | |
| 211 | - $system_info['php_info']['PHP GD'] = $gd_info; | |
| 212 | - | |
| 213 | - // More here https://docs.woocommerce.com/document/problems-with-large-amounts-of-data-not-saving-variations-rates-etc/ | |
| 214 | - | |
| 215 | - | |
| 216 | - foreach ( $all_plugins as $path => $plugin ) { | |
| 217 | - if ( is_plugin_active( $path ) ) | |
| 218 | - $system_info['active_plugins'][$plugin['Name']] = $plugin['Version']; | |
| 219 | - else | |
| 220 | - $system_info['inactive_plugins'][$plugin['Name']] = $plugin['Version']; | |
| 221 | - } | |
| 222 | - | |
| 223 | - // Showing | |
| 224 | - foreach ( $system_info as $section_name => $section_values ) { | |
| 225 | - ?> | |
| 226 | - <span class="wpdevelop"> | |
| 227 | - <table class="table table-striped table-bordered"> | |
| 228 | - <thead><tr><th colspan="2" style="border-bottom: 1px solid #eeeeee;padding: 10px;"><?php echo strtoupper( $section_name ); ?></th></tr></thead> | |
| 229 | - <tbody> | |
| 230 | - <?php | |
| 231 | - if ( !empty( $section_values ) ) { | |
| 232 | - foreach ( $section_values as $key => $value ) { | |
| 233 | - ?> | |
| 234 | - <tr> | |
| 235 | - <td scope="row" style="width:18em;padding:4px 8px;"><?php echo $key; ?></td> | |
| 236 | - <td scope="row" style="padding:4px 8px;"><?php echo $value; ?></td> | |
| 237 | - </tr> | |
| 238 | - <?php | |
| 239 | - } | |
| 240 | - } | |
| 241 | - ?> | |
| 242 | - </tbody> | |
| 243 | - </table> | |
| 244 | - </span> | |
| 245 | - <div class="clear"></div> | |
| 246 | - <?php | |
| 247 | - } | |
| 248 | -?> | |
| 249 | -<hr> | |
| 250 | -<div style="color:#777;"> | |
| 251 | -<h4 style="font-size:1.1em;">Commonly required configuration vars in php.ini file:</h4> | |
| 252 | -<h4>General section:</h4> | |
| 253 | -<pre><code>memory_limit = 256M | |
| 254 | -max_execution_time = 120 | |
| 255 | -post_max_size = 8M | |
| 256 | -upload_max_filesize = 8M | |
| 257 | -max_input_vars = 20480 | |
| 258 | -post_max_size = 64M</code></pre> | |
| 259 | -<h4>Suhosin section (if installed):</h4> | |
| 260 | -<pre><code>suhosin.post.max_array_index_length = 1024 | |
| 261 | -suhosin.post.max_totalname_length = 65535 | |
| 262 | -suhosin.post.max_vars = 2048 | |
| 263 | -suhosin.post.max_value_length = 1000000 | |
| 264 | -suhosin.post.max_name_length = 256 | |
| 265 | -suhosin.post.max_array_depth = 1000 | |
| 266 | -suhosin.request.max_array_index_length = 1024 | |
| 267 | -suhosin.request.max_totalname_length = 65535 | |
| 268 | -suhosin.request.max_vars = 2048 | |
| 269 | -suhosin.request.max_value_length = 1000000 | |
| 270 | -suhosin.request.max_varname_length = 256 | |
| 271 | -suhosin.request.max_array_depth = 1000</code></pre> | |
| 272 | -</div> | |
| 273 | -<?php | |
| 274 | - // phpinfo(); | |
| 275 | - } | |
| 93 | + echo '---'; | |
| 276 | 94 | } |
| 277 | 95 | |
| 278 | 96 | |
| 279 | 97 | |
| @@ -296,9 +114,9 @@ | ||
| 296 | 114 | function wpbm_is_wpbc_supported() { |
| 297 | 115 | |
| 298 | 116 | // 7.2.1 - its start version of Booking Calendar which support integration with Booking Manager 2.0 |
| 299 | 117 | |
| 300 | - if ( version_compare( wpbm_get_wpbc_version(), '7.2.1') >= 0 ) { | |
| 118 | + if ( version_compare( wpbm_get_wpbc_version(), '9.8') >= 0 ) { | |
| 301 | 119 | return true; |
| 302 | 120 | } else { |
| 303 | 121 | return false; |
| 304 | 122 | } |
| @@ -431,9 +249,9 @@ | ||
| 431 | 249 | '', // Unknown/unhandled entities |
| 432 | 250 | ' ' // Runs of spaces, post-handling |
| 433 | 251 | ); |
| 434 | 252 | |
| 435 | - $newstring = preg_replace( $plain_search_array, $get_plain_replace_array, strip_tags( $string ) ); | |
| 253 | + $newstring = preg_replace( $plain_search_array, $get_plain_replace_array, wp_strip_all_tags( $string ) ); | |
| 436 | 254 | |
| 437 | 255 | return $newstring; |
| 438 | 256 | } |
| 439 | 257 | // </editor-fold> |
| @@ -462,8 +280,10 @@ | ||
| 462 | 280 | $replace = wp_parse_args( $replace_array, $defaults ); |
| 463 | 281 | |
| 464 | 282 | foreach ( $replace as $replace_shortcode => $replace_value ) { |
| 465 | 283 | |
| 284 | + $replace_value = esc_js( $replace_value ); // FixIn: | |
| 285 | + | |
| 466 | 286 | $subject = str_replace( array( '[' . $replace_shortcode . ']' |
| 467 | 287 | , '{' . $replace_shortcode . '}' ) |
| 468 | 288 | , $replace_value |
| 469 | 289 | , $subject ); |
| @@ -476,10 +296,50 @@ | ||
| 476 | 296 | |
| 477 | 297 | return $subject; |
| 478 | 298 | } |
| 479 | 299 | |
| 300 | + | |
| 301 | +/** | |
| 302 | + * Sanitize the frontend listing template. | |
| 303 | + * | |
| 304 | + * The listing template is stored as an option and rendered by the public | |
| 305 | + * [booking-manager-listing] shortcode, so script-capable markup must never be | |
| 306 | + * persisted or returned to visitors. | |
| 307 | + * | |
| 308 | + * @param string $template Template HTML with Booking Manager placeholders. | |
| 309 | + * @return string Safe template HTML. | |
| 310 | + */ | |
| 311 | +function wpbm_sanitize_listing_template( $template ) { | |
| 312 | + | |
| 313 | + if ( ! is_string( $template ) ) { | |
| 314 | + $template = ''; | |
| 315 | + } | |
| 316 | + | |
| 317 | + $allowed_html = wp_kses_allowed_html( 'post' ); | |
| 318 | + | |
| 319 | + // Keep compatibility with templates that embed safe external content. | |
| 320 | + $allowed_html['iframe'] = array( | |
| 321 | + 'src' => true | |
| 322 | + , 'style' => true | |
| 323 | + , 'id' => true | |
| 324 | + , 'class' => true | |
| 325 | + , 'width' => true | |
| 326 | + , 'height' => true | |
| 327 | + , 'title' => true | |
| 328 | + , 'loading' => true | |
| 329 | + , 'allowfullscreen' => true | |
| 330 | + ); | |
| 331 | + | |
| 332 | + if ( isset( $allowed_html['a'] ) ) { | |
| 333 | + $allowed_html['a']['target'] = true; | |
| 334 | + $allowed_html['a']['rel'] = true; | |
| 335 | + } | |
| 336 | + | |
| 337 | + return wp_kses( $template, $allowed_html ); | |
| 338 | +} | |
| 339 | + | |
| 480 | 340 | /** Simple hack to make array strings lowercase |
| 481 | - * | |
| 341 | + * | |
| 482 | 342 | * @param type $array |
| 483 | 343 | * @return type |
| 484 | 344 | */ |
| 485 | 345 | function wpbm_arraytolower( $array ){ |
| @@ -506,22 +366,22 @@ | ||
| 506 | 366 | } |
| 507 | 367 | } |
| 508 | 368 | |
| 509 | 369 | /** Check if this valid timestamp |
| 510 | - * | |
| 370 | + * | |
| 511 | 371 | * @param string|int $timestamp |
| 512 | 372 | * @return bool |
| 513 | 373 | */ |
| 514 | 374 | function wpbm_is_valid_timestamp( $timestamp ) { |
| 515 | - return ( ( (string) (int) $timestamp === $timestamp) | |
| 375 | + return ( ( (string) (int) $timestamp === $timestamp) | |
| 516 | 376 | && ($timestamp <= PHP_INT_MAX) |
| 517 | - && ($timestamp >= ~PHP_INT_MAX) | |
| 377 | + && ($timestamp >= ~PHP_INT_MAX) | |
| 518 | 378 | ); |
| 519 | 379 | } |
| 520 | 380 | // </editor-fold> |
| 521 | 381 | |
| 522 | - | |
| 523 | -// <editor-fold defaultstate="collapsed" desc=" F i l e s && U R L s " > | |
| 382 | + | |
| 383 | +// <editor-fold defaultstate="collapsed" desc=" F i l e s && U R L s " > | |
| 524 | 384 | //////////////////////////////////////////////////////////////////////////////// |
| 525 | 385 | // F i l e s && U R L s |
| 526 | 386 | //////////////////////////////////////////////////////////////////////////////// |
| 527 | 387 | |
| @@ -546,9 +406,9 @@ | ||
| 546 | 406 | return trailingslashit( WPBM_PLUGIN_URL ) . ltrim( $path, '/\\' ); |
| 547 | 407 | } |
| 548 | 408 | |
| 549 | 409 | /** Check if such file exist or not. |
| 550 | - * | |
| 410 | + * | |
| 551 | 411 | * @param string $path - relative path to file (relative to plugin folder). |
| 552 | 412 | * @return boolean true | false |
| 553 | 413 | */ |
| 554 | 414 | function wpbm_is_file_exist( $path ) { |
| @@ -554,14 +414,14 @@ | ||
| 554 | 414 | function wpbm_is_file_exist( $path ) { |
| 555 | 415 | |
| 556 | 416 | if ( file_exists( trailingslashit( WPBM_PLUGIN_DIR ) . ltrim( $path, '/\\' ) ) ) // check if this file exist |
| 557 | 417 | return true; |
| 558 | - else | |
| 418 | + else | |
| 559 | 419 | return false; |
| 560 | 420 | } |
| 561 | - | |
| 421 | + | |
| 562 | 422 | /** Set URL from absolute to relative (starting from /) |
| 563 | - * | |
| 423 | + * | |
| 564 | 424 | * @param type $url |
| 565 | 425 | * @return type |
| 566 | 426 | */ |
| 567 | 427 | function wpbm_set_relative_url( $url ){ |
| @@ -574,24 +434,24 @@ | ||
| 574 | 434 | $url = trim($url_path, '/'); |
| 575 | 435 | return '/' . $url; |
| 576 | 436 | } |
| 577 | 437 | |
| 578 | -/** Get Correct Relative URL | |
| 579 | - * | |
| 438 | +/** Get Correct Relative URL | |
| 439 | + * | |
| 580 | 440 | * @param type $link |
| 581 | 441 | * @return string |
| 582 | 442 | */ |
| 583 | 443 | function wpbm_make_link_relative( $link ){ |
| 584 | 444 | |
| 585 | - if ( $link == get_option('siteurl') ) | |
| 445 | + if ( $link == get_option('siteurl') ) | |
| 586 | 446 | $link = '/'; |
| 587 | - $link = '/' . trim( wp_make_link_relative( $link ), '/' ); | |
| 447 | + $link = '/' . trim( wp_make_link_relative( $link ), '/' ); | |
| 588 | 448 | |
| 589 | - return $link; | |
| 449 | + return $link; | |
| 590 | 450 | } |
| 591 | 451 | |
| 592 | -/** Get Correct Absolute URL | |
| 593 | - * | |
| 452 | +/** Get Correct Absolute URL | |
| 453 | + * | |
| 594 | 454 | * @param string $link |
| 595 | 455 | * @return type |
| 596 | 456 | */ |
| 597 | 457 | function wpbm_make_link_absolute( $link ){ |
| @@ -596,17 +456,17 @@ | ||
| 596 | 456 | */ |
| 597 | 457 | function wpbm_make_link_absolute( $link ){ |
| 598 | 458 | |
| 599 | 459 | if ( ( $link != get_option('siteurl') ) && ( strpos($link, 'http') !== 0 ) ) |
| 600 | - $link = get_option('siteurl') . '/' . trim( wp_make_link_relative( $link ), '/' ); | |
| 460 | + $link = get_option('siteurl') . '/' . trim( wp_make_link_relative( $link ), '/' ); | |
| 601 | 461 | return esc_js( $link ) ; |
| 602 | 462 | } |
| 603 | 463 | |
| 604 | 464 | |
| 605 | 465 | if (!function_exists ('get_file_data_wpdev')) { |
| 606 | - | |
| 466 | + | |
| 607 | 467 | /** Get header info from this file, just for compatibility with WordPress 2.8 and older versions |
| 608 | - * | |
| 468 | + * | |
| 609 | 469 | * @param type $file |
| 610 | 470 | * @param type $default_headers |
| 611 | 471 | * @param type $context |
| 612 | 472 | * @return type |
| @@ -612,15 +472,15 @@ | ||
| 612 | 472 | * @return type |
| 613 | 473 | */ |
| 614 | 474 | function get_file_data_wpdev( $file, $default_headers, $context = '' ) { |
| 615 | 475 | // We don't need to write to the file, so just open for reading. |
| 616 | - $fp = fopen( $file, 'r' ); | |
| 476 | + $fp = fopen( $file, 'r' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen | |
| 617 | 477 | |
| 618 | 478 | // Pull only the first 8kiB of the file in. |
| 619 | - $file_data = fread( $fp, 8192 ); | |
| 479 | + $file_data = fread( $fp, 8192 );// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fread | |
| 620 | 480 | |
| 621 | 481 | // PHP will close file handle, but we are good citizens. |
| 622 | - fclose( $fp ); | |
| 482 | + fclose( $fp );// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose | |
| 623 | 483 | |
| 624 | 484 | if( $context != '' ) { |
| 625 | 485 | $extra_headers = array(); //apply_filters( "extra_$context".'_headers', array() ); |
| 626 | 486 | |
| @@ -648,9 +508,9 @@ | ||
| 648 | 508 | } |
| 649 | 509 | |
| 650 | 510 | |
| 651 | 511 | /** Get content from specific URL |
| 652 | - * | |
| 512 | + * | |
| 653 | 513 | * @param string $url |
| 654 | 514 | * @return string|boolean (false on error) |
| 655 | 515 | */ |
| 656 | 516 | function wpbm_get_ssl_page_content( $url ) { |
| @@ -658,13 +518,15 @@ | ||
| 658 | 518 | $request = new WP_Http(); |
| 659 | 519 | |
| 660 | 520 | $result = $request->request( $url |
| 661 | 521 | , array( // Default Parameters |
| 522 | + 'reject_unsafe_urls' => true, //FixIn: 2.0.29.1 | |
| 523 | + 'user-agent' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405' //FixIn: 2.0.12.1 | |
| 662 | 524 | // 'method' => 'GET', |
| 663 | 525 | // 'timeout' => 5, // timeout value for an HTTP request. |
| 664 | - // 'redirection' => 5, // number of redirects allowed during an HTTP request. | |
| 665 | - // 'httpversion' => '1.0', | |
| 666 | - // 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), | |
| 526 | + // 'redirection' => 5, // number of redirects allowed during an HTTP request. | |
| 527 | + // 'httpversion' => '1.0', | |
| 528 | + // 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), | |
| 667 | 529 | // 'reject_unsafe_urls' => false, |
| 668 | 530 | // 'blocking' => true, |
| 669 | 531 | // 'headers' => array(), |
| 670 | 532 | // 'cookies' => array(), |
| @@ -675,14 +537,14 @@ | ||
| 675 | 537 | // 'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt', |
| 676 | 538 | // 'stream' => false, |
| 677 | 539 | // 'filename' => null, |
| 678 | 540 | // 'limit_response_size' => null |
| 679 | - ) | |
| 541 | + ) | |
| 680 | 542 | ); |
| 681 | 543 | |
| 682 | - if ( | |
| 683 | - ( ! is_wp_error( $result ) ) | |
| 684 | - && ( $result[ 'response' ][ 'code' ] == '200' ) | |
| 544 | + if ( | |
| 545 | + ( ! is_wp_error( $result ) ) | |
| 546 | + && ( $result[ 'response' ][ 'code' ] == '200' ) | |
| 685 | 547 | ) { |
| 686 | 548 | |
| 687 | 549 | return $result[ 'body' ]; |
| 688 | 550 | |
| @@ -692,11 +554,16 @@ | ||
| 692 | 554 | if ( is_wp_error( $result ) ) { |
| 693 | 555 | $error_message = $result->get_error_message(); |
| 694 | 556 | } else { |
| 695 | 557 | $error_message = __( 'Unknown error during downloading feed', 'booking-manager' ); |
| 558 | + | |
| 559 | + // Show more detail info of not ability to download .ics feeds. //FixIn: 2.0.10.5 | |
| 560 | + $error_message .= $result[ 'body' ]; | |
| 561 | + //do_action( 'wpbc_admin_show_top_notice', $error_message, 'error', 5000 ); | |
| 562 | + //die; | |
| 696 | 563 | } |
| 697 | 564 | do_action( 'wpbc_admin_show_top_notice', $error_message, 'error', 5000 ); // N_O_T_I_C_E in H_E_A_D_E_R |
| 698 | - debuge($error_message); //FixIn: 2.0.1.3 | |
| 565 | +// debuge($error_message); //FixIn: 2.0.1.3 //FixIn: 2.0.8.2 | |
| 699 | 566 | |
| 700 | 567 | return false; |
| 701 | 568 | } |
| 702 | 569 | } |
| @@ -722,9 +589,9 @@ | ||
| 722 | 589 | $d = 0; // string bytes counter |
| 723 | 590 | |
| 724 | 591 | // Iterate over every character in the string, escaping with a slash or encoding to UTF-8 where necessary |
| 725 | 592 | for ( $c = 0; $c < $strlen_var; ++ $c ) { |
| 726 | - $ord_var_c = ord( $str{$c} ); | |
| 593 | + $ord_var_c = ord( $str[$c] ); //FixIn: 2.0.17.1 | |
| 727 | 594 | switch ( true ) { |
| 728 | 595 | case(($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): // characters U-00000000 - U-0000007F (same as ASCII) |
| 729 | 596 | $d ++; |
| 730 | 597 | break; |
| @@ -753,15 +620,15 @@ | ||
| 753 | 620 | |
| 754 | 621 | // </editor-fold> |
| 755 | 622 | |
| 756 | 623 | |
| 757 | -// <editor-fold defaultstate="collapsed" desc=" A d m i n M e n u L i n k s " > | |
| 624 | +// <editor-fold defaultstate="collapsed" desc=" A d m i n M e n u L i n k s " > | |
| 758 | 625 | //////////////////////////////////////////////////////////////////////////// |
| 759 | 626 | // A d m i n M e n u L i n k s |
| 760 | 627 | //////////////////////////////////////////////////////////////////////////// |
| 761 | 628 | |
| 762 | 629 | /** Get URL to specific Admin Menu page |
| 763 | - * | |
| 630 | + * | |
| 764 | 631 | * @param string $menu_type - { item | add | resources | settings } |
| 765 | 632 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 766 | 633 | * @return string - URL to menu |
| 767 | 634 | */ |
| @@ -789,19 +656,19 @@ | ||
| 789 | 656 | } |
| 790 | 657 | |
| 791 | 658 | if ( $is_absolute_url ) { |
| 792 | 659 | $link = admin_url( 'admin.php' ) . '?page=' . $link ; |
| 793 | - } | |
| 660 | + } | |
| 794 | 661 | |
| 795 | - return $link; | |
| 662 | + return $link; | |
| 796 | 663 | } |
| 797 | 664 | |
| 798 | 665 | // // // // // // // // // // // // // // // // // // // // // // // // // / |
| 799 | 666 | |
| 800 | 667 | /** Get URL of item Listing or Calendar Overview page |
| 801 | - * | |
| 668 | + * | |
| 802 | 669 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 803 | - * @param boolean $is_old - { default: true } | |
| 670 | + * @param boolean $is_old - { default: true } | |
| 804 | 671 | * @return string - URL to menu |
| 805 | 672 | */ |
| 806 | 673 | function wpbm_get_master_url( $is_absolute_url = true ) { |
| 807 | 674 | return wpbm_get_menu_url( 'master', $is_absolute_url ); |
| @@ -806,12 +673,12 @@ | ||
| 806 | 673 | function wpbm_get_master_url( $is_absolute_url = true ) { |
| 807 | 674 | return wpbm_get_menu_url( 'master', $is_absolute_url ); |
| 808 | 675 | } |
| 809 | 676 | |
| 810 | -/** Get URL of item > Add item page | |
| 811 | - * | |
| 677 | +/** Get URL of item > Add item page | |
| 678 | + * | |
| 812 | 679 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 813 | - * @param boolean $is_old - { default: true } | |
| 680 | + * @param boolean $is_old - { default: true } | |
| 814 | 681 | * @return string - URL to menu |
| 815 | 682 | */ |
| 816 | 683 | function wpbm_get_new_wpbm_url( $is_absolute_url = true ) { |
| 817 | 684 | return wpbm_get_menu_url( 'add', $is_absolute_url ); |
| @@ -816,18 +683,18 @@ | ||
| 816 | 683 | function wpbm_get_new_wpbm_url( $is_absolute_url = true ) { |
| 817 | 684 | return wpbm_get_menu_url( 'add', $is_absolute_url ); |
| 818 | 685 | } |
| 819 | 686 | |
| 820 | -/** Get URL of item > Settings page | |
| 821 | - * | |
| 687 | +/** Get URL of item > Settings page | |
| 688 | + * | |
| 822 | 689 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 823 | - * @param boolean $is_old - { default: true } | |
| 690 | + * @param boolean $is_old - { default: true } | |
| 824 | 691 | * @return string - URL to menu |
| 825 | 692 | */ |
| 826 | 693 | function wpbm_get_settings_url( $is_absolute_url = true ) { |
| 827 | 694 | return wpbm_get_menu_url( 'settings', $is_absolute_url ); |
| 828 | 695 | } |
| 829 | - | |
| 696 | + | |
| 830 | 697 | // // // // // // // // // // // // // // // // // // // // // // // // // / |
| 831 | 698 | |
| 832 | 699 | /** Check if this item Listing or Calendar Overview page |
| 833 | 700 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| @@ -832,62 +699,62 @@ | ||
| 832 | 699 | /** Check if this item Listing or Calendar Overview page |
| 833 | 700 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 834 | 701 | * @return boolean true | false |
| 835 | 702 | */ |
| 836 | -function wpbm_is_master_page( $server_param = 'REQUEST_URI' ) { | |
| 703 | +function wpbm_is_master_page( $server_param = 'REQUEST_URI' ) { | |
| 837 | 704 | |
| 838 | - if ( ( is_admin() ) && | |
| 839 | - ( strpos($_SERVER[ $server_param ],'page=oplugins') !== false ) && | |
| 840 | - ( strpos($_SERVER[ $server_param ],'tab=wpbm-') === false ) && // not the settings | |
| 841 | - ( ( strpos($_SERVER[ $server_param ],'tab=wpbm') !== false ) // tab specified | |
| 842 | - || ( strpos($_SERVER[ $server_param ],'tab=') === false ) ) // or tab not specified at all | |
| 705 | + if ( ( is_admin() ) && isset($_SERVER[ $server_param ]) && | |
| 706 | + ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'page=oplugins') !== false ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 707 | + ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'tab=wpbm-') === false ) && // not the settings // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 708 | + ( ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'tab=wpbm') !== false ) // tab specified // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 709 | + || ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'tab=') === false ) ) // or tab not specified at all // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 843 | 710 | ) { |
| 844 | 711 | return true; |
| 845 | - } | |
| 712 | + } | |
| 846 | 713 | return false; |
| 847 | 714 | } |
| 848 | 715 | |
| 849 | -/** Check if this item > Add item page | |
| 716 | +/** Check if this item > Add item page | |
| 850 | 717 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 851 | 718 | * @return boolean true | false |
| 852 | 719 | */ |
| 853 | 720 | function wpbm_is_new_wpbm_page( $server_param = 'REQUEST_URI' ) { |
| 854 | 721 | |
| 855 | - if ( ( is_admin() ) && | |
| 856 | - ( strpos($_SERVER[ $server_param ],'page=oplugins') !== false ) && | |
| 857 | - ( strpos($_SERVER[ $server_param ],'tab=wpbm-new') !== false ) | |
| 722 | + if ( ( is_admin() ) && isset($_SERVER[ $server_param ]) && | |
| 723 | + ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'page=oplugins') !== false ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 724 | + ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'tab=wpbm-new') !== false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 858 | 725 | ) { |
| 859 | 726 | return true; |
| 860 | - } | |
| 727 | + } | |
| 861 | 728 | return false; |
| 862 | 729 | } |
| 863 | 730 | |
| 864 | 731 | |
| 865 | -/** Check if this item > Settings page | |
| 732 | +/** Check if this item > Settings page | |
| 866 | 733 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 867 | 734 | * @return boolean true | false |
| 868 | - */ | |
| 735 | + */ | |
| 869 | 736 | function wpbm_is_settings_page( $server_param = 'REQUEST_URI' ) { |
| 870 | 737 | |
| 871 | - if ( ( is_admin() ) && | |
| 872 | - ( strpos($_SERVER[ $server_param ],'page=oplugins') !== false ) && | |
| 873 | - ( strpos($_SERVER[ $server_param ],'tab=wpbm-settings') !== false ) | |
| 738 | + if ( ( is_admin() ) && isset($_SERVER[ $server_param ]) && | |
| 739 | + ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'page=oplugins') !== false ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 740 | + ( strpos(sanitize_text_field( wp_unslash($_SERVER[ $server_param ])),'tab=wpbm-settings') !== false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 874 | 741 | ) { |
| 875 | 742 | return true; |
| 876 | - } | |
| 743 | + } | |
| 877 | 744 | return false; |
| 878 | 745 | } |
| 879 | 746 | |
| 880 | 747 | // </editor-fold> |
| 881 | - | |
| 882 | 748 | |
| 883 | -// <editor-fold defaultstate="collapsed" desc=" A d m i n U I E l e m e n t s " > | |
| 749 | + | |
| 750 | +// <editor-fold defaultstate="collapsed" desc=" A d m i n U I E l e m e n t s " > | |
| 884 | 751 | //////////////////////////////////////////////////////////////////////////// |
| 885 | 752 | // A d m i n U I E l e m e n t s |
| 886 | 753 | //////////////////////////////////////////////////////////////////////////// |
| 887 | 754 | |
| 888 | 755 | /** Get Number of new items |
| 889 | - * | |
| 756 | + * | |
| 890 | 757 | * @return int |
| 891 | 758 | */ |
| 892 | 759 | function wpbm_get_number_new_items(){ |
| 893 | 760 | return 0; |
| @@ -894,9 +761,9 @@ | ||
| 894 | 761 | } |
| 895 | 762 | |
| 896 | 763 | |
| 897 | 764 | /** Show Admin B A R . |
| 898 | - * | |
| 765 | + * | |
| 899 | 766 | * @global type $wp_admin_bar |
| 900 | 767 | * @return type |
| 901 | 768 | */ |
| 902 | 769 | function wp_admin_bar_items_menu(){ |
| @@ -923,9 +790,9 @@ | ||
| 923 | 790 | $update_title = $title; |
| 924 | 791 | |
| 925 | 792 | |
| 926 | 793 | if ( $update_count > 0 ) { |
| 927 | - $update_count_title = " <span id='ab-updates' class='wpbm-count bk-update-count' >" . number_format_i18n($update_count) . "</span>" ; //id='wpbm-count' | |
| 794 | + $update_count_title = " <span class='wpbm-count bk-update-count' style='background: #f0f0f1;color: #2c3338;display: inline;padding: 2px 5px;font-weight: 600;border-radius: 10px;'>" . number_format_i18n($update_count) . "</span>" ; //id='wpbm-count' | |
| 928 | 795 | $update_title .= $update_count_title; |
| 929 | 796 | } |
| 930 | 797 | |
| 931 | 798 | $link_items = wpbm_get_master_url(); |
| @@ -984,33 +851,16 @@ | ||
| 984 | 851 | // add_action( 'admin_bar_menu', 'wp_admin_bar_items_menu', 70 ); // Add Admin Bar |
| 985 | 852 | |
| 986 | 853 | |
| 987 | 854 | /** Show Rating link at footer */ |
| 988 | -function wpbm_show_wpbm_footer(){ | |
| 855 | +function wpbm_show_wpbm_footer(){ | |
| 989 | 856 | |
| 990 | - if ( ! wpbm_is_this_demo() ) { | |
| 857 | + // Nothing here. | |
| 858 | +} | |
| 859 | +// </editor-fold> | |
| 991 | 860 | |
| 992 | - $message = sprintf( __( 'If you like %s please leave us a %s rating. A huge thank you in advance!', 'booking-manager') | |
| 993 | - , '<strong>Booking Manager</strong>' . ' ' . WPBM_VERSION_NUM | |
| 994 | - , '<a href="https://wordpress.org/support/plugin/booking-manager/reviews/#new-post" target="_blank" title="' . esc_attr__( 'Thanks :)', 'booking-manager') . '">' | |
| 995 | - . '★★★★★' | |
| 996 | - . '</a>' | |
| 997 | - ); | |
| 998 | 861 | |
| 999 | - echo '<div id="wpbm-footer" style="position:absolute;bottom:40px;text-align:left;width:95%;font-size:0.9em;text-shadow:0 1px 0 #fff;margin:0;color:#888;">' . $message . '</div>'; | |
| 1000 | - ?> | |
| 1001 | - <script type="text/javascript"> | |
| 1002 | - jQuery(document).ready(function(){ | |
| 1003 | - jQuery('#wpfooter').append( jQuery('#wpbm-footer') ); | |
| 1004 | - }); | |
| 1005 | - </script> | |
| 1006 | - <?php | |
| 1007 | - } | |
| 1008 | -} | |
| 1009 | -// </editor-fold> | |
| 1010 | - | |
| 1011 | - | |
| 1012 | -// <editor-fold defaultstate="collapsed" desc=" DB - cheking if table, field or index exists " > | |
| 862 | +// <editor-fold defaultstate="collapsed" desc=" DB - cheking if table, field or index exists " > | |
| 1013 | 863 | //////////////////////////////////////////////////////////////////////////// |
| 1014 | 864 | // DB - cheking if table, field or index exists |
| 1015 | 865 | //////////////////////////////////////////////////////////////////////////// |
| 1016 | 866 | |
| @@ -1015,9 +865,9 @@ | ||
| 1015 | 865 | //////////////////////////////////////////////////////////////////////////// |
| 1016 | 866 | |
| 1017 | 867 | /** |
| 1018 | 868 | * Check if table exist |
| 1019 | - * | |
| 869 | + * | |
| 1020 | 870 | * @global type $wpdb |
| 1021 | 871 | * @param string $tablename |
| 1022 | 872 | * @return 0|1 |
| 1023 | 873 | */ |
| @@ -1024,31 +874,23 @@ | ||
| 1024 | 874 | function wpbm_is_table_exists( $tablename ) { |
| 1025 | 875 | |
| 1026 | 876 | global $wpdb; |
| 1027 | 877 | |
| 1028 | - if ( (! empty($wpdb->prefix) ) && ( strpos($tablename, $wpdb->prefix) === false ) ) | |
| 1029 | - $tablename = $wpdb->prefix . $tablename ; | |
| 878 | + if ( ( ! empty( $wpdb->prefix ) ) && ( strpos( $tablename, $wpdb->prefix ) === false ) ) { | |
| 879 | + $tablename = $wpdb->prefix . $tablename; | |
| 880 | + } | |
| 1030 | 881 | |
| 1031 | - $sql_check_table = $wpdb->prepare("SHOW TABLES LIKE %s" , $tablename ); //FixIn 5.4.3 | |
| 1032 | 882 | |
| 1033 | - $res = $wpdb->get_results( $sql_check_table ); | |
| 1034 | 883 | |
| 1035 | - return count($res); //FixIn 5.4.3 | |
| 1036 | - /* | |
| 1037 | - $sql_check_table = $wpdb->prepare(" | |
| 1038 | - SELECT COUNT(*) AS count | |
| 1039 | - FROM information_schema.tables | |
| 1040 | - WHERE table_schema = '". DB_NAME ."' | |
| 1041 | - AND table_name = %s " , $tablename ); | |
| 884 | + $res = $wpdb->get_results( $wpdb->prepare( "SHOW TABLES LIKE %s", $tablename ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 1042 | 885 | |
| 1043 | - $res = $wpdb->get_results( $sql_check_table ); | |
| 1044 | - return $res[0]->count;*/ | |
| 886 | + return count( $res ); //FixIn 5.4.3. | |
| 1045 | 887 | } |
| 1046 | 888 | |
| 1047 | 889 | |
| 1048 | 890 | /** |
| 1049 | 891 | * Check if table exist |
| 1050 | - * | |
| 892 | + * | |
| 1051 | 893 | * @global type $wpdb |
| 1052 | 894 | * @param string $tablename |
| 1053 | 895 | * @param type $fieldname |
| 1054 | 896 | * @return 0|1 |
| @@ -1057,9 +899,9 @@ | ||
| 1057 | 899 | global $wpdb; |
| 1058 | 900 | if ( (! empty($wpdb->prefix) ) && ( strpos($tablename, $wpdb->prefix) === false ) ) $tablename = $wpdb->prefix . $tablename ; |
| 1059 | 901 | $sql_check_table = "SHOW COLUMNS FROM {$tablename}" ; |
| 1060 | 902 | |
| 1061 | - $res = $wpdb->get_results( $sql_check_table ); | |
| 903 | + $res = $wpdb->get_results( $sql_check_table ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 1062 | 904 | |
| 1063 | 905 | foreach ($res as $fld) { |
| 1064 | 906 | if ($fld->Field == $fieldname) return 1; |
| 1065 | 907 | } |
| @@ -1069,9 +911,9 @@ | ||
| 1069 | 911 | |
| 1070 | 912 | |
| 1071 | 913 | /** |
| 1072 | 914 | * Check if index exist |
| 1073 | - * | |
| 915 | + * | |
| 1074 | 916 | * @global type $wpdb |
| 1075 | 917 | * @param string $tablename |
| 1076 | 918 | * @param type $fieldindex |
| 1077 | 919 | * @return 0|1 |
| @@ -1078,24 +920,24 @@ | ||
| 1078 | 920 | */ |
| 1079 | 921 | function wpbm_is_index_in_table_exists( $tablename , $fieldindex) { |
| 1080 | 922 | global $wpdb; |
| 1081 | 923 | if ( (! empty($wpdb->prefix) ) && ( strpos($tablename, $wpdb->prefix) === false ) ) $tablename = $wpdb->prefix . $tablename ; |
| 1082 | - $sql_check_table = $wpdb->prepare("SHOW INDEX FROM {$tablename} WHERE Key_name = %s", $fieldindex ); | |
| 1083 | - $res = $wpdb->get_results( $sql_check_table ); | |
| 924 | + | |
| 925 | + $res = $wpdb->get_results( $wpdb->prepare("SHOW INDEX FROM {$tablename} WHERE Key_name = %s", $fieldindex ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 1084 | 926 | if (count($res)>0) return 1; |
| 1085 | 927 | else return 0; |
| 1086 | 928 | } |
| 1087 | 929 | |
| 1088 | 930 | // </editor-fold> |
| 1089 | - | |
| 1090 | - | |
| 1091 | -// <editor-fold defaultstate="collapsed" desc=" E s c a p i n g " > | |
| 931 | + | |
| 932 | + | |
| 933 | +// <editor-fold defaultstate="collapsed" desc=" E s c a p i n g " > | |
| 1092 | 934 | //////////////////////////////////////////////////////////////////////////// |
| 1093 | 935 | // E s c a p i n g |
| 1094 | 936 | //////////////////////////////////////////////////////////////////////////// |
| 1095 | 937 | |
| 1096 | 938 | /** Transform the REQESTS parameters (GET and POST) into URL |
| 1097 | - * | |
| 939 | + * | |
| 1098 | 940 | * @param type $page_param |
| 1099 | 941 | * @param array $exclude_params |
| 1100 | 942 | * @param type $only_these_parameters |
| 1101 | 943 | * @return type |
| @@ -1103,25 +945,25 @@ | ||
| 1103 | 945 | function wpbm_get_params_in_url( $page_param , $exclude_params = array(), $only_these_parameters = false, $is_escape_url = false, $only_get = false ){ |
| 1104 | 946 | |
| 1105 | 947 | $exclude_params[] = 'page'; |
| 1106 | 948 | |
| 1107 | - if ( isset( $_GET['page'] ) ) | |
| 1108 | - $page_param = $_GET['page']; | |
| 949 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 950 | + if ( isset( $_GET['page'] ) ) { $page_param = $_GET['page']; } | |
| 1109 | 951 | |
| 1110 | 952 | $get_paramaters = array( 'page' => $page_param ); |
| 1111 | 953 | |
| 1112 | 954 | if ( $only_get ) |
| 1113 | - $check_params = $_GET; | |
| 1114 | - else | |
| 1115 | - $check_params = $_REQUEST; | |
| 1116 | -//debuge($check_params); | |
| 955 | + $check_params = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 956 | + else | |
| 957 | + $check_params = $_REQUEST; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 958 | +//debuge($check_params); | |
| 1117 | 959 | foreach ( $check_params as $prm_key => $prm_value ) { |
| 1118 | 960 | |
| 1119 | 961 | // Skip parameters arrays, like $_GET['rvaluation_to'] = Array ( [0] => 6, [1] => 14, [2] => 14 ) |
| 1120 | - if ( | |
| 1121 | - ( is_string( $prm_value ) ) | |
| 1122 | - || ( is_numeric( $prm_value ) ) | |
| 1123 | - ) { | |
| 962 | + if ( | |
| 963 | + ( is_string( $prm_value ) ) | |
| 964 | + || ( is_numeric( $prm_value ) ) | |
| 965 | + ) { | |
| 1124 | 966 | |
| 1125 | 967 | if ( strlen( $prm_value ) > 1000 ) { // Check about TOOO long parameters, if it exist then reset it. |
| 1126 | 968 | $prm_value = ''; |
| 1127 | 969 | } |
| @@ -1130,9 +972,9 @@ | ||
| 1130 | 972 | if ( ( $only_these_parameters === false ) || ( in_array( $prm_key, $only_these_parameters ) ) ) |
| 1131 | 973 | $get_paramaters[ $prm_key ] = $prm_value; |
| 1132 | 974 | } |
| 1133 | 975 | } |
| 1134 | -//debuge($check_params, $get_paramaters, $exclude_params ); | |
| 976 | +//debuge($check_params, $get_paramaters, $exclude_params ); | |
| 1135 | 977 | $url = admin_url( add_query_arg( $get_paramaters , 'admin.php' ) ); |
| 1136 | 978 | |
| 1137 | 979 | if ( $is_escape_url ) |
| 1138 | 980 | $url = esc_url( $url ); |
| @@ -1141,9 +983,9 @@ | ||
| 1141 | 983 | |
| 1142 | 984 | /* // Old variant: |
| 1143 | 985 | if ( isset( $_GET['page'] ) ) $page_param = $_GET['page']; |
| 1144 | 986 | |
| 1145 | - $url_start = 'admin.php?page=' . $page_param . '&'; | |
| 987 | + $url_start = 'admin.php?page=' . $page_param . '&'; | |
| 1146 | 988 | $exclude_params[] = 'page'; |
| 1147 | 989 | foreach ( $_REQUEST as $prm_key => $prm_value ) { |
| 1148 | 990 | |
| 1149 | 991 | if ( !in_array( $prm_key, $exclude_params ) ) |
| @@ -1154,18 +996,18 @@ | ||
| 1154 | 996 | } |
| 1155 | 997 | $url_start = substr( $url_start, 0, -1 ); |
| 1156 | 998 | |
| 1157 | 999 | return $url_start; |
| 1158 | - */ | |
| 1000 | + */ | |
| 1159 | 1001 | } |
| 1160 | 1002 | |
| 1161 | 1003 | |
| 1162 | 1004 | /** Clean Request Parameters |
| 1163 | - * | |
| 1005 | + * | |
| 1164 | 1006 | */ |
| 1165 | -function wpbm_check_request_paramters() { | |
| 1007 | +function wpbm_check_request_paramters() { | |
| 1166 | 1008 | |
| 1167 | - $clean_params = array(); | |
| 1009 | + $clean_params = array(); | |
| 1168 | 1010 | |
| 1169 | 1011 | $clean_params[ 'wh_wpbm_id' ] = 'digit_or_csd'; // '0' | '1' | '' |
| 1170 | 1012 | $clean_params[ 'wh_wpbm_date' ] = 'digit_or_date'; // number | date 2016-07-20 |
| 1171 | 1013 | $clean_params[ 'wh_wpbm_datenext' ] = 'd'; // '1' | '2' .... |
| @@ -1176,13 +1018,13 @@ | ||
| 1176 | 1018 | |
| 1177 | 1019 | // elements only listed in array:: |
| 1178 | 1020 | if ( is_array( $clean_type ) ) { // check only values from the list in this array |
| 1179 | 1021 | |
| 1180 | - if ( ( isset( $_REQUEST[ $request_key ] ) ) && ( ! in_array( $_REQUEST[ $request_key ], $clean_type ) ) ) | |
| 1181 | - $clean_type = 's'; | |
| 1182 | - else | |
| 1022 | + if ( ( isset( $_REQUEST[ $request_key ] ) ) && ( ! in_array( $_REQUEST[ $request_key ], $clean_type ) ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1023 | + $clean_type = 's'; | |
| 1024 | + else | |
| 1183 | 1025 | $clean_type = 'checked_skip_it'; |
| 1184 | - } | |
| 1026 | + } | |
| 1185 | 1027 | |
| 1186 | 1028 | switch ( $clean_type ) { |
| 1187 | 1029 | |
| 1188 | 1030 | case 'checked_skip_it': |
| @@ -1189,36 +1031,34 @@ | ||
| 1189 | 1031 | |
| 1190 | 1032 | break; |
| 1191 | 1033 | |
| 1192 | 1034 | case 'digit_or_date': // digit or comma separated digit |
| 1193 | - if ( isset( $_REQUEST[ $request_key ] ) ) | |
| 1194 | - $_REQUEST[ $request_key ] = wpbm_clean_digit_or_date( $_REQUEST[ $request_key ] ); // nums | |
| 1035 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1036 | + if ( isset( $_REQUEST[ $request_key ] ) ) { $_REQUEST[ $request_key ] = wpbm_clean_digit_or_date( $_REQUEST[ $request_key ] ); } // nums | |
| 1195 | 1037 | |
| 1196 | 1038 | break; |
| 1197 | 1039 | |
| 1198 | 1040 | case 'digit_or_csd': // digit or comma separated digit |
| 1199 | - if ( isset( $_REQUEST[ $request_key ] ) ) | |
| 1200 | - $_REQUEST[ $request_key ] = wpbm_clean_digit_or_csd( $_REQUEST[ $request_key ] ); // nums | |
| 1041 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1042 | + if ( isset( $_REQUEST[ $request_key ] ) ) { $_REQUEST[ $request_key ] = wpbm_clean_digit_or_csd( $_REQUEST[ $request_key ] ); } // nums | |
| 1201 | 1043 | |
| 1202 | 1044 | break; |
| 1203 | 1045 | |
| 1204 | 1046 | case 's': // string |
| 1205 | - if ( isset( $_REQUEST[ $request_key ] ) ) | |
| 1206 | - $_REQUEST[ $request_key ] = wpbm_clean_like_string_for_db( $_REQUEST[ $request_key ] ); | |
| 1047 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1048 | + if ( isset( $_REQUEST[ $request_key ] ) ) { $_REQUEST[ $request_key ] = wpbm_clean_like_string_for_db( $_REQUEST[ $request_key ] ); } | |
| 1207 | 1049 | |
| 1208 | 1050 | break; |
| 1209 | 1051 | |
| 1210 | 1052 | case 'd': // digit |
| 1211 | - if ( isset( $_REQUEST[ $request_key ] ) ) | |
| 1212 | - if ( $_REQUEST[ $request_key ] !== '' ) | |
| 1213 | - $_REQUEST[ $request_key ] = intval( $_REQUEST[ $request_key ] ); | |
| 1053 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1054 | + if (( isset( $_REQUEST[ $request_key ] ) ) && ( $_REQUEST[ $request_key ] !== '' )) { $_REQUEST[ $request_key ] = intval( $_REQUEST[ $request_key ] ); } | |
| 1214 | 1055 | |
| 1215 | 1056 | break; |
| 1216 | 1057 | |
| 1217 | 1058 | default: |
| 1218 | - if ( isset( $_REQUEST[ $request_key ] ) ) { | |
| 1219 | - $_REQUEST[ $request_key ] = intval( $_REQUEST[ $request_key ] ); | |
| 1220 | - } | |
| 1059 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1060 | + if ( isset( $_REQUEST[ $request_key ] ) ) { $_REQUEST[ $request_key ] = intval( $_REQUEST[ $request_key ] ); } | |
| 1221 | 1061 | break; |
| 1222 | 1062 | } |
| 1223 | 1063 | |
| 1224 | 1064 | |
| @@ -1225,15 +1065,15 @@ | ||
| 1225 | 1065 | } |
| 1226 | 1066 | |
| 1227 | 1067 | } |
| 1228 | 1068 | |
| 1229 | - | |
| 1069 | + | |
| 1230 | 1070 | /** Check paramter if it number or comma separated list of numbers |
| 1231 | - * | |
| 1071 | + * | |
| 1232 | 1072 | * @global type $wpdb |
| 1233 | 1073 | * @param string $value |
| 1234 | 1074 | * @return string |
| 1235 | - * | |
| 1075 | + * | |
| 1236 | 1076 | * Exmaple: |
| 1237 | 1077 | wpbm_clean_digit_or_csd( '12,a,45,9' ) => '12,0,45,9' |
| 1238 | 1078 | * or |
| 1239 | 1079 | wpbm_clean_digit_or_csd( '10a' ) => '10 |
| @@ -1239,9 +1079,9 @@ | ||
| 1239 | 1079 | wpbm_clean_digit_or_csd( '10a' ) => '10 |
| 1240 | 1080 | * or |
| 1241 | 1081 | wpbm_clean_digit_or_csd( array( '12,a,45,9', '10a' ) ) => array ( '12,0,45,9', '10' ) |
| 1242 | 1082 | */ |
| 1243 | -function wpbm_clean_digit_or_csd( $value ) { //FixIn:6.2.1.4 | |
| 1083 | +function wpbm_clean_digit_or_csd( $value ) { //FixIn:6.2.1.4 | |
| 1244 | 1084 | |
| 1245 | 1085 | if ( $value === '' ) return $value; |
| 1246 | 1086 | |
| 1247 | 1087 | |
| @@ -1246,9 +1086,9 @@ | ||
| 1246 | 1086 | |
| 1247 | 1087 | |
| 1248 | 1088 | if ( is_array( $value ) ) { |
| 1249 | 1089 | foreach ( $value as $key => $check_value ) { |
| 1250 | - $value[ $key ] = wpbm_clean_digit_or_csd( $check_value ); | |
| 1090 | + $value[ $key ] = wpbm_clean_digit_or_csd( $check_value ); | |
| 1251 | 1091 | } |
| 1252 | 1092 | return $value; |
| 1253 | 1093 | } |
| 1254 | 1094 | |
| @@ -1265,12 +1105,12 @@ | ||
| 1265 | 1105 | } |
| 1266 | 1106 | $result = implode(',', $result ); |
| 1267 | 1107 | return $result; |
| 1268 | 1108 | } |
| 1269 | - | |
| 1270 | - | |
| 1109 | + | |
| 1110 | + | |
| 1271 | 1111 | /** Cehck about Valid date, like 2016-07-20 or digit |
| 1272 | - * | |
| 1112 | + * | |
| 1273 | 1113 | * @param string $value |
| 1274 | 1114 | * @return string or int |
| 1275 | 1115 | */ |
| 1276 | 1116 | function wpbm_clean_digit_or_date( $value ) { //FixIn:6.2.1.4 |
| @@ -1284,12 +1124,12 @@ | ||
| 1284 | 1124 | return intval( $value ); |
| 1285 | 1125 | } |
| 1286 | 1126 | |
| 1287 | 1127 | } |
| 1288 | - | |
| 1289 | 1128 | |
| 1129 | + | |
| 1290 | 1130 | /** Check $value for injection here |
| 1291 | - * | |
| 1131 | + * | |
| 1292 | 1132 | * @param type $value |
| 1293 | 1133 | * @return type |
| 1294 | 1134 | */ |
| 1295 | 1135 | function wpbm_clean_parameter( $value ) { |
| @@ -1294,16 +1134,16 @@ | ||
| 1294 | 1134 | */ |
| 1295 | 1135 | function wpbm_clean_parameter( $value ) { |
| 1296 | 1136 | |
| 1297 | 1137 | $value = preg_replace( '/<[^>]*>/', '', $value ); // clean any tags |
| 1298 | - $value = str_replace( '<', ' ', $value ); | |
| 1299 | - $value = str_replace( '>', ' ', $value ); | |
| 1300 | - $value = strip_tags( $value ); | |
| 1138 | + $value = str_replace( '<', ' ', $value ); | |
| 1139 | + $value = str_replace( '>', ' ', $value ); | |
| 1140 | + $value = wp_strip_all_tags( $value ); | |
| 1301 | 1141 | |
| 1302 | - // Clean SQL injection | |
| 1142 | + // Clean SQL injection | |
| 1303 | 1143 | $value = esc_sql( $value ); |
| 1304 | 1144 | |
| 1305 | - return $value; | |
| 1145 | + return $value; | |
| 1306 | 1146 | } |
| 1307 | 1147 | |
| 1308 | 1148 | |
| 1309 | 1149 | function wpbm_esc_like( $value_trimmed ) { |
| @@ -1316,14 +1156,14 @@ | ||
| 1316 | 1156 | } |
| 1317 | 1157 | |
| 1318 | 1158 | |
| 1319 | 1159 | /** Clean user string for using in SQL LIKE statement - append to LIKE sql |
| 1320 | - * | |
| 1160 | + * | |
| 1321 | 1161 | * @param string $value - to clean |
| 1322 | 1162 | * @return string - escaped |
| 1323 | - * Exmaple: | |
| 1163 | + * Exmaple: | |
| 1324 | 1164 | * $search_escaped_like_title = wpbm_clean_like_string_for_append_in_sql_for_db( $input_var ); |
| 1325 | - * | |
| 1165 | + * | |
| 1326 | 1166 | * $where_sql = " WHERE title LIKE ". $search_escaped_like_title ." "; |
| 1327 | 1167 | */ |
| 1328 | 1168 | function wpbm_clean_like_string_for_append_in_sql_for_db( $value ) { |
| 1329 | 1169 | global $wpdb; |
| @@ -1328,13 +1168,13 @@ | ||
| 1328 | 1168 | function wpbm_clean_like_string_for_append_in_sql_for_db( $value ) { |
| 1329 | 1169 | global $wpdb; |
| 1330 | 1170 | |
| 1331 | 1171 | $value_trimmed = trim( stripslashes( $value ) ); |
| 1332 | -$wild = '%'; | |
| 1333 | -$like = $wild . wpbm_esc_like( $value_trimmed ) . $wild; | |
| 1334 | -$sql = $wpdb->prepare( "'%s'", $like ); | |
| 1172 | + $wild = '%'; | |
| 1173 | + $like = $wild . wpbm_esc_like( $value_trimmed ) . $wild; | |
| 1174 | + $sql = $wpdb->prepare( "'%s'", $like ); // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedSimplePlaceholder | |
| 1335 | 1175 | |
| 1336 | - return $sql; | |
| 1176 | + return $sql; | |
| 1337 | 1177 | |
| 1338 | 1178 | |
| 1339 | 1179 | /* Help: |
| 1340 | 1180 | * First half of escaping for LIKE special characters % and _ before preparing for MySQL. |
| @@ -1349,22 +1189,22 @@ | ||
| 1349 | 1189 | * |
| 1350 | 1190 | * Example Escape Chain: |
| 1351 | 1191 | * |
| 1352 | 1192 | * $sql = esc_sql( wpbm_esc_like( $input ) ); |
| 1353 | - */ | |
| 1193 | + */ | |
| 1354 | 1194 | |
| 1355 | 1195 | } |
| 1356 | 1196 | |
| 1357 | 1197 | |
| 1358 | -/** Clean string for using in SQL LIKE requests inside single quotes: WHERE title LIKE '%". $escaped_search_title ."%' | |
| 1198 | +/** Clean string for using in SQL LIKE requests inside single quotes: WHERE title LIKE '%". $escaped_search_title ."%' | |
| 1359 | 1199 | * Replaced _ to \_ % to \% \ to \\ |
| 1360 | 1200 | * @param string $value - to clean |
| 1361 | 1201 | * @return string - escaped |
| 1362 | - * Exmaple: | |
| 1202 | + * Exmaple: | |
| 1363 | 1203 | * $search_escaped_like_title = wpbm_clean_like_string_for_db( $input_var ); |
| 1364 | - * | |
| 1204 | + * | |
| 1365 | 1205 | * $where_sql = " WHERE title LIKE '%". $search_escaped_like_title ."%' "; |
| 1366 | - * | |
| 1206 | + * | |
| 1367 | 1207 | * Important! Use SINGLE quotes after in SQL query: LIKE '%".$data."%' |
| 1368 | 1208 | */ |
| 1369 | 1209 | function wpbm_clean_like_string_for_db( $value ){ |
| 1370 | 1210 | |
| @@ -1373,9 +1213,9 @@ | ||
| 1373 | 1213 | $value_trimmed = trim( stripslashes( $value ) ); |
| 1374 | 1214 | |
| 1375 | 1215 | $value_trimmed = wpbm_esc_like( $value_trimmed ); |
| 1376 | 1216 | |
| 1377 | - $value = trim( $wpdb->prepare( "'%s'", $value_trimmed ) , "'" ); | |
| 1217 | + $value = trim( $wpdb->prepare( "'%s'", $value_trimmed ) , "'" ); // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedSimplePlaceholder | |
| 1378 | 1218 | |
| 1379 | 1219 | return $value; |
| 1380 | 1220 | |
| 1381 | 1221 | /* Help: |
| @@ -1391,26 +1231,26 @@ | ||
| 1391 | 1231 | * |
| 1392 | 1232 | * Example Escape Chain: |
| 1393 | 1233 | * |
| 1394 | 1234 | * $sql = esc_sql( wpbm_esc_like( $input ) ); |
| 1395 | - */ | |
| 1235 | + */ | |
| 1396 | 1236 | } |
| 1397 | 1237 | |
| 1398 | 1238 | |
| 1399 | 1239 | /** Escape string from SQL for the HTML form field |
| 1400 | - * | |
| 1240 | + * | |
| 1401 | 1241 | * @param string $value |
| 1402 | 1242 | * @return string |
| 1403 | - * | |
| 1243 | + * | |
| 1404 | 1244 | * Used: esc_sql function. |
| 1405 | - * | |
| 1406 | - * https://codex.wordpress.org/Function_Reference/esc_sql | |
| 1407 | - * Note: Be careful to use this function correctly. It will only escape values to be used in strings in the query. | |
| 1408 | - * That is, it only provides escaping for values that will be within quotes in the SQL (as in field = '{$escaped_value}'). | |
| 1409 | - * If your value is not going to be within quotes, your code will still be vulnerable to SQL injection. | |
| 1410 | - * For example, this is vulnerable, because the escaped value is not surrounded by quotes in the SQL query: | |
| 1411 | - * ORDER BY {$escaped_value}. As such, this function does not escape unquoted numeric values, field names, or SQL keywords. | |
| 1412 | - * | |
| 1245 | + * | |
| 1246 | + * https://codex.wordpress.org/Function_Reference/esc_sql | |
| 1247 | + * Note: Be careful to use this function correctly. It will only escape values to be used in strings in the query. | |
| 1248 | + * That is, it only provides escaping for values that will be within quotes in the SQL (as in field = '{$escaped_value}'). | |
| 1249 | + * If your value is not going to be within quotes, your code will still be vulnerable to SQL injection. | |
| 1250 | + * For example, this is vulnerable, because the escaped value is not surrounded by quotes in the SQL query: | |
| 1251 | + * ORDER BY {$escaped_value}. As such, this function does not escape unquoted numeric values, field names, or SQL keywords. | |
| 1252 | + * | |
| 1413 | 1253 | */ |
| 1414 | 1254 | function wpbm_clean_string_for_form( $value ){ |
| 1415 | 1255 | |
| 1416 | 1256 | global $wpdb; |
| @@ -1427,16 +1267,16 @@ | ||
| 1427 | 1267 | |
| 1428 | 1268 | } |
| 1429 | 1269 | // </editor-fold> |
| 1430 | 1270 | |
| 1431 | - | |
| 1432 | -// <editor-fold defaultstate="collapsed" desc=" U s e r s " > | |
| 1271 | + | |
| 1272 | +// <editor-fold defaultstate="collapsed" desc=" U s e r s " > | |
| 1433 | 1273 | //////////////////////////////////////////////////////////////////////////////// |
| 1434 | 1274 | // U s e r s |
| 1435 | 1275 | //////////////////////////////////////////////////////////////////////////////// |
| 1436 | 1276 | |
| 1437 | 1277 | /** Get ID of active user |
| 1438 | - * | |
| 1278 | + * | |
| 1439 | 1279 | * @return type |
| 1440 | 1280 | */ |
| 1441 | 1281 | function get_wpbm_current_user_id() { |
| 1442 | 1282 | $user = wp_get_current_user(); |
| @@ -1443,11 +1283,35 @@ | ||
| 1443 | 1283 | return ( isset( $user->ID ) ? (int) $user->ID : 0 ); |
| 1444 | 1284 | } |
| 1445 | 1285 | |
| 1446 | 1286 | |
| 1287 | +/** | |
| 1288 | + * Resolve a requested per-user settings target to the current user. | |
| 1289 | + * | |
| 1290 | + * Booking Manager's established AJAX payloads include a user ID. The value is | |
| 1291 | + * retained for request compatibility, but it must never authorize a write to | |
| 1292 | + * another user's preferences. | |
| 1293 | + * | |
| 1294 | + * @param mixed $requested_user_id User ID supplied by the request. | |
| 1295 | + * | |
| 1296 | + * @return int Current user ID when the request target matches; otherwise 0. | |
| 1297 | + */ | |
| 1298 | +function wpbm_get_authorized_user_option_target_id( $requested_user_id ) { | |
| 1299 | + $current_user_id = get_wpbm_current_user_id(); | |
| 1300 | + | |
| 1301 | + if ( 0 === $current_user_id || ! is_scalar( $requested_user_id ) ) { | |
| 1302 | + return 0; | |
| 1303 | + } | |
| 1304 | + | |
| 1305 | + $requested_user_id = absint( wp_unslash( (string) $requested_user_id ) ); | |
| 1306 | + | |
| 1307 | + return ( $current_user_id === $requested_user_id ) ? $current_user_id : 0; | |
| 1308 | +} | |
| 1309 | + | |
| 1310 | + | |
| 1447 | 1311 | /** Check if Current User have specific Role |
| 1448 | - * | |
| 1449 | - * @return bool Whether the current user has the given capability. | |
| 1312 | + * | |
| 1313 | + * @return bool Whether the current user has the given capability. | |
| 1450 | 1314 | */ |
| 1451 | 1315 | function wpbm_is_current_user_have_this_role( $user_role ) { |
| 1452 | 1316 | |
| 1453 | 1317 | if ( $user_role == 'administrator' ) $user_role = 'activate_plugins'; |
| @@ -1460,64 +1324,44 @@ | ||
| 1460 | 1324 | } |
| 1461 | 1325 | |
| 1462 | 1326 | |
| 1463 | 1327 | function wpbm_get_user_ip() { |
| 1464 | -//return '84.243.195.114' ; // Test //90.36.89.174 | |
| 1465 | - if (isset($_SERVER['HTTP_CLIENT_IP'])) { | |
| 1466 | - $userIP = $_SERVER['HTTP_CLIENT_IP'] ; | |
| 1467 | - } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
| 1468 | - $userIP = $_SERVER['HTTP_X_FORWARDED_FOR'] ; | |
| 1469 | - } elseif (isset($_SERVER['HTTP_X_FORWARDED'])) { | |
| 1470 | - $userIP = $_SERVER['HTTP_X_FORWARDED'] ; | |
| 1471 | - } elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) { | |
| 1472 | - $userIP = $_SERVER['HTTP_FORWARDED_FOR'] ; | |
| 1473 | - } elseif (isset($_SERVER['HTTP_FORWARDED'])) { | |
| 1474 | - $userIP = $_SERVER['HTTP_FORWARDED'] ; | |
| 1475 | - } elseif (isset($_SERVER['REMOTE_ADDR'])) { | |
| 1476 | - $userIP = $_SERVER['REMOTE_ADDR'] ; | |
| 1477 | - } else { | |
| 1478 | - $userIP = "" ; | |
| 1479 | - } | |
| 1480 | - | |
| 1481 | - $userIP = explode( ',', $userIP ); | |
| 1482 | - $userIP = array_map( 'trim', $userIP ); | |
| 1483 | - | |
| 1484 | - return $userIP[0] ; | |
| 1328 | + return '---'; | |
| 1485 | 1329 | } |
| 1486 | 1330 | add_wpbm_filter( 'wpbm_get_user_ip', 'wpbm_get_user_ip' ); |
| 1487 | 1331 | // </editor-fold> |
| 1488 | 1332 | |
| 1489 | 1333 | |
| 1490 | -// <editor-fold defaultstate="collapsed" desc=" Mesages for Admin panel " > | |
| 1491 | -//////////////////////////////////////////////////////////////////////////////// | |
| 1492 | -// Mesages for Admin panel | |
| 1493 | -//////////////////////////////////////////////////////////////////////////////// | |
| 1334 | +// <editor-fold defaultstate="collapsed" desc=" Mesages for Admin panel " > | |
| 1335 | +//////////////////////////////////////////////////////////////////////////////// | |
| 1336 | +// Mesages for Admin panel | |
| 1337 | +//////////////////////////////////////////////////////////////////////////////// | |
| 1494 | 1338 | |
| 1495 | 1339 | function wpbm_show_fixed_message( $message, $time_to_show , $message_type = 'updated' , $notice_id = 0, $is_dismissible = false ) { |
| 1496 | 1340 | |
| 1497 | 1341 | // Generate unique HTML ID for the message |
| 1498 | 1342 | if ( $notice_id == 0 ) |
| 1499 | - $notice_id = intval( time() * rand(10, 100) ); | |
| 1343 | + $notice_id = intval( time() * wp_rand(10, 100) ); | |
| 1500 | 1344 | |
| 1501 | 1345 | $notice_id = 'wpbm_system_notice_' . $notice_id; |
| 1502 | 1346 | |
| 1503 | 1347 | $is_dismissible = false; |
| 1504 | 1348 | |
| 1505 | - if ( | |
| 1349 | + if ( | |
| 1506 | 1350 | ( ( $is_dismissible ) && ( ! wpbm_section_is_dismissed( $notice_id ) ) ) |
| 1507 | 1351 | || ( ! $is_dismissible ) |
| 1508 | - // || true | |
| 1352 | + // || true | |
| 1509 | 1353 | ){ |
| 1510 | 1354 | |
| 1511 | - ?><div id="<?php echo $notice_id; ?>" | |
| 1512 | - class="wpbm_system_notice wpbm_is_dismissible wpbm_is_hideable <?php echo $message_type; ?>" | |
| 1513 | - data-nonce="<?php echo wp_create_nonce( $nonce_name = $notice_id . '_wpbmnonce' ); ?>" | |
| 1514 | - data-user-id="<?php echo get_current_user_id(); ?>" | |
| 1515 | - ><?php | |
| 1355 | + ?><div id="<?php echo esc_attr($notice_id); ?>" | |
| 1356 | + class="wpbm_system_notice wpbm_is_dismissible wpbm_is_hideable <?php echo esc_attr( $message_type ); ?>" | |
| 1357 | + data-nonce="<?php echo esc_attr(wp_create_nonce( $nonce_name = $notice_id . '_wpbmnonce' )); ?>" | |
| 1358 | + data-user-id="<?php echo esc_attr(get_current_user_id()); ?>" | |
| 1359 | + ><?php | |
| 1516 | 1360 | |
| 1517 | 1361 | wpbm_x_dismiss_button(); |
| 1518 | 1362 | |
| 1519 | - echo $message; | |
| 1363 | + echo wp_kses_post($message); | |
| 1520 | 1364 | |
| 1521 | 1365 | ?></div><?php |
| 1522 | 1366 | |
| 1523 | 1367 | // Get the time of message showing |
| @@ -1522,19 +1366,19 @@ | ||
| 1522 | 1366 | |
| 1523 | 1367 | // Get the time of message showing |
| 1524 | 1368 | $time_to_show = intval( $time_to_show ) * 1000; |
| 1525 | 1369 | |
| 1526 | - if ( $time_to_show > 0 ) { | |
| 1527 | - ?> <script type="text/javascript"> | |
| 1528 | - jQuery('#<?php echo $notice_id; ?>').animate({opacity: 1},<?php echo $time_to_show; ?>).fadeOut( 2000 ); | |
| 1370 | + if ( $time_to_show > 0 ) { | |
| 1371 | + ?> <script type="text/javascript"> | |
| 1372 | + jQuery('#<?php echo esc_attr($notice_id); ?>').animate({opacity: 1},<?php echo esc_attr( $time_to_show ); ?>).fadeOut( 2000 ); | |
| 1529 | 1373 | </script> <?php |
| 1530 | - } | |
| 1531 | - } | |
| 1374 | + } | |
| 1375 | + } | |
| 1532 | 1376 | } |
| 1533 | 1377 | |
| 1534 | 1378 | |
| 1535 | 1379 | /** Show Ajax message at the top of page |
| 1536 | - * | |
| 1380 | + * | |
| 1537 | 1381 | * @param type $message |
| 1538 | 1382 | * @param type $time_to_show |
| 1539 | 1383 | * @param type $is_error |
| 1540 | 1384 | */ |
| @@ -1546,24 +1390,24 @@ | ||
| 1546 | 1390 | // Escape any JavaScript from message |
| 1547 | 1391 | $notice = html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ; |
| 1548 | 1392 | |
| 1549 | 1393 | ?><script type="text/javascript"> |
| 1550 | - var my_message = '<?php echo $notice; ?>'; | |
| 1551 | - wpbm_admin_show_message( my_message, '<?php echo ( $is_error ? 'error' : 'success' ); ?>', <?php echo $time_to_show; ?> ); | |
| 1394 | + var my_message = '<?php echo esc_js( $notice ); ?>'; | |
| 1395 | + wpbm_admin_show_message( my_message, '<?php echo ( $is_error ? 'error' : 'success' ); ?>', <?php echo esc_attr($time_to_show); ?> ); | |
| 1552 | 1396 | </script><?php |
| 1553 | 1397 | } |
| 1554 | 1398 | |
| 1555 | 1399 | |
| 1556 | 1400 | /** Show "Saved Changes" message at the top of settings page. |
| 1557 | - * | |
| 1558 | - */ | |
| 1401 | + * | |
| 1402 | + */ | |
| 1559 | 1403 | function wpbm_show_changes_saved_message() { |
| 1560 | 1404 | wpbm_show_message ( __('Changes saved.', 'booking-manager'), 5 ); |
| 1561 | -} | |
| 1405 | +} | |
| 1562 | 1406 | |
| 1563 | 1407 | |
| 1564 | 1408 | /** Show Message at Top of Admin Pages |
| 1565 | - * | |
| 1409 | + * | |
| 1566 | 1410 | * @param type $message - mesage to show |
| 1567 | 1411 | * @param type $time_to_show - number of seconds to show, if 0 or skiped, then unlimited time. |
| 1568 | 1412 | * @param type $message_type - Default: updated { updated | error | notice } |
| 1569 | 1413 | */ |
| @@ -1569,9 +1413,9 @@ | ||
| 1569 | 1413 | */ |
| 1570 | 1414 | function wpbm_show_message ( $message, $time_to_show , $message_type = 'updated') { |
| 1571 | 1415 | |
| 1572 | 1416 | // Generate unique HTML ID for the message |
| 1573 | - $inner_message_id = intval( time() * rand(10, 100) ); | |
| 1417 | + $inner_message_id = intval( time() * wp_rand(10, 100) ); | |
| 1574 | 1418 | |
| 1575 | 1419 | // Get formated HTML message |
| 1576 | 1420 | $notice = wpbm_get_formated_message( $message, $message_type, $inner_message_id ); |
| 1577 | 1421 | |
| @@ -1578,13 +1422,16 @@ | ||
| 1578 | 1422 | // Get the time of message showing |
| 1579 | 1423 | $time_to_show = intval( $time_to_show ) * 1000; |
| 1580 | 1424 | |
| 1581 | 1425 | // Show this Message |
| 1582 | - ?> <script type="text/javascript"> | |
| 1426 | + ?> <script type="text/javascript"> | |
| 1583 | 1427 | if ( jQuery('.wpbm_admin_message').length ) { |
| 1584 | - jQuery('.wpbm_admin_message').append( '<?php echo $notice; ?>' ); | |
| 1428 | + jQuery('.wpbm_admin_message').append( '<?php | |
| 1429 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1430 | + echo ($notice); | |
| 1431 | + ?>' ); | |
| 1585 | 1432 | <?php if ( $time_to_show > 0 ) { ?> |
| 1586 | - jQuery('#wpbm_inner_message_<?php echo $inner_message_id; ?>').animate({opacity: 1},<?php echo $time_to_show; ?>).fadeOut( 2000 ); | |
| 1433 | + jQuery('#wpbm_inner_message_<?php echo esc_attr($inner_message_id); ?>').animate({opacity: 1},<?php echo esc_attr($time_to_show); ?>).fadeOut( 2000 ); | |
| 1587 | 1434 | <?php } ?> |
| 1588 | 1435 | } |
| 1589 | 1436 | </script> <?php |
| 1590 | 1437 | } |
| @@ -1590,9 +1437,9 @@ | ||
| 1590 | 1437 | } |
| 1591 | 1438 | |
| 1592 | 1439 | |
| 1593 | 1440 | /** Escape and prepare message to show it |
| 1594 | - * | |
| 1441 | + * | |
| 1595 | 1442 | * @param type $message - message |
| 1596 | 1443 | * @param type $message_type - Default: updated { updated | error | notice } |
| 1597 | 1444 | * @param string $inner_message_id - ID of message DIV, can be skipped |
| 1598 | 1445 | * @return string |
| @@ -1617,13 +1464,13 @@ | ||
| 1617 | 1464 | } |
| 1618 | 1465 | |
| 1619 | 1466 | |
| 1620 | 1467 | /** Show system info in settings page |
| 1621 | - * | |
| 1622 | - * @param string $message ... | |
| 1468 | + * | |
| 1469 | + * @param string $message ... | |
| 1623 | 1470 | * @param string $message_type 'info' | 'warning' | 'error' |
| 1624 | 1471 | * @param string $title __('Important!' , 'booking-manager') | __('Note' , 'booking-manager') |
| 1625 | - * | |
| 1472 | + * | |
| 1626 | 1473 | * Exmaple: wpbm_show_message_in_settings( __( 'Nothing Found', 'booking-manager'), 'warning', __('Important!' , 'booking-manager') ); |
| 1627 | 1474 | */ |
| 1628 | 1475 | function wpbm_show_message_in_settings( $message, $message_type = 'info', $title = '' , $is_echo = true ) { |
| 1629 | 1476 | |
| @@ -1642,9 +1489,9 @@ | ||
| 1642 | 1489 | |
| 1643 | 1490 | $message_content .= '<div class="clear"></div>'; |
| 1644 | 1491 | |
| 1645 | 1492 | if ( $is_echo ) |
| 1646 | - echo $message_content; | |
| 1493 | + echo wp_kses_post( $message_content ); | |
| 1647 | 1494 | else |
| 1648 | 1495 | return $message_content; |
| 1649 | 1496 | |
| 1650 | 1497 | } |
| @@ -1650,36 +1497,39 @@ | ||
| 1650 | 1497 | } |
| 1651 | 1498 | // </editor-fold> |
| 1652 | 1499 | |
| 1653 | 1500 | |
| 1654 | -// <editor-fold defaultstate="collapsed" desc=" Settings Meta Boxes " > | |
| 1655 | -//////////////////////////////////////////////////////////////////////////////// | |
| 1501 | +// <editor-fold defaultstate="collapsed" desc=" Settings Meta Boxes " > | |
| 1502 | +//////////////////////////////////////////////////////////////////////////////// | |
| 1656 | 1503 | // Settings Meta Boxes |
| 1657 | -//////////////////////////////////////////////////////////////////////////////// | |
| 1504 | +//////////////////////////////////////////////////////////////////////////////// | |
| 1658 | 1505 | function wpbm_open_meta_box_section( $metabox_id, $title ) { |
| 1659 | 1506 | |
| 1660 | 1507 | $my_close_open_win_id = $metabox_id . '_metabox'; |
| 1661 | - ?> | |
| 1662 | - <div class='meta-box'> | |
| 1663 | - <div | |
| 1664 | - id="<?php echo $my_close_open_win_id; ?>" | |
| 1665 | - class="postbox <?php if ( '1' == get_user_option( 'wpbm_win_' . $my_close_open_win_id ) ) echo 'closed'; ?>" | |
| 1666 | - > <div title="<?php _e('Click to toggle', 'booking-manager'); ?>" | |
| 1667 | - class="handlediv" | |
| 1668 | - onclick="javascript:wpbm_verify_window_opening(<?php echo get_wpbm_current_user_id(); ?>, '<?php echo $my_close_open_win_id; ?>');" | |
| 1669 | - ><br/></div> | |
| 1670 | - <h3 class='hndle'> | |
| 1671 | - <span><?php echo wp_kses_post( $title ); ?></span> | |
| 1672 | - </h3> | |
| 1673 | - <div class="inside"> | |
| 1674 | - <?php | |
| 1508 | + //FixIn: 2.0.16.1 | |
| 1509 | + ?> | |
| 1510 | + <div class='meta-box'> | |
| 1511 | + <div | |
| 1512 | + id="<?php echo esc_attr($my_close_open_win_id); ?>" | |
| 1513 | + class="postbox <?php if ( '1' == get_user_option( 'wpbm_win_' . $my_close_open_win_id ) ) echo 'closed'; ?>" | |
| 1514 | + ><div class="postbox-header" style="display: flex;flex-flow: row nowrap;border-bottom: 1px solid #ccd0d4;"><?php //FixIn: 8.7.8.1 ?> | |
| 1515 | + <h3 class='hndle' style="flex: 1 1 auto;border: none;"> | |
| 1516 | + <span><?php echo wp_kses_post( $title ); ?></span> | |
| 1517 | + </h3> | |
| 1518 | + <div title="<?php echo esc_attr(__('Click to toggle','booking-manager')); ?>" | |
| 1519 | + class="handlediv" | |
| 1520 | + onclick="javascript:wpbm_verify_window_opening(<?php echo esc_attr( get_wpbm_current_user_id() ); ?>, '<?php echo esc_attr($my_close_open_win_id); ?>');" | |
| 1521 | + ><br/></div> | |
| 1522 | + </div> | |
| 1523 | + <div class="inside"> | |
| 1524 | + <?php | |
| 1675 | 1525 | } |
| 1676 | 1526 | |
| 1677 | 1527 | function wpbm_close_meta_box_section() { |
| 1678 | 1528 | ?> |
| 1679 | - </div> | |
| 1680 | - </div> | |
| 1681 | - </div> | |
| 1529 | + </div> | |
| 1530 | + </div> | |
| 1531 | + </div> | |
| 1682 | 1532 | <?php |
| 1683 | 1533 | } |
| 1684 | 1534 | // </editor-fold> |
| 1685 | 1535 | |
| @@ -1684,23 +1534,23 @@ | ||
| 1684 | 1534 | // </editor-fold> |
| 1685 | 1535 | |
| 1686 | 1536 | |
| 1687 | 1537 | // from Toolbar |
| 1688 | -// <editor-fold defaultstate="collapsed" desc=" M o d a l s " > | |
| 1689 | -//////////////////////////////////////////////////////////////////////////////// | |
| 1538 | +// <editor-fold defaultstate="collapsed" desc=" M o d a l s " > | |
| 1539 | +//////////////////////////////////////////////////////////////////////////////// | |
| 1690 | 1540 | // M o d a l s |
| 1691 | 1541 | //////////////////////////////////////////////////////////////////////////////// |
| 1692 | 1542 | |
| 1693 | -/** Start Loyouts - Modal Window structure */ | |
| 1543 | +/** Start Loyouts - Modal Window structure */ | |
| 1694 | 1544 | function wpbm_write_content_for_modals_start_here() { |
| 1695 | - | |
| 1545 | + | |
| 1696 | 1546 | ?><span id="wpbm_content_for_modals"></span><?php |
| 1697 | 1547 | } |
| 1698 | -add_wpbm_action( 'wpbm_write_content_for_modals', 'wpbm_write_content_for_modals_start_here'); | |
| 1548 | +add_wpbm_action( 'wpbm_write_content_for_modals', 'wpbm_write_content_for_modals_start_here'); | |
| 1699 | 1549 | // </editor-fold> |
| 1700 | 1550 | |
| 1701 | 1551 | |
| 1702 | -// <editor-fold defaultstate="collapsed" desc=" Inline JavaScript " > | |
| 1552 | +// <editor-fold defaultstate="collapsed" desc=" Inline JavaScript " > | |
| 1703 | 1553 | //////////////////////////////////////////////////////////////////////////////// |
| 1704 | 1554 | // Inline J a v a S c r i p t to Footer page |
| 1705 | 1555 | //////////////////////////////////////////////////////////////////////////////// |
| 1706 | 1556 | /** |
| @@ -1736,9 +1586,9 @@ | ||
| 1736 | 1586 | |
| 1737 | 1587 | $wpbm_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wpbm_queued_js ); |
| 1738 | 1588 | $wpbm_queued_js = str_replace( "\r", '', $wpbm_queued_js ); |
| 1739 | 1589 | |
| 1740 | - echo $wpbm_queued_js . "});\n</script>\n<!-- End WPBM JavaScript -->\n"; | |
| 1590 | + echo $wpbm_queued_js . "});\n</script>\n<!-- End WPBM JavaScript -->\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1741 | 1591 | |
| 1742 | 1592 | $wpbm_queued_js = ''; |
| 1743 | 1593 | unset( $wpbm_queued_js ); |
| 1744 | 1594 | } |
| @@ -1746,9 +1596,9 @@ | ||
| 1746 | 1596 | |
| 1747 | 1597 | // </editor-fold> |
| 1748 | 1598 | |
| 1749 | 1599 | // from Toolbar |
| 1750 | -// <editor-fold defaultstate="collapsed" desc=" JS & CSS - Tooltips & Popover" > | |
| 1600 | +// <editor-fold defaultstate="collapsed" desc=" JS & CSS - Tooltips & Popover" > | |
| 1751 | 1601 | //////////////////////////////////////////////////////////////////////////////// |
| 1752 | 1602 | // JS & CSS |
| 1753 | 1603 | //////////////////////////////////////////////////////////////////////////////// |
| 1754 | 1604 | |
| @@ -1753,15 +1603,15 @@ | ||
| 1753 | 1603 | //////////////////////////////////////////////////////////////////////////////// |
| 1754 | 1604 | |
| 1755 | 1605 | /** Load suport JavaScript for "Items" page*/ |
| 1756 | 1606 | function wpbm_js_for_items_page() { |
| 1757 | - | |
| 1607 | + | |
| 1758 | 1608 | $is_use_hints = get_wpbm_option( 'wpbm_is_use_hints_at_admin_panel' ); |
| 1759 | 1609 | if ( $is_use_hints == 'On' ) |
| 1760 | 1610 | wpbm_bs_javascript_tooltips(); // JS Tooltips |
| 1761 | 1611 | |
| 1762 | - wpbm_bs_javascript_popover(); // JS Popover | |
| 1763 | - | |
| 1612 | + wpbm_bs_javascript_popover(); // JS Popover | |
| 1613 | + | |
| 1764 | 1614 | //wpbm_datepicker_js(); // JS Datepicker |
| 1765 | 1615 | wpbm_datepicker_css(); // CSS DatePicker |
| 1766 | 1616 | } |
| 1767 | 1617 | |
| @@ -1767,14 +1617,14 @@ | ||
| 1767 | 1617 | |
| 1768 | 1618 | |
| 1769 | 1619 | /** Datepicker activation JavaScript */ |
| 1770 | 1620 | function wpbm_datepicker_js() { |
| 1771 | - | |
| 1621 | + | |
| 1772 | 1622 | ?><script type="text/javascript"> |
| 1773 | 1623 | jQuery(document).ready( function(){ |
| 1774 | 1624 | |
| 1775 | 1625 | function applyCSStoDays( date ){ |
| 1776 | - return [true, 'date_available']; | |
| 1626 | + return [true, 'date_available']; | |
| 1777 | 1627 | } |
| 1778 | 1628 | jQuery('input.wpbm-filters-section-calendar').datepick( |
| 1779 | 1629 | { beforeShowDay: applyCSStoDays, |
| 1780 | 1630 | showOn: 'focus', |
| @@ -1785,9 +1635,9 @@ | ||
| 1785 | 1635 | nextText: '»', |
| 1786 | 1636 | dateFormat: 'yy-mm-dd', |
| 1787 | 1637 | changeMonth: false, |
| 1788 | 1638 | changeYear: false, |
| 1789 | - minDate: null, | |
| 1639 | + minDate: null, | |
| 1790 | 1640 | maxDate: null, //'1Y', |
| 1791 | 1641 | showStatus: false, |
| 1792 | 1642 | multiSeparator: ', ', |
| 1793 | 1643 | closeAtTop: false, |
| @@ -1798,9 +1648,9 @@ | ||
| 1798 | 1648 | mandatory: true |
| 1799 | 1649 | } |
| 1800 | 1650 | ); |
| 1801 | 1651 | }); |
| 1802 | - </script><?php | |
| 1652 | + </script><?php | |
| 1803 | 1653 | } |
| 1804 | 1654 | |
| 1805 | 1655 | |
| 1806 | 1656 | /** Support CSS - datepick, etc... */ |
| @@ -1836,16 +1686,16 @@ | ||
| 1836 | 1686 | height: auto; |
| 1837 | 1687 | } |
| 1838 | 1688 | </style> |
| 1839 | 1689 | <?php |
| 1840 | -} | |
| 1690 | +} | |
| 1841 | 1691 | |
| 1842 | 1692 | |
| 1843 | 1693 | /** Sortable Table JavaScript */ |
| 1844 | 1694 | function wpbm_sortable_js() { |
| 1845 | 1695 | ?> |
| 1846 | - <script type="text/javascript"> | |
| 1847 | - // Activate Sortable Functionality | |
| 1696 | + <script type="text/javascript"> | |
| 1697 | + // Activate Sortable Functionality | |
| 1848 | 1698 | jQuery( document ).ready(function(){ |
| 1849 | 1699 | |
| 1850 | 1700 | jQuery('.wpbm_input_table tbody th').css('cursor','move'); |
| 1851 | 1701 | |
| @@ -1869,20 +1719,20 @@ | ||
| 1869 | 1719 | }); |
| 1870 | 1720 | }); |
| 1871 | 1721 | </script> |
| 1872 | 1722 | <?php |
| 1873 | - | |
| 1723 | + | |
| 1874 | 1724 | } |
| 1875 | 1725 | // </editor-fold> |
| 1876 | 1726 | |
| 1877 | 1727 | |
| 1878 | -// <editor-fold defaultstate="collapsed" desc=" R e l o a d p a g e " > | |
| 1728 | +// <editor-fold defaultstate="collapsed" desc=" R e l o a d p a g e " > | |
| 1879 | 1729 | //////////////////////////////////////////////////////////////////////////////// |
| 1880 | 1730 | // R e l o a d p a g e |
| 1881 | 1731 | //////////////////////////////////////////////////////////////////////////////// |
| 1882 | 1732 | /** |
| 1883 | 1733 | * Reload page by using JavaScript |
| 1884 | - * | |
| 1734 | + * | |
| 1885 | 1735 | * @param string $url - URL of page to load |
| 1886 | 1736 | */ |
| 1887 | 1737 | function wpbm_reload_page_by_js( $url ) { |
| 1888 | 1738 | |
| @@ -1889,10 +1739,10 @@ | ||
| 1889 | 1739 | $redir = html_entity_decode( esc_url( $url ) ); |
| 1890 | 1740 | |
| 1891 | 1741 | if ( ! empty( $redir ) ) { |
| 1892 | 1742 | ?> |
| 1893 | - <script type="text/javascript"> | |
| 1894 | - window.location.href = '<?php echo $redir ?>'; | |
| 1743 | + <script type="text/javascript"> | |
| 1744 | + window.location.href = '<?php echo esc_url($redir); ?>'; | |
| 1895 | 1745 | </script> |
| 1896 | 1746 | <?php |
| 1897 | 1747 | } |
| 1898 | 1748 | } |
| @@ -1898,9 +1748,9 @@ | ||
| 1898 | 1748 | } |
| 1899 | 1749 | |
| 1900 | 1750 | |
| 1901 | 1751 | /** Redirect browser to a specific page |
| 1902 | - * | |
| 1752 | + * | |
| 1903 | 1753 | * @param string $url - URL of page to redirect |
| 1904 | 1754 | */ |
| 1905 | 1755 | function wpbm_redirect( $url ) { |
| 1906 | 1756 | |
| @@ -1908,20 +1758,20 @@ | ||
| 1908 | 1758 | |
| 1909 | 1759 | $url = html_entity_decode( esc_url( $url ) ); |
| 1910 | 1760 | |
| 1911 | 1761 | echo '<script type="text/javascript">'; |
| 1912 | - echo 'window.location.href="'.$url.'";'; | |
| 1762 | + echo 'window.location.href="'.esc_url($url).'";'; | |
| 1913 | 1763 | echo '</script>'; |
| 1914 | 1764 | echo '<noscript>'; |
| 1915 | - echo '<meta http-equiv="refresh" content="0;url='.$url.'" />'; | |
| 1765 | + echo '<meta http-equiv="refresh" content="0;url='.esc_url($url).'" />'; | |
| 1916 | 1766 | echo '</noscript>'; |
| 1917 | 1767 | } |
| 1918 | 1768 | // </editor-fold> |
| 1919 | 1769 | |
| 1920 | 1770 | |
| 1921 | -// <editor-fold defaultstate="collapsed" desc=" P a g i n a t i o n o f T a b l e L i s t i n g " > | |
| 1771 | +// <editor-fold defaultstate="collapsed" desc=" P a g i n a t i o n o f T a b l e L i s t i n g " > | |
| 1922 | 1772 | /** Show P a g i n a t i o n |
| 1923 | - * | |
| 1773 | + * | |
| 1924 | 1774 | * @param int $summ_number_of_items - total number of items |
| 1925 | 1775 | * @param int $active_page_num - number of activated page |
| 1926 | 1776 | * @param int $num_items_per_page - number of items per page |
| 1927 | 1777 | * @param array $only_these_parameters - array of keys to exclude from links |
| @@ -1937,11 +1787,10 @@ | ||
| 1937 | 1787 | if ( $pages_number < 2 ) |
| 1938 | 1788 | return; |
| 1939 | 1789 | |
| 1940 | 1790 | //Fix: 5.1.4 - Just in case we are having tooo much resources, then we need to show all resources - and its empty string |
| 1941 | - if ( ( isset($_REQUEST['wh_wpbm_type'] ) ) && ( strlen($_REQUEST['wh_wpbm_type']) > 1000 ) ) { | |
| 1942 | - $_REQUEST['wh_wpbm_type'] = ''; | |
| 1943 | - } | |
| 1791 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1792 | + if ( ( isset($_REQUEST['wh_wpbm_type'] ) ) && ( strlen($_REQUEST['wh_wpbm_type']) > 1000 ) ) { $_REQUEST['wh_wpbm_type'] = ''; } | |
| 1944 | 1793 | |
| 1945 | 1794 | // First parameter will overwriten by $_GET['page'] parameter |
| 1946 | 1795 | $bk_admin_url = wpbm_get_params_in_url( wpbm_get_master_url( false ), array('page_num'), $only_these_parameters ); |
| 1947 | 1796 | |
| @@ -1947,9 +1796,9 @@ | ||
| 1947 | 1796 | |
| 1948 | 1797 | |
| 1949 | 1798 | ?> |
| 1950 | 1799 | <span class="wpdevelop wpbm-pagination"> |
| 1951 | - <div class="container-fluid"> | |
| 1800 | + <div class="container-fluid"> | |
| 1952 | 1801 | <div class="row"> |
| 1953 | 1802 | <div class="col-sm-12 text-center control-group0"> |
| 1954 | 1803 | <nav class="btn-toolbar"> |
| 1955 | 1804 | <div class="btn-group wpbm-no-margin" style="float:none;"> |
| @@ -1954,13 +1803,13 @@ | ||
| 1954 | 1803 | <nav class="btn-toolbar"> |
| 1955 | 1804 | <div class="btn-group wpbm-no-margin" style="float:none;"> |
| 1956 | 1805 | |
| 1957 | 1806 | <?php if ( $pages_number > 1 ) { ?> |
| 1958 | - <a class="button button-secondary <?php echo ( $active_page_num == 1 ) ? ' disabled' : ''; ?>" | |
| 1959 | - href="<?php echo $bk_admin_url; ?>&page_num=<?php if ($active_page_num == 1) { echo $active_page_num; } else { echo ($active_page_num-1); } echo $url_sufix; ?>"> | |
| 1960 | - <?php _e('Prev', 'booking-manager'); ?> | |
| 1807 | + <a class="button button-secondary <?php echo ( $active_page_num == 1 ) ? ' disabled' : ''; ?>" | |
| 1808 | + href="<?php echo esc_url($bk_admin_url); ?>&page_num=<?php if ($active_page_num == 1) { echo esc_attr( $active_page_num ); } else { echo esc_attr($active_page_num-1); } echo esc_attr( $url_sufix ); ?>"> | |
| 1809 | + <?php esc_html_e('Prev', 'booking-manager'); ?> | |
| 1961 | 1810 | </a> |
| 1962 | - <?php } | |
| 1811 | + <?php } | |
| 1963 | 1812 | |
| 1964 | 1813 | /** Number visible pages (links) that linked to active page, other pages skipped by "..." */ |
| 1965 | 1814 | $num_closed_steps = 3; |
| 1966 | 1815 | |
| @@ -1965,23 +1814,23 @@ | ||
| 1965 | 1814 | $num_closed_steps = 3; |
| 1966 | 1815 | |
| 1967 | 1816 | for ( $pg_num = 1; $pg_num <= $pages_number; $pg_num++ ) { |
| 1968 | 1817 | |
| 1969 | - if ( ! ( | |
| 1970 | - ( $pages_number > ( $num_closed_steps * 4) ) | |
| 1971 | - && ( $pg_num > $num_closed_steps ) | |
| 1972 | - && ( ( $pages_number - $pg_num + 1 ) > $num_closed_steps ) | |
| 1973 | - && ( abs( $active_page_num - $pg_num ) > $num_closed_steps ) | |
| 1818 | + if ( ! ( | |
| 1819 | + ( $pages_number > ( $num_closed_steps * 4) ) | |
| 1820 | + && ( $pg_num > $num_closed_steps ) | |
| 1821 | + && ( ( $pages_number - $pg_num + 1 ) > $num_closed_steps ) | |
| 1822 | + && ( abs( $active_page_num - $pg_num ) > $num_closed_steps ) | |
| 1974 | 1823 | ) ) { |
| 1975 | - ?> <a class="button button-secondary <?php if ($pg_num == $active_page_num ) echo ' active'; ?>" | |
| 1976 | - href="<?php echo $bk_admin_url; ?>&page_num=<?php echo $pg_num; echo $url_sufix; ?>"> | |
| 1977 | - <?php echo $pg_num; ?> | |
| 1978 | - </a><?php | |
| 1824 | + ?> <a class="button button-secondary <?php if ($pg_num == $active_page_num ) echo ' active'; ?>" | |
| 1825 | + href="<?php echo esc_attr( $bk_admin_url ); ?>&page_num=<?php echo esc_attr( $pg_num); echo esc_attr( $url_sufix); ?>"> | |
| 1826 | + <?php echo esc_html($pg_num); ?> | |
| 1827 | + </a><?php | |
| 1979 | 1828 | |
| 1980 | - if ( ( $pages_number > ( $num_closed_steps * 4) ) | |
| 1981 | - && ( ($pg_num+1) > $num_closed_steps ) | |
| 1982 | - && ( ( $pages_number - ( $pg_num + 1 ) ) > $num_closed_steps ) | |
| 1983 | - && ( abs($active_page_num - ( $pg_num + 1 ) ) > $num_closed_steps ) | |
| 1829 | + if ( ( $pages_number > ( $num_closed_steps * 4) ) | |
| 1830 | + && ( ($pg_num+1) > $num_closed_steps ) | |
| 1831 | + && ( ( $pages_number - ( $pg_num + 1 ) ) > $num_closed_steps ) | |
| 1832 | + && ( abs($active_page_num - ( $pg_num + 1 ) ) > $num_closed_steps ) | |
| 1984 | 1833 | ) { |
| 1985 | 1834 | echo ' <a class="button button-secondary disabled" href="javascript:void(0);">...</a> '; |
| 1986 | 1835 | } |
| 1987 | 1836 | } |
| @@ -1987,11 +1836,11 @@ | ||
| 1987 | 1836 | } |
| 1988 | 1837 | } |
| 1989 | 1838 | |
| 1990 | 1839 | if ( $pages_number > 1 ) { ?> |
| 1991 | - <a class="button button-secondary <?php echo ( $active_page_num == $pages_number ) ? ' disabled' : ''; ?>" | |
| 1992 | - href="<?php echo $bk_admin_url; ?>&page_num=<?php if ($active_page_num == $pages_number) { echo $active_page_num; } else { echo ($active_page_num+1); } echo $url_sufix; ?>"> | |
| 1993 | - <?php _e('Next', 'booking-manager'); ?> | |
| 1840 | + <a class="button button-secondary <?php echo ( $active_page_num == $pages_number ) ? ' disabled' : ''; ?>" | |
| 1841 | + href="<?php echo esc_attr( $bk_admin_url ); ?>&page_num=<?php if ($active_page_num == $pages_number) { echo esc_attr( $active_page_num); } else { echo esc_attr($active_page_num+1); } echo esc_attr( $url_sufix); ?>"> | |
| 1842 | + <?php esc_html_e('Next', 'booking-manager'); ?> | |
| 1994 | 1843 | </a> |
| 1995 | 1844 | <?php } ?> |
| 1996 | 1845 | |
| 1997 | 1846 | </div> |
| @@ -2004,9 +1853,9 @@ | ||
| 2004 | 1853 | } |
| 2005 | 1854 | // </editor-fold> |
| 2006 | 1855 | |
| 2007 | 1856 | |
| 2008 | -// <editor-fold defaultstate="collapsed" desc=" D a t e s " > | |
| 1857 | +// <editor-fold defaultstate="collapsed" desc=" D a t e s " > | |
| 2009 | 1858 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2010 | 1859 | // Dates Format |
| 2011 | 1860 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2012 | 1861 | |
| @@ -2011,9 +1860,9 @@ | ||
| 2011 | 1860 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2012 | 1861 | |
| 2013 | 1862 | |
| 2014 | 1863 | /** Get Formated Date & time |
| 2015 | - * | |
| 1864 | + * | |
| 2016 | 1865 | * @param string $date_sql - 2017-07-31 00:00:00 || 2017-07-31 |
| 2017 | 1866 | * @param string $date_format - Optional. - "m / d / Y, D H:i:s" |
| 2018 | 1867 | * @param string $seperator - Optional. - " " |
| 2019 | 1868 | * @return string - July 29, 2014 12:00 am |
| @@ -2018,21 +1867,21 @@ | ||
| 2018 | 1867 | * @param string $seperator - Optional. - " " |
| 2019 | 1868 | * @return string - July 29, 2014 12:00 am |
| 2020 | 1869 | */ |
| 2021 | 1870 | function wpbm_get_date_time_formatted( $date_sql, $date_format = false, $seperator = ' ', $skip_midnight_time = false ) { |
| 2022 | - | |
| 1871 | + | |
| 2023 | 1872 | $return_date = wpbm_get_date_formatted( $date_sql, $date_format ); |
| 2024 | - | |
| 2025 | - $return_time = wpbm_get_time_formatted( $date_sql, $date_format, $skip_midnight_time ); | |
| 1873 | + | |
| 1874 | + $return_time = wpbm_get_time_formatted( $date_sql, $date_format, $skip_midnight_time ); | |
| 2026 | 1875 | if ( ! empty( $return_time ) ) |
| 2027 | 1876 | $return_date .= $seperator . $return_time; |
| 2028 | - | |
| 1877 | + | |
| 2029 | 1878 | return $return_date; |
| 2030 | 1879 | } |
| 2031 | 1880 | |
| 2032 | 1881 | |
| 2033 | 1882 | /** Get Formated Date |
| 2034 | - * | |
| 1883 | + * | |
| 2035 | 1884 | * @param string $date_sql - 2017-07-31 00:00:00 || 2017-07-31 |
| 2036 | 1885 | * @param string $date_format - Optional. - "m / d / Y, D" |
| 2037 | 1886 | * @param bool $skip_midnight_time - Default false - if 00:00:00 then return ''; |
| 2038 | 1887 | * @return string - July 29, 2014 |
| @@ -2040,17 +1889,17 @@ | ||
| 2040 | 1889 | function wpbm_get_date_formatted( $date_sql, $date_format = false ) { |
| 2041 | 1890 | |
| 2042 | 1891 | if ( $date_format === false ) $date_format = get_wpbm_option( 'wpbm_date_format' ); |
| 2043 | 1892 | if ( empty( $date_format ) ) $date_format = "m / d / Y, D"; |
| 2044 | - | |
| 1893 | + | |
| 2045 | 1894 | $formated_date = date_i18n( $date_format, strtotime( $date_sql ) ); |
| 2046 | - | |
| 1895 | + | |
| 2047 | 1896 | return $formated_date; |
| 2048 | 1897 | } |
| 2049 | 1898 | |
| 2050 | 1899 | |
| 2051 | 1900 | /** Get Formated Date & time |
| 2052 | - * | |
| 1901 | + * | |
| 2053 | 1902 | * @param string $date_sql - 2017-07-31 00:00:00 || 2017-07-31 |
| 2054 | 1903 | * @param string $time_format - Optional. - "H:i:s" |
| 2055 | 1904 | * @return string - 12:00 am |
| 2056 | 1905 | */ |
| @@ -2057,20 +1906,20 @@ | ||
| 2057 | 1906 | function wpbm_get_time_formatted( $date_sql, $time_format = false , $skip_midnight_time = false ) { |
| 2058 | 1907 | |
| 2059 | 1908 | if ( ( $skip_midnight_time ) && ( '00:00:00' == substr( $date_sql, -8 ) ) ) |
| 2060 | 1909 | return ''; |
| 2061 | - | |
| 1910 | + | |
| 2062 | 1911 | if ( $time_format === false ) $time_format = get_wpbm_option( 'wpbm_time_format' ); |
| 2063 | 1912 | if ( empty( $time_format ) ) $time_format = 'h:i a'; |
| 2064 | - | |
| 1913 | + | |
| 2065 | 1914 | $formated_date = date_i18n( $time_format, strtotime( $date_sql ) ); |
| 2066 | - | |
| 2067 | - return $formated_date; | |
| 1915 | + | |
| 1916 | + return $formated_date; | |
| 2068 | 1917 | } |
| 2069 | 1918 | |
| 2070 | 1919 | |
| 2071 | 1920 | /** Check if "current_day" is tomorrow from "next_day" |
| 2072 | - * | |
| 1921 | + * | |
| 2073 | 1922 | * @param string $current_day_sql_check : 2015-02-29 00:00:00 |
| 2074 | 1923 | * @param string $next_day_sql_check : 2015-02-30 00:00:00 |
| 2075 | 1924 | * @return boolean : true | false |
| 2076 | 1925 | */ |
| @@ -2077,28 +1926,28 @@ | ||
| 2077 | 1926 | function wpbm_is_next_day( $current_day_sql_check, $next_day_sql_check ) { |
| 2078 | 1927 | |
| 2079 | 1928 | // Current day |
| 2080 | 1929 | $current_day_unix = strtotime( $current_day_sql_check ); |
| 2081 | - | |
| 1930 | + | |
| 2082 | 1931 | $current_day_midnight_sql = date_i18n( 'Y-m-d', $current_day_unix ); |
| 2083 | 1932 | $current_day_midnight_unix = strtotime( $current_day_midnight_sql ); |
| 2084 | - | |
| 1933 | + | |
| 2085 | 1934 | $calc_next_day_unix = strtotime( '+1 day', $current_day_midnight_unix ); |
| 2086 | - | |
| 1935 | + | |
| 2087 | 1936 | // Next day |
| 2088 | - $next_day_unix = strtotime( $next_day_sql_check ); | |
| 1937 | + $next_day_unix = strtotime( $next_day_sql_check ); | |
| 2089 | 1938 | $next_day_midnight_sql = date_i18n( 'Y-m-d', $next_day_unix ); |
| 2090 | 1939 | $next_day_midnight_unix = strtotime( $next_day_midnight_sql ); |
| 2091 | - | |
| 2092 | - | |
| 2093 | - if ( $calc_next_day_unix == $next_day_midnight_unix ) | |
| 2094 | - return true; | |
| 2095 | - else | |
| 2096 | - return false; | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + if ( $calc_next_day_unix == $next_day_midnight_unix ) | |
| 1943 | + return true; | |
| 1944 | + else | |
| 1945 | + return false; | |
| 2097 | 1946 | } |
| 2098 | 1947 | |
| 2099 | 1948 | /** Check if "current_day" is same day of "other_day" |
| 2100 | - * | |
| 1949 | + * | |
| 2101 | 1950 | * @param string $current_day_sql_check : 2015-02-29 00:00:00 |
| 2102 | 1951 | * @param string $other_day_sql_check : 2015-02-30 00:00:00 |
| 2103 | 1952 | * @return boolean : true | false |
| 2104 | 1953 | */ |
| @@ -2105,27 +1954,27 @@ | ||
| 2105 | 1954 | function wpbm_is_this_same_day( $current_day_sql_check, $other_day_sql_check ) { |
| 2106 | 1955 | |
| 2107 | 1956 | // Current day |
| 2108 | 1957 | $current_day_unix = strtotime( $current_day_sql_check ); |
| 2109 | - | |
| 1958 | + | |
| 2110 | 1959 | $current_day_midnight_sql = date_i18n( 'Y-m-d', $current_day_unix ); |
| 2111 | 1960 | $current_day_midnight_unix = strtotime( $current_day_midnight_sql ); |
| 2112 | - | |
| 1961 | + | |
| 2113 | 1962 | // Other day |
| 2114 | - $other_day_unix = strtotime( $other_day_sql_check ); | |
| 1963 | + $other_day_unix = strtotime( $other_day_sql_check ); | |
| 2115 | 1964 | $other_day_midnight_sql = date_i18n( 'Y-m-d', $other_day_unix ); |
| 2116 | 1965 | $other_day_midnight_unix = strtotime( $other_day_midnight_sql ); |
| 2117 | - | |
| 2118 | - | |
| 2119 | - if ( $current_day_midnight_unix == $other_day_midnight_unix ) | |
| 2120 | - return true; | |
| 2121 | - else | |
| 2122 | - return false; | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + if ( $current_day_midnight_unix == $other_day_midnight_unix ) | |
| 1969 | + return true; | |
| 1970 | + else | |
| 1971 | + return false; | |
| 2123 | 1972 | } |
| 2124 | 1973 | |
| 2125 | 1974 | |
| 2126 | 1975 | /** Get days in short format view |
| 2127 | - * | |
| 1976 | + * | |
| 2128 | 1977 | * @param string $days Dates: 15.05.2015, 16.05.2015, 17.05.2015 |
| 2129 | 1978 | * @return string Dates in format: 15.05.2015 - 17.05.2015 |
| 2130 | 1979 | */ |
| 2131 | 1980 | function wpbm_get_dates_short_format( $dates_sql_csv ) { // $days - string with comma seperated dates |
| @@ -2139,24 +1988,24 @@ | ||
| 2139 | 1988 | $result_string = ''; |
| 2140 | 1989 | $last_show_day = ''; |
| 2141 | 1990 | |
| 2142 | 1991 | foreach ( $days as $day ) { |
| 2143 | - | |
| 1992 | + | |
| 2144 | 1993 | $is_fin_at_end = false; |
| 2145 | - | |
| 1994 | + | |
| 2146 | 1995 | if ( $previosday === false ) { // First Day |
| 2147 | - | |
| 1996 | + | |
| 2148 | 1997 | $result_string = wpbm_get_date_time_formatted( $day, false, ' ', true ); // echo format for first day |
| 2149 | 1998 | $last_show_day = $day; |
| 2150 | 1999 | $previosday = $day; // Set previos day for next loop |
| 2151 | - | |
| 2000 | + | |
| 2152 | 2001 | } else { // Not first day |
| 2153 | - | |
| 2154 | - if ( | |
| 2155 | - wpbm_is_next_day( $previosday, $day ) | |
| 2156 | - || wpbm_is_this_same_day( $previosday, $day ) | |
| 2002 | + | |
| 2003 | + if ( | |
| 2004 | + wpbm_is_next_day( $previosday, $day ) | |
| 2005 | + || wpbm_is_this_same_day( $previosday, $day ) | |
| 2157 | 2006 | ) { // Check if $day next day from previous |
| 2158 | - | |
| 2007 | + | |
| 2159 | 2008 | $previosday = $day; // Set previos day for next loop |
| 2160 | 2009 | $is_fin_at_end = true; |
| 2161 | 2010 | } else { |
| 2162 | 2011 | if ( $last_show_day !== $previosday ) { // check if previos day was show or no |
| @@ -2165,10 +2014,10 @@ | ||
| 2165 | 2014 | $result_string .= ', ' . wpbm_get_date_time_formatted( $day, false, ' ', true ); // assign in needed format this day |
| 2166 | 2015 | $previosday = $day; // Set previos day for next loop |
| 2167 | 2016 | $last_show_day = $day; |
| 2168 | 2017 | } |
| 2169 | - } | |
| 2170 | - | |
| 2018 | + } | |
| 2019 | + | |
| 2171 | 2020 | } |
| 2172 | 2021 | |
| 2173 | 2022 | if ( $is_fin_at_end ) { |
| 2174 | 2023 | $result_string .= ' - ' . wpbm_get_date_time_formatted( $day, false, ' ', true ); |
| @@ -2176,5 +2025,5 @@ | ||
| 2176 | 2025 | |
| 2177 | 2026 | return $result_string; |
| 2178 | 2027 | } |
| 2179 | 2028 | |
| 2180 | -// </editor-fold> | |
| 2029 | +// </editor-fold> | |