ads
1 week ago
groups
1 week ago
metaboxes
1 year ago
pages
3 months ago
placements
1 week ago
class-action-links.php
1 week ago
class-addon-box.php
1 year ago
class-addon-updater.php
3 months ago
class-admin-menu.php
1 week ago
class-admin-notices.php
1 year ago
class-ajax.php
3 months ago
class-assets.php
1 week ago
class-authors.php
1 year ago
class-edd-updater.php
4 weeks ago
class-list-filters.php
1 week ago
class-marketing.php
1 year ago
class-metabox-ad-settings.php
1 year ago
class-metabox-ad.php
1 year ago
class-misc.php
1 week ago
class-page-quick-edit.php
1 year ago
class-plugin-installer.php
1 year ago
class-post-list.php
1 year ago
class-post-types.php
1 week ago
class-screen-options.php
3 months ago
class-settings.php
1 year ago
class-shortcode-creator.php
1 year ago
class-system-info.php
1 year ago
class-tinymce.php
2 years ago
class-translation-promo.php
1 year ago
class-upgrades.php
1 year ago
class-version-control.php
3 months ago
class-welcome.php
1 year ago
class-wordpress-dashboard.php
1 year ago
index.php
2 years ago
class-system-info.php
292 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin System Info. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.50.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Admin; |
| 11 | |
| 12 | use AdvancedAds\Framework\Utilities\Params; |
| 13 | |
| 14 | defined( 'ABSPATH' ) || exit; |
| 15 | |
| 16 | /** |
| 17 | * Admin System Info. |
| 18 | */ |
| 19 | class System_Info { |
| 20 | |
| 21 | /** |
| 22 | * Get system information. |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | public function get_info() { |
| 27 | $data = '### Begin System Info ###' . "\n\n"; |
| 28 | |
| 29 | $data .= $this->advanced_ads_info(); |
| 30 | $data .= $this->site_info(); |
| 31 | $data .= $this->wp_info(); |
| 32 | $data .= $this->uploads_info(); |
| 33 | $data .= $this->plugins_info(); |
| 34 | $data .= $this->server_info(); |
| 35 | |
| 36 | $data .= "\n" . '### End System Info ###'; |
| 37 | |
| 38 | return $data; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get Advanced Ads info. |
| 43 | * |
| 44 | * @return string |
| 45 | */ |
| 46 | private function advanced_ads_info() { |
| 47 | $data = '-- Advanced Ads Info' . "\n\n"; |
| 48 | $data .= $this->get_it_spaced( 'Pro', defined( 'AAP_VERSION' ) ? 'Activated' : 'Not Activated', 22 ); |
| 49 | |
| 50 | return $data; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get Site info. |
| 55 | * |
| 56 | * @return string |
| 57 | */ |
| 58 | private function site_info() { |
| 59 | $data = "\n" . '-- Site Info' . "\n\n"; |
| 60 | $data .= $this->get_it_spaced( 'Site URL', site_url(), 17 ); |
| 61 | $data .= $this->get_it_spaced( 'Home URL', home_url(), 17 ); |
| 62 | $data .= $this->get_it_spaced( 'Multisite', is_multisite() ? 'Yes' : 'No', 16 ); |
| 63 | |
| 64 | return $data; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Get WordPress Configuration info. |
| 69 | * |
| 70 | * @return string |
| 71 | */ |
| 72 | private function wp_info() { |
| 73 | global $wpdb; |
| 74 | |
| 75 | $theme_data = wp_get_theme(); |
| 76 | $theme = $theme_data->name . ' ' . $theme_data->version; |
| 77 | |
| 78 | $data = "\n" . '-- WordPress Configuration' . "\n\n"; |
| 79 | $data .= $this->get_it_spaced( 'Version', get_bloginfo( 'version' ), 18 ); |
| 80 | $data .= $this->get_it_spaced( 'Language', get_locale(), 17 ); |
| 81 | $data .= $this->get_it_spaced( 'User Language', get_user_locale(), 12 ); |
| 82 | $data .= $this->get_it_spaced( 'Permalink Structure', get_option( 'permalink_structure' ) ?? 'Default', 6 ); |
| 83 | $data .= $this->get_it_spaced( 'Active Theme', $theme, 13 ); |
| 84 | $data .= $this->get_it_spaced( 'Show On Front', get_option( 'show_on_front' ), 12 ); |
| 85 | $data .= $this->get_it_spaced( 'ABSPATH', ABSPATH, 18 ); |
| 86 | $data .= $this->get_it_spaced( 'Table Prefix', 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ), 13 ); //phpcs:ignore |
| 87 | $data .= $this->get_it_spaced( 'WP_DEBUG', defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set', 17 ); |
| 88 | $data .= $this->get_it_spaced( 'Memory Limit', WP_MEMORY_LIMIT, 13 ); |
| 89 | $data .= $this->get_it_spaced( 'Registered Post Stati', implode( ', ', get_post_stati() ), 4 ); |
| 90 | $data .= $this->get_it_spaced( 'Revisions', WP_POST_REVISIONS ? WP_POST_REVISIONS > 1 ? 'Limited to ' . WP_POST_REVISIONS : 'Enabled' : 'Disabled', 16 ); |
| 91 | |
| 92 | return $data; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Get Uploads/Constants info. |
| 97 | * |
| 98 | * @return string |
| 99 | */ |
| 100 | private function uploads_info() { |
| 101 | $uploads_dir = wp_upload_dir(); |
| 102 | |
| 103 | $data = "\n" . '-- WordPress Uploads/Constants' . "\n\n"; |
| 104 | $data .= $this->get_it_spaced( 'WP_CONTENT_DIR', defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR ? WP_CONTENT_DIR : 'Disabled' : 'Not set', 11 ); |
| 105 | $data .= $this->get_it_spaced( 'WP_CONTENT_URL', defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL ? WP_CONTENT_URL : 'Disabled' : 'Not set', 11 ); |
| 106 | $data .= $this->get_it_spaced( 'UPLOADS', defined( 'UPLOADS' ) ? UPLOADS ? UPLOADS : 'Disabled' : 'Not set', 18 ); |
| 107 | $data .= $this->get_it_spaced( 'wp_uploads_dir() path', $uploads_dir['path'], 4 ); |
| 108 | $data .= $this->get_it_spaced( 'wp_uploads_dir() url', $uploads_dir['url'], 5 ); |
| 109 | $data .= $this->get_it_spaced( 'wp_uploads_dir() basedir', $uploads_dir['basedir'], 1 ); |
| 110 | $data .= $this->get_it_spaced( 'wp_uploads_dir() baseurl', $uploads_dir['baseurl'], 1 ); |
| 111 | |
| 112 | return $data; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Get Plugins info. |
| 117 | * |
| 118 | * @return string |
| 119 | */ |
| 120 | private function plugins_info() { |
| 121 | $data = $this->mu_plugins(); |
| 122 | $data .= $this->installed_plugins(); |
| 123 | $data .= $this->multisite_plugins(); |
| 124 | |
| 125 | return $data; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Get MU Plugins info. |
| 130 | * |
| 131 | * @return string |
| 132 | */ |
| 133 | private function mu_plugins() { |
| 134 | $data = ''; |
| 135 | |
| 136 | // Must-use plugins. |
| 137 | // NOTE: MU plugins can't show updates! |
| 138 | $muplugins = get_mu_plugins(); |
| 139 | |
| 140 | if ( ! empty( $muplugins ) && count( $muplugins ) > 0 ) { |
| 141 | $data = "\n" . '-- Must-Use Plugins' . "\n\n"; |
| 142 | |
| 143 | foreach ( $muplugins as $plugin => $plugin_data ) { |
| 144 | $data .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | return $data; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Get Installed Plugins info. |
| 153 | * |
| 154 | * @return string |
| 155 | */ |
| 156 | private function installed_plugins() { |
| 157 | $updates = get_plugin_updates(); |
| 158 | |
| 159 | // WordPress active plugins. |
| 160 | $data = "\n" . '-- WordPress Active Plugins' . "\n\n"; |
| 161 | |
| 162 | $plugins = get_plugins(); |
| 163 | $active_plugins = get_option( 'active_plugins', [] ); |
| 164 | |
| 165 | foreach ( $plugins as $plugin_path => $plugin ) { |
| 166 | if ( ! in_array( $plugin_path, $active_plugins, true ) ) { |
| 167 | continue; |
| 168 | } |
| 169 | |
| 170 | $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : ''; |
| 171 | $data .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n"; |
| 172 | } |
| 173 | |
| 174 | // WordPress inactive plugins. |
| 175 | $data .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; |
| 176 | |
| 177 | foreach ( $plugins as $plugin_path => $plugin ) { |
| 178 | if ( in_array( $plugin_path, $active_plugins, true ) ) { |
| 179 | continue; |
| 180 | } |
| 181 | |
| 182 | $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : ''; |
| 183 | $data .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n"; |
| 184 | } |
| 185 | |
| 186 | return $data; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Get Multisite Plugins info. |
| 191 | * |
| 192 | * @return string |
| 193 | */ |
| 194 | private function multisite_plugins() { |
| 195 | $data = ''; |
| 196 | |
| 197 | if ( ! is_multisite() ) { |
| 198 | return $data; |
| 199 | } |
| 200 | |
| 201 | $updates = get_plugin_updates(); |
| 202 | |
| 203 | // WordPress Multisite active plugins. |
| 204 | $data = "\n" . '-- Network Active Plugins' . "\n\n"; |
| 205 | |
| 206 | $plugins = wp_get_active_network_plugins(); |
| 207 | $active_plugins = get_site_option( 'active_sitewide_plugins', [] ); |
| 208 | |
| 209 | foreach ( $plugins as $plugin_path ) { |
| 210 | $plugin_base = plugin_basename( $plugin_path ); |
| 211 | |
| 212 | if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { |
| 213 | continue; |
| 214 | } |
| 215 | |
| 216 | $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : ''; |
| 217 | $plugin = get_plugin_data( $plugin_path ); |
| 218 | $data .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n"; |
| 219 | } |
| 220 | |
| 221 | return $data; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Get Server info. |
| 226 | * |
| 227 | * @return string |
| 228 | */ |
| 229 | private function server_info() { |
| 230 | global $wpdb; |
| 231 | |
| 232 | // Server configuration (really just versions). |
| 233 | $software = Params::server( 'SERVER_SOFTWARE', '' ); |
| 234 | $software = sanitize_text_field( wp_unslash( $software ) ); |
| 235 | |
| 236 | $data = "\n" . '-- Webserver Configuration' . "\n\n"; |
| 237 | $data .= $this->get_it_spaced( 'PHP Version:', PHP_VERSION, 14 ); |
| 238 | $data .= $this->get_it_spaced( 'MySQL Version', $wpdb->db_version(), 13 ); |
| 239 | $data .= $this->get_it_spaced( 'Webserver Info', $software, 12 ); |
| 240 | |
| 241 | // PHP configs... now we're getting to the important stuff. |
| 242 | $data .= "\n" . '-- PHP Configuration' . "\n\n"; |
| 243 | $data .= $this->get_it_spaced( 'Memory Limit', ini_get( 'memory_limit' ), 13 ); |
| 244 | $data .= $this->get_it_spaced( 'Upload Max Size', ini_get( 'upload_max_filesize' ), 10 ); |
| 245 | $data .= $this->get_it_spaced( 'Post Max Size', ini_get( 'post_max_size' ), 12 ); |
| 246 | $data .= $this->get_it_spaced( 'Upload Max Filesize', ini_get( 'upload_max_filesize' ), 6 ); |
| 247 | $data .= $this->get_it_spaced( 'Time Limit', ini_get( 'max_execution_time' ), 15 ); |
| 248 | $data .= $this->get_it_spaced( 'Max Input Vars', ini_get( 'max_input_vars' ), 11 ); |
| 249 | $data .= $this->get_it_spaced( 'Display Errors', ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ), 11 ); |
| 250 | |
| 251 | // PHP extensions and such. |
| 252 | $data .= "\n" . '-- PHP Extensions' . "\n\n"; |
| 253 | $data .= $this->get_it_spaced( 'cURL', function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported', 21 ); |
| 254 | $data .= $this->get_it_spaced( 'fsockopen', function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported', 16 ); |
| 255 | $data .= $this->get_it_spaced( 'SOAP Client', class_exists( 'SoapClient', false ) ? 'Installed' : 'Not Installed', 14 ); |
| 256 | $data .= $this->get_it_spaced( 'Suhosin', extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed', 18 ); |
| 257 | |
| 258 | // Session stuff. |
| 259 | $data .= "\n" . '-- Session Configuration' . "\n\n"; |
| 260 | $data .= $this->get_it_spaced( 'Session', isset( $_SESSION ) ? 'Enabled' : 'Disabled', 18 ); |
| 261 | |
| 262 | // The rest of this is only relevant if session is enabled. |
| 263 | if ( isset( $_SESSION ) ) { |
| 264 | $data .= $this->get_it_spaced( 'Session Name', esc_html( ini_get( 'session.name' ) ), 13 ); |
| 265 | $data .= $this->get_it_spaced( 'Cookie Path', esc_html( ini_get( 'session.cookie_path' ) ), 14 ); |
| 266 | $data .= $this->get_it_spaced( 'Save Path', esc_html( ini_get( 'session.save_path' ) ), 16 ); |
| 267 | $data .= $this->get_it_spaced( 'Use Cookies', ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ), 14 ); |
| 268 | $data .= $this->get_it_spaced( 'Use Only Cookies', ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ), 9 ); |
| 269 | } |
| 270 | |
| 271 | return $data; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Consistent spacing in labels |
| 276 | * |
| 277 | * @param string $label Label of data. |
| 278 | * @param string $value Value of data. |
| 279 | * @param int $space Space count. |
| 280 | * |
| 281 | * @return string |
| 282 | */ |
| 283 | private function get_it_spaced( $label, $value, $space = 9 ): string { |
| 284 | return sprintf( |
| 285 | '%1$s:%2$s%3$s' . "\n", |
| 286 | $label, |
| 287 | str_repeat( ' ', $space ), |
| 288 | $value |
| 289 | ); |
| 290 | } |
| 291 | } |
| 292 |