Changeset 3356902
- Timestamp:
- 09/05/2025 09:06:04 PM (7 months ago)
- Location:
- bad-ip-wp/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
bad-ip-wp.php (modified) (2 diffs)
-
includes/BadIPAdmin.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bad-ip-wp/trunk/README.txt
r3354922 r3356902 4 4 Requires at least: 3.0.1 5 5 Tested up to: 6.6.0 6 Stable tag: 2.0. 26 Stable tag: 2.0.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 64 64 == Changelog == 65 66 = 2.0.3 = 67 * bugfix for PHP 8.2 deprecation, refactored bad_query logic 65 68 66 69 = 2.0.2 = -
bad-ip-wp/trunk/bad-ip-wp.php
r3354922 r3356902 5 5 * 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. 6 6 * Centralized logging and real-time firewall control with dashboard integration. 7 * Version: 2.0. 27 * Version: 2.0.3 8 8 * Author: Iridium Intelligence 9 9 * Author URI: https://iridiumintel.com … … 20 20 } 21 21 22 define('BAD_IP_VERSION', '2.0. 2');22 define('BAD_IP_VERSION', '2.0.3'); 23 23 define('BAD_IP_PLUGIN_DIR', plugin_dir_path(__FILE__)); 24 24 define('BAD_IP_PLUGIN_URL', plugin_dir_url(__FILE__)); -
bad-ip-wp/trunk/includes/BadIPAdmin.php
r3353501 r3356902 283 283 $user_ip = BadIPHelper::getUserIP(); 284 284 $_now = current_time('mysql'); 285 //error_log("🚨 [BadIP] hook_bad_ip_head"); 285 286 286 287 if (BadIPHelper::checkIPInBlacklist($user_ip) && !BadIPHelper::checkIPInWhiteList($user_ip)) { … … 294 295 $settings = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}bad_ip_settings"); 295 296 296 if (!$settings || !BadIPHelper::checkOnline(BAD_IP_API_URL)) {297 if (!$settings) { // || !BadIPHelper::checkOnline(BAD_IP_API_URL) 297 298 return; 298 299 } … … 301 302 return; 302 303 } 304 305 $origin = $settings->login_incidents === '1' ? get_site_url() : 'anonymous'; 306 $reporter = get_site_url(); 303 307 304 308 $payload = [ 305 309 'uid' => $settings->token, 306 310 'ip' => $user_ip, 311 'origin' => $origin, 312 'reporter' => $reporter, 307 313 ]; 308 314 … … 316 322 if ($cached_result !== false) { 317 323 $rsp = json_decode($cached_result); 324 318 325 } else { 319 326 $response = wp_remote_post(BAD_IP_API_URL . 'bad_ip/check/?uid=' . $settings->token, [ … … 324 331 325 332 $rsp_body = wp_remote_retrieve_body($response); 326 set_transient($transient_key, $rsp_body, 60 ); // keširaj rezultat na 60 sekundi333 set_transient($transient_key, $rsp_body, 600); // keširaj rezultat na 10 minuta 327 334 $rsp = json_decode($rsp_body); 328 335 } … … 354 361 } 355 362 363 /* 356 364 if (!empty($_SERVER['QUERY_STRING']) && isset($_SERVER['REQUEST_URI'])) { 357 365 $query = $_SERVER['REQUEST_URI']; 358 366 if (!BadIPHelper::checkQuery($query)) { 359 367 360 error_log('✅ [BadIP] BADQUERY: ' . $query);368 //error_log('✅ [BadIP] BADQUERY: ' . $query); 361 369 362 370 $payload = [ 363 371 'uid' => $settings->token, 364 372 'query' => $query, 373 'origin' => $origin, 374 'reporter' => $reporter, 365 375 ]; 366 376 $response = wp_remote_post(BAD_IP_API_URL . 'bad_query/check/?uid=' . $settings->token, [ … … 387 397 } 388 398 } 399 */ 389 400 } 390 401 … … 470 481 } 471 482 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(); 474 485 $qs = $_SERVER['QUERY_STRING'] ?? ''; 475 486 $action = $_SERVER['REQUEST_URI'] ?? null; … … 480 491 } 481 492 493 /* 482 494 $payload = [ 483 495 'uid' => $settings->token, … … 487 499 'action' => $action, 488 500 ]; 489 490 501 $cache_key = 'bad_ip_check_' . md5($user_ip); 491 502 $cached_rsp = get_transient($cache_key); 492 493 503 if (!$cached_rsp) { 494 504 $response = wp_remote_post(BAD_IP_API_URL . 'bad_ip/check/?uid=' . $settings->token, [ … … 506 516 $rsp = $cached_rsp; 507 517 } 518 */ 508 519 509 520 // Log to local DB … … 514 525 'action' => $action, 515 526 ]); 527 528 $this->report_incident('bad_query', $action); 529 516 530 } 517 531 } … … 523 537 $url = home_url(add_query_arg([], $_SERVER['REQUEST_URI'])); 524 538 $agent = $_SERVER['HTTP_USER_AGENT'] ?? ''; 539 540 541 $origin = 'anonymous'; 542 $reporter = get_site_url(); 525 543 526 544 $data = [ … … 530 548 'url' => $url, 531 549 'user_agent' => $agent, 550 'action' => $detail, 551 'origin' => $origin, 552 'reporter' => $reporter, 532 553 ]; 533 554 534 wp_remote_post(BAD_IP_API_URL . 'report', [555 $response = wp_remote_post(BAD_IP_API_URL . 'incidents', [ 535 556 'method' => 'POST', 536 557 'timeout' => 3,
Note: See TracChangeset
for help on using the changeset viewer.