Server IP : 172.67.157.199 / Your IP : 3.149.234.209 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/plugins/defender-security/src/component/security-tweaks/ |
Upload File : |
<?php /** * Handles checks and operations related to the PHP version used by the server. * * @package WP_Defender\Component\Security_Tweaks */ namespace WP_Defender\Component\Security_Tweaks; use Calotes\Base\Component; /** * Handles checks and operations related to the PHP version used by the server. */ class PHP_Version extends Component { /** * Identifier slug for the component. * * @var string */ public $slug = 'php-version'; /** * Minimum PHP version required. * * @var string|null */ public $min_php = null; /** * Recommended stable PHP version. * * @var string|null */ public $stable_php = null; /** * Current PHP version of the server. * * @var string */ public $current_php = PHP_VERSION; /** * Check whether the issue has been resolved or not. * * @return bool */ public function check() { return $this->is_resolved(); } /** * Here is the code for processing. * * @return bool */ public function process(): bool { return true; } /** * This is for un-do stuff that has to be done in @process. * * @return bool */ public function revert(): bool { return true; } /** * Shield up. * * @return bool */ public function shield_up(): bool { return true; } /** * Check wheter the issue is resolved or not. * * @return bool */ private function is_resolved() { $this->set_php_versions(); return version_compare( $this->current_php, $this->min_php, '>' ); } /** * Setup PHP versions. * * @return void */ private function set_php_versions() { if ( ! function_exists( 'wp_check_php_version' ) ) { require_once ABSPATH . 'wp-admin/includes/misc.php'; } $info = wp_check_php_version(); if ( ! $info ) { $this->min_php = 'n/a'; $this->stable_php = 'n/a'; return; } $supported_php = apply_filters( "defender_{$this->slug}_supported_php", array( '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', ) ); $this->stable_php = $info['recommended_version']; $position = array_search( $this->stable_php, $supported_php, true ); if ( false !== $position && ! empty( $supported_php[ $position ] ) ) { $this->min_php = $supported_php[ $position ]; } } /** * Return a summary data of this tweak. * * @return array */ public function to_array(): array { $this->set_php_versions(); return array( 'slug' => $this->slug, 'title' => esc_html__( 'Update PHP to latest version', 'defender-security' ), 'errorReason' => sprintf( /* translators: %s: Min PHP version. %s: Min PHP version. */ esc_html__( 'PHP versions older than %1$s are no longer supported. For security and stability we strongly recommend you upgrade your PHP version to version %2$s or newer as soon as possible.', 'defender-security' ), $this->min_php, $this->min_php ), 'successReason' => esc_html__( 'You have the latest version of PHP installed, good stuff!', 'defender-security' ), 'misc' => array( 'php_version' => $this->current_php, 'min_php_version' => $this->min_php, 'stable_php_version' => $this->stable_php, ), ); } }