'Apache', 'litespeed' => 'LiteSpeed', 'nginx' => 'Nginx', 'iis' => 'IIS', 'unknown' => __('Unknown', 'all-in-one-wp-content-security')); $software = self::server_software(); return $labels[$software]; } /** * Whether the web server reads .htaccess files */ public static function uses_htaccess() { return in_array(self::server_software(), array('apache', 'litespeed'), true); } /** * Managed WordPress hosts detected from constants / environment variables they set */ public static function managed_host() { $hosts = array( 'wpengine' => array('WP Engine', defined('WPE_APIKEY') || function_exists('is_wpe')), 'kinsta' => array('Kinsta', defined('KINSTAMU_VERSION')), 'pantheon' => array('Pantheon', isset($_ENV['PANTHEON_ENVIRONMENT']) || defined('PANTHEON_ENVIRONMENT')), 'vip' => array('WordPress VIP', defined('WPCOM_IS_VIP_ENV') && WPCOM_IS_VIP_ENV), 'atomic' => array('WordPress.com', defined('IS_ATOMIC') && IS_ATOMIC), 'pressable' => array('Pressable', defined('IS_PRESSABLE') && IS_PRESSABLE), 'godaddy' => array('GoDaddy Managed WordPress', defined('GD_SYSTEM_PLUGIN_DIR')), 'flywheel' => array('Flywheel', defined('FLYWHEEL_CONFIG_DIR')), 'siteground' => array('SiteGround', defined('SG_OPTIMIZER_VERSION')), ); foreach ($hosts as $key => $host) { if ($host[1]) { return array('key' => $key, 'name' => $host[0]); } } return null; } /** * Whether PHP runs as the owner of the WordPress files (suEXEC / PHP-FPM pool per account) */ public static function php_runs_as_file_owner() { if (!function_exists('posix_geteuid')) { return null; } $owner = @fileowner(ABSPATH . 'wp-includes/version.php'); if ($owner === false) { return null; } return posix_geteuid() === $owner; } public static function php_user() { if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) { $info = posix_getpwuid(posix_geteuid()); if (is_array($info) && isset($info['name'])) { return $info['name']; } } return function_exists('get_current_user') ? get_current_user() : ''; } public static function uploads_dir() { $uploads = wp_upload_dir(null, false); return array( 'path' => isset($uploads['basedir']) ? wp_normalize_path($uploads['basedir']) : wp_normalize_path(WP_CONTENT_DIR . '/uploads'), 'url' => isset($uploads['baseurl']) ? $uploads['baseurl'] : content_url('uploads'), ); } /** * Map a file inside the WordPress directory to its public URL (or '' when it is not below the site root) */ public static function path_to_url($path) { $path = wp_normalize_path($path); $content = wp_normalize_path(WP_CONTENT_DIR); if (strpos($path, $content . '/') === 0) { return content_url(substr($path, strlen($content) + 1)); } $root = wp_normalize_path(ABSPATH); if (strpos($path, $root) === 0) { return site_url(substr($path, strlen($root))); } return ''; } public static function has_object_cache() { return (bool) wp_using_ext_object_cache(); } /** * Summary for the Server Health screen */ public static function summary() { global $wpdb; $host = self::managed_host(); $uploads = self::uploads_dir(); return array( 'wordpress' => get_bloginfo('version'), 'php' => PHP_VERSION, 'php_sapi' => PHP_SAPI, 'server' => self::server_label(), 'server_raw' => isset($_SERVER['SERVER_SOFTWARE']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE'])) : '', 'os' => PHP_OS_FAMILY, 'database' => method_exists($wpdb, 'db_server_info') ? $wpdb->db_server_info() : $wpdb->db_version(), 'managed_host' => $host ? $host['name'] : '', 'https' => wp_is_using_https(), 'object_cache' => self::has_object_cache(), 'environment' => wp_get_environment_type(), 'multisite' => is_multisite(), 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time'), 'php_user' => self::php_user(), 'php_owns_files' => self::php_runs_as_file_owner(), 'uploads' => AOWPCS_Plugin::relative_path($uploads['path']), 'cron_disabled' => defined('DISABLE_WP_CRON') && DISABLE_WP_CRON, ); } }