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 / fw_fileguard.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
fw_fileguard.php
87 lines
1 <?php
2 /*
3 +=====================================================================+
4 | _ _ _ _ _____ _ _ _ |
5 | | \ | (_)_ __ (_) __ _| ___(_)_ __ _____ ____ _| | | |
6 | | \| | | '_ \ | |/ _` | |_ | | '__/ _ \ \ /\ / / _` | | | |
7 | | |\ | | | | || | (_| | _| | | | | __/\ V V / (_| | | | |
8 | |_| \_|_|_| |_|/ |\__,_|_| |_|_| \___| \_/\_/ \__,_|_|_| |
9 | |__/ |
10 | (c) NinTechNet Limited ~ https://nintechnet.com/ |
11 +=====================================================================+
12 */
13
14 if (! isset( $nfw_['nfw_options']['enabled'] ) ) {
15 header('HTTP/1.1 404 Not Found');
16 header('Status: 404 Not Found');
17 exit;
18 }
19
20 /* ------------------------------------------------------------------ */
21 function fw_fileguard() {
22
23 global $nfw_;
24
25 /**
26 * Look for exclusion.
27 */
28 if ( empty( $nfw_['nfw_options']['fg_exclude'] ) ||
29 ! @preg_match( "`{$nfw_['nfw_options']['fg_exclude']}`", $_SERVER['SCRIPT_FILENAME'] ) ) {
30 /**
31 * Stat() the requested script.
32 */
33 if ( $nfw_['nfw_options']['fg_stat'] = stat( $_SERVER['SCRIPT_FILENAME'] ) ) {
34 /**
35 * Was it created/modified lately ?
36 */
37 if ( time() - $nfw_['nfw_options']['fg_mtime'] * 3660 < $nfw_['nfw_options']['fg_stat']['ctime'] ) {
38 /**
39 * Did we check it already ?
40 */
41 if (! is_file("{$nfw_['log_dir']}/cache/fg_{$nfw_['nfw_options']['fg_stat']['ino']}.php") ) {
42 /**
43 * Log it.
44 */
45 NinjaFirewall_log::write(
46 "Access to a script modified/created less than {$nfw_['nfw_options']['fg_mtime']} hour(s) ago",
47 $_SERVER['SCRIPT_FILENAME'],
48 NFWLOG_INFO, 0, $nfw_['nfw_options'], $nfw_['log_dir']
49 );
50 /**
51 * Send the notification.
52 */
53 $headers = 'From: "NinjaFirewall" <postmaster@'. $_SERVER['SERVER_NAME'] . ">\r\n";
54 $subject = [];
55 $content = [ $nfw_['nfw_options']['fg_mtime'], $_SERVER['SERVER_NAME'],
56 NFW_REMOTE_ADDR, $_SERVER['SCRIPT_FILENAME'], $_SERVER['REQUEST_URI'],
57 date('F j, Y @ H:i:s T', $nfw_['nfw_options']['fg_stat']['ctime'] ) ];
58
59 require_once __DIR__ .'/class_mail.php';
60 NinjaFirewall_mail::PHPsend(
61 $nfw_['nfw_options']['alert_email'], 'fileguard',
62 $subject, $content, $nfw_['log_dir'], $headers
63 );
64 /**
65 * Remember it so that we don't spam the admin each time the script is requested.
66 */
67 touch( "{$nfw_['log_dir']}/cache/fg_{$nfw_['nfw_options']['fg_stat']['ino']}.php" );
68 }
69 /**
70 * Undocumented: if 'NFW_FG_BLOCK' is defined in the .htninja, we block the request.
71 */
72 if ( defined('NFW_FG_BLOCK') ) {
73
74 $nfw_['incidentID'] = NinjaFirewall_log::write(
75 'File Guard: blocked request',
76 $_SERVER['SCRIPT_FILENAME'],
77 NFWLOG_INFO, 0, $nfw_['nfw_options'], $nfw_['log_dir']
78 );
79 nfw_block();
80 }
81 }
82 }
83 }
84 }
85 /* ------------------------------------------------------------------ */
86 // EOF
87