PluginProbe ʕ •ᴥ•ʔ
NinjaFirewall (WP Edition) – Advanced Security Plugin and Firewall / 4.9
NinjaFirewall (WP Edition) – Advanced Security Plugin and Firewall v4.9
4.9 4.8.8 4.8.7 4.8.6 trunk 4.5 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6 4.6.1 4.7 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.8 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5
ninjafirewall / lib / settings_dashboard.php
ninjafirewall / lib Last commit date
share 9 years ago .htaccess 11 years ago anti_malware.php 5 years ago class-api.php 4 weeks ago class-centralised-logging.php 4 weeks ago class-coupon.php 7 months ago class-email-sodium.php 4 weeks ago class-firewall-log.php 4 weeks ago class-helpers.php 9 months ago class-import-export.php 5 months ago class-ip.php 5 months ago class-nfw-database.php 7 months ago class-plugin-upgrade.php 4 weeks ago class-security-updates.php 4 weeks ago class-session.php 4 weeks ago class_mail.php 4 weeks ago firewall.php 4 weeks ago fw_fileguard.php 5 months ago fw_livelog.php 1 year ago help.php 4 weeks ago helpers.php 4 weeks ago i18n-extra.php 4 weeks ago i18n.php 1 year ago index.html 13 years ago init_update.php 2 years ago install.php 1 year ago install_default.php 4 weeks ago loader.php 7 months ago mail_template_firewall.php 1 year ago mail_template_plugin.php 4 weeks ago scheduled_tasks.php 3 years ago settings_dashboard.php 4 weeks ago settings_dashboard_about.php 4 weeks ago settings_dashboard_statistics.php 2 months ago settings_event_notifications.php 4 weeks ago settings_events.php 2 months ago settings_firewall_options.php 2 months ago settings_firewall_policies.php 4 weeks ago settings_login_protection.php 2 months ago settings_logs.php 4 weeks ago settings_logs_firewall_log.php 4 weeks ago settings_logs_live_log.php 2 months ago settings_monitoring.php 4 weeks ago settings_monitoring_file_check.php 2 months ago settings_monitoring_file_guard.php 2 months ago settings_network.php 2 months ago settings_security_rules.php 2 months ago settings_security_rules_editor.php 4 weeks ago settings_security_rules_update.php 4 weeks ago sign.pub 7 years ago thickbox.php 4 years ago widget.php 3 years ago wpplus.php 5 months ago
settings_dashboard.php
539 lines
1 <?php
2 /*
3 +---------------------------------------------------------------------+
4 | NinjaFirewall (WP Edition) |
5 | |
6 | (c) NinTechNet - https://nintechnet.com/ |
7 +---------------------------------------------------------------------+
8 | This program is free software: you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License as |
10 | published by the Free Software Foundation, either version 3 of |
11 | the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 +---------------------------------------------------------------------+ i18n+ / sa / 2
18 */
19
20 if (! defined('NFW_ENGINE_VERSION') ) {
21 die('Forbidden');
22 }
23
24 nf_not_allowed('block', __LINE__ );
25
26 $nfw_options = nfw_get_option('nfw_options');
27
28 // Tab and div display
29 if ( empty( $_REQUEST['tab'] ) ) { $_REQUEST['tab'] = 'dashboard'; }
30
31 if ( $_REQUEST['tab'] == 'statistics' ) {
32 $dashboard_tab = ''; $dashboard_div = ' style="display:none"';
33 $statistics_tab = ' nav-tab-active'; $statistics_div = '';
34 $about_tab = ''; $about_div = ' style="display:none"';
35
36 } elseif ( $_REQUEST['tab'] == 'about' ) {
37 $dashboard_tab = ''; $dashboard_div = ' style="display:none"';
38 $statistics_tab = ''; $statistics_div = ' style="display:none"';
39 $about_tab = ' nav-tab-active'; $about_div = '';
40
41 } else {
42 $_REQUEST['tab'] = 'dashboard';
43 $dashboard_tab = ' nav-tab-active'; $dashboard_div = '';
44 $statistics_tab = ''; $statistics_div = ' style="display:none"';
45 $about_tab = ''; $about_div = ' style="display:none"';
46 }
47
48 if (! defined('NF_DISABLED') ) {
49 is_nfw_enabled();
50 }
51
52 if (! defined( 'NFW_WPWAF' ) && defined( 'NFW_PID' ) ) {
53 // Check if we have our PID. If we don't, that means there must
54 // be a Full WAF instance of the firewall running in a parent
55 // directory. Therefore, we need to allow Full WAF update from
56 // this page:
57 $nfw_pid = 0;
58 if ( file_exists( NFW_LOG_DIR .'/nfwlog/cache/.pid' ) ) {
59 $nfw_pid = trim( file_get_contents( NFW_LOG_DIR .'/nfwlog/cache/.pid' ) );
60 }
61 if ( NFW_PID != $nfw_pid ) {
62 define('NFW_WPWAF', 2);
63 }
64 }
65
66 // Search for Full WAF post-install
67 $res = get_transient( 'nfw_fullwaf' );
68 if ( $res !== false ) {
69 if ( defined( 'NFW_WPWAF' ) ) {
70 // 1: Apache mod_php
71 // 2: Apache + CGI/FastCGI or PHP-FPM
72 // 3: Apache + suPHP
73 // 4: Nginx + CGI/FastCGI or PHP-FPM
74 // 5: Litespeed
75 // 6: Openlitespeed
76 // 7: Other webserver + CGI/FastCGI or PHP-FPM
77 list( $httpserver, $time ) = explode( ':', $res );
78 $message = '';
79
80 if ( $httpserver == 6 ) {
81 $message = __('Make sure you followed the instructions and restarted Openlitespeed.', 'ninjafirewall' );
82 delete_transient( 'nfw_fullwaf' );
83
84 } elseif ( $httpserver == 1 || $httpserver == 5 ) {
85 $message = sprintf( __('Make sure your HTTP server support the %s directive in .htaccess files. Maybe you need to restart your HTTP server to apply the change, or simply to wait a few seconds and reload this page?', 'ninjafirewall' ), '<code>php_value auto_prepend_file</code>' );
86 delete_transient( 'nfw_fullwaf' );
87
88 } else {
89 $now = time();
90 // <5 minutes
91 if ( $now < $time ) {
92 $time_left = $time - $now;
93 $message = sprintf( __('Because PHP caches INI files, you may need to wait up to five minutes before the changes are reloaded by the PHP interpreter. <strong>Please wait for <font id="nfw-waf-count">%d</font> seconds</strong> before trying again (you can navigate away from this page and come back in a few minutes).', 'ninjafirewall'), (int) $time_left );
94 $countdown = 1;
95 } else {
96 delete_transient( 'nfw_fullwaf' );
97 }
98 }
99 if (! empty( $message ) ) {
100 echo '<div class="notice-warning notice is-dismissible"><p>'.
101 __('Oops! Full WAF mode is not enabled yet.', 'ninjafirewall' ) .'<br />'.
102 $message .
103 '</p></div>';
104 if ( isset( $countdown ) ) {
105 echo '<script>fullwaf_count='. $time_left .';fullwaf=setInterval(nfwjs_fullwaf_countdown,1000);</script>';
106 }
107 }
108 }
109 }
110 // Error log deletion:
111 if (! empty( $_POST['delete-error-log'] ) ){
112 if ( empty( $_POST['nfwnonce_errorlog'] ) || ! wp_verify_nonce( $_POST['nfwnonce_errorlog'], 'delete_error_log' ) ) {
113 wp_nonce_ays('delete_error_log');
114 }
115 if ( file_exists( NFW_LOG_DIR .'/nfwlog/error_log.php' ) ) {
116 @unlink( NFW_LOG_DIR .'/nfwlog/error_log.php' );
117 }
118 }
119 ?>
120 <div class="wrap">
121 <h1><img style="vertical-align:top;width:33px;height:33px;" src="<?php echo plugins_url( '/ninjafirewall/images/ninjafirewall_32.png') ?>">&nbsp;<?php _e('NinjaFirewall (WP Edition)', 'ninjafirewall') ?></h1>
122
123 <?php
124
125 // Display a one-time notice after two weeks of use
126 nfw_rate_notice( $nfw_options );
127
128 // Full WAF settings change
129 if (! empty( $_GET['nfwafconfig'] ) ) {
130 echo '<div class="updated notice is-dismissible"><p>' . esc_html__('Your changes have been saved.', 'ninjafirewall') . '</p></div>';
131 }
132 ?>
133 <br />
134 <h2 class="nav-tab-wrapper wp-clearfix" style="cursor:pointer">
135 <a id="tab-dashboard" class="nav-tab<?php echo $dashboard_tab ?>" onClick="nfwjs_switch_tabs('dashboard', 'dashboard:statistics:about')"><?php _e( 'Dashboard', 'ninjafirewall' ) ?></a>
136 <a id="tab-statistics" class="nav-tab<?php echo $statistics_tab ?>" href="?page=NinjaFirewall&tab=statistics"><?php _e( 'Statistics', 'ninjafirewall' ) ?></a>
137 <a id="tab-about" class="nav-tab<?php echo $about_tab ?>" onClick="nfwjs_switch_tabs('about', 'dashboard:statistics:about')"><?php _e( 'About...', 'ninjafirewall' ) ?></a>
138 <?php nfw_contextual_help() ?>
139 </h2>
140
141 <br />
142
143 <!-- Dashboard -->
144
145 <div id="dashboard-options"<?php echo $dashboard_div ?>>
146
147 <h3><?php _e('Firewall Dashboard', 'ninjafirewall') ?></h3>
148
149 <table>
150 <tr>
151 <td>
152 <table class="form-table nfw-table">
153
154 <?php
155 if ( NF_DISABLED ) {
156 // An instance of the firewall running in Full WAF (or Pro/Pro+ Edition)
157 // in a parent directory will force us to run in Full WAF mode to override it.
158 if ( defined( 'NFW_STATUS' ) && ( NFW_STATUS > 19 && NFW_STATUS < 24 ) ) {
159 $msg = __('It seems that you may have another instance of NinjaFirewall running in a parent directory. Make sure to follow these instructions:', 'ninjafirewall');
160 $msg.= '<ol><li>';
161 $msg.= __('Temporarily disable the firewall in the parent folder by renaming its PHP INI or .htaccess file.', 'ninjafirewall');
162 $msg.= '</li><li>';
163 $msg.= __('Install NinjaFirewall on this site in Full WAF mode.', 'ninjafirewall');
164 $msg.= '</li><li>';
165 $msg.= __('Restore the PHP INI or .htaccess in the parent folder to re-enable the firewall.', 'ninjafirewall');
166 $msg.= '</li></ol>';
167
168 } elseif (! empty( $GLOBALS['err_fw'][NF_DISABLED] ) ) {
169 $msg = $GLOBALS['err_fw'][NF_DISABLED];
170 } else {
171 $msg = __('Unknown error', 'ninjafirewall') .' #'. NF_DISABLED;
172 }
173 ?>
174 <tr>
175 <th scope="row" class="row-med"><?php _e('Firewall', 'ninjafirewall') ?></th>
176 <td><span class="dashicons dashicons-dismiss nfw-danger"></span><?php echo $msg ?></td>
177 </tr>
178
179 <?php
180 } else {
181 ?>
182 <tr>
183 <th scope="row" class="row-med"><?php _e('Firewall', 'ninjafirewall') ?></th>
184 <td><?php _e('Enabled', 'ninjafirewall') ?></td>
185 </tr>
186 <?php
187 }
188
189 ?>
190 <tr>
191 <th scope="row" class="row-med"><?php esc_html_e('Mode', 'ninjafirewall') ?></th>
192 <td>
193 <?php
194 if ( defined( 'NFW_WPWAF' ) ) {
195 printf( esc_html__('NinjaFirewall is running in %s mode. For better protection, activate its Full WAF mode:', 'ninjafirewall'), '<a href="https://blog.nintechnet.com/full_waf-vs-wordpress_waf/" target="_blank">WordPress WAF</a>');
196 ?>
197 <p><input type="button" id="nfw-activate-thickbox" value="<?php esc_attr_e('Activate Full WAF mode', 'ninjafirewall') ?>" class="button-secondary"></p>
198 <?php
199 } else {
200 if (! NF_DISABLED ) {
201 printf( esc_html__('NinjaFirewall is running in %s mode.', 'ninjafirewall'), '<a href="https://blog.nintechnet.com/full_waf-vs-wordpress_waf/" target="_blank">Full WAF</a>');
202 ?>
203 <p><input type="button" id="nfw-configure-thickbox" value="<?php esc_attr_e('Configure', 'ninjafirewall') ?>" class="button-secondary"></p>
204 <?php
205 } else {
206 echo '-';
207 }
208 }
209 ?>
210 </td>
211 </tr>
212 <?php
213
214 if (! empty( $nfw_options['debug'] ) ) {
215 ?>
216 <tr>
217 <th scope="row" class="row-med"><?php _e('Debugging mode', 'ninjafirewall') ?></th>
218 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php _e('Enabled.', 'ninjafirewall') ?>&nbsp;<a href="?page=nfsubopt"><?php _e('Click here to turn Debugging Mode off', 'ninjafirewall') ?></a></td>
219 </tr>
220 <?php
221 }
222 ?>
223 <tr>
224 <th scope="row" class="row-med"><?php _e('Edition', 'ninjafirewall') ?></th>
225 <td>WP Edition ~ <a href="?page=nfsubwplus"><?php _e('Need more security? Explore our supercharged premium version: NinjaFirewall (WP+ Edition)', 'ninjafirewall' ) ?></a></td>
226 </tr>
227 <tr>
228 <th scope="row" class="row-med"><?php _e('Version', 'ninjafirewall') ?></th>
229 <td><?php echo NFW_ENGINE_VERSION . ' ~ ' . __('Security rules:', 'ninjafirewall' ) . ' ' . preg_replace('/(\d{4})(\d\d)(\d\d)/', '$1-$2-$3', $nfw_options['rules_version']) ?></td>
230 </tr>
231
232 <tr>
233 <th scope="row" class="row-med"><?php _e('PHP SAPI', 'ninjafirewall') ?></th>
234 <td>
235 <?php
236 if ( defined('HHVM_VERSION') ) {
237 echo 'HHVM';
238 } else {
239 echo strtoupper(PHP_SAPI);
240 }
241 echo ' ~ '. PHP_MAJOR_VERSION .'.'. PHP_MINOR_VERSION .'.'. PHP_RELEASE_VERSION;
242 ?>
243 </td>
244 </tr>
245 <?php
246
247 // If security rules updates are disabled, warn the user
248 if ( empty( $nfw_options['enable_updates'] ) ) {
249 ?>
250 <tr>
251 <th scope="row" class="row-med"><?php _e('Updates', 'ninjafirewall') ?></th>
252 <td><span class="dashicons dashicons-dismiss nfw-danger"></span><a href="?page=nfsubupdates&tab=updates"><?php _e( 'Security rules updates are disabled.', 'ninjafirewall' ) ?></a> <?php _e( 'If you want your blog to be protected against the latest threats, enable automatic security rules updates.', 'ninjafirewall' ) ?></td>
253 </tr>
254 <?php
255 }
256
257 if ( empty( NinjaFirewall_session::read('nfw_goodguy') ) ) {
258 ?>
259 <tr>
260 <th scope="row" class="row-med"><?php _e('Admin user', 'ninjafirewall') ?></th>
261 <td><span class="dashicons dashicons-dismiss nfw-danger"></span><?php printf( __('You are not whitelisted. Ensure that the "Do not block WordPress administrator" option is enabled in the <a href="%s">Firewall Policies</a> menu, otherwise you could get blocked by the firewall while working from your administration dashboard.', 'ninjafirewall'), '?page=nfsubpolicies') ?></td>
262 </tr>
263 <?php
264 } else {
265 $current_user = wp_get_current_user();
266 ?>
267 <tr>
268 <th scope="row" class="row-med"><?php _e('Admin user', 'ninjafirewall') ?></th>
269 <td><code><?php echo htmlspecialchars( $current_user->user_login ) ?></code>: <?php _e('You are whitelisted by the firewall.', 'ninjafirewall') ?></td>
270 </tr>
271 <?php
272 }
273 if ( defined('NFW_ALLOWED_ADMIN') && ! is_multisite() ) {
274 ?>
275 <tr>
276 <th scope="row" class="row-med"><?php _e('Restrictions', 'ninjafirewall') ?></th>
277 <td><?php _e('Access to NinjaFirewall is restricted to specific users.', 'ninjafirewall') ?></td>
278 </tr>
279 <?php
280 }
281
282 // Try to find out if there is any "lost" session between the firewall
283 // and the plugin part of NinjaFirewall (could be a buggy plugin killing
284 // the session etc), unless we just installed it
285 if ( defined( 'NFW_SWL' ) && ! empty( NinjaFirewall_session::read('nfw_goodguy') ) && empty( $_REQUEST['nfw_firstrun'] ) ) {
286 ?>
287 <tr>
288 <th scope="row" class="row-med"><?php esc_html_e('User session', 'ninjafirewall') ?></th>
289 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php esc_html_e('It seems that the user session set by NinjaFirewall was not found by the firewall script.', 'ninjafirewall') ?></td>
290 </tr>
291 <?php
292 }
293
294 if ( ! empty( $nfw_options['clogs_pubkey'] ) ) {
295 $err_msg = $ok_msg = '';
296 if (! preg_match( '/^[a-f0-9]{40}:([a-f0-9:.]{3,39}|\*)$/', $nfw_options['clogs_pubkey'], $match ) ) {
297 $err_msg = sprintf( __('the public key is invalid. Please <a href="%s">check your configuration</a>.', 'ninjafirewall'), '?page=nfsublog#clogs');
298
299 } else {
300 if ( $match[1] == '*' ) {
301 $ok_msg = __( "No IP address restriction.", 'ninjafirewall');
302
303 } elseif ( filter_var( $match[1], FILTER_VALIDATE_IP ) ) {
304 $ok_msg = sprintf( __("IP address %s is allowed to access NinjaFirewall's log on this server.", 'ninjafirewall'), htmlspecialchars( $match[1]) );
305
306 } else {
307 $err_msg = sprintf( __('the whitelisted IP is not valid. Please <a href="%s">check your configuration</a>.', 'ninjafirewall'), '?page=nfsublog#clogs');
308 }
309 }
310 ?>
311 <tr>
312 <th scope="row" class="row-med"><?php _e('Centralized Logging', 'ninjafirewall') ?></th>
313 <?php
314 if ( $err_msg ) {
315 ?>
316 <td><span class="dashicons dashicons-dismiss nfw-danger"></span><?php printf( __('Error: %s', 'ninjafirewall'), $err_msg) ?></td>
317 </tr>
318 <?php
319 $err_msg = '';
320 } else {
321 ?>
322 <td><a href="?page=nfsublog#clogs"><?php _e('Enabled', 'ninjafirewall'); echo "</a>. $ok_msg"; ?></td>
323 </tr>
324 <?php
325 }
326 }
327
328 if (! filter_var(NFW_REMOTE_ADDR, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) ) {
329 ?>
330 <tr>
331 <th scope="row" class="row-med"><?php _e('Source IP', 'ninjafirewall') ?> <span class="ninjafirewall-tip" data-tip="<?php esc_attr_e('In the Premium version of NinjaFirewall, you can use the IP Access Control section to easily configure all IP address related options (source, whitelist, blacklist, rate limiting etc).', 'ninjafirewall' ) ?>"></span></th>
332 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php printf( __('You have a private IP : %s', 'ninjafirewall') .'<br />'. __('If your site is behind a reverse proxy or a load balancer, ensure that you have setup your HTTP server or PHP to forward the correct visitor IP, otherwise use the NinjaFirewall %s configuration file.', 'ninjafirewall'), htmlentities(NFW_REMOTE_ADDR), '<code><a href="https://blog.nintechnet.com/ninjafirewall-wp-edition-the-htninja-configuration-file/">.htninja</a></code>') ?></td>
333 </tr>
334 <?php
335 }
336 if (! empty( $_SERVER["HTTP_CF_CONNECTING_IP"] ) ) {
337 if ( NFW_REMOTE_ADDR != $_SERVER["HTTP_CF_CONNECTING_IP"] ) {
338 ?>
339 <tr>
340 <th scope="row" class="row-med"><?php _e('CDN detection', 'ninjafirewall') ?> <span class="ninjafirewall-tip" data-tip="<?php esc_attr_e('In the Premium version of NinjaFirewall, you can use the IP Access Control section to easily configure all IP address related options (source, whitelist, blacklist, rate limiting etc).', 'ninjafirewall' ) ?>"></span></th>
341 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php printf( __('%s detected: you seem to be using Cloudflare CDN services. Ensure that you have setup your HTTP server or PHP to forward the correct visitor IP, otherwise use the NinjaFirewall %s configuration file.', 'ninjafirewall'), '<code>HTTP_CF_CONNECTING_IP</code>', '<code><a href="https://blog.nintechnet.com/ninjafirewall-wp-edition-the-htninja-configuration-file/">.htninja</a></code>') ?></td>
342 </tr>
343 <?php
344 }
345 }
346 if (! empty( $_SERVER["HTTP_INCAP_CLIENT_IP"] ) ) {
347 if ( NFW_REMOTE_ADDR != $_SERVER["HTTP_INCAP_CLIENT_IP"] ) {
348 ?>
349 <tr>
350 <th scope="row" class="row-med"><?php _e('CDN detection', 'ninjafirewall') ?> <span class="ninjafirewall-tip" data-tip="<?php esc_attr_e('In the Premium version of NinjaFirewall, you can use the IP Access Control section to easily configure all IP address related options (source, whitelist, blacklist, rate limiting etc).', 'ninjafirewall' ) ?>"></span></th>
351 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php printf( __('%s detected: you seem to be using Incapsula CDN services. Ensure that you have setup your HTTP server or PHP to forward the correct visitor IP, otherwise use the NinjaFirewall %s configuration file.', 'ninjafirewall'), '<code>HTTP_INCAP_CLIENT_IP</code>', '<code><a href="https://blog.nintechnet.com/ninjafirewall-wp-edition-the-htninja-configuration-file/">.htninja</a></code>') ?></td>
352 </tr>
353 <?php
354 }
355 }
356
357 if (! is_writable( NFW_LOG_DIR . '/nfwlog' ) ) {
358 ?>
359 <tr>
360 <th scope="row" class="row-med"><?php _e('Log dir', 'ninjafirewall') ?></th>
361 <td><span class="dashicons dashicons-dismiss nfw-danger"></span><?php printf( __('%s directory is not writable! Please chmod it to 0777 or equivalent.', 'ninjafirewall'), '<code>'. htmlspecialchars(NFW_LOG_DIR) .'/nfwlog/</code>') ?></td>
362 </tr>
363 <?php
364 }
365
366 if (! is_writable( NFW_LOG_DIR . '/nfwlog/cache') ) {
367 ?>
368 <tr>
369 <th scope="row" class="row-med"><?php _e('Log dir', 'ninjafirewall') ?></th>
370 <td><span class="dashicons dashicons-dismiss nfw-danger"></span><?php printf(__('%s directory is not writable! Please chmod it to 0777 or equivalent.', 'ninjafirewall'), '<code>'. htmlspecialchars(NFW_LOG_DIR) . '/nfwlog/cache/</code>') ?></td>
371 </tr>
372 <?php
373 }
374
375
376 if (! defined('NF_DISABLE_PHPINICHECK') && ! defined('NFW_WPWAF') ) {
377
378 // Make sure the PHP INI is not viewable by webusers
379 if ( file_exists( ABSPATH .'php.ini' ) ) {
380 $res = nfw_is_inireadable( 'php.ini' );
381 if ( $res !== false ) {
382 ?>
383 <tr>
384 <th scope="row" class="row-med">PHP INI</th>
385 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php printf( esc_html__('The php.ini file is readable by web users: %s', 'ninjafirewall'), '<code>'. htmlspecialchars( $res ) .'</code>' ) ?> <br /><a href="https://blog.nintechnet.com/protecting-ninjafirewalls-php-ini-file/" target="_blank"><?php esc_html_e('Consult our blog for more info.', 'ninjafirewall') ?></a></td>
386 </tr>
387 <?php
388 }
389 }
390 if ( file_exists( ABSPATH .'.user.ini' ) ) {
391 $res = nfw_is_inireadable( '.user.ini' );
392 if ( $res !== false ) {
393 ?>
394 <tr>
395 <th scope="row" class="row-med">PHP INI</th>
396 <td><span class="dashicons dashicons-warning nfw-warning"></span><?php printf( esc_html__('The .user.ini file is readable by web users: %s', 'ninjafirewall'), '<code>'. htmlspecialchars( $res ) .'</code>' ) ?><br /><a href="https://blog.nintechnet.com/protecting-ninjafirewalls-php-ini-file/" target="_blank"><?php esc_html_e('Consult our blog for more info.', 'ninjafirewall') ?></a></td>
397 </tr>
398 <?php
399 }
400 }
401 }
402
403 // Error log
404 $log = NFW_LOG_DIR . '/nfwlog/error_log.php';
405 if ( file_exists( $log ) ) {
406 $errlog_content = file( $log );
407 array_shift( $errlog_content );
408 if (! empty( $errlog_content ) ) {
409 ?>
410 <tr id="error-log-alert">
411 <th scope="row" class="row-med"><?php _e('Error log', 'ninjafirewall') ?></th>
412 <td><input type="button" id="nfw-errorlog-thickbox" value="<?php _e('View error log', 'ninjafirewall') ?>" class="button-secondary" style="color:#ba0000;border-color:#ba0000;"></td>
413 </tr>
414 <?php
415 }
416 }
417
418 /**
419 * Check for NinjaFirewall optional config file.
420 */
421 $doc_root = rtrim( $_SERVER['DOCUMENT_ROOT'], '/');
422 if ( @file_exists( $file = $doc_root . '/.htninja') ||
423 @file_exists( $file = dirname( $doc_root ) . '/.htninja') ) {
424
425 echo '<tr>
426 <th scope="row" class="row-med">'. esc_html__('Optional configuration file',
427 'ninjafirewall') .'</th><td><code>'. htmlentities( $file ) .'</code></td>
428 </tr>';
429 /**
430 * Check if we have a MySQLi link identifier defined in the .htninja.
431 */
432 if (! empty( $GLOBALS['nfw_mysqli'] ) && ! empty( $GLOBALS['nfw_table_prefix'] ) ) {
433 echo '<tr>
434 <th scope="row" class="row-med">'. esc_html__('MySQLi link identifier',
435 'ninjafirewall') .'</th><td>' .
436 esc_html__('A MySQLi link identifier was detected in your <code>.htninja</code>.',
437 'ninjafirewall') . '</td>
438 </tr>';
439 }
440 }
441 ?>
442 <tr>
443 <th scope="row" class="row-med"><?php _e('Help &amp; configuration', 'ninjafirewall') ?></th>
444 <td><a href="https://blog.nintechnet.com/securing-wordpress-with-a-web-application-firewall-ninjafirewall/">Securing WordPress with NinjaFirewall (WP Edition)</a></td>
445 </tr>
446
447 </table>
448
449 </td>
450 <td style="vertical-align:top;text-align: center"><?php
451 /**
452 * Display a discount coupon, if any.
453 */
454 if (! empty( $nfw_options['coupon']['date'] ) ) {
455 require_once __DIR__ .'/class-coupon.php';
456 $coupon = new NinjaFirewall_coupon();
457 $coupon->show();
458 }
459 ?></td>
460 </tr>
461 </table>
462
463 </div>
464
465 <!-- Monthly statistics -->
466 <div id="statistics-options"<?php echo $statistics_div ?>>
467 <?php include __DIR__ .'/settings_dashboard_statistics.php'; ?>
468 </div>
469
470 <!-- About... -->
471 <div id="about-options"<?php echo $about_div ?>>
472 <?php include __DIR__ .'/settings_dashboard_about.php'; ?>
473 </div>
474
475 </div>
476 <?php
477
478 // Load thickbox
479 require __DIR__ .'/thickbox.php';
480
481 // ---------------------------------------------------------------------
482 // Verify if PHP INI file is readable by web users.
483
484 function nfw_is_inireadable( $ini ) {
485
486 if ( is_multisite() ) {
487 $url = network_home_url('/') . $ini;
488 } else {
489 $url = home_url('/') . $ini;
490 }
491 global $wp_version;
492 $opts = array(
493 'http' => array(
494 // We only care about the returned HTTP code
495 'ignore_errors' => true,
496 // Max 2 seconds
497 'timeout' => 2,
498 'method' => "GET",
499 'header' =>
500 "Accept-language: en-US,en;q=0.5\r\n" .
501 "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" .
502 "User-Agent: Mozilla/5.0 (compatible; NinjaFirewall/". NFW_ENGINE_VERSION ."; WordPress/$wp_version)\r\n"
503 )
504 );
505
506 if ( empty( $_SERVER['SERVER_ADDR'] ) ) {
507 return false;
508 }
509 $addr = $_SERVER['SERVER_ADDR'];
510 if (! filter_var( $addr, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
511 // We don't want a fatal error if we're running on localhost e.g., dev site etc
512 $opts['ssl']['verify_peer'] = false;
513 $opts['ssl']['verify_peer_name'] = false;
514 }
515 $context = stream_context_create( $opts );
516 // As we don't want monitoring/debugging plugins to throw a warning or error
517 // in the backend because the server returned a 403 error, we don't use
518 // the WordPress's API
519 @file_get_contents( $url, false, $context );
520 /**
521 * $http_response_header is deprecated in PHP 8.5, hence we use the
522 * http_get_last_response_headers() function instead (PHP >= 8.4).
523 */
524 if ( function_exists('http_get_last_response_headers') ) {
525 $http_response_header = http_get_last_response_headers();
526 }
527 if ( empty( $http_response_header ) ) {
528 return false;
529 }
530 $response = explode( ' ', $http_response_header[0] );
531 if (! empty( $response[1] ) && (int) $response[1] == 200 ) {
532 return $url;
533 }
534 return false;
535
536 }
537 // ---------------------------------------------------------------------
538 // EOF
539