Plugin Directory

Changeset 3337887


Ignore:
Timestamp:
08/01/2025 03:11:47 PM (8 months ago)
Author:
supersoju
Message:

Pick real IP from proxies

Location:
wpcommand/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wpcommand/trunk/plugin.php

    r2949600 r3337887  
    44Plugin Name: WP Command and Control
    55Description: Manage your WordPress site with <a href="https://wpcommandcontrol.com/">WP Command and Control</a>. <strong>Deactivate to clear your API Key.</strong>
    6 Version: 2.3.5.2
     6Version: 2.3.6
    77Author: SoJu Studios
    88Author URI: http://supersoju.com/
  • wpcommand/trunk/readme.txt

    r2949600 r3337887  
    22Contributors: supersoju
    33Tags: wpcommand, wpcontrol, remote administration, multiple wordpress
    4 Requires at least: 3.1
    5 Tested up to: 6.3
    6 Stable tag: 2.3.5.2
     4Requires at least: 5.0
     5Tested up to: 6.8.2
     6Stable tag: 2.3.6
    77
    88WP Command and Control allows you to manage multiple WordPress installs from a single dashboard.
  • wpcommand/trunk/wpcac.api.php

    r2949600 r3337887  
    2626            exit;
    2727        }
     28
     29        $all_ips = array();
     30        if (!empty($_SERVER['REMOTE_ADDR'])) {
     31            $all_ips[] = $_SERVER['REMOTE_ADDR'];
     32        }
     33        $proxy_headers = array(
     34            'HTTP_CF_CONNECTING_IP',     // Cloudflare original IP
     35            'HTTP_X_FORWARDED_FOR',      // Standard proxy chain
     36            'HTTP_X_REAL_IP',            // Nginx proxy
     37            'HTTP_CLIENT_IP'             // Some proxies
     38        );
     39        foreach ($proxy_headers as $header) {
     40            if (!empty($_SERVER[$header])) {
     41                $header_ips = array_map('trim', explode(',', $_SERVER[$header]));
     42                foreach ($header_ips as $ip) {
     43                    if (filter_var($ip, FILTER_VALIDATE_IP) && !in_array($ip, $all_ips)) {
     44                        $all_ips[] = $ip;
     45                    }
     46                }
     47            }
     48        }
     49        $req_ip = implode(',', $all_ips);
    2850
    2951        $response = wp_remote_post( 'https://wpcommandcontrol.com/client/api/verify_request', [
     
    3557                'action' => 'verify_ips',
    3658                'verify' => $verify,
    37                 'req_ip' => $_SERVER['REMOTE_ADDR'],
     59                'req_ip' => $req_ip,
    3860            ],
    3961        ]);
Note: See TracChangeset for help on using the changeset viewer.