Completed
Push — dev/5.5.4 ( 00f8da...b8ed00 )
by Sudar
02:11
created

BD_System_Info_page   B

Complexity

Total Complexity 36

Size/Duplication

Total Lines 205
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 36
lcom 1
cbo 1
dl 0
loc 205
rs 8.8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A factory() 0 9 2
A initialize() 0 16 1
B render_header() 0 25 5
D render_body() 0 111 27
A generate_sysinfo_download() 0 9 1
1
<?php
2
/**
3
 * Display System Info.
4
 *
5
 * Also provide an option to download system info for using in support requests.
6
 *
7
 * @since       5.5.4
8
 * @note        Based on the code from Easy Digital Downloads plugin
9
 * @author		Sudar
10
 * @package     BulkDelete\Admin
11
 */
12
13
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
14
15
/**
16
 * Encapsulates System info.
17
 *
18
 * @since 5.5.4
19
 */
20
class BD_System_Info_page extends BD_Base_Page {
21
22
	/**
23
	 * Make this class a "hybrid Singleton".
24
	 *
25
	 * @static
26
	 * @since 5.5.4
27
	 */
28
	public static function factory() {
29
		static $instance = false;
30
31
		if ( ! $instance ) {
32
			$instance = new self;
33
		}
34
35
		return $instance;
36
	}
37
38
	/**
39
	 * Initialize and setup variables.
40
	 *
41
	 * @since 5.5.4
42
	 */
43
	protected function initialize() {
44
		$this->page_slug = 'bulk-delete-info';
45
		$this->menu_action = 'bd_after_all_menus';
46
		$this->actions = array( 'download_sysinfo' );
47
48
		$this->label = array(
49
			'page_title' => __( 'Bulk Delete - System Info', 'bulk-delete' ),
50
			'menu_title' => __( 'System Info', 'bulk-delete' ),
51
		);
52
53
		$this->messages = array(
54
			'info_message' => __( 'Please include this information when posting support requests.', 'bulk-delete' ),
55
		);
56
57
		add_action( 'bd_download_sysinfo', array( $this, 'generate_sysinfo_download' ) );
58
	}
59
60
	/**
61
	 * Render header.
62
	 *
63
	 * @since 5.5.4
64
	 */
65
	protected function render_header() {
66
?>
67
		<div class="updated">
68
			<p><strong><?php echo $this->messages['info_message']; ?></strong></p>
69
		</div>
70
71
		<?php if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { ?>
72
			<div class="notice notice-warning">
73
				<p><strong>
74
					<?php printf( __( 'SAVEQUERIES is <a href="%s" target="_blank">enabled</a>. This puts additional load on the memory and will restrict the number of items that can be deleted.', 'bulk-delete' ), 'https://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis' ); ?>
75
				</strong></p>
76
			</div>
77
		<?php } ?>
78
79
		<?php if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) { ?>
80
			<div class="notice notice-warning">
81
				<p><strong>
82
					<?php printf( __( 'DISABLE_WP_CRON is <a href="%s" target="_blank">enabled</a>. This prevents scheduler from running.', 'bulk-delete' ), 'https://codex.wordpress.org/Editing_wp-config.php#Disable_Cron_and_Cron_Timeout' ); ?>
83
				</strong></p>
84
			</div>
85
		<?php } ?>
86
87
		<?php bd_render_sidebar_iframe(); ?>
88
<?php
89
	}
90
91
	/**
92
	 * Shows the system info panel which contains version data and debug info.
93
	 *
94
	 * @since 5.5.4
95
	 * @global $wpdb Global object $wpdb Used to query the database using the WordPress Database API
96
	 */
