| @@ -12,11 +12,9 @@ | ||
| 12 | 12 | // phpcs:disable -- required to support custom wp-config.php file location |
| 13 | 13 | |
| 14 | 14 | // set php.ini variables. |
| 15 | 15 | @ignore_user_abort( true ); |
| 16 | -if ( false !== strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) ) { | |
| 17 | - @set_time_limit( 0 ); | |
| 18 | -} | |
| 16 | +@set_time_limit( 0 ); | |
| 19 | 17 | $mem = '512M'; |
| 20 | 18 | @ini_set( 'memory_limit', $mem ); |
| 21 | 19 | @ini_set( 'max_execution_time', 0 ); |
| 22 | 20 | |
| @@ -30,27 +28,27 @@ | ||
| 30 | 28 | $included = false; |
| 31 | 29 | |
| 32 | 30 | |
| 33 | 31 | if ( file_exists( __DIR__ . '/../../../../wp-load.php' ) ) { |
| 34 | - include_once __DIR__ . '/../../../../wp-load.php'; // NOSONAR - WP compatible. | |
| 35 | - $included = true; | |
| 32 | + include_once __DIR__ . '/../../../../wp-load.php'; | |
| 33 | + $included = true; | |
| 36 | 34 | } elseif ( file_exists( __DIR__ . '/../../../../wp-config.php' ) ) { |
| 37 | - $wp_config = file_get_contents( __DIR__ . '/../../../../wp-config.php' ); // phpcs:ignore -- used before loading WP. | |
| 38 | - preg_match_all( '/.*define[^d].*ABSPATH.*/i', $wp_config, $matches ); | |
| 39 | - if ( ! empty( $matches ) ) { | |
| 40 | - foreach ( $matches as $match ) { | |
| 41 | - $execute = str_ireplace( 'ABSPATH', 'TMPABSPATH', $match[0] ); | |
| 42 | - $execute = str_ireplace( '__FILE__', "'" . __DIR__ . '/../../../../wp-config.php' . "'", $execute ); | |
| 43 | - eval( $execute ); // NOSONAR - wp-config file are safe content. | |
| 44 | - if ( file_exists( TMPABSPATH . 'wp-load.php' ) ) { | |
| 45 | - include_once TMPABSPATH . 'wp-load.php'; // NOSONAR - WP compatible. | |
| 46 | - $included = true; | |
| 47 | - break; | |
| 48 | - } | |
| 49 | - } | |
| 50 | - } | |
| 35 | + $wp_config = file_get_contents( __DIR__ . '/../../../../wp-config.php' ); // phpcs:ignore -- used before loading WP. | |
| 36 | + preg_match_all( '/.*define[^d].*ABSPATH.*/i', $wp_config, $matches ); | |
| 37 | + if ( count( $matches ) > 0 ) { | |
| 38 | + foreach ( $matches as $match ) { | |
| 39 | + $execute = str_ireplace( 'ABSPATH', 'TMPABSPATH', $match[0] ); | |
| 40 | + $execute = str_ireplace( '__FILE__', "'" . __DIR__ . '/../../../../wp-config.php' . "'", $execute ); | |
| 41 | + eval( $execute ); | |
| 42 | + if ( file_exists( TMPABSPATH . 'wp-load.php' ) ) { | |
| 43 | + include_once TMPABSPATH . 'wp-load.php'; | |
| 44 | + $included = true; | |
| 45 | + break; | |
| 46 | + } | |
| 47 | + } | |
| 48 | + } | |
| 51 | 49 | } |
| 52 | 50 | |
| 53 | 51 | // phpcs:enable |
| 54 | 52 | if ( ! $included ) { |
| 55 | - exit( 'Unsupported WordPress setup' ); | |
| 53 | + exit( 'Unsupported WordPress setup' ); | |
| 56 | 54 | } |