| @@ -1,64 +1,34 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * MainWP bootstrap. | |
| 4 | - * | |
| 5 | - * Set default php.ini variables | |
| 6 | - * check if load wp-load & wp-config exist & include them | |
| 7 | - * else exit due to "Unsupported WordPress Setup". | |
| 8 | - * | |
| 9 | - * @package MainWP/Bootstrap | |
| 10 | - */ | |
| 11 | - | |
| 12 | -// phpcs:disable WordPress.Security.PluginSecurity.MissingDirectFileAccessProtection | |
| 13 | - | |
| 14 | -/** | |
| 15 | - * This file must execute before WordPress loads to locate wp-load.php, | |
| 16 | - * so the standard ABSPATH check would break functionality. | |
| 17 | - * | |
| 18 | - * Do not prevent direct access ! defined( 'ABSPATH' ) exit | |
| 19 | - * to support custom wp-config.php file location, but do prevent direct access if WP is not loaded. | |
| 20 | - */ | |
| 21 | - | |
| 22 | -// set php.ini variables. | |
| 23 | -@ignore_user_abort( true ); | |
| 24 | -if ( false !== strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) ) { | |
| 25 | - @set_time_limit( 0 ); | |
| 26 | -} | |
| 27 | -$mem = '512M'; | |
| 28 | -@ini_set( 'memory_limit', $mem ); | |
| 29 | -@ini_set( 'max_execution_time', 0 ); | |
| 30 | - | |
| 31 | -/** | |
| 32 | - * Checks whether cron is in progress. | |
| 33 | - * | |
| 34 | - * @const ( bool ) Default: true | |
| 35 | - * @source https://github.com/mainwp/mainwp/blob/master/cron/bootstrap.php | |
| 36 | - */ | |
| 37 | -define( 'DOING_CRON', true ); | |
| 38 | -$included = false; | |
| 39 | - | |
| 40 | - | |
| 41 | -if ( file_exists( __DIR__ . '/../../../../wp-load.php' ) ) { | |
| 42 | - include_once __DIR__ . '/../../../../wp-load.php'; // NOSONAR - WP compatible. | |
| 43 | - $included = true; | |
| 44 | -} elseif ( file_exists( __DIR__ . '/../../../../wp-config.php' ) ) { | |
| 45 | - $wp_config = file_get_contents( __DIR__ . '/../../../../wp-config.php' ); // phpcs:ignore -- used before loading WP. | |
| 46 | - preg_match_all( '/.*define[^d].*ABSPATH.*/i', $wp_config, $matches ); | |
| 47 | - if ( ! empty( $matches ) ) { | |
| 48 | - foreach ( $matches as $match ) { | |
| 49 | - $execute = str_ireplace( 'ABSPATH', 'TMPABSPATH', $match[0] ); | |
| 50 | - $execute = str_ireplace( '__FILE__', "'" . __DIR__ . '/../../../../wp-config.php' . "'", $execute ); | |
| 51 | - eval( $execute ); // NOSONAR - wp-config file are safe content. | |
| 52 | - if ( file_exists( TMPABSPATH . 'wp-load.php' ) ) { | |
| 53 | - include_once TMPABSPATH . 'wp-load.php'; // NOSONAR - WP compatible. | |
| 54 | - $included = true; | |
| 55 | - break; | |
| 56 | - } | |
| 57 | - } | |
| 58 | - } | |
| 59 | -} | |
| 60 | - | |
| 61 | -// phpcs:enable | |
| 62 | -if ( ! $included ) { | |
| 63 | - exit( 'Unsupported WordPress setup' ); | |
| 64 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +@ignore_user_abort( true ); | |
| 4 | +@set_time_limit( 0 ); | |
| 5 | +$mem = '512M'; | |
| 6 | +@ini_set( 'memory_limit', $mem ); | |
| 7 | +@ini_set( 'max_execution_time', 0 ); | |
| 8 | + | |
| 9 | +define( 'DOING_CRON', true ); | |
| 10 | +$included = false; | |
| 11 | + | |
| 12 | +if ( file_exists( __DIR__ . '/../../../../wp-load.php' ) ) { | |
| 13 | + include_once __DIR__ . '/../../../../wp-load.php'; | |
| 14 | + $included = true; | |
| 15 | +} else if ( file_exists( __DIR__ . '/../../../../wp-config.php' ) ) { | |
| 16 | + $wp_config = file_get_contents( __DIR__ . '/../../../../wp-config.php' ); | |
| 17 | + preg_match_all( '/.*define[^d].*ABSPATH.*/i', $wp_config, $matches ); | |
| 18 | + if ( count( $matches ) > 0 ) { | |
| 19 | + foreach ( $matches as $match ) { | |
| 20 | + $execute = str_ireplace( 'ABSPATH', 'TMPABSPATH', $match[ 0 ] ); | |
| 21 | + $execute = str_ireplace( '__FILE__', "'" . __DIR__ . '/../../../../wp-config.php' . "'", $execute ); | |
| 22 | + eval( $execute ); | |
| 23 | + if ( file_exists( TMPABSPATH . 'wp-load.php' ) ) { | |
| 24 | + include_once TMPABSPATH . 'wp-load.php'; | |
| 25 | + $included = true; | |
| 26 | + break; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + } | |
| 30 | +} | |
| 31 | + | |
| 32 | +if ( !$included ) { | |
| 33 | + exit( 'Unsupported wordpress setup' ); | |
| 34 | +} | |