share
9 years ago
.htaccess
11 years ago
anti_malware.php
5 years ago
class-api.php
3 weeks ago
class-centralised-logging.php
3 weeks ago
class-coupon.php
7 months ago
class-email-sodium.php
2 months ago
class-firewall-log.php
3 weeks ago
class-helpers.php
9 months ago
class-import-export.php
4 months ago
class-ip.php
5 months ago
class-nfw-database.php
7 months ago
class-plugin-upgrade.php
3 weeks ago
class-security-updates.php
3 weeks ago
class-session.php
3 weeks ago
class_mail.php
2 months ago
firewall.php
3 weeks ago
fw_fileguard.php
5 months ago
fw_livelog.php
1 year ago
help.php
3 weeks ago
helpers.php
3 weeks ago
i18n-extra.php
3 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
3 weeks ago
loader.php
7 months ago
mail_template_firewall.php
1 year ago
mail_template_plugin.php
3 weeks ago
scheduled_tasks.php
3 years ago
settings_dashboard.php
3 weeks ago
settings_dashboard_about.php
2 months ago
settings_dashboard_statistics.php
2 months ago
settings_event_notifications.php
3 weeks ago
settings_events.php
2 months ago
settings_firewall_options.php
2 months ago
settings_firewall_policies.php
3 weeks ago
settings_login_protection.php
2 months ago
settings_logs.php
3 weeks ago
settings_logs_firewall_log.php
3 weeks ago
settings_logs_live_log.php
2 months ago
settings_monitoring.php
2 months 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
3 weeks ago
settings_security_rules_update.php
3 weeks ago
sign.pub
7 years ago
thickbox.php
4 years ago
widget.php
3 years ago
wpplus.php
4 months ago
class-centralised-logging.php
81 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 ( class_exists('NinjaFirewall_centralisedlogging') ) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | class NinjaFirewall_centralisedlogging { |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * Return the requested local log. |
| 23 | */ |
| 24 | public static function run( $nfw ) { |
| 25 | |
| 26 | $pubkey = explode(':', $nfw['nfw_options']['clogs_pubkey'], 2 ); |
| 27 | |
| 28 | if ( isset( $pubkey[1]) && $pubkey[1] != '*') { |
| 29 | |
| 30 | if ( NFW_REMOTE_ADDR != $pubkey[1] ) { |
| 31 | |
| 32 | NinjaFirewall_log::write( |
| 33 | 'Centralized logging: IP not allowed', |
| 34 | NFW_REMOTE_ADDR, |
| 35 | NFWLOG_INFO, 0, $nfw['nfw_options'], $nfw['log_dir'] |
| 36 | ); |
| 37 | self::die(); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if ( empty( $pubkey[0] ) || ! hash_equals( $pubkey[0], sha1( $_POST['clogs_req'] ) ) ) { |
| 42 | |
| 43 | NinjaFirewall_log::write( |
| 44 | 'Centralized logging: public key rejected', |
| 45 | NFW_REMOTE_ADDR, |
| 46 | NFWLOG_INFO, 0, $nfw['nfw_options'], $nfw['log_dir'] |
| 47 | ); |
| 48 | self::die(); |
| 49 | } |
| 50 | |
| 51 | $cur_month = date('Y-m'); |
| 52 | $log_file = "{$nfw['log_dir']}/firewall_{$cur_month}.php"; |
| 53 | |
| 54 | if (! is_file( $log_file ) ) { |
| 55 | exit('1:'); |
| 56 | } |
| 57 | |
| 58 | $data = file( $log_file, FILE_SKIP_EMPTY_LINES ); |
| 59 | if ( $data === false ) { |
| 60 | exit('2:'); |
| 61 | } |
| 62 | |
| 63 | echo '0:~*~:' . base64_encode( json_encode( $data ) ); |
| 64 | exit; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /** |
| 69 | * Exit. |
| 70 | */ |
| 71 | private static function die() { |
| 72 | |
| 73 | header('HTTP/1.1 406 Not Acceptable'); |
| 74 | header('Status: 406 Not Acceptable'); |
| 75 | exit; |
| 76 | } |
| 77 | |
| 78 | } |
| 79 | // ===================================================================== |
| 80 | // EOF |
| 81 |