97
	protected function render_body() {
98
		global $wpdb;
99
?>
100
		<textarea wrap="off" style="width:100%;height:500px;font-family:Menlo,Monaco,monospace;white-space:pre;" readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="bulk-delete-sysinfo" title="<?php _e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'bulk-delete' ); ?>">
101
### Begin System Info ###
102
<?php
103
		/**
104
		 * Runs before displaying system info.
105
		 *
106
		 * This action is primarily for adding extra content in System Info.
107
		 */
108
		do_action( 'bd_system_info_before' );
109
?>
110
111
Multisite:                <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
112
113
SITE_URL:                 <?php echo site_url() . "\n"; ?>
114
HOME_URL:                 <?php echo home_url() . "\n"; ?>
115
Browser:                  <?php echo esc_html( $_SERVER['HTTP_USER_AGENT'] ), "\n"; ?>
116
117
Permalink Structure:      <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
118
Active Theme:             <?php echo bd_get_current_theme_name() . "\n"; ?>
119
<?php
120
		$host = bd_identify_host();
121
		if ( '' !== $host ) : ?>
122
Host:                     <?php echo $host . "\n\n"; ?>
123
<?php
124
		endif;
125
126
		$post_types = get_post_types();
127
?>
128
Registered Post types:    <?php echo implode( ', ', $post_types ) . "\n"; ?>
129
<?php
130
		foreach ( $post_types as $post_type ) {
131
			echo $post_type;
132
			if ( strlen( $post_type ) < 26 ) {
133
				echo str_repeat( ' ', 26 - strlen( $post_type ) );
134
			}
135
			$post_count = wp_count_posts( $post_type );
136
			foreach ( $post_count as $key => $value ) {
137
				echo $key, '=', $value, ', ';
138
			}
139
			echo "\n";
140
		}
141
?>
142
143
Bulk Delete Version:      <?php echo Bulk_Delete::VERSION . "\n"; ?>
144
WordPress Version:        <?php echo get_bloginfo( 'version' ) . "\n"; ?>
145
PHP Version:              <?php echo PHP_VERSION . "\n"; ?>
146
MySQL Version:            <?php echo $wpdb->db_version() . "\n"; ?>
147
Web Server Info:          <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
148
149
WordPress Memory Limit:   <?php echo WP_MEMORY_LIMIT; ?><?php echo "\n"; ?>
150
WordPress Max Limit:      <?php echo WP_MAX_MEMORY_LIMIT; ?><?php echo "\n"; ?>
151
PHP Memory Limit:         <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
152
153
SAVEQUERIES:              <?php echo defined( 'SAVEQUERIES' ) ? SAVEQUERIES ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
154
WP_DEBUG:                 <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
155
WP_SCRIPT_DEBUG:          <?php echo defined( 'WP_SCRIPT_DEBUG' ) ? WP_SCRIPT_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
156
157
GMT Offset:               <?php echo esc_html( get_option( 'gmt_offset' ) ), "\n\n"; ?>
158
DISABLE_WP_CRON:          <?php echo defined( 'DISABLE_WP_CRON' ) ? DISABLE_WP_CRON ? 'Yes' . "\n" : 'No' . "\n" : 'Not set' . "\n" ?>
159
WP_CRON_LOCK_TIMEOUT:     <?php echo defined( 'WP_CRON_LOCK_TIMEOUT' ) ? WP_CRON_LOCK_TIMEOUT : 'Not set', "\n" ?>
160
EMPTY_TRASH_DAYS:         <?php echo defined( 'EMPTY_TRASH_DAYS' ) ? EMPTY_TRASH_DAYS : 'Not set', "\n" ?>
161
162
PHP Safe Mode:            <?php echo ini_get( 'safe_mode' ) ? 'Yes' : 'No', "\n"; ?>
163
PHP Upload Max Size:      <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
164
PHP Post Max Size:        <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
165
PHP Upload Max Filesize:  <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
166
PHP Time Limit:           <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
167
PHP Max Input Vars:       <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
168
PHP Arg Separator:        <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
169
PHP Allow URL File Open:  <?php echo ini_get( 'allow_url_fopen' ) ? 'Yes' : 'No', "\n"; ?>
170
171
WP Table Prefix:          <?php echo $wpdb->prefix, "\n";?>
172
173
Session:                  <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
174
Session Name:             <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
175
Cookie Path:              <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
176
Save Path:                <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
177
Use Cookies:              <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
178
Use Only Cookies:         <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
179
180
DISPLAY ERRORS:           <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
181
FSOCKOPEN:                <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
182
cURL:                     <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
183
SOAP Client:              <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
184
SUHOSIN:                  <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
185
186
ACTIVE PLUGINS:
187
188
<?php bd_print_current_plugins(); ?>
189
190
<?php
191
		if ( is_multisite() ) : ?>
192
NETWORK ACTIVE PLUGINS:
193
194
<?php
195
			bd_print_network_active_plugins();
196
		endif;
197
?>
198
199
<?php do_action( 'bd_system_info_after' );?>
200
### End System Info ###</textarea>
201
202
		<p class="submit">
203
			<input type="hidden" name="bd_action" value="download_sysinfo">
204
			<?php submit_button( 'Download System Info File', 'primary', 'bulk-delete-download-sysinfo', false ); ?>
205
		</p>
206
<?php
207
	}
208
209
	/**
210
	 * Generates the System Info Download File.
211
	 *
212
	 * @since 5.0
213
	 * @return void
214
	 */
215
	public function generate_sysinfo_download() {
216
		nocache_headers();
217
218
		header( 'Content-type: text/plain' );
219
		header( 'Content-Disposition: attachment; filename="bulk-delete-system-info.txt"' );
220
221
		echo wp_strip_all_tags( $_POST['bulk-delete-sysinfo'] );
222
		die();
223
	}
224
}
225
226
BD_System_Info_page::factory();
227