Changeset 2916773
- Timestamp:
- 05/24/2023 11:00:16 AM (3 years ago)
- Location:
- verifiedvisitors
- Files:
-
- 12 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from verifiedvisitors/trunk)
-
tags/1.1.0/VerifiedVisitors.php (modified) (2 diffs)
-
tags/1.1.0/class.admin.php (modified) (4 diffs)
-
tags/1.1.0/class.config.php (modified) (1 diff)
-
tags/1.1.0/models/class.vac-request.php (modified) (3 diffs)
-
tags/1.1.0/readme.txt (modified) (2 diffs)
-
tags/1.1.0/utils/class.request-utils.php (modified) (2 diffs)
-
trunk/VerifiedVisitors.php (modified) (2 diffs)
-
trunk/class.admin.php (modified) (4 diffs)
-
trunk/class.config.php (modified) (1 diff)
-
trunk/models/class.vac-request.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/utils/class.request-utils.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
verifiedvisitors/tags/1.1.0/VerifiedVisitors.php
r2890354 r2916773 5 5 /** 6 6 * @package VerifiedVisitors 7 * @version 1. 0.07 * @version 1.1.0 8 8 * 9 9 * Plugin Name: VerifiedVisitors … … 12 12 * Author: VerifiedVisitors 13 13 * Author URI: https://www.verifiedvisitors.com/ 14 * Version: 1. 0.015 * Stable tag: 1. 0.014 * Version: 1.1.0 15 * Stable tag: 1.1.0 16 16 * Requires at least: 4.9 17 17 * Requires PHP: 7.2 -
verifiedvisitors/tags/1.1.0/class.admin.php
r2890354 r2916773 43 43 function settings_section_callback() 44 44 { 45 // echo '<p>Verified Visitors API Key</p>'; 45 ?> 46 <p>API keys can be generated from your profile settings page in the VerifiedVisitors dashboard.</p> 47 <p>Please see the install instructions for more information.</p> 48 <?php 46 49 } 47 50 … … 49 52 { 50 53 $setting = get_option(Config::VV_API_KEY_OPTION); 51 ?>54 ?> 52 55 <input type="text" style="width: 500px" name="<?php echo Config::VV_API_KEY_OPTION ?>" value="<?php echo isset($setting) ? esc_attr($setting) : ''; ?>" /> 53 <p>API keys can be generated from your profile settings page in the VerifiedVisitors dashboard.</p>54 <p>Please see the install instructions for more information.</p>55 56 <?php 56 57 } … … 70 71 function options_page_html() 71 72 { 72 // Check user capabilities73 73 if (!current_user_can('manage_options')) { 74 74 return; 75 75 } 76 76 77 // Add error/update messages77 $option_key = Config::VV_API_KEY_OPTION; 78 78 79 // Check if the user have submitted the settings80 // WordPress will add the "settings-updated" $_GET parameter to the url81 79 if (isset($_GET['settings-updated'])) { 82 // Add settings saved message with the class of "updated" 83 add_settings_error( 84 'vv_messages', 85 'vv_message', 86 'Settings saved successfully', 87 'updated' 80 $response = wp_remote_post( 81 Config::API_URL, 82 array( 83 'headers' => array( 84 'authorization' => 'bearer ' . get_option($option_key) 85 ), 86 'timeout' => 5 87 ) 88 88 ); 89 90 $response_code = wp_remote_retrieve_response_code($response); 91 error_log($response_code); 92 93 if ($response_code == 400) { 94 add_settings_error( 95 $option_key, 96 "{$option_key}_success", 97 'Settings saved successfully', 98 'updated' 99 ); 100 } else { 101 add_settings_error( 102 $option_key, 103 "{$option_key}_failed_to_verify", 104 'Failed to verify API token', 105 'error' 106 ); 107 } 89 108 } 90 109 91 // Show error/update messages 92 settings_errors('vv_messages'); 110 settings_errors($option_key); 93 111 ?> 94 112 <div class="wrap"> … … 96 114 <form action="options.php" method="post"> 97 115 <?php 98 // Output security fields for the registered setting "vv"99 116 settings_fields('vv'); 100 // Output setting sections and their fields (sections are registered for "vv", each field is registered to a specific section)101 117 do_settings_sections('vv'); 102 // Output save settings button103 118 submit_button('Save'); 104 119 ?> -
verifiedvisitors/tags/1.1.0/class.config.php
r2890354 r2916773 10 10 public const COOKIE_NAME = 'vv_vid'; 11 11 public const COOKIE_EXPIRATION = 30 * DAY_IN_SECONDS; 12 public const VERSION = '1. 0.0';12 public const VERSION = '1.1.0'; 13 13 public const H_CAPTCHA_RESPONSE_KEY = "hCaptchaResponse"; 14 14 } -
verifiedvisitors/tags/1.1.0/models/class.vac-request.php
r2890354 r2916773 9 9 public $host; 10 10 public $uri; 11 public $method; 12 public $headers; 13 public $connection; 14 public $referer; 15 public $origin; 16 public $pragma; 17 public $xForwardedFor; 18 public $xForwardedProto; 19 public $xRequestedWith; 20 public $xRealIp; 21 public $trueClientIp; 22 public $via; 23 public $accept; 24 public $acceptEncoding; 25 public $acceptLanguage; 26 public $acceptCharset; 27 public $contentType; 28 public $contentLength; 29 public $cacheControl; 11 30 public $hCaptchaToken; 12 public $method;13 public $referer;14 public $xForwardedFor;15 31 public $worker; 16 32 … … 20 36 string $host, 21 37 string $uri, 38 string $method, 39 ?array $headers, 40 ?string $connection, 41 ?string $referer, 42 ?string $origin, 43 ?string $pragma, 44 ?string $xForwardedFor, 45 ?string $xForwardedProto, 46 ?string $xRequestedWith, 47 ?string $xRealIp, 48 ?string $trueClientIp, 49 ?string $via, 50 ?string $accept, 51 ?string $acceptEncoding, 52 ?string $acceptLanguage, 53 ?string $acceptCharset, 54 ?string $contentType, 55 ?string $contentLength, 56 ?string $cacheControl, 22 57 ?string $hCaptchaToken, 23 string $method,24 ?string $referer,25 ?string $xForwardedFor,26 58 Worker $worker 27 59 ) { … … 30 62 $this->host = $host; 31 63 $this->uri = $uri; 64 $this->method = $method; 65 $this->headers = $headers; 66 $this->connection = $connection; 67 $this->referer = $referer; 68 $this->origin = $origin; 69 $this->pragma = $pragma; 70 $this->xForwardedFor = $xForwardedFor; 71 $this->xForwardedProto = $xForwardedProto; 72 $this->xRequestedWith = $xRequestedWith; 73 $this->xRealIp = $xRealIp; 74 $this->trueClientIp = $trueClientIp; 75 $this->via = $via; 76 $this->accept = $accept; 77 $this->acceptEncoding = $acceptEncoding; 78 $this->acceptLanguage = $acceptLanguage; 79 $this->acceptCharset = $acceptCharset; 80 $this->contentType = $contentType; 81 $this->contentLength = $contentLength; 82 $this->cacheControl = $cacheControl; 32 83 $this->hCaptchaToken = $hCaptchaToken; 33 $this->method = $method;34 $this->referer = $referer;35 $this->xForwardedFor = $xForwardedFor;36 84 $this->worker = $worker; 37 85 } -
verifiedvisitors/tags/1.1.0/readme.txt
r2890354 r2916773 4 4 Requires at least: 4.9 5 5 Tested up to: 6.1 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 Requires PHP: 7.2 8 8 License: GPLv3 or later … … 110 110 == Changelog == 111 111 112 = 1.1.0 = 113 * Collect additional request headers for improved visitor categorisation 114 * Validate API key in plugin settings page 115 * General improvements 116 112 117 = 1.0 = 113 118 * Initial release. -
verifiedvisitors/tags/1.1.0/utils/class.request-utils.php
r2890354 r2916773 5 5 class RequestUtils 6 6 { 7 private static function get_raw_server_value(string $name) 8 { 9 if (array_key_exists($name, $_SERVER) && !empty($_SERVER[$name])) { 10 $sanitised_value = sanitize_text_field($_SERVER[$name]); 11 return $sanitised_value; 12 } 13 return null; 14 } 15 16 private static function get_ip_address(string $name) 17 { 18 $sanitised_value = self::get_raw_server_value($name); 19 $filtered_value = filter_var($sanitised_value, FILTER_VALIDATE_IP); 20 if ($filtered_value == false) { 21 error_log("{$name} was not a valid IP address"); 22 $filtered_value = null; 23 } 24 return $filtered_value; 25 } 26 27 private static function get_request_method() 28 { 29 $sanitised_method = self::get_raw_server_value('REQUEST_METHOD'); 30 $method = ValidateUtils::validate_request_method($sanitised_method); 31 if ($method == null) { 32 error_log('REQUEST_METHOD was not a valid HTTP method'); 33 } 34 return $method; 35 } 36 7 37 public static function build_vac_request(?string $vv_vid) 8 38 { 9 39 $headers = getallheaders(); 10 $user_agent = $headers['User-Agent'] ?? null;11 $host = $headers['Host'] ?? null;12 $contextType = $headers['Content-Type'] ?? null;13 40 14 $client_ip = filter_var(sanitize_text_field($_SERVER['HTTP_CLIENT_IP']), FILTER_VALIDATE_IP); 15 if ($client_ip == false) { 16 error_log('HTTP_CLIENT_IP was not a valid IP address'); 17 $client_ip = null; 18 } 41 $request_time = self::get_raw_server_value('REQUEST_TIME_FLOAT') ?? microtime(true); 42 $milliseconds = floor($request_time * 1000); 19 43 20 $x_forwarded_for = filter_var(sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']), FILTER_VALIDATE_IP); 21 if ($x_forwarded_for == false) { 22 error_log('HTTP_X_FORWARDED_FOR was not a valid IP address'); 23 $x_forwarded_for = null; 24 } 25 26 $remote_addr = filter_var(sanitize_text_field($_SERVER['REMOTE_ADDR']), FILTER_VALIDATE_IP); 27 if ($remote_addr == false) { 28 error_log('REMOTE_ADDR was not a valid IP address'); 29 $remote_addr = null; 30 } 31 32 $ip = $client_ip; 33 if ($ip == null) { 34 $ip = $remote_addr; 35 } 36 37 $escaped_url = esc_url(sanitize_text_field($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])); 44 $sanitised_host = self::get_raw_server_value('HTTP_HOST'); 45 $sanitised_uri = self::get_raw_server_value('REQUEST_URI'); 46 $sanitised_url = "{$sanitised_host}{$sanitised_uri}"; 47 $escaped_url = esc_url($sanitised_url); 38 48 $host = wp_parse_url($escaped_url, PHP_URL_HOST); 39 49 $path = wp_parse_url($escaped_url, PHP_URL_PATH); 40 50 $query_string = wp_parse_url($escaped_url, PHP_URL_QUERY); 51 $query_string = empty($query_string) ? "" : "?{$query_string}"; 52 $uri = "{$host}{$path}{$query_string}"; 53 $method = self::get_request_method(); 41 54 42 $uri = $host . $path; 43 if (!empty($query_string)) { 44 $uri = "{$uri}?{$query_string}"; 45 } 55 $connection = self::get_raw_server_value('HTTP_CONNECTION'); 46 56 47 $method = !empty($_SERVER['REQUEST_METHOD']) 48 ? ValidateUtils::validate_request_method(sanitize_text_field($_SERVER['REQUEST_METHOD'])) 49 : null; 50 if ($method == null) { 51 error_log('REQUEST_METHOD was not a valid HTTP method'); 52 } 57 $referer = esc_url(self::get_raw_server_value('HTTP_REFERER')); 58 $origin = self::get_raw_server_value('HTTP_ORIGIN'); 59 $pragma = self::get_raw_server_value('HTTP_PRAGMA'); 53 60 54 $referer = esc_url(sanitize_text_field($_SERVER['HTTP_REFERER'])); 61 $user_agent = self::get_raw_server_value('HTTP_USER_AGENT'); 62 $host = self::get_raw_server_value('HTTP_HOST'); 63 64 $client_ip = self::get_ip_address('HTTP_CLIENT_IP'); 65 $remote_addr = self::get_ip_address('REMOTE_ADDR'); 66 $ip = $client_ip ?? $remote_addr; 67 68 $x_forwarded_for = self::get_ip_address('HTTP_X_FORWARDED_FOR'); 69 $x_forwarded_proto = self::get_raw_server_value('HTTP_X_FORWARDED_PROTO'); 70 $x_requested_with = self::get_raw_server_value('HTTP_X_REQUESTED_WITH'); 71 $x_real_ip = self::get_ip_address('HTTP_X_REAL_IP'); 72 $true_client_ip = self::get_ip_address('HTTP_TRUE_CLIENT_IP'); 73 $via = self::get_raw_server_value('HTTP_VIA'); 74 75 $accept_encoding = self::get_raw_server_value('HTTP_ACCEPT_ENCODING'); 76 $accept = self::get_raw_server_value('HTTP_ACCEPT'); 77 $accept_language = self::get_raw_server_value('HTTP_ACCEPT_LANGUAGE'); 78 $accept_charset = self::get_raw_server_value('HTTP_ACCEPT_CHARSET'); 79 80 $content_type = $headers['Content-Type']; 81 $content_length = $headers['Content-Length']; 82 83 $cache_control = self::get_raw_server_value('HTTP_CACHE_CONTROL'); 55 84 56 85 $token = null; 57 if ($method == 'POST' && StringUtils::str_starts_with($conte xtType, "application/json")) {86 if ($method == 'POST' && StringUtils::str_starts_with($content_type, "application/json")) { 58 87 $post = file_get_contents('php://input'); 59 88 $data = json_decode($post); 60 89 $token = $data->hCaptchaResponse; 61 90 } 62 63 $milliseconds = floor(microtime(true) * 1000);64 91 65 92 $vac_request = new VacRequest( … … 68 95 $host, 69 96 $uri, 97 $method, 98 array_keys($headers), 99 $connection, 100 $referer, 101 $origin, 102 $pragma, 103 $x_forwarded_for, 104 $x_forwarded_proto, 105 $x_requested_with, 106 $x_real_ip, 107 $true_client_ip, 108 $via, 109 $accept, 110 $accept_encoding, 111 $accept_language, 112 $accept_charset, 113 $content_type, 114 $content_length, 115 $cache_control, 70 116 $token, 71 $method,72 $referer,73 $x_forwarded_for,74 117 new Worker(Config::VERSION) 75 118 ); -
verifiedvisitors/trunk/VerifiedVisitors.php
r2890354 r2916773 5 5 /** 6 6 * @package VerifiedVisitors 7 * @version 1. 0.07 * @version 1.1.0 8 8 * 9 9 * Plugin Name: VerifiedVisitors … … 12 12 * Author: VerifiedVisitors 13 13 * Author URI: https://www.verifiedvisitors.com/ 14 * Version: 1. 0.015 * Stable tag: 1. 0.014 * Version: 1.1.0 15 * Stable tag: 1.1.0 16 16 * Requires at least: 4.9 17 17 * Requires PHP: 7.2 -
verifiedvisitors/trunk/class.admin.php
r2890354 r2916773 43 43 function settings_section_callback() 44 44 { 45 // echo '<p>Verified Visitors API Key</p>'; 45 ?> 46 <p>API keys can be generated from your profile settings page in the VerifiedVisitors dashboard.</p> 47 <p>Please see the install instructions for more information.</p> 48 <?php 46 49 } 47 50 … … 49 52 { 50 53 $setting = get_option(Config::VV_API_KEY_OPTION); 51 ?>54 ?> 52 55 <input type="text" style="width: 500px" name="<?php echo Config::VV_API_KEY_OPTION ?>" value="<?php echo isset($setting) ? esc_attr($setting) : ''; ?>" /> 53 <p>API keys can be generated from your profile settings page in the VerifiedVisitors dashboard.</p>54 <p>Please see the install instructions for more information.</p>55 56 <?php 56 57 } … … 70 71 function options_page_html() 71 72 { 72 // Check user capabilities73 73 if (!current_user_can('manage_options')) { 74 74 return; 75 75 } 76 76 77 // Add error/update messages77 $option_key = Config::VV_API_KEY_OPTION; 78 78 79 // Check if the user have submitted the settings80 // WordPress will add the "settings-updated" $_GET parameter to the url81 79 if (isset($_GET['settings-updated'])) { 82 // Add settings saved message with the class of "updated" 83 add_settings_error( 84 'vv_messages', 85 'vv_message', 86 'Settings saved successfully', 87 'updated' 80 $response = wp_remote_post( 81 Config::API_URL, 82 array( 83 'headers' => array( 84 'authorization' => 'bearer ' . get_option($option_key) 85 ), 86 'timeout' => 5 87 ) 88 88 ); 89 90 $response_code = wp_remote_retrieve_response_code($response); 91 error_log($response_code); 92 93 if ($response_code == 400) { 94 add_settings_error( 95 $option_key, 96 "{$option_key}_success", 97 'Settings saved successfully', 98 'updated' 99 ); 100 } else { 101 add_settings_error( 102 $option_key, 103 "{$option_key}_failed_to_verify", 104 'Failed to verify API token', 105 'error' 106 ); 107 } 89 108 } 90 109 91 // Show error/update messages 92 settings_errors('vv_messages'); 110 settings_errors($option_key); 93 111 ?> 94 112 <div class="wrap"> … … 96 114 <form action="options.php" method="post"> 97 115 <?php 98 // Output security fields for the registered setting "vv"99 116 settings_fields('vv'); 100 // Output setting sections and their fields (sections are registered for "vv", each field is registered to a specific section)101 117 do_settings_sections('vv'); 102 // Output save settings button103 118 submit_button('Save'); 104 119 ?> -
verifiedvisitors/trunk/class.config.php
r2890354 r2916773 10 10 public const COOKIE_NAME = 'vv_vid'; 11 11 public const COOKIE_EXPIRATION = 30 * DAY_IN_SECONDS; 12 public const VERSION = '1. 0.0';12 public const VERSION = '1.1.0'; 13 13 public const H_CAPTCHA_RESPONSE_KEY = "hCaptchaResponse"; 14 14 } -
verifiedvisitors/trunk/models/class.vac-request.php
r2890354 r2916773 9 9 public $host; 10 10 public $uri; 11 public $method; 12 public $headers; 13 public $connection; 14 public $referer; 15 public $origin; 16 public $pragma; 17 public $xForwardedFor; 18 public $xForwardedProto; 19 public $xRequestedWith; 20 public $xRealIp; 21 public $trueClientIp; 22 public $via; 23 public $accept; 24 public $acceptEncoding; 25 public $acceptLanguage; 26 public $acceptCharset; 27 public $contentType; 28 public $contentLength; 29 public $cacheControl; 11 30 public $hCaptchaToken; 12 public $method;13 public $referer;14 public $xForwardedFor;15 31 public $worker; 16 32 … … 20 36 string $host, 21 37 string $uri, 38 string $method, 39 ?array $headers, 40 ?string $connection, 41 ?string $referer, 42 ?string $origin, 43 ?string $pragma, 44 ?string $xForwardedFor, 45 ?string $xForwardedProto, 46 ?string $xRequestedWith, 47 ?string $xRealIp, 48 ?string $trueClientIp, 49 ?string $via, 50 ?string $accept, 51 ?string $acceptEncoding, 52 ?string $acceptLanguage, 53 ?string $acceptCharset, 54 ?string $contentType, 55 ?string $contentLength, 56 ?string $cacheControl, 22 57 ?string $hCaptchaToken, 23 string $method,24 ?string $referer,25 ?string $xForwardedFor,26 58 Worker $worker 27 59 ) { … … 30 62 $this->host = $host; 31 63 $this->uri = $uri; 64 $this->method = $method; 65 $this->headers = $headers; 66 $this->connection = $connection; 67 $this->referer = $referer; 68 $this->origin = $origin; 69 $this->pragma = $pragma; 70 $this->xForwardedFor = $xForwardedFor; 71 $this->xForwardedProto = $xForwardedProto; 72 $this->xRequestedWith = $xRequestedWith; 73 $this->xRealIp = $xRealIp; 74 $this->trueClientIp = $trueClientIp; 75 $this->via = $via; 76 $this->accept = $accept; 77 $this->acceptEncoding = $acceptEncoding; 78 $this->acceptLanguage = $acceptLanguage; 79 $this->acceptCharset = $acceptCharset; 80 $this->contentType = $contentType; 81 $this->contentLength = $contentLength; 82 $this->cacheControl = $cacheControl; 32 83 $this->hCaptchaToken = $hCaptchaToken; 33 $this->method = $method;34 $this->referer = $referer;35 $this->xForwardedFor = $xForwardedFor;36 84 $this->worker = $worker; 37 85 } -
verifiedvisitors/trunk/readme.txt
r2890354 r2916773 4 4 Requires at least: 4.9 5 5 Tested up to: 6.1 6 Stable tag: 1. 0.06 Stable tag: 1.1.0 7 7 Requires PHP: 7.2 8 8 License: GPLv3 or later … … 110 110 == Changelog == 111 111 112 = 1.1.0 = 113 * Collect additional request headers for improved visitor categorisation 114 * Validate API key in plugin settings page 115 * General improvements 116 112 117 = 1.0 = 113 118 * Initial release. -
verifiedvisitors/trunk/utils/class.request-utils.php
r2890354 r2916773 5 5 class RequestUtils 6 6 { 7 private static function get_raw_server_value(string $name) 8 { 9 if (array_key_exists($name, $_SERVER) && !empty($_SERVER[$name])) { 10 $sanitised_value = sanitize_text_field($_SERVER[$name]); 11 return $sanitised_value; 12 } 13 return null; 14 } 15 16 private static function get_ip_address(string $name) 17 { 18 $sanitised_value = self::get_raw_server_value($name); 19 $filtered_value = filter_var($sanitised_value, FILTER_VALIDATE_IP); 20 if ($filtered_value == false) { 21 error_log("{$name} was not a valid IP address"); 22 $filtered_value = null; 23 } 24 return $filtered_value; 25 } 26 27 private static function get_request_method() 28 { 29 $sanitised_method = self::get_raw_server_value('REQUEST_METHOD'); 30 $method = ValidateUtils::validate_request_method($sanitised_method); 31 if ($method == null) { 32 error_log('REQUEST_METHOD was not a valid HTTP method'); 33 } 34 return $method; 35 } 36 7 37 public static function build_vac_request(?string $vv_vid) 8 38 { 9 39 $headers = getallheaders(); 10 $user_agent = $headers['User-Agent'] ?? null;11 $host = $headers['Host'] ?? null;12 $contextType = $headers['Content-Type'] ?? null;13 40 14 $client_ip = filter_var(sanitize_text_field($_SERVER['HTTP_CLIENT_IP']), FILTER_VALIDATE_IP); 15 if ($client_ip == false) { 16 error_log('HTTP_CLIENT_IP was not a valid IP address'); 17 $client_ip = null; 18 } 41 $request_time = self::get_raw_server_value('REQUEST_TIME_FLOAT') ?? microtime(true); 42 $milliseconds = floor($request_time * 1000); 19 43 20 $x_forwarded_for = filter_var(sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']), FILTER_VALIDATE_IP); 21 if ($x_forwarded_for == false) { 22 error_log('HTTP_X_FORWARDED_FOR was not a valid IP address'); 23 $x_forwarded_for = null; 24 } 25 26 $remote_addr = filter_var(sanitize_text_field($_SERVER['REMOTE_ADDR']), FILTER_VALIDATE_IP); 27 if ($remote_addr == false) { 28 error_log('REMOTE_ADDR was not a valid IP address'); 29 $remote_addr = null; 30 } 31 32 $ip = $client_ip; 33 if ($ip == null) { 34 $ip = $remote_addr; 35 } 36 37 $escaped_url = esc_url(sanitize_text_field($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])); 44 $sanitised_host = self::get_raw_server_value('HTTP_HOST'); 45 $sanitised_uri = self::get_raw_server_value('REQUEST_URI'); 46 $sanitised_url = "{$sanitised_host}{$sanitised_uri}"; 47 $escaped_url = esc_url($sanitised_url); 38 48 $host = wp_parse_url($escaped_url, PHP_URL_HOST); 39 49 $path = wp_parse_url($escaped_url, PHP_URL_PATH); 40 50 $query_string = wp_parse_url($escaped_url, PHP_URL_QUERY); 51 $query_string = empty($query_string) ? "" : "?{$query_string}"; 52 $uri = "{$host}{$path}{$query_string}"; 53 $method = self::get_request_method(); 41 54 42 $uri = $host . $path; 43 if (!empty($query_string)) { 44 $uri = "{$uri}?{$query_string}"; 45 } 55 $connection = self::get_raw_server_value('HTTP_CONNECTION'); 46 56 47 $method = !empty($_SERVER['REQUEST_METHOD']) 48 ? ValidateUtils::validate_request_method(sanitize_text_field($_SERVER['REQUEST_METHOD'])) 49 : null; 50 if ($method == null) { 51 error_log('REQUEST_METHOD was not a valid HTTP method'); 52 } 57 $referer = esc_url(self::get_raw_server_value('HTTP_REFERER')); 58 $origin = self::get_raw_server_value('HTTP_ORIGIN'); 59 $pragma = self::get_raw_server_value('HTTP_PRAGMA'); 53 60 54 $referer = esc_url(sanitize_text_field($_SERVER['HTTP_REFERER'])); 61 $user_agent = self::get_raw_server_value('HTTP_USER_AGENT'); 62 $host = self::get_raw_server_value('HTTP_HOST'); 63 64 $client_ip = self::get_ip_address('HTTP_CLIENT_IP'); 65 $remote_addr = self::get_ip_address('REMOTE_ADDR'); 66 $ip = $client_ip ?? $remote_addr; 67 68 $x_forwarded_for = self::get_ip_address('HTTP_X_FORWARDED_FOR'); 69 $x_forwarded_proto = self::get_raw_server_value('HTTP_X_FORWARDED_PROTO'); 70 $x_requested_with = self::get_raw_server_value('HTTP_X_REQUESTED_WITH'); 71 $x_real_ip = self::get_ip_address('HTTP_X_REAL_IP'); 72 $true_client_ip = self::get_ip_address('HTTP_TRUE_CLIENT_IP'); 73 $via = self::get_raw_server_value('HTTP_VIA'); 74 75 $accept_encoding = self::get_raw_server_value('HTTP_ACCEPT_ENCODING'); 76 $accept = self::get_raw_server_value('HTTP_ACCEPT'); 77 $accept_language = self::get_raw_server_value('HTTP_ACCEPT_LANGUAGE'); 78 $accept_charset = self::get_raw_server_value('HTTP_ACCEPT_CHARSET'); 79 80 $content_type = $headers['Content-Type']; 81 $content_length = $headers['Content-Length']; 82 83 $cache_control = self::get_raw_server_value('HTTP_CACHE_CONTROL'); 55 84 56 85 $token = null; 57 if ($method == 'POST' && StringUtils::str_starts_with($conte xtType, "application/json")) {86 if ($method == 'POST' && StringUtils::str_starts_with($content_type, "application/json")) { 58 87 $post = file_get_contents('php://input'); 59 88 $data = json_decode($post); 60 89 $token = $data->hCaptchaResponse; 61 90 } 62 63 $milliseconds = floor(microtime(true) * 1000);64 91 65 92 $vac_request = new VacRequest( … … 68 95 $host, 69 96 $uri, 97 $method, 98 array_keys($headers), 99 $connection, 100 $referer, 101 $origin, 102 $pragma, 103 $x_forwarded_for, 104 $x_forwarded_proto, 105 $x_requested_with, 106 $x_real_ip, 107 $true_client_ip, 108 $via, 109 $accept, 110 $accept_encoding, 111 $accept_language, 112 $accept_charset, 113 $content_type, 114 $content_length, 115 $cache_control, 70 116 $token, 71 $method,72 $referer,73 $x_forwarded_for,74 117 new Worker(Config::VERSION) 75 118 );
Note: See TracChangeset
for help on using the changeset viewer.