Changeset 2880756
- Timestamp:
- 03/15/2023 08:16:24 PM (3 years ago)
- Location:
- traffic-jammer/trunk
- Files:
-
- 5 edited
-
README.md (modified) (1 diff)
-
includes/class-trafficjammer-abuseipdb.php (modified) (3 diffs)
-
partials/options-page.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
traffic-jammer.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
traffic-jammer/trunk/README.md
r2859772 r2880756 8 8 Tested up to: 6.1 9 9 10 Stable tag: 1.0. 810 Stable tag: 1.0.9 11 11 12 12 Requires PHP: 7.4 -
traffic-jammer/trunk/includes/class-trafficjammer-abuseipdb.php
r2859772 r2880756 25 25 */ 26 26 public function __construct() { 27 $setting_options = get_option( 'wp_traffic_jammer_ options' );27 $setting_options = get_option( 'wp_traffic_jammer_abuseipdb' ); 28 28 $this->api = $setting_options['abuseipdb_key']; 29 29 } … … 48 48 ); 49 49 50 if ( $response) {50 if ( isset( $response ) && ( ! is_wp_error( $response ) ) ) { 51 51 return json_decode( $response['body'], true ); 52 52 } … … 73 73 ); 74 74 75 if ( $response) {75 if ( isset( $response ) && ( ! is_wp_error( $response ) ) ) { 76 76 $data = json_decode( $response, true ); 77 77 if ( isset( $data['errors'] ) ) { -
traffic-jammer/trunk/partials/options-page.php
r2859772 r2880756 26 26 27 27 <?php 28 if ( isset( $_GET['settings-updated'] ) && empty( get_settings_errors( 'trafficjammer_messages' ) ) ) { 29 // add settings saved message with the class of "updated". 30 add_settings_error( 'trafficjammer_messages', 'trafficjammer_message', __( 'Settings Saved', 'wp_traffic_jammer' ), 'updated' ); 31 } 32 settings_errors( 'trafficjammer_messages' ); 28 33 if ( 'blockbot' === $cef6d44b_tab ) { 29 34 ?> … … 77 82 ?> 78 83 <form action="options.php" method="post" class="form-table"> 79 <?php settings_fields( 'wp_traffic_jammer_options' ); ?> 84 <?php settings_fields( 'wp_traffic_jammer_abuseipdb' ); ?> 85 80 86 <table> 81 87 <?php do_settings_fields( 'wp_traffic_jammer', 'trafficjammer_abuseipdb_section' ); ?> -
traffic-jammer/trunk/readme.txt
r2859834 r2880756 5 5 Requires at least: 4.7 6 6 Tested up to: 6.1 7 Stable tag: 1.0. 87 Stable tag: 1.0.9 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 51 51 52 52 == Changelog == 53 = 1.0.9 = 54 * fix bug on updating abuseipdb key and options 55 * added checking of error when calling abuseipdb endpoint 56 53 57 = 1.0.8 = 54 58 * Settings for AbuseIPDB has a separate tab -
traffic-jammer/trunk/traffic-jammer.php
r2859772 r2880756 9 9 * Plugin URI: https://wordpress.org/plugins/traffic-jammer/ 10 10 * Description: WordPress plugin to block IP and bots that causes malicious traffic. 11 * Version: 1.0. 811 * Version: 1.0.9 12 12 * Requires at least: 5.2 13 13 * Requires PHP: 7.4 … … 104 104 wp_clear_scheduled_hook( 'trafficjammer_cron_hook' ); 105 105 remove_action( 'init', 'trafficjammer_traffic_live' ); 106 107 $wpdb->query( 'TRUNCATE TABLE ' . $table_name ); 106 $wpdb->query( $wpdb->prepare( 'TRUNCATE TABLE %s', $table_name ) ); 108 107 109 108 } … … 117 116 function trafficjammer_cron_exec() { 118 117 global $wpdb; 119 $table_name = $wpdb->prefix . 'trafficjammer_traffic';118 $table_name = $wpdb->prefix . 'trafficjammer_traffic'; 120 119 $setting_options = get_option( 'wp_traffic_jammer_options' ); 120 $abuseipdb = get_option( 'wp_traffic_jammer_abuseipdb' ); 121 121 122 122 // Check for Threshold. 123 if ( isset( $ setting_options['abuseipdb_threshold'] ) ) {124 $threshold = $ setting_options['abuseipdb_threshold'];123 if ( isset( $abuseipdb['abuseipdb_threshold'] ) ) { 124 $threshold = $abuseipdb['abuseipdb_threshold']; 125 125 } else { 126 126 $threshold = 100; … … 128 128 129 129 // Check if there is AbuseIPDB API key. 130 if ( isset( $ setting_options['abuseipdb_key'] ) ) {130 if ( isset( $abuseipdb['abuseipdb_key'] ) ) { 131 131 $blocklist = get_option( 'wp_traffic_jammer_blocklist' ); 132 132 $blocklist = array_map( 'trim', explode( ',', $blocklist ) ); … … 151 151 152 152 // Cleanup Logs. 153 $interval_day = isset( $settting_option ['log_retention'] ) ? $settting_option['log_retention'] : 3;153 $interval_day = isset( $settting_options['log_retention'] ) ? $settting_options['log_retention'] : 3; 154 154 $wpdb->query( 'DELETE FROM ' . $table_name . ' WHERE `date` < DATE_SUB( NOW(), INTERVAL ' . $interval_day . ' DAY );' ); 155 155 } … … 169 169 $url = wp_parse_url( $cef6d44b_server['REQUEST_URI'] ); 170 170 171 if ( isset( $setting_options['qs_stamp'] ) && $setting_options['qs_stamp'] === 'yes' ) {171 if ( isset( $setting_options['qs_stamp'] ) && $setting_options['qs_stamp'] === 'yes' ) { 172 172 if ( '/' === $url['path'] && preg_match( '/^([0-9]{10})$/', $url['query'] ) ) { 173 173 header( 'HTTP/1.0 403 Forbidden' ); … … 198 198 global $wpdb, $cef6d44b_server; 199 199 $setting_options = get_option( 'wp_traffic_jammer_options' ); 200 $blocklist = get_option( 'wp_traffic_jammer_blocklist' );201 $blocklist = array_map( 'trim', explode( ',', $blocklist ) );200 $blocklist = get_option( 'wp_traffic_jammer_blocklist' ); 201 $blocklist = array_map( 'trim', explode( ',', $blocklist ) ); 202 202 203 203 // Check settings for the threshold. … … 491 491 492 492 register_setting( 493 'wp_traffic_jammer_ abuseipdb', // option group.494 'wp_traffic_jammer_ abuseipdb', // option name.493 'wp_traffic_jammer_options', // option group. 494 'wp_traffic_jammer_options', // option name. 495 495 ); 496 496 497 497 register_setting( 498 'wp_traffic_jammer_options', 499 'wp_traffic_jammer_options' 500 ); 501 498 'wp_traffic_jammer_abuseipdb', 499 'wp_traffic_jammer_abuseipdb' 500 ); 502 501 wp_enqueue_script( 'jquery-ui-tabs' ); 503 502 … … 599 598 */ 600 599 function trafficjammer_abuseipdb_key() { 601 $setting_options = get_option( 'wp_traffic_jammer_ options' );602 echo '<input type="text" name="wp_traffic_jammer_ options[abuseipdb_key]" size="50" ';600 $setting_options = get_option( 'wp_traffic_jammer_abuseipdb' ); 601 echo '<input type="text" name="wp_traffic_jammer_abuseipdb[abuseipdb_key]" size="50" '; 603 602 if ( isset( $setting_options['abuseipdb_key'] ) ) { 604 603 echo ' value="' . esc_attr( $setting_options['abuseipdb_key'] ) . '"'; … … 614 613 */ 615 614 function trafficjammer_abuse_threshold() { 616 $setting_options = get_option( 'wp_traffic_jammer_ options' );615 $setting_options = get_option( 'wp_traffic_jammer_abuseipdb' ); 617 616 if ( isset( $setting_options['abuseipdb_threshold'] ) ) { 618 617 $threshold = $setting_options['abuseipdb_threshold']; … … 620 619 $threshold = 100; 621 620 } 622 echo '<select name="wp_traffic_jammer_ options[abuseipdb_threshold]">';621 echo '<select name="wp_traffic_jammer_abuseipdb[abuseipdb_threshold]">'; 623 622 for ( $i = 70; $i <= 100; $i = $i + 10 ) { 624 623 echo '<option value="' . esc_html( $i ) . '"';
Note: See TracChangeset
for help on using the changeset viewer.