Plugin Directory

Changeset 2880756


Ignore:
Timestamp:
03/15/2023 08:16:24 PM (3 years ago)
Author:
slick2
Message:

release version 1.0.9

Location:
traffic-jammer/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • traffic-jammer/trunk/README.md

    r2859772 r2880756  
    88Tested up to: 6.1
    99
    10 Stable tag: 1.0.8
     10Stable tag: 1.0.9
    1111
    1212Requires PHP: 7.4
  • traffic-jammer/trunk/includes/class-trafficjammer-abuseipdb.php

    r2859772 r2880756  
    2525     */
    2626    public function __construct() {
    27         $setting_options = get_option( 'wp_traffic_jammer_options' );
     27        $setting_options = get_option( 'wp_traffic_jammer_abuseipdb' );
    2828        $this->api       = $setting_options['abuseipdb_key'];
    2929    }
     
    4848        );
    4949
    50         if ( $response ) {
     50        if ( isset( $response ) && ( ! is_wp_error( $response ) ) ) {
    5151            return json_decode( $response['body'], true );
    5252        }
     
    7373        );
    7474
    75         if ( $response ) {
     75        if ( isset( $response ) && ( ! is_wp_error( $response ) ) ) {
    7676            $data = json_decode( $response, true );
    7777            if ( isset( $data['errors'] ) ) {
  • traffic-jammer/trunk/partials/options-page.php

    r2859772 r2880756  
    2626
    2727    <?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' );
    2833    if ( 'blockbot' === $cef6d44b_tab ) {
    2934        ?>
     
    7782        ?>
    7883            <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           
    8086            <table>
    8187                <?php do_settings_fields( 'wp_traffic_jammer', 'trafficjammer_abuseipdb_section' ); ?>         
  • traffic-jammer/trunk/readme.txt

    r2859834 r2880756  
    55Requires at least: 4.7
    66Tested up to: 6.1
    7 Stable tag: 1.0.8
     7Stable tag: 1.0.9
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    5151
    5252== Changelog ==
     53= 1.0.9 =
     54* fix bug on updating abuseipdb key and options
     55* added checking of error when calling abuseipdb endpoint
     56
    5357= 1.0.8 =
    5458* Settings for AbuseIPDB has a separate tab
  • traffic-jammer/trunk/traffic-jammer.php

    r2859772 r2880756  
    99 * Plugin URI:          https://wordpress.org/plugins/traffic-jammer/
    1010 * Description:         WordPress plugin to block IP and bots that causes malicious traffic.
    11  * Version:             1.0.8
     11 * Version:             1.0.9
    1212 * Requires at least:   5.2
    1313 * Requires PHP:        7.4
     
    104104    wp_clear_scheduled_hook( 'trafficjammer_cron_hook' );
    105105    remove_action( 'init', 'trafficjammer_traffic_live' );
    106 
    107     $wpdb->query( 'TRUNCATE TABLE ' . $table_name );
     106    $wpdb->query( $wpdb->prepare( 'TRUNCATE TABLE %s', $table_name ) );
    108107
    109108}
     
    117116function trafficjammer_cron_exec() {
    118117    global $wpdb;
    119     $table_name = $wpdb->prefix . 'trafficjammer_traffic';
     118    $table_name      = $wpdb->prefix . 'trafficjammer_traffic';
    120119    $setting_options = get_option( 'wp_traffic_jammer_options' );
     120    $abuseipdb       = get_option( 'wp_traffic_jammer_abuseipdb' );
    121121
    122122    // 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'];
    125125    } else {
    126126        $threshold = 100;
     
    128128
    129129    // Check if there is AbuseIPDB API key.
    130     if ( isset( $setting_options['abuseipdb_key'] ) ) {
     130    if ( isset( $abuseipdb['abuseipdb_key'] ) ) {
    131131        $blocklist = get_option( 'wp_traffic_jammer_blocklist' );
    132132        $blocklist = array_map( 'trim', explode( ',', $blocklist ) );
     
    151151
    152152    // 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;
    154154    $wpdb->query( 'DELETE FROM ' . $table_name . ' WHERE `date` < DATE_SUB( NOW(), INTERVAL ' . $interval_day . ' DAY );' );
    155155}
     
    169169    $url = wp_parse_url( $cef6d44b_server['REQUEST_URI'] );
    170170
    171     if( isset( $setting_options['qs_stamp'] ) && $setting_options['qs_stamp'] === 'yes' ) {
     171    if ( isset( $setting_options['qs_stamp'] ) && $setting_options['qs_stamp'] === 'yes' ) {
    172172        if ( '/' === $url['path'] && preg_match( '/^([0-9]{10})$/', $url['query'] ) ) {
    173173            header( 'HTTP/1.0 403 Forbidden' );
     
    198198    global $wpdb, $cef6d44b_server;
    199199    $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 ) );
    202202
    203203    // Check settings for the threshold.
     
    491491
    492492    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.
    495495    );
    496496
    497497    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    );
    502501    wp_enqueue_script( 'jquery-ui-tabs' );
    503502
     
    599598 */
    600599function 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" ';
    603602    if ( isset( $setting_options['abuseipdb_key'] ) ) {
    604603        echo ' value="' . esc_attr( $setting_options['abuseipdb_key'] ) . '"';
     
    614613 */
    615614function trafficjammer_abuse_threshold() {
    616     $setting_options = get_option( 'wp_traffic_jammer_options' );
     615    $setting_options = get_option( 'wp_traffic_jammer_abuseipdb' );
    617616    if ( isset( $setting_options['abuseipdb_threshold'] ) ) {
    618617        $threshold = $setting_options['abuseipdb_threshold'];
     
    620619        $threshold = 100;
    621620    }
    622     echo '<select name="wp_traffic_jammer_options[abuseipdb_threshold]">';
     621    echo '<select name="wp_traffic_jammer_abuseipdb[abuseipdb_threshold]">';
    623622    for ( $i = 70; $i <= 100; $i = $i + 10 ) {
    624623        echo '<option value="' . esc_html( $i ) . '"';
Note: See TracChangeset for help on using the changeset viewer.