0 ? round(($used / $disk_total) * 100) : 0; // Website-Größe berechnen $website_size = $this->get_directory_size(ABSPATH); // PHP Version Check $current_php = phpversion(); $latest_stable_php = '8.3.0'; // Aktuelle stabile Version $update_recommended = version_compare($current_php, $latest_stable_php, '<'); // Datenbank-Informationen $db_size = $wpdb->get_var( $wpdb->prepare( "SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = %s", DB_NAME ) ); $table_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM information_schema.TABLES WHERE table_schema = %s", DB_NAME ) ); $max_allowed_packet = $wpdb->get_var( "SHOW VARIABLES LIKE 'max_allowed_packet'", 1 ); $max_connections = $wpdb->get_var( "SHOW VARIABLES LIKE 'max_connections'", 1 ); return array( 'server' => array( 'software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : 'Unbekannt', 'os' => php_uname(), 'hostname' => php_uname( 'n' ), 'architecture' => php_uname( 'm' ), ), 'php' => array( 'version' => $current_php, 'latest_stable' => $latest_stable_php, 'update_recommended' => $update_recommended, 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time'), 'upload_max_filesize' => ini_get('upload_max_filesize'), 'post_max_size' => ini_get('post_max_size'), 'max_input_vars' => ini_get('max_input_vars'), 'display_errors' => ini_get('display_errors') ? 'An' : 'Aus', 'allow_url_fopen' => ini_get('allow_url_fopen') ? 'Ja' : 'Nein' ), 'database' => array( 'type' => 'MySQL', 'version' => $wpdb->db_version(), 'charset' => $wpdb->charset, 'collation' => $wpdb->collate, 'prefix' => $wpdb->prefix, 'max_allowed_packet' => $max_allowed_packet ? size_format($max_allowed_packet) : 'Unbekannt', 'max_connections' => $max_connections ? $max_connections : 'Unbekannt', 'table_count' => $table_count, 'database_size' => $db_size ? size_format($db_size) : 'Unbekannt' ), 'wordpress' => array( 'version' => get_bloginfo('version'), 'multisite' => is_multisite() ? 'Ja' : 'Nein', 'language' => get_locale(), 'debug_mode' => (defined('WP_DEBUG') && WP_DEBUG) ? 'Ja' : 'Nein', 'wp_memory_limit' => WP_MEMORY_LIMIT, 'wp_max_memory_limit' => WP_MAX_MEMORY_LIMIT, 'home_url' => home_url(), 'site_url' => site_url() ), 'theme' => array( 'active' => array( 'name' => $theme->get('Name'), 'version' => $theme->get('Version'), 'author' => $theme->get('Author'), 'template' => $theme->get('Template'), 'stylesheet' => $theme->get_stylesheet() ), 'all' => $this->get_all_themes() ), 'plugins' => array( 'total' => count($plugins), 'active' => count($active), 'inactive' => count($plugins) - count($active), 'list' => $this->get_all_plugins() ), 'extensions' => $extensions, 'disk' => array( 'total_formatted' => size_format($disk_total), 'free_formatted' => size_format($disk_free), 'used_formatted' => size_format($used), 'used_percentage' => $used_percentage, 'website_size' => size_format($website_size) ) ); } /** * Berechnet die Größe eines Verzeichnisses rekursiv */ private function get_directory_size($path) { $total_size = 0; $timeout = time() + 5; // 5 Sekunden Timeout if (is_dir($path)) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CATCH_GET_CHILD ); foreach ($files as $file) { if (time() > $timeout) { break; // Timeout erreicht } if ($file->isFile()) { $total_size += $file->getSize(); } } } return $total_size; } /** * Gibt alle installierten Themes zurück */ private function get_all_themes() { $all_themes = wp_get_themes(); $current_theme = wp_get_theme(); $themes_list = array(); foreach ( $all_themes as $theme_slug => $theme ) { $themes_list[] = array( 'name' => $theme->get( 'Name' ), 'version' => $theme->get( 'Version' ), 'author' => wp_strip_all_tags( $theme->get( 'Author' ) ), 'is_active' => ( $current_theme->get_stylesheet() === $theme_slug ), ); } return $themes_list; } /** * Gibt alle installierten Plugins zurück */ private function get_all_plugins() { $all_plugins = get_plugins(); $active_plugins = get_option( 'active_plugins', array() ); $plugins_list = array(); foreach ( $all_plugins as $plugin_file => $plugin_data ) { $plugins_list[] = array( 'name' => $plugin_data['Name'], 'version' => $plugin_data['Version'], 'author' => wp_strip_all_tags( $plugin_data['Author'] ), 'is_active' => in_array( $plugin_file, $active_plugins, true ), ); } return $plugins_list; } }