PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.2.2
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / pages / page-mainwp-server-information.php

page-mainwp-server-information.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.2.2, at pages/page-mainwp-server-information.php

1,941 lines 88.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Info Page.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 // phpcs:disable Generic.Metrics.CyclomaticComplexity -- complexity.
11 /**
12 * Class MainWP_Server_Information
13 */
14 class MainWP_Server_Information { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
15
16 const WARNING = 1;
17 const ERROR = 2;
18
19 /**
20 * The Info page sub-pages.
21 *
22 * @static
23 * @var array Sub pages.
24 */
25 public static $subPages;
26
27 /**
28 * Get Class Name
29 *
30 * @return string __CLASS__
31 */
32 public static function get_class_name() {
33 return __CLASS__;
34 }
35
36 /**
37 * Method init_menu()
38 *
39 * Initiate Info subPage menu.
40 *
41 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
42 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_apache_server_software()
43 */
44 public static function init_menu() { // phpcs:ignore -- NOSONAR - complex.
45
46 add_action( 'mainwp_pageheader_infor', array( static::get_class_name(), 'render_header' ) );
47 add_action( 'mainwp_pagefooter_infor', array( static::get_class_name(), 'render_footer' ) );
48
49 add_submenu_page(
50 'mainwp_tab',
51 __( 'Info', 'mainwp' ),
52 ' <span id="mainwp-ServerInformation">' . esc_html__( 'Info', 'mainwp' ) . '</span>',
53 'read',
54 'ServerInformation',
55 array(
56 static::get_class_name(),
57 'render',
58 )
59 );
60 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ServerInformationCron' ) ) {
61 add_submenu_page(
62 'mainwp_tab',
63 __( 'Cron Schedules', 'mainwp' ),
64 '<div class="mainwp-hidden">' . esc_html__( 'Cron Schedules', 'mainwp' ) . '</div>',
65 'read',
66 'ServerInformationCron',
67 array(
68 static::get_class_name(),
69 'render_cron',
70 )
71 );
72 }
73
74 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ErrorLog' ) ) {
75 add_submenu_page(
76 'mainwp_tab',
77 __( 'Error Log', 'mainwp' ),
78 '<div class="mainwp-hidden">' . esc_html__( 'Error Log', 'mainwp' ) . '</div>',
79 'read',
80 'ErrorLog',
81 array(
82 static::get_class_name(),
83 'render_error_log_page',
84 )
85 );
86 }
87 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'WPConfig' ) ) {
88 add_submenu_page(
89 'mainwp_tab',
90 __( 'WP-Config File', 'mainwp' ),
91 '<div class="mainwp-hidden">' . esc_html__( 'WP-Config File', 'mainwp' ) . '</div>',
92 'read',
93 'WPConfig',
94 array(
95 static::get_class_name(),
96 'render_wp_config',
97 )
98 );
99 }
100 if ( ! MainWP_Menu::is_disable_menu_item( 3, '.htaccess' ) && MainWP_Server_Information_Handler::is_apache_server_software() ) {
101 add_submenu_page(
102 'mainwp_tab',
103 __( '.htaccess File', 'mainwp' ),
104 '<div class="mainwp-hidden">' . esc_html__( '.htaccess File', 'mainwp' ) . '</div>',
105 'read',
106 '.htaccess',
107 array(
108 static::get_class_name(),
109 'render_htaccess',
110 )
111 );
112 }
113 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ActionLogs' ) ) {
114 add_submenu_page(
115 'mainwp_tab',
116 __( 'Custom Event Monitor', 'mainwp' ),
117 '<div class="mainwp-hidden">' . esc_html__( 'Custom Event Monitor', 'mainwp' ) . '</div>',
118 'read',
119 'ActionLogs',
120 array(
121 static::get_class_name(),
122 'render_action_logs',
123 )
124 );
125 }
126
127 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginPrivacy' ) ) {
128 add_submenu_page(
129 'mainwp_tab',
130 __( 'Plugin Privacy', 'mainwp' ),
131 '<div class="mainwp-hidden">' . esc_html__( 'Plugin Privacy', 'mainwp' ) . '</div>',
132 'read',
133 'PluginPrivacy',
134 array(
135 static::get_class_name(),
136 'render_plugin_privacy_page',
137 )
138 );
139 }
140
141 /**
142 * Filter mainwp_getsubpages_server
143 *
144 * Filters subpages for the Info page.
145 *
146 * @since Unknown
147 */
148 $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-server', array( array() ), '4.0.7.2', 'mainwp_getsubpages_server' ); // NOSONAR - not IP.
149 static::$subPages = apply_filters( 'mainwp_getsubpages_server', $sub_pages );
150
151 if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
152 foreach ( static::$subPages as $subPage ) {
153 if ( ! isset( $subPage['slug'] ) ) {
154 continue;
155 }
156 if ( MainWP_Menu::is_disable_menu_item( 3, 'Server' . $subPage['slug'] ) ) {
157 continue;
158 }
159 add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Server' . $subPage['slug'], $subPage['callback'] );
160 }
161 }
162 }
163
164 /**
165 * Renders Sub Pages Menu.
166 *
167 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
168 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_apache_server_software()
169 */
170 public static function init_subpages_menu() { // phpcs:ignore -- NOSONAR - complex.
171 ?>
172 <div id="menu-mainwp-ServerInformation" class="mainwp-submenu-wrapper">
173 <div class="wp-submenu sub-open">
174 <div class="mainwp_boxout">
175 <div class="mainwp_boxoutin"></div>
176 <a href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformation' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Server', 'mainwp' ); ?></a>
177 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ServerInformationCron' ) ) { ?>
178 <a href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformationCron' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Cron Schedules', 'mainwp' ); ?></a>
179 <?php } ?>
180 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ErrorLog' ) ) { ?>
181 <a href="<?php echo esc_url( admin_url( 'admin.php?page=ErrorLog' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Error Log', 'mainwp' ); ?></a>
182 <?php } ?>
183 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'WPConfig' ) ) { ?>
184 <a href="<?php echo esc_url( admin_url( 'admin.php?page=WPConfig' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'WP-Config File', 'mainwp' ); ?></a>
185 <?php } ?>
186 <?php
187 if ( ! MainWP_Menu::is_disable_menu_item( 3, '.htaccess' ) && MainWP_Server_Information_Handler::is_apache_server_software() ) {
188 ?>
189 <a href="<?php echo esc_url( admin_url( 'admin.php?page=.htaccess' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( '.htaccess File', 'mainwp' ); ?></a>
190 <?php
191 }
192 ?>
193 <?php
194 if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
195 foreach ( static::$subPages as $subPage ) {
196 if ( ! isset( $subPage['menu_hidden'] ) || ( isset( $subPage['menu_hidden'] ) && true !== $subPage['menu_hidden'] ) ) {
197 if ( MainWP_Menu::is_disable_menu_item( 3, 'Server' . $subPage['slug'] ) ) {
198 continue;
199 }
200 ?>
201 <a href="<?php echo esc_url( admin_url( 'admin.php?page=Server' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $subPage['title'] ); ?></a>
202 <?php
203 }
204 }
205 }
206 ?>
207 </div>
208 </div>
209 </div>
210 <?php
211 }
212
213 /**
214 * Initiates Server Information left menu.
215 *
216 * @param array $subPages array of subpages.
217 *
218 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
219 * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
220 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
221 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_apache_server_software()
222 */
223 public static function init_left_menu( $subPages = array() ) {
224 MainWP_Menu::add_left_menu(
225 array(
226 'title' => esc_html__( 'Info', 'mainwp' ),
227 'parent_key' => 'mainwp_tab',
228 'slug' => 'ServerInformation',
229 'href' => 'admin.php?page=ServerInformation',
230 'icon' => '<i class="info circle icon"></i>',
231 ),
232 0
233 );
234
235 /**
236 * MainWP active menu slugs array.
237 *
238 * @global object
239 */
240 global $_mainwp_menu_active_slugs;
241
242 $_mainwp_menu_active_slugs['ActionLogs'] = 'ServerInformation';
243
244 $init_sub_subleftmenu = array(
245 array(
246 'title' => esc_html__( 'Server', 'mainwp' ),
247 'parent_key' => 'ServerInformation',
248 'href' => 'admin.php?page=ServerInformation',
249 'slug' => 'ServerInformation',
250 'right' => '',
251 ),
252 array(
253 'title' => esc_html__( 'Cron Schedules', 'mainwp' ),
254 'parent_key' => 'ServerInformation',
255 'href' => 'admin.php?page=ServerInformationCron',
256 'slug' => 'ServerInformationCron',
257 'right' => '',
258 ),
259 array(
260 'title' => esc_html__( 'Error Log', 'mainwp' ),
261 'parent_key' => 'ServerInformation',
262 'href' => 'admin.php?page=ErrorLog',
263 'slug' => 'ErrorLog',
264 'right' => '',
265 ),
266 array(
267 'title' => esc_html__( 'Custom Event Monitor', 'mainwp' ),
268 'parent_key' => 'ServerInformation',
269 'href' => 'admin.php?page=ActionLogs',
270 'slug' => 'ActionLogs',
271 'right' => '',
272 ),
273 array(
274 'title' => esc_html__( 'Plugin Privacy', 'mainwp' ),
275 'parent_key' => 'ServerInformation',
276 'href' => 'admin.php?page=PluginPrivacy',
277 'slug' => 'PluginPrivacy',
278 'right' => '',
279 ),
280 );
281
282 MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'ServerInformation', 'Server' );
283 foreach ( $init_sub_subleftmenu as $item ) {
284 if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
285 continue;
286 }
287 MainWP_Menu::add_left_menu( $item, 2 );
288 }
289 }
290
291 /**
292 * Renders Info header.
293 *
294 * @param string $shownPage Current page.
295 *
296 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
297 * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
298 * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation()
299 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_apache_server_software()
300 */
301 public static function render_header( $shownPage = '' ) {
302 $params = array(
303 'title' => esc_html__( 'Info', 'mainwp' ),
304 );
305
306 MainWP_UI::render_top_header( $params );
307
308 $renderItems = array();
309
310 $renderItems[] = array(
311 'title' => esc_html__( 'Server', 'mainwp' ),
312 'href' => 'admin.php?page=ServerInformation',
313 'active' => ( '' === $shownPage ) ? true : false,
314 );
315
316 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ServerInformationCron' ) ) {
317 $renderItems[] = array(
318 'title' => esc_html__( 'Cron Schedules', 'mainwp' ),
319 'href' => 'admin.php?page=ServerInformationCron',
320 'active' => ( 'ServerInformationCron' === $shownPage ) ? true : false,
321 );
322 }
323
324 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ErrorLog' ) ) {
325 $renderItems[] = array(
326 'title' => esc_html__( 'Error Log', 'mainwp' ),
327 'href' => 'admin.php?page=ErrorLog',
328 'active' => ( 'ErrorLog' === $shownPage ) ? true : false,
329 );
330 }
331
332 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ActionLogs' ) ) {
333 $renderItems[] = array(
334 'title' => esc_html__( 'Custom Event Monitor', 'mainwp' ),
335 'href' => 'admin.php?page=ActionLogs',
336 'active' => ( 'ActionLogs' === $shownPage ) ? true : false,
337 );
338 }
339
340 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginPrivacy' ) ) {
341 $renderItems[] = array(
342 'title' => esc_html__( 'Plugin Privacy', 'mainwp' ),
343 'href' => 'admin.php?page=PluginPrivacy',
344 'active' => ( 'PluginPrivacy' === $shownPage ) ? true : false,
345 );
346 }
347
348 MainWP_UI::render_page_navigation( $renderItems );
349
350 static::render_actions_bar();
351
352 echo '<div>';
353 }
354
355 /**
356 * Renders Server Information footer.
357 */
358 public static function render_footer() {
359 echo '</div>';
360 }
361
362 /**
363 * Renders Server Information action bar element.
364 */
365 public static function render_actions_bar() {
366 if ( isset( $_GET['page'] ) && 'ServerInformation' === $_GET['page'] ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
367 ?>
368 <div class="mainwp-actions-bar">
369 <div class="ui two column grid">
370 <div class="column"></div>
371 <div class="right aligned column">
372 <a href="#" style="margin-left:5px" class="ui mini basic green button" id="mainwp-copy-meta-system-report" data-inverted="" data-position="left center" data-tooltip="<?php esc_attr_e( 'Copy the system report to paste it to the MainWP Community.', 'mainwp' ); ?>"><?php esc_html_e( 'Copy System Report for the MainWP Community', 'mainwp' ); ?></a>
373 <a href="#" class="ui mini green button" id="mainwp-download-system-report"><?php esc_html_e( 'Download System Report', 'mainwp' ); ?></a>
374 </div>
375 </div>
376 </div>
377 <?php
378 endif;
379 }
380
381 /**
382 * Renders Server Information page.
383 *
384 * @return void
385 *
386 * @uses \MainWP\Dashboard\MainWP_Extensions_View::get_available_extensions()
387 * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_extensions()
388 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_mainwp_version()
389 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_current_version()
390 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_file_system_method()
391 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_php_allow_url_fopen()
392 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_php_exif()
393 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_php_iptc()
394 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_php_xml()
395 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_loaded_php_extensions()
396 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_sql_mode()
397 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_wp_root()
398 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_name()
399 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_software()
400 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_os()
401 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_architecture()
402 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_ip()
403 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_protocol()
404 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_http_host()
405 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_https()
406 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::server_self_connect()
407 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_user_agent()
408 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_port()
409 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_gateway_interface()
410 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::memory_usage()
411 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_complete_url()
412 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_request_time()
413 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_http_accept()
414 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_server_accept_charset()
415 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_script_file_name()
416 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_current_page_uri()
417 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_remote_address()
418 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_remote_host()
419 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_remote_port()
420 */
421 public static function render() {
422 if ( ! mainwp_current_user_have_right( 'dashboard', 'see_server_information' ) ) {
423 mainwp_do_not_have_permissions( 'server information', 'mainwp' );
424 return;
425 }
426 static::render_header( '' );
427
428 /**
429 * Action: mainwp_before_server_info_table
430 *
431 * Fires on the top of the Info page, before the Server Info table.
432 *
433 * @since 4.0
434 */
435 do_action( 'mainwp_before_server_info_table' );
436 ?>
437 <div class="ui segment">
438 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-server-info-info-message' ) ) : ?>
439 <div class="ui info message">
440 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-server-info-info-message"></i>
441 <?php printf( esc_html__( 'Check your system configuration and make sure your MainWP Dashboard passes all system requirements. If you need help with resolving specific errors, please review this %1$shelp document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/resolving-system-requirement-issues/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
442 </div>
443 <?php endif; ?>
444 <?php
445 if ( function_exists( 'curl_version' ) && ! MainWP_Server_Information_Handler::curlssl_compare( 'OpenSSL/1.1.0', '>=' ) ) {
446 echo "<div class='ui yellow message'>" . sprintf( esc_html__( 'Your host needs to update OpenSSL to at least version 1.1.0 which is already over 4 years old and contains patches for over 60 vulnerabilities.%1$sThese range from Denial of Service to Remote Code Execution. %2$sClick here for more information.%3$s', 'mainwp' ), '<br/>', '<a href="https://community.letsencrypt.org/t/openssl-client-compatibility-changes-for-let-s-encrypt-certificates/143816" target="_blank">', '</a>' ) . '</div>';
447 }
448 ?>
449 <table id="mainwp-system-report-wordpress-table" class="ui unstackable table single line mainwp-system-report-table mainwp-system-info-table">
450 <thead>
451 <tr>
452 <th scope="col" ><?php esc_html_e( 'WordPress Check', 'mainwp' ); ?></th>
453 <th scope="col" ><?php esc_html_e( 'Required', 'mainwp' ); ?></th>
454 <th scope="col" ><?php esc_html_e( 'Detected', 'mainwp' ); ?></th>
455 <th scope="col" class="right aligned"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
456 </tr>
457 </thead>
458 <tbody>
459 <?php static::render_wordpress_check_tbody(); ?>
460 </tbody>
461 </table>
462
463 <table id="mainwp-system-report-php-table" class="ui unstackable table fixed mainwp-system-report-table mainwp-system-info-table">
464 <thead>
465 <tr>
466 <th scope="col" ><?php esc_html_e( 'PHP', 'mainwp' ); ?></th>
467 <th scope="col" ><?php esc_html_e( 'Required', 'mainwp' ); ?></th>
468 <th scope="col" ><?php esc_html_e( 'Detected', 'mainwp' ); ?></th>
469 <th scope="col" class="right aligned"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
470 </tr>
471 </thead>
472 <tbody>
473 <?php static::render_php_check_tbody(); ?>
474 </tbody>
475 </table>
476
477 <table id="mainwp-system-report-mysql-table" class="ui unstackable table mainwp-system-report-table mainwp-system-info-table">
478 <thead>
479 <tr>
480 <th scope="col" ><?php esc_html_e( 'MySQL', 'mainwp' ); ?></th>
481 <th scope="col" ><?php esc_html_e( 'Required', 'mainwp' ); ?></th>
482 <th scope="col" ><?php esc_html_e( 'Detected', 'mainwp' ); ?></th>
483 <th scope="col" class="right aligned"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
484 </tr>
485 </thead>
486 <tbody>
487 <?php static::render_mysql_check_tbody(); ?>
488 </tbody>
489 </table>
490
491 <table id="mainwp-system-report-server-table" class="ui unstackable table mainwp-system-report-table mainwp-system-info-table">
492 <thead>
493 <tr>
494 <th scope="col" ><?php esc_html_e( 'Server Configuration', 'mainwp' ); ?></th>
495 <th scope="col" ><?php esc_html_e( 'Detected Value', 'mainwp' ); ?></th>
496 </tr>
497 </thead>
498 <tbody>
499 <?php static::render_server_check_tbody(); ?>
500 </tbody>
501 </table>
502
503 <table id="mainwp-system-report-dashboard-table" class="ui unstackable table mainwp-system-report-table mainwp-system-info-table">
504 <thead>
505 <tr>
506 <th scope="col" ><?php esc_html_e( 'MainWP Dashboard Settings', 'mainwp' ); ?></th>
507 <th scope="col" ><?php esc_html_e( 'Detected Value', 'mainwp' ); ?></th>
508 </tr>
509 </thead>
510 <tbody>
511 <?php static::render_dashboard_check_tbody(); ?>
512 </tbody>
513 </table>
514
515 <table id="mainwp-system-report-extensions-table" class="ui unstackable table single line mainwp-system-report-table mainwp-system-info-table">
516 <thead>
517 <tr>
518 <th scope="col" ><?php esc_html_e( 'Extensions', 'mainwp' ); ?></th>
519 <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
520 <th scope="col" ><?php esc_html_e( 'License', 'mainwp' ); ?></th>
521 <th scope="col" class="right aligned"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
522 </tr>
523 </thead>
524 <tbody>
525 <?php static::render_extensions_license_check_tbody(); ?>
526 </tbody>
527 </table>
528
529 <table id="mainwp-system-report-plugins-table" class="ui single line table unstackable mainwp-system-report-table mainwp-system-info-table">
530 <thead>
531 <tr>
532 <th scope="col" ><?php esc_html_e( 'Plugin', 'mainwp' ); ?></th>
533 <th scope="col" ><?php esc_html_e( 'Version', 'mainwp' ); ?></th>
534 <th scope="col" ><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
535 </tr>
536 </thead>
537 <tbody>
538 <?php static::render_plugins_check_tbody(); ?>
539 </tbody>
540 </table>
541
542 <div id="download-server-information" style="opacity:0">
543 <textarea readonly="readonly" contenteditable="true" wrap="off"></textarea>
544 </div>
545
546 <script type="text/javascript">
547 let responsive = true;
548 if( jQuery( window ).width() > 1140 ) {
549 responsive = false;
550 }
551 jQuery( document ).ready( function() {
552 jQuery( '.mainwp-system-info-table:not(#mainwp-system-report-extensions-table)' ).DataTable( {
553 responsive: responsive,
554 colreorder: true,
555 paging: false,
556 info: false,
557 } );
558 jQuery( '#mainwp-system-report-extensions-table' ).DataTable( {
559 responsive: responsive,
560 colreorder: true,
561 paging: false,
562 info: false,
563 "language": {
564 "emptyTable": "<?php esc_html_e( 'No installed extensions', 'mainwp' ); ?>"
565 },
566 } );
567 } );
568 </script>
569 </div>
570
571 <?php
572
573 /**
574 * Action: mainwp_after_server_info_table
575 *
576 * Fires on the bottom of the Info page, after the Server Info table.
577 *
578 * @since 4.0
579 */
580 do_action( 'mainwp_after_server_info_table' );
581
582 static::render_footer( '' );
583 }
584
585 /**
586 * Renders WordPress checks table body.
587 *
588 * @return void
589 */
590 public static function render_wordpress_check_tbody() {
591 static::render_row( 'WordPress Version', '>=', '6.2', 'get_wordpress_version', '', '', null, null, static::ERROR );
592 static::render_row( 'WordPress Memory Limit', '>=', '64M', 'get_wordpress_memory_limit', '', '', null );
593 static::render_row( 'MultiSite Disabled', '=', true, 'check_if_multisite', '', '', null );
594 ?>
595 <tr>
596 <td><?php esc_html_e( 'FileSystem Method', 'mainwp' ); ?></td>
597 <td><?php echo esc_html( '= direct' ); ?></td>
598 <td><?php echo MainWP_Server_Information_Handler::get_file_system_method(); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
599 <td class="right aligned"><?php echo static::get_file_system_method_check(); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
600 </tr>
601 <?php
602 }
603
604 /**
605 * Renders PHP checks table body.
606 *
607 * @return void
608 */
609 public static function render_php_check_tbody() {
610 static::render_row( 'PHP Version', '>=', '7.4', 'get_php_version', '', '', null, null, static::ERROR );
611 static::render_row( 'PHP Safe Mode Disabled', '=', true, 'get_php_safe_mode', '', '', null );
612 static::render_row( 'PHP Max Execution Time', '>=', '30', 'get_max_execution_time', 'seconds', '=', '0' );
613 static::render_row( 'PHP Max Input Time', '>=', '30', 'get_max_input_time', 'seconds', '=', '0' );
614 static::render_row( 'PHP Memory Limit', '>=', '256M', 'get_php_memory_limit', '', '', null, 'filesize' );
615 static::render_row( 'PCRE Backtracking Limit', '>=', '10000', 'get_output_buffer_size', '', '', null );
616 static::render_row( 'PHP Upload Max Filesize', '>=', '2M', 'get_upload_max_filesize', '', '', null, 'filesize' );
617 static::render_row( 'PHP Post Max Size', '>=', '2M', 'get_post_max_size', '', '', null, 'filesize' );
618 static::render_row( 'SSL Extension Enabled', '=', true, 'get_ssl_support', '', '', null );
619 static::render_row( 'SSL Warnings', '=', '', 'get_ssl_warning', 'empty', '', null );
620 static::render_row( 'cURL Extension Enabled', '=', true, 'get_curl_support', '', '', null, null, static::ERROR );
621 static::render_row( 'cURL Timeout', '>=', '300', 'get_curl_timeout', 'seconds', '=', '0' );
622 if ( function_exists( 'curl_version' ) ) {
623 $reuire_curl = '7.18.1';
624 if ( version_compare( MainWP_Server_Information_Handler::get_php_version(), '8.0.0' ) >= 0 ) {
625 $reuire_curl = '7.29.0';
626 }
627 static::render_row( 'cURL Version', '>=', $reuire_curl, 'get_curl_version', '', '', null );
628 $openssl_version = 'OpenSSL/1.1.0';
629 static::render_row(
630 'OpenSSL Version',
631 '>=',
632 $openssl_version,
633 'get_curl_ssl_version',
634 '',
635 '',
636 null,
637 'curlssl'
638 );
639
640 $wk = MainWP_Server_Information_Handler::get_openssl_working_status();
641 ?>
642 <tr>
643 <td>OpenSSL Working Status</td>
644 <td>Yes</td>
645 <td><?php echo $wk ? 'Yes' : 'No'; ?></td>
646 <td class="right aligned"><?php $wk ? static::get_pass_html( true ) : static::get_warning_html( self::WARNING, true ); ?></td>
647 </tr>
648 <?php
649
650 }
651 ?>
652 <tr>
653 <td><?php esc_html_e( 'PHP Allow URL fopen', 'mainwp' ); ?></td>
654 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
655 <td><?php MainWP_Server_Information_Handler::get_php_allow_url_fopen(); ?></td>
656 <td></td>
657 </tr>
658 <tr>
659 <td><?php esc_html_e( 'PHP Exif Support', 'mainwp' ); ?></td>
660 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
661 <td><?php MainWP_Server_Information_Handler::get_php_exif(); ?></td>
662 <td></td>
663 </tr>
664 <tr>
665 <td><?php esc_html_e( 'PHP IPTC Support', 'mainwp' ); ?></td>
666 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
667 <td><?php MainWP_Server_Information_Handler::get_php_iptc(); ?></td>
668 <td></td>
669 </tr>
670 <tr>
671 <td><?php esc_html_e( 'PHP XML Support', 'mainwp' ); ?></td>
672 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
673 <td><?php MainWP_Server_Information_Handler::get_php_xml(); ?></td>
674 <td></td>
675 </tr>
676 <tr>
677 <td><?php esc_html_e( 'Function `tmpfile` enabled', 'mainwp' ); ?></td>
678 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
679 <td>
680 <?php
681 $tmpfile_enabled = MainWP_System_View::is_tmpfile_enable();
682 echo $tmpfile_enabled ? esc_html__( 'Enabled', 'mainwp' ) : esc_html__( 'Disabled', 'mainwp' );
683 ?>
684 </td>
685 <td class="right aligned"><?php $tmpfile_enabled ? static::get_pass_html( true ) : static::get_warning_html( self::WARNING, true ); ?></td>
686 </tr>
687 <tr>
688 <td><?php esc_html_e( 'PHP Session enabled', 'mainwp' ); ?></td>
689 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
690 <td>
691 <?php
692 $session_disable = MainWP_Cache::is_session_disable();
693 echo $session_disable ? esc_html__( 'Disabled', 'mainwp' ) : esc_html__( 'Enabled', 'mainwp' );
694 ?>
695 </td>
696 <td class="right aligned"><?php echo ! $session_disable ? static::get_pass_html() : static::get_warning_html(); //phpcs:ignore -- ok. ?></td>
697 </tr>
698 <tr>
699 <td><?php esc_html_e( 'PHP Disabled Functions', 'mainwp' ); ?></td>
700 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
701 <td><?php static::php_disabled_functions(); ?></td>
702 <td></td>
703 </tr>
704 <tr>
705 <td><?php esc_html_e( 'PHP Loaded Extensions', 'mainwp' ); ?></td>
706 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
707 <td><?php MainWP_Server_Information_Handler::get_loaded_php_extensions(); ?></td>
708 <td></td>
709 </tr>
710 <?php
711 }
712
713 /**
714 * Renders MySQL checks table body.
715 *
716 * @return void
717 */
718 public static function render_mysql_check_tbody() {
719 static::render_row( 'MySQL Version', '>=', '5.0', 'get_mysql_version', '', '', null, null, static::ERROR );
720 ?>
721 <tr>
722 <td><?php esc_html_e( 'MySQL Mode', 'mainwp' ); ?></td>
723 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
724 <td><?php MainWP_Server_Information_Handler::get_sql_mode(); ?></td>
725 <td></td>
726 </tr>
727 <tr>
728 <td><?php esc_html_e( 'MySQL Client Encoding', 'mainwp' ); ?></td>
729 <td><?php esc_html_e( 'N/A', 'mainwp' ); ?></td>
730 <td><?php echo defined( 'DB_CHARSET' ) ? esc_html( DB_CHARSET ) : ''; ?></td>
731 <td></td>
732 </tr>
733 <?php
734 }
735
736 /**
737 * Renders Server checks table body.
738 *
739 * @return void
740 */
741 public static function render_server_check_tbody() {
742 ?>
743 <tr class="mwp-not-generate-row">
744 <td><?php esc_html_e( 'WordPress Root Directory', 'mainwp' ); ?></td>
745 <td><?php MainWP_Server_Information_Handler::get_wp_root(); ?></td>
746 </tr>
747 <tr class="mwp-not-generate-row">
748 <td><?php esc_html_e( 'Server Name', 'mainwp' ); ?></td>
749 <td><?php MainWP_Server_Information_Handler::get_server_name(); ?></td>
750 </tr>
751 <tr>
752 <td><?php esc_html_e( 'Server Software', 'mainwp' ); ?></td>
753 <td><?php MainWP_Server_Information_Handler::get_server_software(); ?></td>
754 </tr>
755 <tr>
756 <td><?php esc_html_e( 'Operating System', 'mainwp' ); ?></td>
757 <td><?php MainWP_Server_Information_Handler::get_os(); ?></td>
758 </tr>
759 <tr>
760 <td><?php esc_html_e( 'Architecture', 'mainwp' ); ?></td>
761 <td><?php MainWP_Server_Information_Handler::get_architecture(); ?></td>
762 </tr>
763 <tr class="mwp-not-generate-row">
764 <td><?php esc_html_e( 'Server IP', 'mainwp' ); ?></td>
765 <td><?php MainWP_Server_Information_Handler::get_server_ip(); ?></td>
766 </tr>
767 <tr>
768 <td><?php esc_html_e( 'Server Protocol', 'mainwp' ); ?></td>
769 <td><?php MainWP_Server_Information_Handler::get_server_protocol(); ?></td>
770 </tr>
771 <tr class="mwp-not-generate-row">
772 <td><?php esc_html_e( 'HTTP Host', 'mainwp' ); ?></td>
773 <td><?php MainWP_Server_Information_Handler::get_http_host(); ?></td>
774 </tr>
775 <tr>
776 <td><?php esc_html_e( 'HTTPS', 'mainwp' ); ?></td>
777 <td><?php MainWP_Server_Information_Handler::get_https(); ?></td>
778 </tr>
779 <tr>
780 <td><?php esc_html_e( 'Server self connect', 'mainwp' ); ?></td>
781 <td><?php MainWP_Server_Information_Handler::server_self_connect(); ?></td>
782 </tr>
783 <tr>
784 <td><?php esc_html_e( 'User Agent', 'mainwp' ); ?></td>
785 <td><?php MainWP_Server_Information_Handler::get_user_agent(); ?></td>
786 </tr>
787 <tr class="mwp-not-generate-row">
788 <td><?php esc_html_e( 'Server Port', 'mainwp' ); ?></td>
789 <td><?php MainWP_Server_Information_Handler::get_server_port(); ?></td>
790 </tr>
791 <tr>
792 <td><?php esc_html_e( 'Gateway Interface', 'mainwp' ); ?></td>
793 <td><?php MainWP_Server_Information_Handler::get_server_gateway_interface(); ?></td>
794 </tr>
795 <tr>
796 <td><?php esc_html_e( 'Memory Usage', 'mainwp' ); ?></td>
797 <td><?php MainWP_Server_Information_Handler::memory_usage(); ?></td>
798 </tr>
799 <tr class="mwp-not-generate-row">
800 <td><?php esc_html_e( 'Complete URL', 'mainwp' ); ?></td>
801 <td><?php MainWP_Server_Information_Handler::get_complete_url(); ?></td>
802 </tr>
803 <tr>
804 <td><?php esc_html_e( 'Request Time', 'mainwp' ); ?></td>
805 <td><?php MainWP_Server_Information_Handler::get_server_request_time(); ?></td>
806 </tr>
807 <tr>
808 <td><?php esc_html_e( 'Accept Content', 'mainwp' ); ?></td>
809 <td><?php MainWP_Server_Information_Handler::get_server_http_accept(); ?></td>
810 </tr>
811 <tr>
812 <td><?php esc_html_e( 'Accept-Charset Content', 'mainwp' ); ?></td>
813 <td><?php MainWP_Server_Information_Handler::get_server_accept_charset(); ?></td>
814 </tr>
815 <tr class="mwp-not-generate-row">
816 <td><?php esc_html_e( 'Currently Executing Script Pathname', 'mainwp' ); ?></td>
817 <td><?php MainWP_Server_Information_Handler::get_script_file_name(); ?></td>
818 </tr>
819 <tr class="mwp-not-generate-row">
820 <td><?php esc_html_e( 'Current Page URI', 'mainwp' ); ?></td>
821 <td><?php MainWP_Server_Information_Handler::get_current_page_uri(); ?></td>
822 </tr>
823 <tr class="mwp-not-generate-row">
824 <td><?php esc_html_e( 'Remote Address', 'mainwp' ); ?></td>
825 <td><?php MainWP_Server_Information_Handler::get_remote_address(); ?></td>
826 </tr>
827 <tr class="mwp-not-generate-row">
828 <td><?php esc_html_e( 'Remote Host', 'mainwp' ); ?></td>
829 <td><?php MainWP_Server_Information_Handler::get_remote_host(); ?></td>
830 </tr>
831 <tr class="mwp-not-generate-row">
832 <td><?php esc_html_e( 'Remote Port', 'mainwp' ); ?></td>
833 <td><?php MainWP_Server_Information_Handler::get_remote_port(); ?></td>
834 </tr>
835 <?php
836 }
837
838 /**
839 * Renders MainWP Dashboard checks table body.
840 *
841 * @return void
842 */
843 public static function render_dashboard_check_tbody() {
844 ?>
845 <tr>
846 <td><?php esc_html_e( 'MainWP Dashboard Version', 'mainwp' ); ?></td>
847 <td><?php echo 'Latest: ' . MainWP_Server_Information_Handler::get_mainwp_version(); ?> | <?php echo 'Detected: ' . MainWP_Server_Information_Handler::get_current_version(); ?> <?php echo static::get_mainwp_version_check(); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
848 </tr>
849 <?php
850 static::check_directory_mainwp_directory();
851 static::display_mainwp_options();
852 }
853
854 /**
855 * Renders extensions API License status table body.
856 *
857 * @return void
858 */
859 public static function render_extensions_license_check_tbody() {
860 $extensions = MainWP_Extensions_Handler::get_extensions();
861 $extensions_slugs = array();
862 if ( empty( $extensions ) ) {
863 return;
864 }
865 foreach ( $extensions as $extension ) {
866 $extensions_slugs[] = $extension['slug'];
867 ?>
868 <tr>
869 <td><?php echo esc_html( $extension['name'] ); ?></td>
870 <td><?php echo esc_html( $extension['version'] ); ?></td>
871 <?php
872 if ( isset( $extension['mainwp'] ) && $extension['mainwp'] ) {
873 ?>
874 <td><?php echo isset( $extension['activated_key'] ) && 'Activated' === $extension['activated_key'] ? esc_html__( 'Active', 'mainwp' ) : esc_html__( 'Inactive', 'mainwp' ); ?></td>
875 <td class="right aligned"><?php echo isset( $extension['activated_key'] ) && 'Activated' === $extension['activated_key'] ? static::get_pass_html() : static::get_warning_html( static::WARNING ); // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
876 <?php
877 } else {
878 ?>
879 <td></td>
880 <td></td>
881 <?php
882 }
883 ?>
884 </tr>
885 <?php
886 }
887 }
888
889 /**
890 * Renders plugins check table body.
891 *
892 * @return void
893 */
894 public static function render_plugins_check_tbody() {
895 $all_extensions = MainWP_Extensions_View::get_available_extensions();
896 $all_plugins = get_plugins();
897 foreach ( $all_plugins as $slug => $plugin ) {
898 if ( isset( $all_extensions[ dirname( $slug ) ] ) ) {
899 continue;
900 }
901 ?>
902 <tr>
903 <td><?php echo esc_html( $plugin['Name'] ); ?></td>
904 <td><?php echo esc_html( $plugin['Version'] ); ?></td>
905 <td class="right aligned"><?php echo is_plugin_active( $slug ) ? esc_html__( 'Active', 'mainwp' ) : esc_html__( 'Inactive', 'mainwp' ); ?></td>
906 </tr>
907 <?php
908 }
909 }
910
911 /**
912 * Renders MainWP system requirements check.
913 *
914 * @return void
915 */
916 public static function render_quick_setup_system_check() {
917 /**
918 * Action: mainwp_before_system_requirements_check
919 *
920 * Fires on the bottom of the System Requirements page, in Quick Setup Wizard.
921 *
922 * @since 4.1
923 */
924 do_action( 'mainwp_before_system_requirements_check' );
925 ?>
926 <table id="mainwp-quick-system-requirements-check" class="ui single line table">
927 <thead>
928 <tr>
929 <th scope="col" ><?php esc_html_e( 'Check', 'mainwp' ); ?></th>
930 <th scope="col" ><?php esc_html_e( 'Required Value', 'mainwp' ); ?></th>
931 <th scope="col" ><?php esc_html_e( 'Detected Value', 'mainwp' ); ?></th>
932 <th scope="col" class="collapsing"><?php esc_html_e( 'Status', 'mainwp' ); ?></th>
933 </tr>
934 </thead>
935 <tbody>
936 <?php
937 static::render_row_with_description( esc_html__( 'PHP Version', 'mainwp' ), '>=', '7.4', 'get_php_version', '', '', null );
938 static::render_row_with_description( esc_html__( 'SSL Extension Enabled', 'mainwp' ), '=', true, 'get_ssl_support', '', '', null );
939 static::render_row_with_description( esc_html__( 'cURL Extension Enabled', 'mainwp' ), '=', true, 'get_curl_support', '', '', null );
940 $openssl_version = 'OpenSSL/1.1.0';
941 static::render_row_with_description(
942 'cURL SSL Version',
943 '>=',
944 $openssl_version,
945 'get_curl_ssl_version',
946 '',
947 '',
948 null,
949 'curlssl'
950 );
951
952 if ( ! MainWP_Server_Information_Handler::curlssl_compare( $openssl_version, '>=' ) ) {
953 echo "<tr class='warning'><td colspan='4'><i class='attention icon'></i>" . sprintf( esc_html__( 'Your host needs to update OpenSSL to at least version 1.1.0 which is already over 4 years old and contains patches for over 60 vulnerabilities.%1$sThese range from Denial of Service to Remote Code Execution. %2$sClick here for more information.%3$s', 'mainwp' ), '<br/>', '<a href="https://community.letsencrypt.org/t/openssl-client-compatibility-changes-for-let-s-encrypt-certificates/143816" target="_blank">', '</a>' ) . '</td></tr>';
954 }
955 static::render_row_with_description( esc_html__( 'MySQL Version', 'mainwp' ), '>=', '5.0', 'get_mysql_version', '', '', null );
956 ?>
957 </tbody>
958 </table>
959 <?php
960 /**
961 * Action: mainwp_after_system_requirements_check
962 *
963 * Fires on the bottom of the System Requirements page, in Quick Setup Wizard.
964 *
965 * @since 4.1
966 */
967 do_action( 'mainwp_after_system_requirements_check' );
968 }
969
970 /**
971 * Compares the detected MainWP Dashboard version agains the verion in WP.org.
972 *
973 * @return mixed Pass|static::get_warning_html().
974 *
975 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_mainwp_version()
976 */
977 public static function get_mainwp_version_check() {
978 $current = get_option( 'mainwp_plugin_version' );
979 $latest = MainWP_Server_Information_Handler::get_mainwp_version();
980 if ( $current === $latest ) {
981 return static::get_pass_html();
982 } else {
983 return static::get_warning_html();
984 }
985 }
986
987 /**
988 * Renders the Cron Schedule page.
989 *
990 * @return void
991 *
992 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
993 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
994 */
995 public static function render_cron() { // phpcs:ignore -- NOSONAR - complex.
996 if ( ! mainwp_current_user_have_right( 'dashboard', 'see_server_information' ) ) {
997 mainwp_do_not_have_permissions( 'cron schedules', 'mainwp' );
998 return;
999 }
1000
1001 static::render_header( 'ServerInformationCron' );
1002
1003 $local_timestamp = MainWP_Utility::get_timestamp();
1004
1005 $freq = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 );
1006 if ( $freq <= 0 ) {
1007 $freq = 1;
1008 }
1009 $auto_update_text = static::get_schedule_auto_update_label( $freq );
1010
1011 $cron_jobs = array(
1012 'Check for available updates' => array( 'mainwp_updatescheck_start_last_timestamp', 'mainwp_cronupdatescheck_action', $auto_update_text ),
1013 'Check for reconnect sites' => array( 'mainwp_cron_last_stats', 'mainwp_cronreconnect_action', esc_html__( 'Once hourly', 'mainwp' ), 'hourly' ),
1014 'Ping childs sites' => array( 'mainwp_cron_last_ping', 'mainwp_cronpingchilds_action', esc_html__( 'Once daily', 'mainwp' ), 'daily' ),
1015 );
1016
1017 $disableSitesMonitoring = get_option( 'mainwp_disableSitesChecking', 1 );
1018 if ( ! $disableSitesMonitoring ) {
1019 $cron_jobs['Child site uptime monitoring'] = array( 'mainwp_cron_checksites_last_timestamp', 'mainwp_croncheckstatus_action', esc_html__( 'Once every minute', 'mainwp' ), 'minutely' );
1020 }
1021
1022 $disableHealthChecking = get_option( 'mainwp_disableSitesHealthMonitoring', 1 ); // disabled by default.
1023 if ( ! $disableHealthChecking ) {
1024 $cron_jobs['Site Health monitoring'] = array( 'mainwp_cron_checksiteshealth_last_timestamp', 'mainwp_cronsitehealthcheck_action', esc_html__( 'Once hourly', 'mainwp' ), 'hourly' );
1025 }
1026
1027 if ( get_option( 'mainwp_enableLegacyBackupFeature' ) ) {
1028 $cron_jobs['Start backups (Legacy)'] = array( 'mainwp_cron_last_backups', 'mainwp_cronbackups_action', esc_html__( 'Once hourly', 'mainwp' ), 'hourly' );
1029 $cron_jobs['Continue backups (Legacy)'] = array( 'mainwp_cron_last_backups_continue', 'mainwp_cronbackups_continue_action', esc_html__( 'Once every five minutes', 'mainwp' ), '5minutely' );
1030 }
1031
1032 /**
1033 * Action: mainwp_before_cron_jobs_table
1034 *
1035 * Renders on the top of the Cron Jobs page, before the Schedules table.
1036 *
1037 * @since 4.0
1038 */
1039 do_action( 'mainwp_before_cron_jobs_table' );
1040 ?>
1041 <div class="ui segment">
1042 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-cron-info-message' ) ) : ?>
1043 <div class="ui info message">
1044 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-cron-info-message"></i>
1045 <?php printf( esc_html__( 'Make sure scheduled actions are working correctly. If scheduled actions do not run normally, please review this %1$shelp document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/scheduled-events-not-occurring/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
1046 </div>
1047 <?php endif; ?>
1048 <table class="ui single line unstackable table" id="mainwp-cron-jobs-table">
1049 <thead>
1050 <tr>
1051 <th scope="col" ><?php esc_html_e( 'Cron Job', 'mainwp' ); ?></th>
1052 <th scope="col" ><?php esc_html_e( 'Hook', 'mainwp' ); ?></th>
1053 <th scope="col" ><?php esc_html_e( 'Schedule', 'mainwp' ); ?></th>
1054 <th scope="col" ><?php esc_html_e( 'Last Run', 'mainwp' ); ?></th>
1055 <th scope="col" ><?php esc_html_e( 'Next Run', 'mainwp' ); ?></th>
1056 </tr>
1057 </thead>
1058 <tbody>
1059 <?php
1060 $useWPCron = ( false === get_option( 'mainwp_wp_cron' ) ) || ( 1 === (int) get_option( 'mainwp_wp_cron' ) );
1061
1062 foreach ( $cron_jobs as $cron_job => $hook ) {
1063
1064 $is_auto_update_job = false;
1065 $lasttime_run = 0;
1066 if ( 'mainwp_updatescheck_start_last_timestamp' === $hook[0] ) {
1067 $update_time = MainWP_Settings::get_websites_automatic_update_time();
1068 $last_run = $update_time['last'];
1069 $next_run = $update_time['next'];
1070 $is_auto_update_job = true;
1071 } elseif ( false === get_option( $hook[0] ) ) {
1072 $last_run = esc_html__( 'Never', 'mainwp' );
1073 } else {
1074 $lasttime_run = get_option( $hook[0] );
1075 if ( $lasttime_run ) {
1076 $last_run = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $lasttime_run ) );
1077 } else {
1078 $last_run = esc_html__( 'Never', 'mainwp' );
1079 }
1080 }
1081
1082 if ( $useWPCron && 'mainwp_updatescheck_start_last_timestamp' !== $hook[0] ) {
1083 $next_run = wp_next_scheduled( $hook[1] );
1084 if ( ! empty( $next_run ) ) {
1085 $next_run = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $next_run ) );
1086 }
1087 }
1088
1089 if ( empty( $next_run ) || ( ! $useWPCron && ! $is_auto_update_job && isset( $hook[3] ) ) ) {
1090 $nexttime_run = static::get_schedule_next_time_to_show( $hook[3], $lasttime_run, $local_timestamp );
1091 if ( $nexttime_run < $local_timestamp + 3 * MINUTE_IN_SECONDS ) {
1092 $next_run = esc_html__( 'Any minute', 'mainwp' );
1093 } else {
1094 $next_run = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $nexttime_run ) );
1095 }
1096 }
1097
1098 // phpcs:disable WordPress.Security.EscapeOutput
1099 ?>
1100 <tr>
1101 <td><?php echo $cron_job; ?></td>
1102 <td><?php echo $hook[1]; ?></td>
1103 <td><?php echo $hook[2]; ?></td>
1104 <td><?php echo esc_html( $last_run ); ?></td>
1105 <td><?php echo ! empty( $next_run ) ? esc_html( $next_run ) : ''; ?></td>
1106 </tr>
1107 <?php
1108 // phpcs:enable
1109 }
1110 /**
1111 * Action: mainwp_cron_jobs_list
1112 *
1113 * Renders as the last row of the Schedules table.
1114 *
1115 * @since 4.0
1116 */
1117 do_action( 'mainwp_cron_jobs_list' );
1118 ?>
1119 </tbody>
1120 </table>
1121 <?php
1122 $table_features = array(
1123 'searching' => 'true',
1124 'paging' => 'false',
1125 'info' => 'false',
1126 'responsive' => 'true',
1127 );
1128 /**
1129 * Filter: mainwp_cron_jobs_table_features
1130 *
1131 * Filters the Cron Schedules table features.
1132 *
1133 * @since 4.1
1134 */
1135 $table_features = apply_filters( 'mainwp_cron_jobs_table_features', $table_features );
1136 ?>
1137 <script type="text/javascript">
1138 jQuery( document ).ready( function() {
1139 let responsive = <?php echo esc_html( $table_features['responsive'] ); ?>;
1140 if( jQuery( window ).width() > 1140 ) {
1141 responsive = false;
1142 }
1143 jQuery( '#mainwp-cron-jobs-table' ).DataTable( {
1144 "searching": <?php echo esc_html( $table_features['searching'] ); ?>,
1145 "paging": <?php echo esc_html( $table_features['paging'] ); ?>,
1146 "info": <?php echo esc_html( $table_features['info'] ); ?>,
1147 "responsive": responsive,
1148 });
1149 } );
1150 </script>
1151 </div>
1152 <?php
1153
1154 /**
1155 * Action: mainwp_after_cron_jobs_table
1156 *
1157 * Renders on the bottom of the Cron Jobs page, after the Schedules table.
1158 *
1159 * @since 4.0
1160 */
1161 do_action( 'mainwp_after_cron_jobs_table' );
1162
1163 static::render_footer( 'ServerInformationCron' );
1164 }
1165
1166 /**
1167 * Get frequency auto update to show.
1168 *
1169 * @param int $freq frequency of auto update.
1170 *
1171 * @return string label of frequency.
1172 */
1173 public static function get_schedule_auto_update_label( $freq ) {
1174 $freq = intval( $freq );
1175 $text = '';
1176 switch ( $freq ) {
1177 case 1:
1178 $text = esc_html__( 'Once per day', 'mainwp' );
1179 break;
1180 case 2:
1181 $text = esc_html__( 'Twice per day', 'mainwp' );
1182 break;
1183 case 3:
1184 $text = esc_html__( 'Three times per day', 'mainwp' );
1185 break;
1186 case 4:
1187 $text = esc_html__( 'Four times per day', 'mainwp' );
1188 break;
1189 case 5:
1190 $text = esc_html__( 'Five times per day', 'mainwp' );
1191 break;
1192 case 6:
1193 $text = esc_html__( 'Six times per day', 'mainwp' );
1194 break;
1195 case 7:
1196 $text = esc_html__( 'Seven times per day', 'mainwp' );
1197 break;
1198 case 8:
1199 $text = esc_html__( 'Eight times per day', 'mainwp' );
1200 break;
1201 case 9:
1202 $text = esc_html__( 'Nine times per day', 'mainwp' );
1203 break;
1204 case 10:
1205 $text = esc_html__( 'Ten times per day', 'mainwp' );
1206 break;
1207 case 11:
1208 $text = esc_html__( 'Eleven times per day', 'mainwp' );
1209 break;
1210 case 12:
1211 $text = esc_html__( 'Twelve times per day', 'mainwp' );
1212 break;
1213 default:
1214 break;
1215 }
1216 return $text;
1217 }
1218
1219 /**
1220 * Get next time of schedule job to show.
1221 *
1222 * @param string $job_freq frequency of schedule job.
1223 * @param int $lasttime_run Lasttime to run.
1224 * @param int $local_timestamp current local time.
1225 *
1226 * @return int next run time of schedule job.
1227 */
1228 public static function get_schedule_next_time_to_show( $job_freq, $lasttime_run, $local_timestamp ) {
1229 $next_time = $local_timestamp;
1230 $lasttime_run = is_numeric( $lasttime_run ) ? intval( $lasttime_run ) : false;
1231 switch ( $job_freq ) {
1232 case 'daily':
1233 $next_time = $lasttime_run ? $lasttime_run + DAY_IN_SECONDS : $local_timestamp + DAY_IN_SECONDS;
1234 break;
1235 case 'hourly':
1236 $next_time = $lasttime_run ? $lasttime_run + HOUR_IN_SECONDS : $local_timestamp + HOUR_IN_SECONDS;
1237 break;
1238 case '5minutely':
1239 $next_time = $lasttime_run ? $lasttime_run + 5 * MINUTE_IN_SECONDS : $local_timestamp + 5 * MINUTE_IN_SECONDS;
1240 break;
1241 case 'minutely':
1242 $next_time = $lasttime_run ? $lasttime_run + MINUTE_IN_SECONDS : $local_timestamp + MINUTE_IN_SECONDS;
1243 break;
1244 default:
1245 break;
1246 }
1247
1248 if ( $next_time < $local_timestamp ) { // to fix next time in past.
1249 $next_time = $local_timestamp;
1250 }
1251
1252 return $next_time;
1253 }
1254
1255 /**
1256 * Checks if the ../wp-content/uploads/mainwp/ directory is writable.
1257 *
1258 * @return bool True if writable, false if not.
1259 *
1260 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir()
1261 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
1262 */
1263 public static function check_directory_mainwp_directory() {
1264 $dirs = MainWP_System_Utility::get_mainwp_dir();
1265 $path = $dirs[0];
1266
1267 $mess = 'Writable';
1268
1269 if ( ! is_dir( dirname( $path ) ) ) {
1270 $mess = 'Not Found';
1271 }
1272
1273 $is_writable = MainWP_System_Utility::is_writable( $path );
1274
1275 if ( $is_writable ) {
1276 $mess = 'Not Writable';
1277 }
1278
1279 return '<tr><td>MainWP Upload Directory</td><td>' . $mess . '</td></tr>';
1280 }
1281
1282 /**
1283 * Renders the directory check row.
1284 *
1285 * @param string $name check name.
1286 * @param string $check desired result.
1287 * @param string $result detected result.
1288 * @param bool $passed true|false check result.
1289 *
1290 * @return bool true.
1291 */
1292 public static function render_directory_row( $name, $check, $result, $passed ) {
1293 // phpcs:disable WordPress.Security.EscapeOutput
1294 ?>
1295 <tr>
1296 <td><?php echo esc_html( $name ); ?></td>
1297 <td><?php echo esc_html( $check ); ?></td>
1298 <td><?php echo esc_html( $result ); ?></td>
1299 <td class="right aligned"><?php echo $passed ? static::get_pass_html() : static::get_warning_html( static::ERROR ); ?></td>
1300 </tr>
1301 <?php
1302 // phpcs:enable
1303 return true;
1304 }
1305
1306 /**
1307 * Renders server information table row.
1308 *
1309 * @param string $config configuraion check.
1310 * @param string $compare comparison operator.
1311 * @param mixed $version reqiored minium version number.
1312 * @param mixed $getter detected version number.
1313 * @param string $extraText additionl text.
1314 * @param null $extraCompare extra compare.
1315 * @param null $extraVersion extra version.
1316 * @param null $whatType comparison type.
1317 * @param int $errorType global variable static::WARNING = 1.
1318 *
1319 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::filesize_compare()
1320 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::curlssl_compare()
1321 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_class_name()
1322 */
1323 public static function render_row( $config, $compare, $version, $getter, $extraText = '', $extraCompare = null, $extraVersion = null, $whatType = null, $errorType = self::WARNING ) { //phpcs:ignore -- NOSONAR - complex.
1324 $currentVersion = call_user_func( array( MainWP_Server_Information_Handler::get_class_name(), $getter ) );
1325 // phpcs:disable WordPress.Security.EscapeOutput
1326 $ver = is_array( $version ) && isset( $version['version'] ) ? esc_html( $version['version'] ) : esc_html( $version );
1327 ?>
1328 <tr>
1329 <td><?php echo esc_html( $config ); ?></td>
1330 <td><?php echo esc_html( $compare ); ?><?php echo ( true === $version ? 'true' : $ver ) . ' ' . $extraText; ?></td>
1331 <td><?php echo true === $currentVersion ? 'true' : $currentVersion; ?></td>
1332 <?php if ( 'filesize' === $whatType ) { ?>
1333 <td class="right aligned"><?php echo MainWP_Server_Information_Handler::filesize_compare( $currentVersion, $version, $compare ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1334 <?php } elseif ( 'get_curl_ssl_version' === $getter ) { ?>
1335 <td class="right aligned"><?php echo MainWP_Server_Information_Handler::curlssl_compare( $version, $compare ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1336 <?php } elseif ( ( 'get_max_input_time' === $getter || 'get_max_execution_time' === $getter ) && -1 === (int) $currentVersion ) { ?>
1337 <td class="right aligned"><?php echo static::get_pass_html(); ?></td>
1338 <?php } else { ?>
1339 <td class="right aligned"><?php echo version_compare( $currentVersion, $version, $compare ) || ( ! empty( $extraCompare ) && version_compare( $currentVersion, $extraVersion, $extraCompare ) ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1340 <?php } ?>
1341 </tr>
1342 <?php
1343 // phpcs:enable
1344 }
1345
1346 /**
1347 * Renders server information table row with description.
1348 *
1349 * @param string $config configuraion check.
1350 * @param string $compare comparison operator.
1351 * @param mixed $version reqiored minium version number.
1352 * @param mixed $getter detected version number.
1353 * @param string $extraText additionl text.
1354 * @param null $extraCompare extra compare.
1355 * @param null $extraVersion extra version.
1356 * @param null $whatType comparison type.
1357 * @param int $errorType global variable static::WARNING = 1.
1358 *
1359 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_class_name()
1360 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::filesize_compare()
1361 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::curlssl_compare()
1362 */
1363 public static function render_row_with_description( $config, $compare, $version, $getter, $extraText = '', $extraCompare = null, $extraVersion = null, $whatType = null, $errorType = self::WARNING ) { // phpcs:ignore -- NOSONAR - complex.
1364 $currentVersion = call_user_func( array( MainWP_Server_Information_Handler::get_class_name(), $getter ) );
1365 // phpcs:disable WordPress.Security.EscapeOutput
1366 $ver = is_array( $version ) && isset( $version['version'] ) ? esc_html( $version['version'] ) : esc_html( $version );
1367 ?>
1368 <tr>
1369 <td><?php echo esc_html( $config ); ?></td>
1370 <td><?php echo esc_html( $compare ); ?> <?php echo ( true === $version ? 'true' : $ver ) . ' ' . $extraText; ?></td>
1371 <td><?php echo true === $currentVersion ? 'true' : $currentVersion; ?></td>
1372 <?php if ( 'filesize' === $whatType ) { ?>
1373 <td class="right aligned"><?php echo MainWP_Server_Information_Handler::filesize_compare( $currentVersion, $version, $compare ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1374 <?php } elseif ( 'get_curl_ssl_version' === $getter ) { ?>
1375 <td class="right aligned"><?php echo MainWP_Server_Information_Handler::curlssl_compare( $version, $compare ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1376 <?php } elseif ( 'get_max_input_time' === $getter && -1 === (int) $currentVersion ) { ?>
1377 <td class="right aligned"><?php echo static::get_pass_html(); ?></td>
1378 <?php } else { ?>
1379 <td class="right aligned"><?php echo version_compare( $currentVersion, $version, $compare ) || ( ! empty( $extraCompare ) && version_compare( $currentVersion, $extraVersion, $extraCompare ) ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1380 <?php } ?>
1381 </tr>
1382 <?php
1383 // phpcs:enable
1384 }
1385
1386 /**
1387 * Checks if file system method is direct.
1388 *
1389 * @return mixed html|static::get_warning_html().
1390 *
1391 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_file_system_method()
1392 */
1393 public static function get_file_system_method_check() {
1394 $fsmethod = MainWP_Server_Information_Handler::get_file_system_method();
1395 if ( 'direct' === $fsmethod ) {
1396 return static::get_pass_html();
1397 } else {
1398 return static::get_warning_html();
1399 }
1400 }
1401
1402 /**
1403 * Renders Error Log page.
1404 *
1405 * Plugin-Name: Error Log Dashboard Widget
1406 * Plugin URI: http://wordpress.org/extend/plugins/error-log-dashboard-widget/
1407 * Description: Robust zero-configuration and low-memory way to keep an eye on error log.
1408 * Author: Andrey "Rarst" Savchenko
1409 * Author URI: http://www.rarst.net/
1410 * Version: 1.0.2
1411 * License: GPLv2 or later
1412
1413 * Includes last_lines() function by phant0m, licensed under cc-wiki and GPLv2+
1414 */
1415 public static function render_error_log_page() {
1416 if ( ! mainwp_current_user_have_right( 'dashboard', 'see_server_information' ) ) {
1417 mainwp_do_not_have_permissions( 'error log', 'mainwp' );
1418 return;
1419 }
1420 static::render_header( 'ErrorLog' );
1421
1422 /**
1423 * Action: mainwp_before_error_log_table
1424 *
1425 * Fires before the Error Log table.
1426 *
1427 * @since 4.1
1428 */
1429 do_action( 'mainwp_before_error_log_table' );
1430 ?>
1431 <div class="ui segment">
1432 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-error-log-info-message' ) ) : ?>
1433 <div class="ui info message">
1434 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-error-log-info-message"></i>
1435 <?php echo esc_html__( 'See the WordPress error log to fix problems that arise on your MainWP Dashboard site.', 'mainwp' ); ?>
1436 </div>
1437 <?php endif; ?>
1438 <table class="ui unstackable table" id="mainwp-error-log-table">
1439 <thead>
1440 <tr>
1441 <th scope="col" ><?php esc_html_e( 'Time', 'mainwp' ); ?></th>
1442 <th scope="col" ><?php esc_html_e( 'Error', 'mainwp' ); ?></th>
1443 </tr>
1444 </thead>
1445 <tbody>
1446 <?php static::render_error_log(); ?>
1447 </tbody>
1448 </table>
1449 <script type="text/javascript">
1450 let responsive = true;
1451 if( jQuery( window ).width() > 1140 ) {
1452 responsive = false;
1453 }
1454
1455 jQuery( document ).ready( function() {
1456 jQuery( '#mainwp-error-log-table' ).DataTable( {
1457 "responsive": responsive,
1458 "ordering": false,
1459 "stateSave": true,
1460 "stateDuration": 0,
1461 "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
1462 "language": {
1463 "emptyTable": '<?php esc_html_e( 'Error logging disabled.', 'mainwp' ); ?><?php echo '<br/>' . sprintf( esc_html__( 'To enable error logging, please check this %1$shelp document%2$s.', 'mainwp' ), '<a href="https://codex.wordpress.org/Debugging_in_WordPress" target="_blank">', '</a>' ); ?>'
1464 },
1465 } );
1466 } );
1467 </script>
1468 </div>
1469 <?php
1470 /**
1471 * Action: mainwp_after_error_log_table
1472 *
1473 * Fires after the Error Log table.
1474 *
1475 * @since 4.1
1476 */
1477 do_action( 'mainwp_after_error_log_table' );
1478
1479 static::render_footer( 'ErrorLog' );
1480 }
1481
1482 /**
1483 * Renders error log page.
1484 *
1485 * @return void
1486 *
1487 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::last_lines()
1488 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_class_name()
1489 */
1490 public static function render_error_log() {
1491 $log_errors = ini_get( 'log_errors' );
1492 if ( ! $log_errors ) {
1493 return;
1494 }
1495
1496 $error_log = ini_get( 'error_log' );
1497 /**
1498 * Filter: error_log_mainwp_logs
1499 *
1500 * Filters the error log files to show.
1501 *
1502 * @since Unknown
1503 */
1504 $logs = apply_filters( 'error_log_mainwp_logs', array( $error_log ) );
1505
1506 /**
1507 * Filter: error_log_mainwp_lines
1508 *
1509 * Limits the number of error log records to be displayed. Default value, 50.
1510 *
1511 * @since Unknown
1512 */
1513 $count = apply_filters( 'error_log_mainwp_lines', 100 );
1514 $lines = array();
1515
1516 foreach ( $logs as $log ) {
1517 if ( is_readable( $log ) ) {
1518 $lines = array_merge( $lines, MainWP_Server_Information_Handler::last_lines( $log, $count ) );
1519 }
1520 }
1521
1522 $lines = array_map( 'trim', $lines );
1523 $lines = array_filter( $lines );
1524
1525 if ( empty( $lines ) ) {
1526
1527 echo '<tr><td>' . esc_html__( 'MainWP is unable to find your error logs, please contact your host for server error logs.', 'mainwp' ) . '</td></tr>';
1528
1529 return;
1530 }
1531
1532 foreach ( $lines as $key => $line ) {
1533 if ( false !== strpos( $line, ']' ) ) {
1534 list( $time, $error ) = explode( ']', $line, 2 );
1535 } else {
1536 list( $time, $error ) = array( '', $line );
1537 }
1538 $time = trim( $time, '[]' );
1539 $error = trim( $error );
1540 $lines[ $key ] = compact( 'time', 'error' );
1541 }
1542
1543 if ( 1 < count( $lines ) ) {
1544 // phpcs:ignore -- ok.
1545 //uasort( $lines, array( MainWP_Server_Information_Handler::get_class_name(), 'time_compare' ) );
1546 $lines = array_slice( $lines, 0, $count );
1547 }
1548
1549 // phpcs:disable WordPress.Security.EscapeOutput
1550 foreach ( $lines as $line ) {
1551 $error = esc_html( $line['error'] );
1552 $time = esc_html( $line['time'] );
1553 if ( ! empty( $error ) ) {
1554 echo '<tr><td>' . $time . '</td><td>' . $error . '</td></tr>';
1555 }
1556 }
1557 // phpcs:enable
1558 }
1559
1560 /**
1561 * Renders the WP Config page.
1562 *
1563 * @return void
1564 */
1565 public static function render_wp_config() {
1566 if ( ! mainwp_current_user_have_right( 'dashboard', 'see_server_information' ) ) {
1567 mainwp_do_not_have_permissions( 'WP-Config.php', 'mainwp' );
1568 return;
1569 }
1570
1571 static::render_header( 'WPConfig' );
1572 /**
1573 * Action: mainwp_before_wp_config_section
1574 *
1575 * Fires before the WP Config section.
1576 *
1577 * @since 4.1
1578 */
1579 do_action( 'mainwp_before_wp_config_section' );
1580 ?>
1581 <div id="mainwp-show-wp-config">
1582 <?php
1583 if ( false !== strpos( ini_get( 'disable_functions' ), 'show_source' ) ) {
1584 esc_html_e( 'File content could not be displayed.', 'mainwp' );
1585 echo '<br />';
1586 esc_html_e( 'It appears that the show_source() PHP function has been disabled on the servre.', 'mainwp' );
1587 echo '<br />';
1588 esc_html_e( 'Please, contact your host support and have them enable the show_source() function for the proper functioning of this feature.', 'mainwp' );
1589 } elseif ( file_exists( ABSPATH . 'wp-config.php' ) ) {
1590 show_source( ABSPATH . 'wp-config.php' );
1591 } else {
1592 $files = get_included_files();
1593 $configFound = false;
1594 if ( is_array( $files ) ) {
1595 foreach ( $files as $file ) {
1596 if ( stristr( $file, 'wp-config.php' ) ) {
1597 $configFound = true;
1598 show_source( $file );
1599 break;
1600 }
1601 }
1602 }
1603 if ( ! $configFound ) {
1604 esc_html_e( 'wp-config.php not found', 'mainwp' );
1605 }
1606 }
1607 ?>
1608 </div>
1609 <?php
1610 /**
1611 * Action: mainwp_after_wp_config_section
1612 *
1613 * Fires after the WP Config section.
1614 *
1615 * @since 4.1
1616 */
1617 do_action( 'mainwp_after_wp_config_section' );
1618
1619 static::render_footer( 'WPConfig' );
1620 }
1621
1622 /**
1623 * Renders action logs page.
1624 *
1625 * @uses \MainWP\Dashboard\MainWP_Logger
1626 * @uses \MainWP\Dashboard\MainWP_Logger::clear_log()
1627 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1628 */
1629 public static function render_action_logs() { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1630 static::render_header( 'ActionLogs' );
1631
1632 if ( isset( $_REQUEST['actionlogs_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1633 $act_log = isset( $_REQUEST['actionlogs_status'] ) ? wp_unslash( $_REQUEST['actionlogs_status'] ) : MainWP_Logger::DISABLED; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1634 $spec_log = 0;
1635 if ( is_string( $act_log ) && false !== strpos( $act_log, 'specific_' ) ) {
1636 $act_log = str_replace( 'specific_', '', $act_log );
1637 $spec_log = 1;
1638 }
1639
1640 $act_log = intval( $act_log );
1641
1642 MainWP_Utility::update_option( 'mainwp_specific_logs', $spec_log );
1643
1644 MainWP_Logger::instance()->log_action( 'Action logs set to: ' . MainWP_Logger::instance()->get_log_text( $act_log ), ( $spec_log ? $act_log : MainWP_Logger::LOG ), 2, true );
1645
1646 if ( MainWP_Logger::DISABLED === $act_log ) {
1647 MainWP_Logger::instance()->set_log_priority( $act_log, $spec_log );
1648 }
1649
1650 MainWP_Utility::update_option( 'mainwp_actionlogs', $act_log );
1651 MainWP_Utility::update_option( 'mainwp_actionlogs_enabled_timestamp', time() );
1652 }
1653
1654 if ( isset( $_REQUEST['actionlogs_clear'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1655 $log_to_db = apply_filters( 'mainwp_logger_to_db', true );
1656 if ( $log_to_db ) {
1657 MainWP_Logger::instance()->clear_log_db();
1658 } else {
1659 MainWP_Logger::instance()->clear_log();
1660 }
1661 }
1662
1663 $enabled = (int) MainWP_Logger::instance()->get_log_status();
1664 $specific_default = array(
1665 MainWP_Logger::UPDATE_CHECK_LOG_PRIORITY => esc_html__( 'Update Checking', 'mainwp' ),
1666 MainWP_Logger::EXECUTION_TIME_LOG_PRIORITY => esc_html__( 'Execution time', 'mainwp' ),
1667 MainWP_Logger::LOGS_AUTO_PURGE_LOG_PRIORITY => esc_html__( 'Logs Auto Purge', 'mainwp' ),
1668 );
1669 $specific_logs = apply_filters( 'mainwp_specific_action_logs', $specific_default ); // deprecated since 4.3.1, use 'mainwp_log_specific_actions' instead.
1670 $specific_logs = apply_filters( 'mainwp_log_specific_actions', $specific_logs );
1671
1672 ?>
1673 <div class="mainwp-sub-header">
1674 <div class="ui mini form two column stackable grid">
1675 <div class="column">
1676 <form method="POST" action="">
1677 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1678 <?php // phpcs:disable WordPress.Security.EscapeOutput ?>
1679 <select name="actionlogs_status" class="ui mini dropdown">
1680 <option value="<?php echo MainWP_Logger::DISABLED; ?>" <?php echo MainWP_Logger::DISABLED === $enabled ? 'selected' : ''; ?>>
1681 <?php esc_html_e( 'Disabled', 'mainwp' ); ?>
1682 </option>
1683 <option value="<?php echo MainWP_Logger::INFO; ?>" <?php echo MainWP_Logger::INFO === $enabled ? 'selected' : ''; ?>>
1684 <?php esc_html_e( 'Info', 'mainwp' ); ?>
1685 </option>
1686 <option value="<?php echo MainWP_Logger::WARNING; ?>" <?php echo MainWP_Logger::WARNING === $enabled ? 'selected' : ''; ?>>
1687 <?php esc_html_e( 'Warning', 'mainwp' ); ?>
1688 </option>
1689 <option value="<?php echo MainWP_Logger::DEBUG; ?>" <?php echo MainWP_Logger::DEBUG === $enabled ? 'selected' : ''; ?>>
1690 <?php esc_html_e( 'Debug', 'mainwp' ); ?>
1691 </option>
1692 <?php
1693 // phpcs:enable
1694 if ( is_array( $specific_logs ) && ! empty( $specific_logs ) ) {
1695 foreach ( $specific_logs as $spec_log => $spec_title ) {
1696 ?>
1697 <option value="specific_<?php echo intval( $spec_log ); ?>" <?php echo (int) $spec_log === (int) $enabled ? 'selected' : ''; ?>>
1698 <?php echo esc_html( $spec_title ); ?>
1699 </option>
1700 <?php
1701 }
1702 }
1703 ?>
1704 </select>
1705 <input type="submit" class="ui green mini button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
1706 <input type="submit" class="ui mini button" name="actionlogs_clear" value="<?php esc_attr_e( 'Delete Log', 'mainwp' ); ?>" />
1707 </form>
1708 </div>
1709 <div class="column">
1710
1711 </div>
1712 </div>
1713 </div>
1714 <div class="ui segment">
1715 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-action-logs-info-message' ) ) : ?>
1716 <div class="ui info message">
1717 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-action-logs-info-message"></i>
1718 <div><?php echo esc_html__( 'Enable a specific logging system.', 'mainwp' ); ?></div>
1719 <p><?php echo esc_html__( 'Each specific log type changes only the type of information logged. It does not change the log view.', 'mainwp' ); ?></p>
1720 <p><?php echo esc_html__( 'After disabling the Action Log, logs will still be visible. To remove records, click the Delete Logs button.', 'mainwp' ); ?></p>
1721 <p><?php printf( esc_html__( 'For additional help, please review this %1$shelp document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/action-logs/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></p>
1722 </div>
1723 <?php endif; ?>
1724 <?php
1725 $log_to_db = apply_filters( 'mainwp_logger_to_db', true );
1726 if ( $log_to_db ) {
1727 return MainWP_Logger::instance()->show_log_db();
1728 } else {
1729 MainWP_Logger::instance()->show_log_file();
1730 }
1731 ?>
1732 </div>
1733 <?php
1734 static::render_footer( 'ActionLogs' );
1735 }
1736
1737 /**
1738 * Renders the Plugin Privacy page.
1739 *
1740 * @return void
1741 */
1742 public static function render_plugin_privacy_page() {
1743
1744 static::render_header( 'PluginPrivacy' );
1745 /**
1746 * Action: mainwp_before_plugin_privacy_section
1747 *
1748 * Fires before the Plugin Privacy section.
1749 *
1750 * @since 4.2
1751 */
1752 do_action( 'mainwp_before_plugin_privacy_section' );
1753 ?>
1754 <div class="ui segment">
1755 <div id="mainwp-plugin-privacy">
1756 <h2 class="ui header">
1757 <?php echo esc_html__( 'MainWP Dashboard Plugin Privacy Policy', 'mainwp' ); ?>
1758 <div class="sub header"><em><?php echo esc_html__( 'Last updated: April 14, 2022', 'mainwp' ); ?></em></div>
1759 </h2>
1760 <p><?php echo esc_html__( 'We value your privacy very highly. Please read this Privacy Policy carefully before using the MainWP Dashboard Plugin ("Plugin") operated by Sick Marketing, LLC d/b/a MainWP, a Limited Liability Company formed in Nevada, United States ("us","we","our") as this Privacy Policy contains important information regarding your privacy.', 'mainwp' ); ?></p>
1761 <p><?php echo esc_html__( 'Your access to and use of the Plugin is conditional upon your acceptance of and compliance with this Privacy Policy. This Privacy Policy applies to everyone accessing or using the Plugin.', 'mainwp' ); ?></p>
1762 <p><?php echo esc_html__( 'By accessing or using the Plugin, you agree to be bound by this Privacy Policy. If you disagree with any part of this Privacy Policy, then you do not have our permission to access or use the Plugin.', 'mainwp' ); ?></p>
1763 <h3 class="ui header"><?php echo esc_html__( 'What personal data we collect', 'mainwp' ); ?></h3>
1764 <p><?php echo esc_html__( 'We do not collect, store, nor process any personal data through this Plugin.', 'mainwp' ); ?></p>
1765 <h3 class="ui header"><?php echo esc_html__( 'Third-party extensions and integrations', 'mainwp' ); ?></h3>
1766 <p><?php echo esc_html__( 'This Plugin may be used with extensions that are operated by parties other than us. We may also provide extensions that have integrations with third party services. We do not control such extensions and integrations and are not responsible for their contents or the privacy or other practices of such extensions or integrations. Further, it is up to you to take precautions to ensure that whatever extensions or integrations you use adequately protect your privacy. Please review the Privacy Policies of such extensions or integrations before using them.', 'mainwp' ); ?></p>
1767 <div class="ui hidden divider"></div>
1768 <div class="ui two columns stackable grid">
1769 <div class="column">
1770 <h3 class="ui header"><?php echo esc_html__( 'Our contact information', 'mainwp' ); ?></h3>
1771 <p><?php echo esc_html__( 'If you have any questions regarding our privacy practices, please do not hesitate to contact us at the following:', 'mainwp' ); ?></p>
1772 <div class="ui list">
1773 <div class="item"><?php echo esc_html__( 'Sick Marketing, LLC d/b/a MainWP', 'mainwp' ); ?></div>
1774 <div class="item"><?php echo esc_html__( 'support@mainwp.com', 'mainwp' ); ?></div>
1775 <div class="item"><?php echo esc_html__( '4730 S. Fort Apache Road', 'mainwp' ); ?></div>
1776 <div class="item"><?php echo esc_html__( 'Suite 300', 'mainwp' ); ?></div>
1777 <div class="item"><?php echo esc_html__( 'PO Box 27740', 'mainwp' ); ?></div>
1778 <div class="item"><?php echo esc_html__( 'Las Vegas, NV 89126', 'mainwp' ); ?></div>
1779 <div class="item"><?php echo esc_html__( 'United States', 'mainwp' ); ?></div>
1780 </div>
1781 </div>
1782 <div class="column">
1783 <h3 class="ui header"><?php echo esc_html__( 'Our representative\'s contact information', 'mainwp' ); ?></h3>
1784 <p><?php echo esc_html__( 'If you are a resident of the European Union or the European Economic Area, you may also contact our representative at the following:', 'mainwp' ); ?></p>
1785 <div class="item"><?php echo esc_html__( 'Ametros Ltd', 'mainwp' ); ?></div>
1786 <div class="item"><?php echo esc_html__( 'Unit 3D', 'mainwp' ); ?></div>
1787 <div class="item"><?php echo esc_html__( 'North Point House', 'mainwp' ); ?></div>
1788 <div class="item"><?php echo esc_html__( 'North Point Business Park', 'mainwp' ); ?></div>
1789 <div class="item"><?php echo esc_html__( 'New Mallow Road', 'mainwp' ); ?></div>
1790 <div class="item"><?php echo esc_html__( 'Cork', 'mainwp' ); ?></div>
1791 <div class="item"><?php echo esc_html__( 'Ireland', 'mainwp' ); ?></div>
1792 <div class="ui hidden divider"></div>
1793 <p><?php echo esc_html__( 'If you are a resident of the United Kingdom, you may contact our representative at the following:', 'mainwp' ); ?></p>
1794 <div class="item"><?php echo esc_html__( 'Ametros Group Ltd', 'mainwp' ); ?></div>
1795 <div class="item"><?php echo esc_html__( 'Lakeside Offices', 'mainwp' ); ?></div>
1796 <div class="item"><?php echo esc_html__( 'Thorn Business Park', 'mainwp' ); ?></div>
1797 <div class="item"><?php echo esc_html__( 'Hereford', 'mainwp' ); ?></div>
1798 <div class="item"><?php echo esc_html__( 'Herefordshire', 'mainwp' ); ?></div>
1799 <div class="item"><?php echo esc_html__( 'HR2 6JT', 'mainwp' ); ?></div>
1800 <div class="item"><?php echo esc_html__( 'England', 'mainwp' ); ?></div>
1801 </div>
1802 </div>
1803 <div class="ui divider"></div>
1804 </div>
1805
1806 <a href="<?php echo esc_url( get_site_url() ) . '/wp-content/plugins/mainwp/privacy-policy.txt'; ?>" class="ui green basic button" target="_blank"><?php echo esc_html__( 'Download MainWP Dashboard Privacy Policy', 'mainwp' ); ?></a> <a href="<?php echo esc_url( get_site_url() ) . '/wp-content/plugins/mainwp/mainwp-child-privacy-policy.txt'; ?>" class="ui green basic button" target="_blank"><?php echo esc_html__( 'Download MainWP Child Privacy Policy', 'mainwp' ); ?></a>
1807 </div>
1808
1809 <?php
1810 /**
1811 * Action: mainwp_after_plugin_privacy_section
1812 *
1813 * Fires after the Plugin Privacy section.
1814 *
1815 * @since 4.2
1816 */
1817 do_action( 'mainwp_after_plugin_privacy_section' );
1818
1819 static::render_footer( 'PluginPrivacy' );
1820 }
1821
1822 /**
1823 * Renders .htaccess File page.
1824 *
1825 * @return void
1826 */
1827 public static function render_htaccess() {
1828 if ( ! mainwp_current_user_have_right( 'dashboard', 'see_server_information' ) ) {
1829 mainwp_do_not_have_permissions( '.htaccess', 'mainwp' );
1830 return;
1831 }
1832 static::render_header( '.htaccess' );
1833 /**
1834 * Action: mainwp_before_htaccess_section
1835 *
1836 * Fires before the .htaccess file section.
1837 *
1838 * @since 4.1
1839 */
1840 do_action( 'mainwp_before_htaccess_section' );
1841 ?>
1842 <div id="mainwp-show-htaccess">
1843 <?php
1844 if ( false !== strpos( ini_get( 'disable_functions' ), 'show_source' ) ) {
1845 esc_html_e( 'File content could not be displayed.', 'mainwp' );
1846 echo '<br />';
1847 esc_html_e( 'It appears that the show_source() PHP function has been disabled on the servre.', 'mainwp' );
1848 echo '<br />';
1849 esc_html_e( 'Please, contact your host support and have them enable the show_source() function for the proper functioning of this feature.', 'mainwp' );
1850 } else {
1851 show_source( ABSPATH . '.htaccess' );
1852 }
1853 ?>
1854 </div>
1855 <?php
1856 /**
1857 * Action: mainwp_after_htaccess_section
1858 *
1859 * Fires after the .htaccess file section.
1860 *
1861 * @since 4.1
1862 */
1863 do_action( 'mainwp_after_htaccess_section' );
1864 static::render_footer( '.htaccess' );
1865 }
1866
1867 /**
1868 * Checks for disable PHP Functions.
1869 *
1870 * @return void
1871 */
1872 public static function php_disabled_functions() {
1873 $disabled_functions = ini_get( 'disable_functions' );
1874 if ( '' !== $disabled_functions ) {
1875 $arr = explode( ',', $disabled_functions );
1876 sort( $arr );
1877 $_count = count( $arr );
1878 for ( $i = 0; $i < $_count; $i++ ) {
1879 echo esc_html( $arr[ $i ] ) . ', ';
1880 }
1881 } else {
1882 esc_html_e( 'No functions disabled.', 'mainwp' );
1883 }
1884 }
1885
1886 /**
1887 * Renders MainWP Settings 'Options'.
1888 *
1889 * @return void
1890 *
1891 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::mainwp_options()
1892 */
1893 public static function display_mainwp_options() {
1894 $options = MainWP_Server_Information_Handler::mainwp_options();
1895 // phpcs:disable WordPress.Security.EscapeOutput
1896 foreach ( $options as $option ) {
1897 echo '<tr><td>' . $option['label'] . '</td><td>' . $option['value'] . '</td></tr>';
1898 }
1899 // phpcs:enable
1900 }
1901
1902 /**
1903 * Renders PHP Warning HTML.
1904 *
1905 * @param int $errorType Global variable static::WARNING = 1.
1906 * @param bool $ech echo or return.
1907 *
1908 * @return string PHP Warning html.
1909 */
1910 private static function get_warning_html( $errorType = self::WARNING, $ech = false ) {
1911 $msg = '';
1912 if ( static::WARNING === $errorType ) {
1913 $msg = '<i class="large yellow exclamation icon"></i><span style="display:none">' . esc_html__( 'Warning', 'mainwp' ) . '</span>';
1914 } else {
1915 $msg = '<i class="large red times icon"></i><span style="display:none">' . esc_html__( 'Fail', 'mainwp' ) . '</span>';
1916 }
1917
1918 if ( $ech ) {
1919 echo $msg; //phpcs:ignore -- escaped.
1920 } else {
1921 return $msg;
1922 }
1923 }
1924
1925 /**
1926 * Renders PHP Pass HTML.
1927 *
1928 * @param bool $ech echo or return.
1929 *
1930 * @return string PHP Pass html.
1931 */
1932 private static function get_pass_html( $ech = false ) {
1933 $msg = '<i class="large green check icon"></i><span style="display:none">' . esc_html__( 'Pass', 'mainwp' ) . '</span>';
1934 if ( $ech ) {
1935 echo $msg; //phpcs:ignore -- escaped.
1936 } else {
1937 return $msg;
1938 }
1939 }
1940 }
1941