PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.3
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.3
8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 7.8.6 All 45 releases
← All changes | includes/admin/tools/system-info.php +522 -0 7.9.28.0.3 View file →
@@ -1,0 +1,522 @@
1 +<?php
2 +/**
3 + * System Info Tool
4 + *
5 + * @package GamiPress\Admin\Tools\System_Info
6 + * @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gmail.com>
7 + * @since 1.1.7
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * Register System Info Tool meta boxes
14 + *
15 + * @since 1.1.7
16 + * @updated 1.5.9 Added the GamiPress installation date on GamiPress info box
17 + *
18 + * @param array $meta_boxes
19 + *
20 + * @return array
21 + */
22 +function gamipress_system_info_tool_meta_boxes( $meta_boxes ) {
23 +
24 + global $wpdb;
25 +
26 + $download = ( defined( 'GAMIPRESS_DOWNLOADING_SYSTEM_INFO' ) && GAMIPRESS_DOWNLOADING_SYSTEM_INFO );
27 +
28 + // ----------------------------------------------------
29 + // Server Info
30 + // ----------------------------------------------------
31 +
32 + $meta_boxes['server-info'] = array(
33 + 'title' => ( ! $download ? gamipress_dashicon( 'dashboard' ) : '' ) . __( 'Server Info', 'gamipress' ),
34 + 'classes' => 'gamipress-list-table',
35 + 'fields' => apply_filters( 'gamipress_server_info_tool_fields', array(
36 + 'hosting_provider' => array(
37 + 'name' => __( 'Hosting Provider', 'gamipress' ),
38 + 'type' => 'display',
39 + 'value' => gamipress_get_hosting_provider(),
40 + ),
41 + 'php_os' => array(
42 + 'name' => __( 'Operating System', 'gamipress' ),
43 + 'type' => 'display',
44 + 'value' => PHP_OS,
45 + ),
46 + 'php_version' => array(
47 + 'name' => __( 'PHP Version', 'gamipress' ),
48 + 'type' => 'display',
49 + 'value' => PHP_VERSION,
50 + 'classes' => ( version_compare( PHP_VERSION, '7.0.0', '>=' ) ? 'gamipress-label-success' : 'gamipress-label-danger' ),
51 + ),
52 + 'server_software' => array(
53 + 'name' => __( 'Webserver Info', 'gamipress' ),
54 + 'type' => 'display',
55 + 'value' => $_SERVER['SERVER_SOFTWARE'],
56 + ),
57 + 'php_title' => array(
58 + 'name' => __( 'PHP Configuration', 'gamipress' ),
59 + 'type' => 'title',
60 + ),
61 + 'php_memory_limit' => array(
62 + 'name' => __( 'Memory Limit', 'gamipress' ),
63 + 'type' => 'display',
64 + 'value' => ini_get( 'memory_limit' ),
65 + ),
66 + 'php_max_execution_time' => array(
67 + 'name' => __( 'Time Limit', 'gamipress' ),
68 + 'type' => 'display',
69 + 'value' => ini_get( 'max_execution_time' ),
70 + ),
71 + 'php_upload_max_filesize' => array(
72 + 'name' => __( 'Upload Max Size', 'gamipress' ),
73 + 'type' => 'display',
74 + 'value' => ini_get( 'upload_max_filesize' ),
75 + ),
76 + 'php_post_max_size' => array(
77 + 'name' => __( 'Post Max Size', 'gamipress' ),
78 + 'type' => 'display',
79 + 'value' => ini_get( 'post_max_size' ),
80 + ),
81 + 'php_max_input_vars' => array(
82 + 'name' => __( 'Max Input Vars', 'gamipress' ),
83 + 'type' => 'display',
84 + 'value' => ini_get( 'max_input_vars' ),
85 + ),
86 + 'php_display_errors' => array(
87 + 'name' => __( 'Display Errors', 'gamipress' ),
88 + 'type' => 'display',
89 + 'value' => ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ),
90 + ),
91 + ) )
92 + );
93 +
94 + // ----------------------------------------------------
95 + // Database Info
96 + // ----------------------------------------------------
97 +
98 + // Check database tables
99 + $logs_exists = gamipress_database_table_exists( GamiPress()->db->logs );
100 + $logs_meta_exists = gamipress_database_table_exists( GamiPress()->db->logs_meta );
101 + $user_earnings_exists = gamipress_database_table_exists( GamiPress()->db->user_earnings );
102 + $user_earnings_meta_exists = gamipress_database_table_exists( GamiPress()->db->user_earnings_meta );
103 + $last_upgrade = get_option( 'gamipress_version', '1.0.0' );
104 + $last_required_upgrade = gamipress_get_last_required_upgrade();
105 +
106 + $meta_boxes['db-info'] = array(
107 + 'title' => ( ! $download ? gamipress_dashicon( 'cloud' ) : '' ) . __( 'Database Info', 'gamipress' ),
108 + 'classes' => 'gamipress-list-table',
109 + 'fields' => apply_filters( 'gamipress_db_info_tool_fields', array(
110 + 'db_host' => array(
111 + 'name' => __( 'Database Host', 'gamipress' ),
112 + 'type' => 'display',
113 + 'value' => DB_HOST,
114 + ),
115 + 'db_version' => array(
116 + 'name' => __( 'MySQL Version', 'gamipress' ),
117 + 'type' => 'display',
118 + 'value' => $wpdb->db_version(),
119 + 'classes' => ( version_compare( $wpdb->db_version(), '5.0', '>=' ) ? 'gamipress-label-success' : 'gamipress-label-danger' ),
120 + ),
121 + 'gamipress_last_upgrade' => array(
122 + 'name' => __( 'Last Upgrade', 'gamipress' ),
123 + 'type' => 'display',
124 + 'value' => $last_upgrade,
125 + 'classes' => ( version_compare( $last_upgrade, $last_required_upgrade, '>=' ) ? 'gamipress-label-success' : 'gamipress-label-danger' ),
126 + ),
127 + 'gamipress_logs' => array(
128 + 'name' => __( 'Logs Database', 'gamipress' ),
129 + 'type' => 'display',
130 + 'value' => ( $logs_exists ? 'Yes' : 'No' ),
131 + 'classes' => ( $logs_exists ? 'gamipress-label-success' : 'gamipress-label-danger' ),
132 + ),
133 + 'gamipress_logs_meta' => array(
134 + 'name' => __( 'Logs Meta Database', 'gamipress' ),
135 + 'type' => 'display',
136 + 'value' => ( $logs_meta_exists ? 'Yes' : 'No' ),
137 + 'classes' => ( $logs_meta_exists ? 'gamipress-label-success' : 'gamipress-label-danger' ),
138 + ),
139 + 'gamipress_user_earnigns' => array(
140 + 'name' => __( 'User Earnings Database', 'gamipress' ),
141 + 'type' => 'display',
142 + 'value' => ( $user_earnings_exists ? 'Yes' : 'No' ),
143 + 'classes' => ( $user_earnings_exists ? 'gamipress-label-success' : 'gamipress-label-danger' ),
144 + ),
145 + 'gamipress_user_earnigns_meta' => array(
146 + 'name' => __( 'User Earnings Meta Database', 'gamipress' ),
147 + 'type' => 'display',
148 + 'value' => ( $user_earnings_meta_exists ? 'Yes' : 'No' ),
149 + 'classes' => ( $user_earnings_meta_exists ? 'gamipress-label-success' : 'gamipress-label-danger' ),
150 + ),
151 + ) )
152 + );
153 +
154 + // ----------------------------------------------------
155 + // WordPress Info
156 + // ----------------------------------------------------
157 +
158 + $locale = get_locale();
159 +
160 + $timezone = get_option( 'timezone_string' );
161 +
162 + if ( ! $timezone ) {
163 + $timezone = get_option( 'gmt_offset' );
164 + }
165 +
166 + // Get WordPress Theme info
167 + $theme_data = wp_get_theme();
168 + $theme = $theme_data->Name . ' (' . $theme_data->Version . ')';
169 + $parent_theme = $theme_data->Template;
170 +
171 + if ( ! empty( $parent_theme ) ) {
172 + $parent_theme_data = wp_get_theme( $parent_theme );
173 + $parent_theme = $parent_theme_data->Name . ' (' . $parent_theme_data->Version . ')';
174 + }
175 +
176 + // Retrieve current plugin information
177 + if( ! function_exists( 'get_plugins' ) ) {
178 + include ABSPATH . '/wp-admin/includes/plugin.php';
179 + }
180 +
181 + $plugins = get_plugins();
182 + $active_plugins = get_option( 'active_plugins', array() );
183 + $active_plugins_output = '';
184 +
185 + foreach ( $plugins as $plugin_path => $plugin ) {
186 + // If the plugin isn't active, don't show it.
187 + if ( ! in_array( $plugin_path, $active_plugins ) )
188 + continue;
189 +
190 + $active_plugins_output .= $plugin['Name'] . ' (' . $plugin['Version'] . ')' . '<br>';
191 + }
192 +
193 + $meta_boxes['wordpress-info'] = array(
194 + 'title' => ( ! $download ? gamipress_dashicon( 'wordpress' ) : '' ) . __( 'WordPress Info', 'gamipress' ),
195 + 'classes' => 'gamipress-list-table',
196 + 'fields' => apply_filters( 'gamipress_wordpress_info_tool_fields', array(
197 + 'site_url' => array(
198 + 'name' => __( 'Site URL', 'gamipress' ),
199 + 'type' => 'display',
200 + 'value' => site_url(),
201 + ),
202 + 'home_url' => array(
203 + 'name' => __( 'Home URL', 'gamipress' ),
204 + 'type' => 'display',
205 + 'value' => home_url(),
206 + ),
207 + 'multisite' => array(
208 + 'name' => __( 'Multisite', 'gamipress' ),
209 + 'type' => 'display',
210 + 'value' => ( is_multisite() ? 'Yes' : 'No' ),
211 + ),
212 + 'wp_version' => array(
213 + 'name' => __( 'Version', 'gamipress' ),
214 + 'type' => 'display',
215 + 'value' => get_bloginfo( 'version' ),
216 + ),
217 + 'wp_locale' => array(
218 + 'name' => __( 'Language', 'gamipress' ),
219 + 'type' => 'display',
220 + 'value' => ( ! empty( $locale ) ? $locale : 'en_US' ),
221 + ),
222 + 'wp_timezone' => array(
223 + 'name' => __( 'Timezone', 'gamipress' ),
224 + 'type' => 'display',
225 + 'value' => $timezone,
226 + ),
227 + 'wp_date' => array(
228 + 'name' => __( 'Site Date', 'gamipress' ),
229 + 'type' => 'display',
230 + 'value' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
231 + ),
232 + 'wp_date_utc' => array(
233 + 'name' => __( 'Universal Date', 'gamipress' ),
234 + 'type' => 'display',
235 + 'value' => date_i18n( 'Y-m-d H:i:s', $timestamp_with_offset = false, $gmt = false ),
236 + ),
237 + 'wp_permalink' => array(
238 + 'name' => __( 'Permalink Structure', 'gamipress' ),
239 + 'type' => 'display',
240 + 'value' => ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ),
241 + ),
242 + 'wp_abspath' => array(
243 + 'name' => __( 'Absolute Path', 'gamipress' ),
244 + 'type' => 'display',
245 + 'value' => ABSPATH,
246 + ),
247 + 'wp_debug' => array(
248 + 'name' => __( 'Debug', 'gamipress' ),
249 + 'type' => 'display',
250 + 'value' => ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ),
251 + ),
252 + 'wp_memory_limit' => array(
253 + 'name' => __( 'Memory Limit', 'gamipress' ),
254 + 'type' => 'display',
255 + 'value' => WP_MEMORY_LIMIT,
256 + ),
257 + 'wp_table_prefix' => array(
258 + 'name' => __( 'Table Prefix:', 'gamipress' ),
259 + 'type' => 'display',
260 + 'value' => $wpdb->prefix,
261 + ),
262 + 'wp_theme' => array(
263 + 'name' => __( 'Active Theme', 'gamipress' ),
264 + 'type' => 'display',
265 + 'value' => $theme,
266 + ),
267 + 'wp_parent_theme' => array(
268 + 'name' => __( 'Parent Theme', 'gamipress' ),
269 + 'type' => 'display',
270 + 'value' => $parent_theme,
271 + ),
272 + 'wp_active_plugins' => array(
273 + 'name' => __( 'Active Plugins', 'gamipress' ),
274 + 'type' => 'display',
275 + 'value' => $active_plugins_output,
276 + ),
277 + ) )
278 + );
279 +
280 + // ----------------------------------------------------
281 + // GamiPress Info
282 + // ----------------------------------------------------
283 +
284 + // Get all points types
285 + $points_types = gamipress_get_points_types();
286 + $points_types_output = '';
287 +
288 + foreach ( $points_types as $points_type_slug => $points_type ) {
289 + $points_types_output .= $points_type['singular_name'] . ' - ' . $points_type['plural_name'] . ' - ' . $points_type_slug . ' (#' . $points_type['ID'] . ')' . '<br>';
290 + }
291 +
292 + // Get all achievement types
293 + $achievement_types = gamipress_get_achievement_types();
294 + $achievement_types_output = '';
295 +
296 + foreach ( $achievement_types as $achievement_type_slug => $achievement_type ) {
297 + $achievement_types_output .= $achievement_type['singular_name'] . ' - ' . $achievement_type['plural_name'] . ' - ' . $achievement_type_slug . ' (#' . $achievement_type['ID'] . ')' . '<br>';
298 + }
299 +
300 + // Get all rank types
301 + $rank_types = gamipress_get_rank_types();
302 + $rank_types_output = '';
303 +
304 + foreach ( $rank_types as $rank_type_slug => $rank_type ) {
305 + $rank_types_output .= $rank_type['singular_name'] . ' - ' . $rank_type['plural_name'] . ' - ' . $rank_type_slug . ' (#' . $rank_type['ID'] . ')' . '<br>';
306 + }
307 +
308 + // Listeners count
309 + $listeners_count = gamipress_get_triggers_listeners_count();
310 + $listeners_count_output = '';
311 +
312 + foreach( $listeners_count as $trigger => $count ) {
313 + $label = gamipress_get_activity_trigger_label( $trigger );
314 +
315 + if( empty( $label ) )
316 + $label = $trigger . ' ' . __( '(Event\'s plugin not installed)', 'gamipress' );
317 +
318 + $listeners_count_output .= ( ! $download ? $label : $trigger ) . ': ' . $count . '<br>';
319 + }
320 +
321 + // Get all settings stored
322 + if( GamiPress()->settings === null ) {
323 + if( gamipress_is_network_wide_active() ) {
324 + GamiPress()->settings = ( $exists = get_site_option( 'gamipress_settings' ) ) ? $exists : array();
325 + } else {
326 + GamiPress()->settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array();
327 + }
328 + }
329 +
330 + $gamipress_settings_output = '';
331 +
332 + if( GamiPress()->settings ) {
333 +
334 + foreach ( GamiPress()->settings as $setting_key => $setting_value ) {
335 +
336 + if( is_array( $setting_value ) )
337 + $setting_value = json_encode( $setting_value );
338 +
339 + $gamipress_settings_output .= $setting_key . ': ' . $setting_value . '<br>';
340 +
341 + }
342 +
343 + }
344 +
345 + // Get the installation date
346 + if( gamipress_is_network_wide_active() ) {
347 + $gamipress_install_date = ( $exists = get_site_option( 'gamipress_install_date' ) ) ? $exists : '';
348 + } else {
349 + $gamipress_install_date = ( $exists = get_option( 'gamipress_install_date' ) ) ? $exists : '';
350 + }
351 +
352 + $meta_boxes['gamipress-info'] = array(
353 + 'title' => ( ! $download ? gamipress_dashicon( 'gamipress' ) : '' ) . __( 'GamiPress Info', 'gamipress' ),
354 + 'classes' => 'gamipress-list-table',
355 + 'fields' => apply_filters( 'gamipress_gamipress_info_tool_fields', array(
356 + 'points_types' => array(
357 + 'name' => __( 'Points Types', 'gamipress' ),
358 + 'type' => 'display',
359 + 'value' => $points_types_output,
360 + ),
361 + 'achievement_types' => array(
362 + 'name' => __( 'Achievement Types', 'gamipress' ),
363 + 'type' => 'display',
364 + 'value' => $achievement_types_output,
365 + ),
366 + 'rank_types' => array(
367 + 'name' => __( 'Rank Types', 'gamipress' ),
368 + 'type' => 'display',
369 + 'value' => $rank_types_output,
370 + ),
371 + 'listeners_count' => array(
372 + 'name' => __( 'Events Listeners', 'gamipress' ),
373 + 'type' => 'display',
374 + 'value' => $listeners_count_output,
375 + ),
376 + 'gamipress_install_date' => array(
377 + 'name' => __( 'Installation Date', 'gamipress' ),
378 + 'type' => 'display',
379 + 'value' => $gamipress_install_date,
380 + ),
381 + 'gamipress_settings' => array(
382 + 'name' => __( 'Settings', 'gamipress' ),
383 + 'type' => 'display',
384 + 'value' => $gamipress_settings_output,
385 + ),
386 + ) )
387 + );
388 +
389 + return $meta_boxes;
390 +
391 +}
392 +add_filter( 'gamipress_tools_system_meta_boxes', 'gamipress_system_info_tool_meta_boxes' );
393 +
394 +/**
395 + * Register Download System Info Tool meta boxes
396 + *
397 + * @since 1.1.7
398 + *
399 + * @param array $meta_boxes
400 + *
401 + * @return array
402 + */
403 +function gamipress_download_system_info_tool_meta_boxes( $meta_boxes ) {
404 +
405 + $meta_boxes['download-system-info'] = array(
406 + 'title' => __( 'Download System Info', 'gamipress' ),
407 + 'fields' => apply_filters( 'gamipress_download_system_info_tool_fields', array(
408 + 'download_system_info' => array(
409 + 'label' => __( 'Download System Info File', 'gamipress' ),
410 + 'type' => 'button',
411 + 'button' => 'primary',
412 + 'action' => 'download_system_info',
413 + ),
414 + ) )
415 + );
416 +
417 + return $meta_boxes;
418 +
419 +}
420 +add_filter( 'gamipress_tools_system_meta_boxes', 'gamipress_download_system_info_tool_meta_boxes', 9999 );
421 +
422 +/**
423 + * Return the hosting provider this site is using if possible
424 + *
425 + * Taken from Easy Digital Downloads
426 + *
427 + * @since 1.1.5
428 + *
429 + * @return mixed string $host if detected, false otherwise
430 + */
431 +function gamipress_get_hosting_provider() {
432 +
433 + if( defined( 'WPE_APIKEY' ) ) {
434 + $host = 'WP Engine';
435 + } elseif( defined( 'PAGELYBIN' ) ) {
436 + $host = 'Pagely';
437 + } elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
438 + $host = 'ICDSoft';
439 + } elseif( DB_HOST == 'mysqlv5' ) {
440 + $host = 'NetworkSolutions';
441 + } elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
442 + $host = 'iPage';
443 + } elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
444 + $host = 'IPower';
445 + } elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
446 + $host = 'MediaTemple Grid';
447 + } elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
448 + $host = 'pair Networks';
449 + } elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
450 + $host = 'Rackspace Cloud';
451 + } elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
452 + $host = 'SysFix.eu Power Hosting';
453 + } elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
454 + $host = 'Flywheel';
455 + } else {
456 + // Adding a general fallback for data gathering
457 + $host = $_SERVER['SERVER_NAME'];
458 + }
459 +
460 + return $host;
461 +}
462 +
463 +/**
464 + * Download System Info action
465 + *
466 + * @since 1.1.5
467 + */
468 +function gamipress_action_download_system_info() {
469 +
470 + if( ! current_user_can( gamipress_get_manager_capability() ) )
471 + return;
472 +
473 + nocache_headers();
474 +
475 + header( 'Content-Type: text/plain' );
476 + header( 'Content-Disposition: attachment; filename="gamipress-system-info.txt"' );
477 +
478 + // Define a global var to meet that this execution is to download a system info file
479 + if( ! defined( 'GAMIPRESS_DOWNLOADING_SYSTEM_INFO' ) )
480 + define( 'GAMIPRESS_DOWNLOADING_SYSTEM_INFO', true );
481 +
482 + $meta_boxes = array();
483 + $output = '';
484 +
485 + $meta_boxes = gamipress_system_info_tool_meta_boxes( $meta_boxes );
486 +
487 + $output .= 'GAMIPRESS SYSTEM INFO START';
488 +
489 + foreach( $meta_boxes as $meta_box_id => $meta_box ) {
490 +
491 + if( $meta_box_id === 'download-system-info' ) {
492 + continue;
493 + }
494 + $output .= "\n\n" . '---------------------------------------------' . "\n";
495 + $output .= $meta_box['title'] . "\n";
496 + $output .= '---------------------------------------------' . "\n\n";
497 +
498 + if( isset( $meta_box['fields'] ) && ! empty( $meta_box['fields'] ) ) {
499 +
500 + // Loop meta box fields
501 + foreach( $meta_box['fields'] as $field_id => $field ) {
502 +
503 + if( $field['type'] === 'title' ) {
504 + $output .= "\n----- " . $field['name'] . " -----\n\n";
505 + } else if( $field['type'] === 'display' ) {
506 + $output .= str_pad( $field['name'] . ':', 30 ) . $field['value'] . "\n";
507 + }
508 +
509 + }
510 +
511 + }
512 + }
513 +
514 + $output .= "\n" . 'GAMIPRESS SYSTEM INFO END';
515 +
516 + $output = str_replace( '<br>', "\n", $output );
517 +
518 + echo $output;
519 + die();
520 +
521 +}
522 +add_action( 'gamipress_action_post_download_system_info', 'gamipress_action_download_system_info' );