Plugin Directory

Changeset 3356902


Ignore:
Timestamp:
09/05/2025 09:06:04 PM (7 months ago)
Author:
iridiumintel
Message:

Update trunk for version 2.0.3: bugfix for PHP 8.2 deprecation, refactored bad_query logic

Location:
bad-ip-wp/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bad-ip-wp/trunk/README.txt

    r3354922 r3356902  
    44Requires at least: 3.0.1
    55Tested up to: 6.6.0
    6 Stable tag: 2.0.2
     6Stable tag: 2.0.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363
    6464== Changelog ==
     65
     66= 2.0.3 =
     67* bugfix for PHP 8.2 deprecation, refactored bad_query logic
    6568
    6669= 2.0.2 =
  • bad-ip-wp/trunk/bad-ip-wp.php

    r3354922 r3356902  
    55 * Description:       Bad IP WP is a lightweight, high-performance WordPress firewall plugin designed to block malicious actors in real time. Includes central server sync, TOR exit node filtering, brute-force protection, and live dashboard control. Built for agencies, sysadmins, and paranoid devs.
    66 *                    Centralized logging and real-time firewall control with dashboard integration.
    7  * Version:           2.0.2
     7 * Version:           2.0.3
    88 * Author:            Iridium Intelligence
    99 * Author URI:        https://iridiumintel.com
     
    2020}
    2121
    22 define('BAD_IP_VERSION', '2.0.2');
     22define('BAD_IP_VERSION', '2.0.3');
    2323define('BAD_IP_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2424define('BAD_IP_PLUGIN_URL', plugin_dir_url(__FILE__));
  • bad-ip-wp/trunk/includes/BadIPAdmin.php

    r3353501 r3356902  
    283283        $user_ip = BadIPHelper::getUserIP();
    284284        $_now = current_time('mysql');
     285        //error_log("🚨 [BadIP] hook_bad_ip_head");
    285286
    286287        if (BadIPHelper::checkIPInBlacklist($user_ip) && !BadIPHelper::checkIPInWhiteList($user_ip)) {
     
    294295        $settings = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}bad_ip_settings");
    295296
    296         if (!$settings || !BadIPHelper::checkOnline(BAD_IP_API_URL)) {
     297        if (!$settings) { // || !BadIPHelper::checkOnline(BAD_IP_API_URL)
    297298            return;
    298299        }
     
    301302            return;
    302303        }
     304
     305        $origin    = $settings->login_incidents === '1' ? get_site_url() : 'anonymous';
     306        $reporter  = get_site_url();
    303307
    304308        $payload = [
    305309            'uid' => $settings->token,
    306310            'ip'  => $user_ip,
     311            'origin' => $origin,
     312            'reporter' => $reporter,
    307313        ];
    308314
     
    316322        if ($cached_result !== false) {
    317323            $rsp = json_decode($cached_result);
     324
    318325        } else {
    319326            $response = wp_remote_post(BAD_IP_API_URL . 'bad_ip/check/?uid=' . $settings->token, [
     
    324331
    325332            $rsp_body = wp_remote_retrieve_body($response);
    326             set_transient($transient_key, $rsp_body, 60); // keširaj rezultat na 60 sekundi
     333            set_transient($transient_key, $rsp_body, 600); // keširaj rezultat na 10 minuta
    327334            $rsp = json_decode($rsp_body);
    328335        }
     
    354361        }
    355362
     363        /*
    356364        if (!empty($_SERVER['QUERY_STRING']) && isset($_SERVER['REQUEST_URI'])) {
    357365            $query = $_SERVER['REQUEST_URI'];
    358366            if (!BadIPHelper::checkQuery($query)) {
    359367
    360                 error_log('✅ [BadIP] BADQUERY: ' . $query);
     368                //error_log('✅ [BadIP] BADQUERY: ' . $query);
    361369
    362370                $payload = [
    363371                    'uid'   => $settings->token,
    364372                    'query' => $query,
     373                    'origin'   => $origin,
     374                    'reporter' => $reporter,
    365375                ];
    366376                $response = wp_remote_post(BAD_IP_API_URL . 'bad_query/check/?uid=' . $settings->token, [
     
    387397            }
    388398        }
     399        */
    389400    }
    390401
     
    470481        }
    471482
    472         $origin    = $settings->login_incidents === '1' ? get_site_url() : 'anonymous';
    473         $reporter  = get_site_url();
     483        //$origin    = $settings->login_incidents === '1' ? get_site_url() : 'anonymous';
     484        //$reporter  = get_site_url();
    474485        $qs        = $_SERVER['QUERY_STRING'] ?? '';
    475486        $action    = $_SERVER['REQUEST_URI'] ?? null;
     
    480491            }
    481492
     493            /*
    482494            $payload = [
    483495                'uid'      => $settings->token,
     
    487499                'action'   => $action,
    488500            ];
    489 
    490501            $cache_key = 'bad_ip_check_' . md5($user_ip);
    491502            $cached_rsp = get_transient($cache_key);
    492 
    493503            if (!$cached_rsp) {
    494504                $response = wp_remote_post(BAD_IP_API_URL . 'bad_ip/check/?uid=' . $settings->token, [
     
    506516                $rsp = $cached_rsp;
    507517            }
     518            */
    508519
    509520            // Log to local DB
     
    514525                'action' => $action,
    515526            ]);
     527
     528            $this->report_incident('bad_query', $action);
     529
    516530        }
    517531    }
     
    523537        $url     = home_url(add_query_arg([], $_SERVER['REQUEST_URI']));
    524538        $agent   = $_SERVER['HTTP_USER_AGENT'] ?? '';
     539
     540
     541        $origin    = 'anonymous';
     542        $reporter  = get_site_url();
    525543
    526544        $data = [
     
    530548            'url'        => $url,
    531549            'user_agent' => $agent,
     550            'action'     => $detail,
     551            'origin'     => $origin,
     552            'reporter'     => $reporter,
    532553        ];
    533554
    534         wp_remote_post(BAD_IP_API_URL . 'report', [
     555        $response = wp_remote_post(BAD_IP_API_URL . 'incidents', [
    535556            'method'    => 'POST',
    536557            'timeout'   => 3,
Note: See TracChangeset for help on using the changeset viewer.