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
2 months 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
2 months 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
2 months 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
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
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
class-api.php
74 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_api') ) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | |
| 19 | class NinjaFirewall_api { |
| 20 | |
| 21 | private static $security_update_uri = 'https://api.nintechnet.com/ninjafirewall/security-update'; |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * Download security updates from the remote API (WordPress, plugins and themes). |
| 26 | */ |
| 27 | public static function download_security_updates() { |
| 28 | |
| 29 | global $wp_version; |
| 30 | $res = wp_remote_get( |
| 31 | self::$security_update_uri, |
| 32 | [ |
| 33 | 'timeout' => 20, |
| 34 | 'httpversion' => '1.1' , |
| 35 | 'user-agent' => 'Mozilla/5.0 (compatible; NinjaFirewall/'. |
| 36 | NFW_ENGINE_VERSION ."; WordPress/$wp_version)", |
| 37 | 'sslverify' => true |
| 38 | ] |
| 39 | ); |
| 40 | |
| 41 | if ( is_wp_error( $res ) ) { |
| 42 | nfw_log_error( |
| 43 | __('Cannot download security rules: connection error. Will try again later', |
| 44 | 'ninjafirewall') |
| 45 | ); |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | if ( $res['response']['code'] != 200 ) { |
| 50 | nfw_log_error( |
| 51 | sprintf( |
| 52 | __('Cannot download security rules: HTTP response error %s. Will try again later', |
| 53 | 'ninjafirewall'), |
| 54 | $res['response']['code'] |
| 55 | ) |
| 56 | ); |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Decode and return the content. |
| 62 | */ |
| 63 | $list = json_decode( $res['body'], true ); |
| 64 | if ( $list === null ) { |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | return $list; |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | // ===================================================================== |
| 73 | // EOF |
| 74 |