| @@ -91,8 +91,30 @@ | ||
| 91 | 91 | ) |
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | + * Some of the IP addresses of Patchstack. | |
| 96 | + * | |
| 97 | + * @var array | |
| 98 | + */ | |
| 99 | + public $ips = array( | |
| 100 | + '18.221.197.243', | |
| 101 | + '52.15.237.250', | |
| 102 | + '3.19.3.34', | |
| 103 | + '3.18.238.17', | |
| 104 | + '13.58.49.77', | |
| 105 | + '18.222.191.77', | |
| 106 | + '3.131.108.250', | |
| 107 | + '3.23.157.140', | |
| 108 | + '18.220.70.233', | |
| 109 | + '3.140.84.221', | |
| 110 | + '185.212.171.100', | |
| 111 | + '3.133.121.93', | |
| 112 | + '18.219.61.133', | |
| 113 | + '3.14.29.150' | |
| 114 | + ); | |
| 115 | + | |
| 116 | + /** | |
| 95 | 117 | * @param Patchstack $plugin |
| 96 | 118 | * @return void |
| 97 | 119 | */ |
| 98 | 120 | public function __construct( $plugin ) { |
| @@ -175,28 +197,8 @@ | ||
| 175 | 197 | return false; |
| 176 | 198 | } |
| 177 | 199 | |
| 178 | 200 | /** |
| 179 | - * Determine if a given PHP function is disabled or not. | |
| 180 | - * | |
| 181 | - * @param string $name Name of the function to check. | |
| 182 | - * @return boolean Whether or not the function is available to call. | |
| 183 | - */ | |
| 184 | - public function function_available( $name ) { | |
| 185 | - $safe_mode = ini_get( 'safe_mode' ); | |
| 186 | - if ( $safe_mode && strtolower( $safe_mode ) != 'off' ) { | |
| 187 | - return false; | |
| 188 | - } | |
| 189 | - | |
| 190 | - // Determine if the function is available. | |
| 191 | - if ( in_array( $name, array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) ) ) { | |
| 192 | - return false; | |
| 193 | - } | |
| 194 | - | |
| 195 | - return true; | |
| 196 | - } | |
| 197 | - | |
| 198 | - /** | |
| 199 | 201 | * Attempt to get the client IP by checking all possible IP (proxy) headers. |
| 200 | 202 | * |
| 201 | 203 | * @return string |
| 202 | 204 | */ |
| @@ -206,38 +208,7 @@ | ||
| 206 | 208 | if ( $override != '' && isset( $_SERVER[ $override ] ) ) { |
| 207 | 209 | return $_SERVER[ $override ]; |
| 208 | 210 | } |
| 209 | 211 | |
| 210 | - // IP address headers which should have priority and be used regardless of other headers. | |
| 211 | - $priority = array( 'HTTP_CF_CONNECTING_IP', 'HTTP_X_SUCURI_CLIENTIP' ); | |
| 212 | - foreach ( $priority as $header ) { | |
| 213 | - if ( isset( $_SERVER[ $header ] ) && filter_var( $_SERVER[ $header ], FILTER_VALIDATE_IP ) !== false ) { | |
| 214 | - return $_SERVER[ $header ]; | |
| 215 | - } | |
| 216 | - } | |
| 217 | - | |
| 218 | - // Special case for hosts that have a weird configuration. | |
| 219 | - if ( $this->function_available( 'php_uname' ) ) { | |
| 220 | - $uname = @php_uname(); | |
| 221 | - | |
| 222 | - // Bluehos and Hostmonster store the real IP in $_SERVER['REMOTE_ADDR'] but the proxy IP in HTTP_X_FORWARDED_FOR.t | |
| 223 | - if ( strpos( $uname, 'bluehost' ) !== false || strpos( $uname, 'hostmonster' ) !== false ) { | |
| 224 | - return $_SERVER['REMOTE_ADDR']; | |
| 225 | - } | |
| 226 | - | |
| 227 | - // Hostgator stores the real IP in $_SERVER['REMOTE_ADDR'] but the proxy IP in HTTP_X_FORWARDED_FOR. | |
| 228 | - if ( ( strpos( $uname, 'websitewelcome' ) || strpos( $uname, 'hostgator' ) ) && isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR'] ) { | |
| 229 | - return $_SERVER['REMOTE_ADDR']; | |
| 230 | - } | |
| 231 | - } | |
| 232 | - | |
| 233 | - // In order of priority, try to get the IP address. | |
| 234 | - $allowed = array( 'HTTP_X_REAL_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'SUCURI_RIP', 'REMOTE_ADDR' ); | |
| 235 | - foreach ( $allowed as $header ) { | |
| 236 | - if ( isset( $_SERVER[ $header ] ) && filter_var( $_SERVER[ $header ], FILTER_VALIDATE_IP ) !== false ) { | |
| 237 | - return $_SERVER[ $header ]; | |
| 238 | - } | |
| 239 | - } | |
| 240 | - | |
| 241 | - return '127.0.0.1'; | |
| 212 | + return isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : ''; | |
| 242 | 213 | } |
| 243 | 214 | } |