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_monitoring_file_guard.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_monitoring_file_guard.php
140 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' ) ) { die( 'Forbidden' ); }
21
22 nf_not_allowed( 'block', __LINE__ );
23
24 $nfw_options = nfw_get_option( 'nfw_options' );
25
26 if ( defined('NFW_WPWAF') ) {
27 ?>
28 <div class="nfw-notice nfw-notice-orange">
29 <p><?php printf( __('You are running NinjaFirewall in <i>WordPress WAF</i> mode. The %s feature will be limited to WordPress files only (e.g., index.php, wp-login.php, xmlrpc.php, admin-ajax.php, wp-load.php etc). If you want it to apply to any PHP script, please <a href="%s">go to the Dashboard page</a> and enable NinjaFirewall\'s Full WAF mode.', 'ninjafirewall'), 'File Guard', '?page=NinjaFirewall') ?></p>
30 </div>
31 <?php
32 }
33
34 // Ensure cache folder is writable
35 if (! is_writable( NFW_LOG_DIR . '/nfwlog/cache/') ) {
36 echo '<div class="nfw-notice nfw-notice-red"><p>' .
37 sprintf( __('The cache directory %s is not writable. Please change its permissions (0777 or equivalent).', 'ninjafirewall'), '('. htmlspecialchars(NFW_LOG_DIR) . '/nfwlog/cache/)' ) . '</p></div>';
38 }
39
40 if ( isset( $_POST['save_fileguard']) ) {
41 if ( empty($_POST['nfwnonce']) || ! wp_verify_nonce($_POST['nfwnonce'], 'fileguard_save') ) {
42 wp_nonce_ays('fileguard_save');
43 }
44 nf_sub_fileguard_save();
45 $nfw_options = nfw_get_option( 'nfw_options' );
46 echo '<div class="updated notice is-dismissible"><p>' . __('Your changes have been saved.', 'ninjafirewall') .'</p></div>';
47 }
48
49 if ( empty($nfw_options['fg_enable']) ) {
50 $nfw_options['fg_enable'] = 0;
51 } else {
52 $nfw_options['fg_enable'] = 1;
53 }
54 if ( empty($nfw_options['fg_mtime']) || ! preg_match('/^[1-9][0-9]?$/', $nfw_options['fg_mtime']) ) {
55 $nfw_options['fg_mtime'] = 10;
56 }
57 if ( empty($nfw_options['fg_exclude']) ) {
58 $fg_exclude = '';
59 } else {
60 $tmp = str_replace('|', ',', $nfw_options['fg_exclude']);
61 $fg_exclude = preg_replace( '/\\\([`.\\/\\\+*?\[^\]$(){}=!<>:-])/', '$1', $tmp );
62 }
63 ?>
64 <form method="post" name="nfwfilefuard">
65 <?php wp_nonce_field('fileguard_save', 'nfwnonce', 0); ?>
66 <table class="form-table nfw-table">
67 <tr style="background-color:#F9F9F9;border: solid 1px #DFDFDF;">
68 <th scope="row" class="row-med"><?php _e('Enable File Guard', 'ninjafirewall') ?></th>
69 <td>
70 <?php nfw_toggle_switch( 'green', 'nfw_options[fg_enable]', __('Enabled', 'ninjafirewall'), __('Disabled', 'ninjafirewall'), 'large', $nfw_options['fg_enable'], false, 'onclick="nfwjs_up_down(\'fg_table\');"' ) ?>
71 </td>
72 </tr>
73 </table>
74
75 <br />
76
77 <div id="fg_table"<?php echo $nfw_options['fg_enable'] == 1 ? '' : ' style="display:none"' ?>>
78 <table class="form-table nfw-table">
79 <tr>
80 <th scope="row" class="row-med"><?php _e('Real-time detection', 'ninjafirewall') ?></th>
81 <td>
82 <?php
83 printf( __('Monitor file activity and send an alert when someone is accessing a PHP script that was modified or created less than %s hour(s) ago.', 'ninjafirewall'), '<input maxlength="2" size="2" value="'. $nfw_options['fg_mtime'] .'" name="nfw_options[fg_mtime]" id="mtime" class="small-text" type="number" />');
84 ?>
85 </td>
86 </tr>
87 <tr>
88 <th scope="row" class="row-med"><?php _e('Exclude the following files/folders (optional)', 'ninjafirewall') ?></th>
89 <td><input class="large-text" type="text" maxlength="255" name="nfw_options[fg_exclude]" value="<?php echo htmlspecialchars( $fg_exclude ); ?>" placeholder="<?php _e('e.g.,', 'ninjafirewall') ?> /foo/bar/cache/ <?php _e('or', 'ninjafirewall') ?> /cache/" /><br /><span class="description"><?php _e('Full or partial case-sensitive string(s), max. 255 characters. Multiple values must be comma-separated', 'ninjafirewall') ?> (<code>,</code>).</span></td>
90 </tr>
91 </table>
92 </div>
93 <br />
94 <input class="button-primary" type="submit" name="Save" value="<?php _e('Save File Guard options', 'ninjafirewall') ?>" />
95 <input type="hidden" name="tab" value="fileguard" />
96 <input type="hidden" name="save_fileguard" value="1" />
97 </form>
98 <?php
99
100 // ---------------------------------------------------------------------
101
102 function nf_sub_fileguard_save() {
103
104 nf_not_allowed( 'block', __LINE__ );
105
106 $nfw_options = nfw_get_option( 'nfw_options' );
107
108 if ( empty($_POST['nfw_options']['fg_enable']) ) {
109 $nfw_options['fg_enable'] = 0;
110 } else {
111 $nfw_options['fg_enable'] = $_POST['nfw_options']['fg_enable'];
112 }
113
114 if ( empty($_POST['nfw_options']['fg_mtime']) || ! preg_match('/^[1-9][0-9]?$/', $_POST['nfw_options']['fg_mtime']) ) {
115 $nfw_options['fg_mtime'] = 10;
116 } else {
117 $nfw_options['fg_mtime'] = $_POST['nfw_options']['fg_mtime'];
118 }
119
120 if ( empty($_POST['nfw_options']['fg_exclude']) || strlen($_POST['nfw_options']['fg_exclude']) > 255 ) {
121 $nfw_options['fg_exclude'] = '';
122 } else {
123 $exclude = '';
124 $fg_exclude = explode(',', $_POST['nfw_options']['fg_exclude'] );
125 foreach ($fg_exclude as $path) {
126 if ( $path ) {
127 $path = str_replace( array(' ', '\\', '|'), '', $path);
128 $exclude .= preg_quote( rtrim($path, ','), '`') . '|';
129 }
130 }
131 $nfw_options['fg_exclude'] = rtrim($exclude, '|');
132 }
133
134 nfw_update_option( 'nfw_options', $nfw_options );
135
136 }
137
138 // ---------------------------------------------------------------------
139 // EOF
140