PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.3
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.3, at pages/page-mainwp-server-information.php

1,972 lines 90.6 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_can( '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
941 $ssl_version = OPENSSL_VERSION_TEXT;
942 $openssl_version = 'OpenSSL/1.1.0';
943 if ( false !== strpos( $ssl_version, 'LibreSSL' ) ) {
944 $openssl_version = 'LibreSSL/2.5.0';
945 }
946
947 static::render_row_with_description(
948 'cURL SSL Version',
949 '>=',
950 $openssl_version,
951 'get_curl_ssl_version',
952 '',
953 '',
954 null,
955 'curlssl'
956 );
957
958 if ( ! MainWP_Server_Information_Handler::curlssl_compare( $openssl_version, '>=' ) ) {
959 ?>
960 <tr class='warning'>
961 <td colspan='4'>
962 <i class='attention icon'></i>
963 <?php
964 if ( false !== strpos( $ssl_version, 'LibreSSL' ) ) {
965 printf( esc_html__( 'Your host needs to update LibreSSL to at least version 2.5.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://www.libressl.org/" target="_blank">', '</a>' );
966 } else {
967 printf( 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>' );
968 }
969 ?>
970 </td>
971 </tr>
972 <?php
973 }
974 static::render_row_with_description( esc_html__( 'MySQL Version', 'mainwp' ), '>=', '5.0', 'get_mysql_version', '', '', null );
975 ?>
976 </tbody>
977 </table>
978 <?php
979 /**
980 * Action: mainwp_after_system_requirements_check
981 *
982 * Fires on the bottom of the System Requirements page, in Quick Setup Wizard.
983 *
984 * @since 4.1
985 */
986 do_action( 'mainwp_after_system_requirements_check' );
987 }
988
989 /**
990 * Compares the detected MainWP Dashboard version agains the verion in WP.org.
991 *
992 * @return mixed Pass|static::get_warning_html().
993 *
994 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_mainwp_version()
995 */
996 public static function get_mainwp_version_check() {
997 $current = get_option( 'mainwp_plugin_version' );
998 $latest = MainWP_Server_Information_Handler::get_mainwp_version();
999 if ( $current === $latest ) {
1000 return static::get_pass_html();
1001 } else {
1002 return static::get_warning_html();
1003 }
1004 }
1005
1006 /**
1007 * Renders the Cron Schedule page.
1008 *
1009 * @return void
1010 *
1011 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
1012 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
1013 */
1014 public static function render_cron() { // phpcs:ignore -- NOSONAR - complex.
1015 if ( ! \mainwp_current_user_can( 'dashboard', 'see_server_information' ) ) {
1016 \mainwp_do_not_have_permissions( 'cron schedules', 'mainwp' );
1017 return;
1018 }
1019
1020 static::render_header( 'ServerInformationCron' );
1021
1022 $local_timestamp = MainWP_Utility::get_timestamp();
1023
1024 $freq = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 );
1025 if ( $freq <= 0 ) {
1026 $freq = 1;
1027 }
1028 $auto_update_text = static::get_schedule_auto_update_label( $freq );
1029
1030 $cron_jobs = array(
1031 'Check for available updates' => array( 'mainwp_updatescheck_start_last_timestamp', 'mainwp_cronupdatescheck_action', $auto_update_text ),
1032 'Check for reconnect sites' => array( 'mainwp_cron_last_stats', 'mainwp_cronreconnect_action', esc_html__( 'Once hourly', 'mainwp' ), 'hourly' ),
1033 'Ping childs sites' => array( 'mainwp_cron_last_ping', 'mainwp_cronpingchilds_action', esc_html__( 'Once daily', 'mainwp' ), 'daily' ),
1034 );
1035
1036 $cron_jobs['Child site uptime monitoring'] = array( 'mainwp_uptimecheck_auto_main_counter_lasttime_started', 'mainwp_cronuptimemonitoringcheck_action', esc_html__( 'Once every minute', 'mainwp' ), 'minutely' );
1037
1038 $disableHealthChecking = get_option( 'mainwp_disableSitesHealthMonitoring', 1 ); // disabled by default.
1039 if ( ! $disableHealthChecking ) {
1040 $cron_jobs['Site Health monitoring'] = array( 'mainwp_cron_checksiteshealth_last_timestamp', 'mainwp_cronsitehealthcheck_action', esc_html__( 'Once hourly', 'mainwp' ), 'hourly' );
1041 }
1042
1043 if ( get_option( 'mainwp_enableLegacyBackupFeature' ) ) {
1044 $cron_jobs['Start backups (Legacy)'] = array( 'mainwp_cron_last_backups', 'mainwp_cronbackups_action', esc_html__( 'Once hourly', 'mainwp' ), 'hourly' );
1045 $cron_jobs['Continue backups (Legacy)'] = array( 'mainwp_cron_last_backups_continue', 'mainwp_cronbackups_continue_action', esc_html__( 'Once every five minutes', 'mainwp' ), '5minutely' );
1046 }
1047
1048 /**
1049 * Action: mainwp_before_cron_jobs_table
1050 *
1051 * Renders on the top of the Cron Jobs page, before the Schedules table.
1052 *
1053 * @since 4.0
1054 */
1055 do_action( 'mainwp_before_cron_jobs_table' );
1056 ?>
1057 <div class="ui segment">
1058 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-cron-info-message' ) ) : ?>
1059 <div class="ui info message">
1060 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-cron-info-message"></i>
1061 <?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>' ); ?>
1062 </div>
1063 <?php endif; ?>
1064 <table class="ui single line unstackable table" id="mainwp-cron-jobs-table">
1065 <thead>
1066 <tr>
1067 <th scope="col" ><?php esc_html_e( 'Cron Job', 'mainwp' ); ?></th>
1068 <th scope="col" ><?php esc_html_e( 'Hook', 'mainwp' ); ?></th>
1069 <th scope="col" ><?php esc_html_e( 'Schedule', 'mainwp' ); ?></th>
1070 <th scope="col" ><?php esc_html_e( 'Last Run', 'mainwp' ); ?></th>
1071 <th scope="col" ><?php esc_html_e( 'Next Run', 'mainwp' ); ?></th>
1072 </tr>
1073 </thead>
1074 <tbody>
1075 <?php
1076 $useWPCron = ( false === get_option( 'mainwp_wp_cron' ) ) || ( 1 === (int) get_option( 'mainwp_wp_cron' ) );
1077
1078 foreach ( $cron_jobs as $cron_job => $hook ) {
1079
1080 $is_auto_update_job = false;
1081 $lasttime_run = 0;
1082 if ( 'mainwp_updatescheck_start_last_timestamp' === $hook[0] ) {
1083 $update_time = MainWP_Settings::get_websites_automatic_update_time();
1084 $last_run = $update_time['last'];
1085 $next_run = $update_time['next'];
1086 $is_auto_update_job = true;
1087 } elseif ( false === get_option( $hook[0] ) ) {
1088 $last_run = esc_html__( 'Never', 'mainwp' );
1089 } else {
1090 $lasttime_run = get_option( $hook[0] );
1091 if ( $lasttime_run ) {
1092 $last_run = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $lasttime_run ) );
1093 } else {
1094 $last_run = esc_html__( 'Never', 'mainwp' );
1095 }
1096 }
1097
1098 if ( $useWPCron && 'mainwp_updatescheck_start_last_timestamp' !== $hook[0] ) {
1099 $next_run = wp_next_scheduled( $hook[1] );
1100 if ( ! empty( $next_run ) ) {
1101 $next_run = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $next_run ) );
1102 }
1103 }
1104
1105 if ( empty( $next_run ) || ( ! $useWPCron && ! $is_auto_update_job && isset( $hook[3] ) ) ) {
1106 $nexttime_run = static::get_schedule_next_time_to_show( $hook[3], $lasttime_run, $local_timestamp );
1107 if ( $nexttime_run < $local_timestamp + 3 * MINUTE_IN_SECONDS ) {
1108 $next_run = esc_html__( 'Any minute', 'mainwp' );
1109 } else {
1110 $next_run = MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $nexttime_run ) );
1111 }
1112 }
1113
1114 // phpcs:disable WordPress.Security.EscapeOutput
1115 ?>
1116 <tr>
1117 <td><?php echo $cron_job; ?></td>
1118 <td><?php echo $hook[1]; ?></td>
1119 <td><?php echo $hook[2]; ?></td>
1120 <td><?php echo esc_html( $last_run ); ?></td>
1121 <td><?php echo ! empty( $next_run ) ? esc_html( $next_run ) : ''; ?></td>
1122 </tr>
1123 <?php
1124 // phpcs:enable
1125 }
1126 /**
1127 * Action: mainwp_cron_jobs_list
1128 *
1129 * Renders as the last row of the Schedules table.
1130 *
1131 * @since 4.0
1132 */
1133 do_action( 'mainwp_cron_jobs_list' );
1134 ?>
1135 </tbody>
1136 </table>
1137 <?php
1138 $table_features = array(
1139 'searching' => 'true',
1140 'paging' => 'false',
1141 'info' => 'false',
1142 'responsive' => 'true',
1143 );
1144 /**
1145 * Filter: mainwp_cron_jobs_table_features
1146 *
1147 * Filters the Cron Schedules table features.
1148 *
1149 * @since 4.1
1150 */
1151 $table_features = apply_filters( 'mainwp_cron_jobs_table_features', $table_features );
1152 ?>
1153 <script type="text/javascript">
1154 jQuery( document ).ready( function() {
1155 let responsive = <?php echo esc_html( $table_features['responsive'] ); ?>;
1156 if( jQuery( window ).width() > 1140 ) {
1157 responsive = false;
1158 }
1159 jQuery( '#mainwp-cron-jobs-table' ).DataTable( {
1160 "searching": <?php echo esc_html( $table_features['searching'] ); ?>,
1161 "paging": <?php echo esc_html( $table_features['paging'] ); ?>,
1162 "info": <?php echo esc_html( $table_features['info'] ); ?>,
1163 "responsive": responsive,
1164 });
1165 } );
1166 </script>
1167 </div>
1168 <?php
1169
1170 /**
1171 * Action: mainwp_after_cron_jobs_table
1172 *
1173 * Renders on the bottom of the Cron Jobs page, after the Schedules table.
1174 *
1175 * @since 4.0
1176 */
1177 do_action( 'mainwp_after_cron_jobs_table' );
1178
1179 static::render_footer( 'ServerInformationCron' );
1180 }
1181
1182 /**
1183 * Get frequency auto update to show.
1184 *
1185 * @param int $freq frequency of auto update.
1186 *
1187 * @return string label of frequency.
1188 */
1189 public static function get_schedule_auto_update_label( $freq ) {
1190 $freq = intval( $freq );
1191 $text = '';
1192 switch ( $freq ) {
1193 case 1:
1194 $text = esc_html__( 'Once per day', 'mainwp' );
1195 break;
1196 case 2:
1197 $text = esc_html__( 'Twice per day', 'mainwp' );
1198 break;
1199 case 3:
1200 $text = esc_html__( 'Three times per day', 'mainwp' );
1201 break;
1202 case 4:
1203 $text = esc_html__( 'Four times per day', 'mainwp' );
1204 break;
1205 case 5:
1206 $text = esc_html__( 'Five times per day', 'mainwp' );
1207 break;
1208 case 6:
1209 $text = esc_html__( 'Six times per day', 'mainwp' );
1210 break;
1211 case 7:
1212 $text = esc_html__( 'Seven times per day', 'mainwp' );
1213 break;
1214 case 8:
1215 $text = esc_html__( 'Eight times per day', 'mainwp' );
1216 break;
1217 case 9:
1218 $text = esc_html__( 'Nine times per day', 'mainwp' );
1219 break;
1220 case 10:
1221 $text = esc_html__( 'Ten times per day', 'mainwp' );
1222 break;
1223 case 11:
1224 $text = esc_html__( 'Eleven times per day', 'mainwp' );
1225 break;
1226 case 12:
1227 $text = esc_html__( 'Twelve times per day', 'mainwp' );
1228 break;
1229 default:
1230 break;
1231 }
1232 return $text;
1233 }
1234
1235 /**
1236 * Get next time of schedule job to show.
1237 *
1238 * @param string $job_freq frequency of schedule job.
1239 * @param int $lasttime_run Lasttime to run.
1240 * @param int $local_timestamp current local time.
1241 *
1242 * @return int next run time of schedule job.
1243 */
1244 public static function get_schedule_next_time_to_show( $job_freq, $lasttime_run, $local_timestamp ) {
1245 $next_time = $local_timestamp;
1246 $lasttime_run = is_numeric( $lasttime_run ) ? intval( $lasttime_run ) : false;
1247 switch ( $job_freq ) {
1248 case 'daily':
1249 $next_time = $lasttime_run ? $lasttime_run + DAY_IN_SECONDS : $local_timestamp + DAY_IN_SECONDS;
1250 break;
1251 case 'hourly':
1252 $next_time = $lasttime_run ? $lasttime_run + HOUR_IN_SECONDS : $local_timestamp + HOUR_IN_SECONDS;
1253 break;
1254 case '5minutely':
1255 $next_time = $lasttime_run ? $lasttime_run + 5 * MINUTE_IN_SECONDS : $local_timestamp + 5 * MINUTE_IN_SECONDS;
1256 break;
1257 case 'minutely':
1258 $next_time = $lasttime_run ? $lasttime_run + MINUTE_IN_SECONDS : $local_timestamp + MINUTE_IN_SECONDS;
1259 break;
1260 default:
1261 break;
1262 }
1263
1264 if ( $next_time < $local_timestamp ) { // to fix next time in past.
1265 $next_time = $local_timestamp;
1266 }
1267
1268 return $next_time;
1269 }
1270
1271 /**
1272 * Checks if the ../wp-content/uploads/mainwp/ directory is writable.
1273 *
1274 * @return bool True if writable, false if not.
1275 *
1276 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir()
1277 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
1278 */
1279 public static function check_directory_mainwp_directory() {
1280 $dirs = MainWP_System_Utility::get_mainwp_dir();
1281 $path = $dirs[0];
1282
1283 $mess = 'Writable';
1284
1285 if ( ! is_dir( dirname( $path ) ) ) {
1286 $mess = 'Not Found';
1287 }
1288
1289 $is_writable = MainWP_System_Utility::is_writable( $path );
1290
1291 if ( $is_writable ) {
1292 $mess = 'Not Writable';
1293 }
1294
1295 return '<tr><td>MainWP Upload Directory</td><td>' . $mess . '</td></tr>';
1296 }
1297
1298 /**
1299 * Renders the directory check row.
1300 *
1301 * @param string $name check name.
1302 * @param string $check desired result.
1303 * @param string $result detected result.
1304 * @param bool $passed true|false check result.
1305 *
1306 * @return bool true.
1307 */
1308 public static function render_directory_row( $name, $check, $result, $passed ) {
1309 // phpcs:disable WordPress.Security.EscapeOutput
1310 ?>
1311 <tr>
1312 <td><?php echo esc_html( $name ); ?></td>
1313 <td><?php echo esc_html( $check ); ?></td>
1314 <td><?php echo esc_html( $result ); ?></td>
1315 <td class="right aligned"><?php echo $passed ? static::get_pass_html() : static::get_warning_html( static::ERROR ); ?></td>
1316 </tr>
1317 <?php
1318 // phpcs:enable
1319 return true;
1320 }
1321
1322 /**
1323 * Renders server information table row.
1324 *
1325 * @param string $config configuraion check.
1326 * @param string $compare comparison operator.
1327 * @param mixed $version reqiored minium version number.
1328 * @param mixed $getter detected version number.
1329 * @param string $extraText additionl text.
1330 * @param null $extraCompare extra compare.
1331 * @param null $extraVersion extra version.
1332 * @param null $whatType comparison type.
1333 * @param int $errorType global variable static::WARNING = 1.
1334 *
1335 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::filesize_compare()
1336 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::curlssl_compare()
1337 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_class_name()
1338 */
1339 public static function render_row( $config, $compare, $version, $getter, $extraText = '', $extraCompare = null, $extraVersion = null, $whatType = null, $errorType = self::WARNING ) { //phpcs:ignore -- NOSONAR - complex.
1340 $currentVersion = call_user_func( array( MainWP_Server_Information_Handler::get_class_name(), $getter ) );
1341 // phpcs:disable WordPress.Security.EscapeOutput
1342 $ver = is_array( $version ) && isset( $version['version'] ) ? esc_html( $version['version'] ) : esc_html( $version );
1343 ?>
1344 <tr>
1345 <td><?php echo esc_html( $config ); ?></td>
1346 <td><?php echo esc_html( $compare ); ?><?php echo ( true === $version ? 'true' : $ver ) . ' ' . $extraText; ?></td>
1347 <td><?php echo true === $currentVersion ? 'true' : $currentVersion; ?></td>
1348 <?php if ( 'filesize' === $whatType ) { ?>
1349 <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>
1350 <?php } elseif ( 'get_curl_ssl_version' === $getter ) { ?>
1351 <td class="right aligned"><?php echo MainWP_Server_Information_Handler::curlssl_compare( $version, $compare ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1352 <?php } elseif ( ( 'get_max_input_time' === $getter || 'get_max_execution_time' === $getter ) && -1 === (int) $currentVersion ) { ?>
1353 <td class="right aligned"><?php echo static::get_pass_html(); ?></td>
1354 <?php } else { ?>
1355 <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>
1356 <?php } ?>
1357 </tr>
1358 <?php
1359 // phpcs:enable
1360 }
1361
1362 /**
1363 * Renders server information table row with description.
1364 *
1365 * @param string $config configuraion check.
1366 * @param string $compare comparison operator.
1367 * @param mixed $version reqiored minium version number.
1368 * @param mixed $getter detected version number.
1369 * @param string $extraText additionl text.
1370 * @param null $extraCompare extra compare.
1371 * @param null $extraVersion extra version.
1372 * @param null $whatType comparison type.
1373 * @param int $errorType global variable static::WARNING = 1.
1374 *
1375 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_class_name()
1376 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::filesize_compare()
1377 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::curlssl_compare()
1378 */
1379 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.
1380 $currentVersion = call_user_func( array( MainWP_Server_Information_Handler::get_class_name(), $getter ) );
1381 // phpcs:disable WordPress.Security.EscapeOutput
1382 $ver = is_array( $version ) && isset( $version['version'] ) ? esc_html( $version['version'] ) : esc_html( $version );
1383 ?>
1384 <tr>
1385 <td><?php echo esc_html( $config ); ?></td>
1386 <td><?php echo esc_html( $compare ); ?> <?php echo ( true === $version ? 'true' : $ver ) . ' ' . $extraText; ?></td>
1387 <td><?php echo true === $currentVersion ? 'true' : $currentVersion; ?></td>
1388 <?php if ( 'filesize' === $whatType ) { ?>
1389 <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>
1390 <?php } elseif ( 'get_curl_ssl_version' === $getter ) { ?>
1391 <td class="right aligned"><?php echo MainWP_Server_Information_Handler::curlssl_compare( $version, $compare ) ? static::get_pass_html() : static::get_warning_html( $errorType ); ?></td>
1392 <?php } elseif ( 'get_max_input_time' === $getter && -1 === (int) $currentVersion ) { ?>
1393 <td class="right aligned"><?php echo static::get_pass_html(); ?></td>
1394 <?php } else { ?>
1395 <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>
1396 <?php } ?>
1397 </tr>
1398 <?php
1399 // phpcs:enable
1400 }
1401
1402 /**
1403 * Checks if file system method is direct.
1404 *
1405 * @return mixed html|static::get_warning_html().
1406 *
1407 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_file_system_method()
1408 */
1409 public static function get_file_system_method_check() {
1410 $fsmethod = MainWP_Server_Information_Handler::get_file_system_method();
1411 if ( 'direct' === $fsmethod ) {
1412 return static::get_pass_html();
1413 } else {
1414 return static::get_warning_html();
1415 }
1416 }
1417
1418 /**
1419 * Renders Error Log page.
1420 *
1421 * Plugin-Name: Error Log Dashboard Widget
1422 * Plugin URI: http://wordpress.org/extend/plugins/error-log-dashboard-widget/
1423 * Description: Robust zero-configuration and low-memory way to keep an eye on error log.
1424 * Author: Andrey "Rarst" Savchenko
1425 * Author URI: http://www.rarst.net/
1426 * Version: 1.0.2
1427 * License: GPLv2 or later
1428
1429 * Includes last_lines() function by phant0m, licensed under cc-wiki and GPLv2+
1430 */
1431 public static function render_error_log_page() {
1432 if ( ! \mainwp_current_user_can( 'dashboard', 'see_server_information' ) ) {
1433 \mainwp_do_not_have_permissions( 'error log', 'mainwp' );
1434 return;
1435 }
1436 static::render_header( 'ErrorLog' );
1437
1438 /**
1439 * Action: mainwp_before_error_log_table
1440 *
1441 * Fires before the Error Log table.
1442 *
1443 * @since 4.1
1444 */
1445 do_action( 'mainwp_before_error_log_table' );
1446 ?>
1447 <div class="ui segment">
1448 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-error-log-info-message' ) ) : ?>
1449 <div class="ui info message">
1450 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-error-log-info-message"></i>
1451 <?php echo esc_html__( 'See the WordPress error log to fix problems that arise on your MainWP Dashboard site.', 'mainwp' ); ?>
1452 </div>
1453 <?php endif; ?>
1454 <table class="ui unstackable table" id="mainwp-error-log-table">
1455 <thead>
1456 <tr>
1457 <th scope="col" ><?php esc_html_e( 'Time', 'mainwp' ); ?></th>
1458 <th scope="col" ><?php esc_html_e( 'Error', 'mainwp' ); ?></th>
1459 </tr>
1460 </thead>
1461 <tbody>
1462 <?php static::render_error_log(); ?>
1463 </tbody>
1464 </table>
1465 <script type="text/javascript">
1466 let responsive = true;
1467 if( jQuery( window ).width() > 1140 ) {
1468 responsive = false;
1469 }
1470
1471 jQuery( document ).ready( function() {
1472 jQuery( '#mainwp-error-log-table' ).DataTable( {
1473 "responsive": responsive,
1474 "ordering": false,
1475 "stateSave": true,
1476 "stateDuration": 0,
1477 "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
1478 "language": {
1479 "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>' ); ?>'
1480 },
1481 columnDefs: [{
1482 "defaultContent": "-",
1483 "targets": "_all"
1484 }]
1485 } );
1486 } );
1487 </script>
1488 </div>
1489 <?php
1490 /**
1491 * Action: mainwp_after_error_log_table
1492 *
1493 * Fires after the Error Log table.
1494 *
1495 * @since 4.1
1496 */
1497 do_action( 'mainwp_after_error_log_table' );
1498
1499 static::render_footer( 'ErrorLog' );
1500 }
1501
1502 /**
1503 * Renders error log page.
1504 *
1505 * @return void
1506 *
1507 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::last_lines()
1508 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::get_class_name()
1509 */
1510 public static function render_error_log() {
1511 $log_errors = ini_get( 'log_errors' );
1512 if ( ! $log_errors ) {
1513 return;
1514 }
1515
1516 $error_log = ini_get( 'error_log' );
1517 /**
1518 * Filter: error_log_mainwp_logs
1519 *
1520 * Filters the error log files to show.
1521 *
1522 * @since Unknown
1523 */
1524 $logs = apply_filters( 'error_log_mainwp_logs', array( $error_log ) );
1525
1526 /**
1527 * Filter: error_log_mainwp_lines
1528 *
1529 * Limits the number of error log records to be displayed. Default value, 50.
1530 *
1531 * @since Unknown
1532 */
1533 $count = apply_filters( 'error_log_mainwp_lines', 100 );
1534 $lines = array();
1535
1536 foreach ( $logs as $log ) {
1537 if ( is_readable( $log ) ) {
1538 $lines = array_merge( $lines, MainWP_Server_Information_Handler::last_lines( $log, $count ) );
1539 }
1540 }
1541
1542 $lines = array_map( 'trim', $lines );
1543 $lines = array_filter( $lines );
1544
1545 if ( empty( $lines ) ) {
1546 echo '<tr><td colspan="2">' . esc_html__( 'MainWP is unable to find your error logs, please contact your host for server error logs.', 'mainwp' ) . '</td></tr>';
1547 return;
1548 }
1549
1550 foreach ( $lines as $key => $line ) {
1551 if ( false !== strpos( $line, ']' ) ) {
1552 list( $time, $error ) = explode( ']', $line, 2 );
1553 } else {
1554 list( $time, $error ) = array( '', $line );
1555 }
1556 $time = trim( $time, '[]' );
1557 $error = trim( $error );
1558 $lines[ $key ] = compact( 'time', 'error' );
1559 }
1560
1561 if ( 1 < count( $lines ) ) {
1562 // phpcs:ignore -- ok.
1563 //uasort( $lines, array( MainWP_Server_Information_Handler::get_class_name(), 'time_compare' ) );
1564 $lines = array_slice( $lines, 0, $count );
1565 }
1566
1567 // phpcs:disable WordPress.Security.EscapeOutput
1568 foreach ( $lines as $line ) {
1569 $error = esc_html( $line['error'] );
1570 $time = esc_html( $line['time'] );
1571 if ( ! empty( $error ) ) {
1572 echo '<tr><td>' . $time . '</td><td>' . $error . '</td></tr>';
1573 }
1574 }
1575 // phpcs:enable
1576 }
1577
1578 /**
1579 * Renders the WP Config page.
1580 *
1581 * @return void
1582 */
1583 public static function render_wp_config() {
1584 if ( ! \mainwp_current_user_can( 'dashboard', 'see_server_information' ) ) {
1585 \mainwp_do_not_have_permissions( 'WP-Config.php', 'mainwp' );
1586 return;
1587 }
1588
1589 static::render_header( 'WPConfig' );
1590 /**
1591 * Action: mainwp_before_wp_config_section
1592 *
1593 * Fires before the WP Config section.
1594 *
1595 * @since 4.1
1596 */
1597 do_action( 'mainwp_before_wp_config_section' );
1598 ?>
1599 <div id="mainwp-show-wp-config">
1600 <?php
1601 if ( false !== strpos( ini_get( 'disable_functions' ), 'show_source' ) ) {
1602 esc_html_e( 'File content could not be displayed.', 'mainwp' );
1603 echo '<br />';
1604 esc_html_e( 'It appears that the show_source() PHP function has been disabled on the servre.', 'mainwp' );
1605 echo '<br />';
1606 esc_html_e( 'Please, contact your host support and have them enable the show_source() function for the proper functioning of this feature.', 'mainwp' );
1607 } elseif ( file_exists( ABSPATH . 'wp-config.php' ) ) {
1608 show_source( ABSPATH . 'wp-config.php' );
1609 } else {
1610 $files = get_included_files();
1611 $configFound = false;
1612 if ( is_array( $files ) ) {
1613 foreach ( $files as $file ) {
1614 if ( stristr( $file, 'wp-config.php' ) ) {
1615 $configFound = true;
1616 show_source( $file );
1617 break;
1618 }
1619 }
1620 }
1621 if ( ! $configFound ) {
1622 esc_html_e( 'wp-config.php not found', 'mainwp' );
1623 }
1624 }
1625 ?>
1626 </div>
1627 <?php
1628 /**
1629 * Action: mainwp_after_wp_config_section
1630 *
1631 * Fires after the WP Config section.
1632 *
1633 * @since 4.1
1634 */
1635 do_action( 'mainwp_after_wp_config_section' );
1636
1637 static::render_footer( 'WPConfig' );
1638 }
1639
1640 /**
1641 * Renders action logs page.
1642 *
1643 * @uses \MainWP\Dashboard\MainWP_Logger
1644 * @uses \MainWP\Dashboard\MainWP_Logger::clear_log()
1645 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1646 */
1647 public static function render_action_logs() { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1648 static::render_header( 'ActionLogs' );
1649
1650 if ( isset( $_REQUEST['actionlogs_status'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1651 $act_log = isset( $_REQUEST['actionlogs_status'] ) ? wp_unslash( $_REQUEST['actionlogs_status'] ) : MainWP_Logger::DISABLED; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1652 $spec_log = 0;
1653 if ( is_string( $act_log ) && false !== strpos( $act_log, 'specific_' ) ) {
1654 $act_log = str_replace( 'specific_', '', $act_log );
1655 $spec_log = 1;
1656 }
1657
1658 $act_log = intval( $act_log );
1659
1660 MainWP_Utility::update_option( 'mainwp_specific_logs', $spec_log );
1661
1662 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 );
1663
1664 if ( MainWP_Logger::DISABLED === $act_log ) {
1665 MainWP_Logger::instance()->set_log_priority( $act_log, $spec_log );
1666 }
1667
1668 MainWP_Utility::update_option( 'mainwp_actionlogs', $act_log );
1669 MainWP_Utility::update_option( 'mainwp_actionlogs_enabled_timestamp', time() );
1670 }
1671
1672 if ( isset( $_REQUEST['actionlogs_clear'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1673 $log_to_db = apply_filters( 'mainwp_logger_to_db', true );
1674 if ( $log_to_db ) {
1675 MainWP_Logger::instance()->clear_log_db();
1676 } else {
1677 MainWP_Logger::instance()->clear_log();
1678 }
1679 }
1680
1681 $enabled = (int) MainWP_Logger::instance()->get_log_status();
1682 $specific_default = array(
1683 MainWP_Logger::UPDATE_CHECK_LOG_PRIORITY => esc_html__( 'Update Checking', 'mainwp' ),
1684 MainWP_Logger::UPTIME_CHECK_LOG_PRIORITY => esc_html__( 'Uptime monitoring', 'mainwp' ),
1685 MainWP_Logger::UPTIME_NOTICE_LOG_PRIORITY => esc_html__( 'Uptime notification', 'mainwp' ),
1686 MainWP_Logger::EXECUTION_TIME_LOG_PRIORITY => esc_html__( 'Execution time', 'mainwp' ),
1687 MainWP_Logger::LOGS_AUTO_PURGE_LOG_PRIORITY => esc_html__( 'Logs Auto Purge', 'mainwp' ),
1688 MainWP_Logger::CONNECT_LOG_PRIORITY => esc_html__( 'Dashboard Connect', 'mainwp' ),
1689 );
1690 $specific_logs = apply_filters( 'mainwp_specific_action_logs', $specific_default ); // deprecated since 4.3.1, use 'mainwp_log_specific_actions' instead.
1691 $specific_logs = apply_filters( 'mainwp_log_specific_actions', $specific_logs );
1692
1693 ?>
1694 <div class="mainwp-sub-header">
1695 <div class="ui mini form two column stackable grid">
1696 <div class="column">
1697 <form method="POST" action="">
1698 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1699 <?php // phpcs:disable WordPress.Security.EscapeOutput ?>
1700 <select name="actionlogs_status" class="ui mini dropdown">
1701 <option value="<?php echo MainWP_Logger::DISABLED; ?>" <?php echo MainWP_Logger::DISABLED === $enabled ? 'selected' : ''; ?>>
1702 <?php esc_html_e( 'Disabled', 'mainwp' ); ?>
1703 </option>
1704 <option value="<?php echo MainWP_Logger::INFO; ?>" <?php echo MainWP_Logger::INFO === $enabled ? 'selected' : ''; ?>>
1705 <?php esc_html_e( 'Info', 'mainwp' ); ?>
1706 </option>
1707 <option value="<?php echo MainWP_Logger::WARNING; ?>" <?php echo MainWP_Logger::WARNING === $enabled ? 'selected' : ''; ?>>
1708 <?php esc_html_e( 'Warning', 'mainwp' ); ?>
1709 </option>
1710 <option value="<?php echo MainWP_Logger::DEBUG; ?>" <?php echo MainWP_Logger::DEBUG === $enabled ? 'selected' : ''; ?>>
1711 <?php esc_html_e( 'Debug', 'mainwp' ); ?>
1712 </option>
1713 <?php
1714 // phpcs:enable
1715 if ( is_array( $specific_logs ) && ! empty( $specific_logs ) ) {
1716 foreach ( $specific_logs as $spec_log => $spec_title ) {
1717 ?>
1718 <option value="specific_<?php echo intval( $spec_log ); ?>" <?php echo (int) $spec_log === (int) $enabled ? 'selected' : ''; ?>>
1719 <?php echo esc_html( $spec_title ); ?>
1720 </option>
1721 <?php
1722 }
1723 }
1724 ?>
1725 </select>
1726 <input type="submit" class="ui green mini button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
1727 <input type="submit" class="ui mini button" name="actionlogs_clear" value="<?php esc_attr_e( 'Delete Log', 'mainwp' ); ?>" />
1728 </form>
1729 </div>
1730 <div class="column">
1731
1732 </div>
1733 </div>
1734 </div>
1735 <div class="ui segment">
1736 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-action-logs-info-message' ) ) : ?>
1737 <div class="ui info message">
1738 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-action-logs-info-message"></i>
1739 <div><?php echo esc_html__( 'Enable a specific logging system.', 'mainwp' ); ?></div>
1740 <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>
1741 <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>
1742 <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>
1743 </div>
1744 <?php endif; ?>
1745 <?php
1746 $log_to_db = apply_filters( 'mainwp_logger_to_db', true );
1747 if ( $log_to_db ) {
1748 return MainWP_Logger::instance()->show_log_db();
1749 } else {
1750 MainWP_Logger::instance()->show_log_file();
1751 }
1752 ?>
1753 </div>
1754 <?php
1755 static::render_footer( 'ActionLogs' );
1756 }
1757
1758 /**
1759 * Renders the Plugin Privacy page.
1760 *
1761 * @return void
1762 */
1763 public static function render_plugin_privacy_page() {
1764
1765 static::render_header( 'PluginPrivacy' );
1766 /**
1767 * Action: mainwp_before_plugin_privacy_section
1768 *
1769 * Fires before the Plugin Privacy section.
1770 *
1771 * @since 4.2
1772 */
1773 do_action( 'mainwp_before_plugin_privacy_section' );
1774 ?>
1775 <div class="ui segment">
1776 <div id="mainwp-plugin-privacy">
1777 <h2 class="ui header">
1778 <?php echo esc_html__( 'MainWP Dashboard Plugin Privacy Policy', 'mainwp' ); ?>
1779 <div class="sub header"><em><?php echo esc_html__( 'Last updated: April 14, 2022', 'mainwp' ); ?></em></div>
1780 </h2>
1781 <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>
1782 <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>
1783 <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>
1784 <h3 class="ui header"><?php echo esc_html__( 'What personal data we collect', 'mainwp' ); ?></h3>
1785 <p><?php echo esc_html__( 'We do not collect, store, nor process any personal data through this Plugin.', 'mainwp' ); ?></p>
1786 <h3 class="ui header"><?php echo esc_html__( 'Third-party extensions and integrations', 'mainwp' ); ?></h3>
1787 <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>
1788 <div class="ui hidden divider"></div>
1789 <div class="ui two columns stackable grid">
1790 <div class="column">
1791 <h3 class="ui header"><?php echo esc_html__( 'Our contact information', 'mainwp' ); ?></h3>
1792 <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>
1793 <div class="ui list">
1794 <div class="item"><?php echo esc_html__( 'Sick Marketing, LLC d/b/a MainWP', 'mainwp' ); ?></div>
1795 <div class="item"><?php echo esc_html__( '[email protected]', 'mainwp' ); ?></div>
1796 <div class="item"><?php echo esc_html__( '4730 S. Fort Apache Road', 'mainwp' ); ?></div>
1797 <div class="item"><?php echo esc_html__( 'Suite 300', 'mainwp' ); ?></div>
1798 <div class="item"><?php echo esc_html__( 'PO Box 27740', 'mainwp' ); ?></div>
1799 <div class="item"><?php echo esc_html__( 'Las Vegas, NV 89126', 'mainwp' ); ?></div>
1800 <div class="item"><?php echo esc_html__( 'United States', 'mainwp' ); ?></div>
1801 </div>
1802 </div>
1803 <div class="column">
1804 <h3 class="ui header"><?php echo esc_html__( 'Our representative\'s contact information', 'mainwp' ); ?></h3>
1805 <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>
1806 <div class="item"><?php echo esc_html__( 'Ametros Ltd', 'mainwp' ); ?></div>
1807 <div class="item"><?php echo esc_html__( 'Unit 3D', 'mainwp' ); ?></div>
1808 <div class="item"><?php echo esc_html__( 'North Point House', 'mainwp' ); ?></div>
1809 <div class="item"><?php echo esc_html__( 'North Point Business Park', 'mainwp' ); ?></div>
1810 <div class="item"><?php echo esc_html__( 'New Mallow Road', 'mainwp' ); ?></div>
1811 <div class="item"><?php echo esc_html__( 'Cork', 'mainwp' ); ?></div>
1812 <div class="item"><?php echo esc_html__( 'Ireland', 'mainwp' ); ?></div>
1813 <div class="ui hidden divider"></div>
1814 <p><?php echo esc_html__( 'If you are a resident of the United Kingdom, you may contact our representative at the following:', 'mainwp' ); ?></p>
1815 <div class="item"><?php echo esc_html__( 'Ametros Group Ltd', 'mainwp' ); ?></div>
1816 <div class="item"><?php echo esc_html__( 'Lakeside Offices', 'mainwp' ); ?></div>
1817 <div class="item"><?php echo esc_html__( 'Thorn Business Park', 'mainwp' ); ?></div>
1818 <div class="item"><?php echo esc_html__( 'Hereford', 'mainwp' ); ?></div>
1819 <div class="item"><?php echo esc_html__( 'Herefordshire', 'mainwp' ); ?></div>
1820 <div class="item"><?php echo esc_html__( 'HR2 6JT', 'mainwp' ); ?></div>
1821 <div class="item"><?php echo esc_html__( 'England', 'mainwp' ); ?></div>
1822 </div>
1823 </div>
1824 <div class="ui divider"></div>
1825 </div>
1826
1827 <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>
1828 </div>
1829
1830 <?php
1831 /**
1832 * Action: mainwp_after_plugin_privacy_section
1833 *
1834 * Fires after the Plugin Privacy section.
1835 *
1836 * @since 4.2
1837 */
1838 do_action( 'mainwp_after_plugin_privacy_section' );
1839
1840 static::render_footer( 'PluginPrivacy' );
1841 }
1842
1843 /**
1844 * Renders .htaccess File page.
1845 *
1846 * @return void
1847 */
1848 public static function render_htaccess() {
1849 if ( ! \mainwp_current_user_can( 'dashboard', 'see_server_information' ) ) {
1850 \mainwp_do_not_have_permissions( '.htaccess', 'mainwp' );
1851 return;
1852 }
1853 static::render_header( '.htaccess' );
1854 /**
1855 * Action: mainwp_before_htaccess_section
1856 *
1857 * Fires before the .htaccess file section.
1858 *
1859 * @since 4.1
1860 */
1861 do_action( 'mainwp_before_htaccess_section' );
1862 ?>
1863 <div id="mainwp-show-htaccess">
1864 <?php
1865 if ( false !== strpos( ini_get( 'disable_functions' ), 'show_source' ) ) {
1866 esc_html_e( 'File content could not be displayed.', 'mainwp' );
1867 echo '<br />';
1868 esc_html_e( 'It appears that the show_source() PHP function has been disabled on the servre.', 'mainwp' );
1869 echo '<br />';
1870 esc_html_e( 'Please, contact your host support and have them enable the show_source() function for the proper functioning of this feature.', 'mainwp' );
1871 } else {
1872 show_source( ABSPATH . '.htaccess' );
1873 }
1874 ?>
1875 </div>
1876 <?php
1877 /**
1878 * Action: mainwp_after_htaccess_section
1879 *
1880 * Fires after the .htaccess file section.
1881 *
1882 * @since 4.1
1883 */
1884 do_action( 'mainwp_after_htaccess_section' );
1885 static::render_footer( '.htaccess' );
1886 }
1887
1888 /**
1889 * Checks for disable PHP Functions.
1890 *
1891 * @return void
1892 */
1893 public static function php_disabled_functions() {
1894 $disabled_functions = ini_get( 'disable_functions' );
1895 if ( '' !== $disabled_functions ) {
1896 $arr = explode( ',', $disabled_functions );
1897 sort( $arr );
1898 $_count = count( $arr );
1899 for ( $i = 0; $i < $_count; $i++ ) {
1900 echo esc_html( $arr[ $i ] ) . ', ';
1901 }
1902 } else {
1903 esc_html_e( 'No functions disabled.', 'mainwp' );
1904 }
1905 }
1906
1907 /**
1908 * Renders MainWP Settings 'Options'.
1909 *
1910 * @return void
1911 *
1912 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::mainwp_options()
1913 */
1914 public static function display_mainwp_options() {
1915 $options = MainWP_Server_Information_Handler::mainwp_options();
1916
1917 $enable_individual_uptime_monitoring = false;
1918 if ( get_option( 'mainwp_individual_uptime_monitoring_schedule_enabled' ) ) {
1919 $enable_individual_uptime_monitoring = true;
1920 }
1921
1922 // phpcs:disable WordPress.Security.EscapeOutput
1923 foreach ( $options as $option ) {
1924 $addition_info = '';
1925 if ( 'is_enable_automatic_check_uptime_monitoring' === $option['name'] && empty( $option['save_value'] ) && $enable_individual_uptime_monitoring ) { // global monitoring disabled.
1926 $addition_info = '<br><em>' . esc_html__( 'Individual uptime monitoring is running', 'mainwp' ) . '</em>';
1927 }
1928 echo '<tr><td>' . $option['label'] . '</td><td>' . $option['value'] . $addition_info . '</td></tr>';
1929 }
1930 // phpcs:enable
1931 }
1932
1933 /**
1934 * Renders PHP Warning HTML.
1935 *
1936 * @param int $errorType Global variable static::WARNING = 1.
1937 * @param bool $ech echo or return.
1938 *
1939 * @return string PHP Warning html.
1940 */
1941 private static function get_warning_html( $errorType = self::WARNING, $ech = false ) {
1942 $msg = '';
1943 if ( static::WARNING === $errorType ) {
1944 $msg = '<i class="large yellow exclamation icon"></i><span style="display:none">' . esc_html__( 'Warning', 'mainwp' ) . '</span>';
1945 } else {
1946 $msg = '<i class="large red times icon"></i><span style="display:none">' . esc_html__( 'Fail', 'mainwp' ) . '</span>';
1947 }
1948
1949 if ( $ech ) {
1950 echo $msg; //phpcs:ignore -- escaped.
1951 } else {
1952 return $msg;
1953 }
1954 }
1955
1956 /**
1957 * Renders PHP Pass HTML.
1958 *
1959 * @param bool $ech echo or return.
1960 *
1961 * @return string PHP Pass html.
1962 */
1963 private static function get_pass_html( $ech = false ) {
1964 $msg = '<i class="large green check icon"></i><span style="display:none">' . esc_html__( 'Pass', 'mainwp' ) . '</span>';
1965 if ( $ech ) {
1966 echo $msg; //phpcs:ignore -- escaped.
1967 } else {
1968 return $msg;
1969 }
1970 }
1971 }
1972