Changeset 3423385
- Timestamp:
- 12/19/2025 06:19:07 AM (3 months ago)
- Location:
- usermaven
- Files:
-
- 8 edited
- 1 copied
-
tags/1.2.4 (copied) (copied from usermaven/trunk)
-
tags/1.2.4/README.txt (modified) (1 diff)
-
tags/1.2.4/includes/class-usermaven-api.php (modified) (8 diffs)
-
tags/1.2.4/includes/class-usermaven.php (modified) (1 diff)
-
tags/1.2.4/usermaven.php (modified) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/includes/class-usermaven-api.php (modified) (8 diffs)
-
trunk/includes/class-usermaven.php (modified) (1 diff)
-
trunk/usermaven.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
usermaven/tags/1.2.4/README.txt
r3375626 r3423385 6 6 Tested up to: 6.8.3 7 7 Requires PHP: 5.6 8 Stable tag: 1.2. 38 Stable tag: 1.2.4 9 9 License: Massachusetts Institute of Technology (MIT) license 10 10 License URI: https://opensource.org/licenses/MIT -
usermaven/tags/1.2.4/includes/class-usermaven-api.php
r3240206 r3423385 4 4 private $api_key; 5 5 private $api_url; 6 private $cookie_less_tracking; 6 7 7 8 public function __construct($tracking_host) { … … 9 10 $this->api_key = get_option('usermaven_api_key'); 10 11 $this->api_url = "$tracking_host/api/v1/s2s/event"; 12 $this->cookie_less_tracking = (bool) get_option('usermaven_cookie_less_tracking'); 11 13 } 12 14 … … 17 19 $current_timestamp_ms = round(microtime(true) * 1000); 18 20 $doc_encoding = get_bloginfo('charset'); 21 $user_agent = $this->get_user_agent(); 22 $source_ip = $this->get_client_ip(); 23 $privacy_policies = $this->get_privacy_policies(); 19 24 20 25 $data = [ … … 32 37 'doc_path' => $_SERVER['REQUEST_URI'] ?? '', 33 38 'doc_host' => $_SERVER['HTTP_HOST'] ?? '', 34 'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '', 39 'user_agent' => $user_agent, 40 'source_ip' => $source_ip, 35 41 'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '', 36 42 'doc_encoding' => (string) $doc_encoding, 37 43 ]; 44 45 if (!empty($privacy_policies)) { 46 $data = array_merge($data, $privacy_policies); 47 } 38 48 39 49 $response = wp_remote_post($url, [ … … 49 59 $body = wp_remote_retrieve_body($response); 50 60 $result = json_decode($body, true); 51 return $result['status'] === 'ok'; 61 62 return isset($result['status']) && $result['status'] === 'ok'; 52 63 } 53 64 … … 57 68 // Get current timestamp in milliseconds 58 69 $current_timestamp_ms = round(microtime(true) * 1000); 70 $user_agent = $this->get_user_agent(); 71 $source_ip = $this->get_client_ip(); 72 $privacy_policies = $this->get_privacy_policies(); 59 73 60 74 $data = [ … … 73 87 'doc_path' => $_SERVER['REQUEST_URI'] ?? '', 74 88 'doc_host' => $_SERVER['HTTP_HOST'] ?? '', 75 'user_agent' => $ _SERVER['HTTP_USER_AGENT'] ?? '',76 'source_ip' => $ _SERVER['REMOTE_ADDR'] ?? '',89 'user_agent' => $user_agent, 90 'source_ip' => $source_ip, 77 91 'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '', 78 92 'doc_encoding' => 'UTF-8', 79 93 ]; 94 95 if (!empty($privacy_policies)) { 96 $data = array_merge($data, $privacy_policies); 97 } 80 98 81 99 $response = wp_remote_post($url, [ … … 92 110 $result = json_decode($body, true); 93 111 94 return $result['status'] === 'ok'; 112 return isset($result['status']) && $result['status'] === 'ok'; 113 } 114 115 /** 116 * Safely resolve client IP, preferring X-Forwarded-For when available. 117 * 118 * @return string 119 */ 120 private function get_client_ip() { 121 $ip_sources = array( 122 'HTTP_X_FORWARDED_FOR', 123 'REMOTE_ADDR', 124 ); 125 126 foreach ($ip_sources as $key) { 127 if (empty($_SERVER[$key])) { 128 continue; 129 } 130 131 // X-Forwarded-For can contain multiple comma-separated addresses. 132 $candidates = $key === 'HTTP_X_FORWARDED_FOR' 133 ? explode(',', $_SERVER[$key]) 134 : array($_SERVER[$key]); 135 136 foreach ($candidates as $candidate) { 137 $candidate = trim($candidate); 138 139 if (filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false || 140 filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { 141 return $candidate; 142 } 143 } 144 } 145 146 return ''; 147 } 148 149 /** 150 * Retrieve user agent string with a safe fallback. 151 * 152 * @return string 153 */ 154 private function get_user_agent() { 155 return isset($_SERVER['HTTP_USER_AGENT']) ? (string) $_SERVER['HTTP_USER_AGENT'] : ''; 156 } 157 158 /** 159 * Return privacy flags when cookie-less tracking is enabled. 160 * 161 * @return array 162 */ 163 private function get_privacy_policies() { 164 if ($this->cookie_less_tracking) { 165 return array( 166 'cookie_policy' => 'strict', 167 'ip_policy' => 'strict', 168 ); 169 } 170 171 return array(); 95 172 } 96 173 } -
usermaven/tags/1.2.4/includes/class-usermaven.php
r3262123 r3423385 81 81 $this->version = USERMAVEN_VERSION; 82 82 } else { 83 $this->version = '1.2. 2';83 $this->version = '1.2.4'; 84 84 } 85 85 $this->plugin_name = 'usermaven'; -
usermaven/tags/1.2.4/usermaven.php
r3375626 r3423385 19 19 * Description: The Easiest Website and Product Analytics Platform 20 20 21 * Version: 1.2. 321 * Version: 1.2.4 22 22 * Author: Usermaven 23 23 * Author URI: https://usermaven.com/ … … 38 38 * Rename this for your plugin and update it as you release new versions. 39 39 */ 40 define( 'USERMAVEN_VERSION', '1.2. 3' );40 define( 'USERMAVEN_VERSION', '1.2.4' ); 41 41 42 42 /** -
usermaven/trunk/README.txt
r3375626 r3423385 6 6 Tested up to: 6.8.3 7 7 Requires PHP: 5.6 8 Stable tag: 1.2. 38 Stable tag: 1.2.4 9 9 License: Massachusetts Institute of Technology (MIT) license 10 10 License URI: https://opensource.org/licenses/MIT -
usermaven/trunk/includes/class-usermaven-api.php
r3240206 r3423385 4 4 private $api_key; 5 5 private $api_url; 6 private $cookie_less_tracking; 6 7 7 8 public function __construct($tracking_host) { … … 9 10 $this->api_key = get_option('usermaven_api_key'); 10 11 $this->api_url = "$tracking_host/api/v1/s2s/event"; 12 $this->cookie_less_tracking = (bool) get_option('usermaven_cookie_less_tracking'); 11 13 } 12 14 … … 17 19 $current_timestamp_ms = round(microtime(true) * 1000); 18 20 $doc_encoding = get_bloginfo('charset'); 21 $user_agent = $this->get_user_agent(); 22 $source_ip = $this->get_client_ip(); 23 $privacy_policies = $this->get_privacy_policies(); 19 24 20 25 $data = [ … … 32 37 'doc_path' => $_SERVER['REQUEST_URI'] ?? '', 33 38 'doc_host' => $_SERVER['HTTP_HOST'] ?? '', 34 'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '', 39 'user_agent' => $user_agent, 40 'source_ip' => $source_ip, 35 41 'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '', 36 42 'doc_encoding' => (string) $doc_encoding, 37 43 ]; 44 45 if (!empty($privacy_policies)) { 46 $data = array_merge($data, $privacy_policies); 47 } 38 48 39 49 $response = wp_remote_post($url, [ … … 49 59 $body = wp_remote_retrieve_body($response); 50 60 $result = json_decode($body, true); 51 return $result['status'] === 'ok'; 61 62 return isset($result['status']) && $result['status'] === 'ok'; 52 63 } 53 64 … … 57 68 // Get current timestamp in milliseconds 58 69 $current_timestamp_ms = round(microtime(true) * 1000); 70 $user_agent = $this->get_user_agent(); 71 $source_ip = $this->get_client_ip(); 72 $privacy_policies = $this->get_privacy_policies(); 59 73 60 74 $data = [ … … 73 87 'doc_path' => $_SERVER['REQUEST_URI'] ?? '', 74 88 'doc_host' => $_SERVER['HTTP_HOST'] ?? '', 75 'user_agent' => $ _SERVER['HTTP_USER_AGENT'] ?? '',76 'source_ip' => $ _SERVER['REMOTE_ADDR'] ?? '',89 'user_agent' => $user_agent, 90 'source_ip' => $source_ip, 77 91 'user_language' => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '', 78 92 'doc_encoding' => 'UTF-8', 79 93 ]; 94 95 if (!empty($privacy_policies)) { 96 $data = array_merge($data, $privacy_policies); 97 } 80 98 81 99 $response = wp_remote_post($url, [ … … 92 110 $result = json_decode($body, true); 93 111 94 return $result['status'] === 'ok'; 112 return isset($result['status']) && $result['status'] === 'ok'; 113 } 114 115 /** 116 * Safely resolve client IP, preferring X-Forwarded-For when available. 117 * 118 * @return string 119 */ 120 private function get_client_ip() { 121 $ip_sources = array( 122 'HTTP_X_FORWARDED_FOR', 123 'REMOTE_ADDR', 124 ); 125 126 foreach ($ip_sources as $key) { 127 if (empty($_SERVER[$key])) { 128 continue; 129 } 130 131 // X-Forwarded-For can contain multiple comma-separated addresses. 132 $candidates = $key === 'HTTP_X_FORWARDED_FOR' 133 ? explode(',', $_SERVER[$key]) 134 : array($_SERVER[$key]); 135 136 foreach ($candidates as $candidate) { 137 $candidate = trim($candidate); 138 139 if (filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false || 140 filter_var($candidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { 141 return $candidate; 142 } 143 } 144 } 145 146 return ''; 147 } 148 149 /** 150 * Retrieve user agent string with a safe fallback. 151 * 152 * @return string 153 */ 154 private function get_user_agent() { 155 return isset($_SERVER['HTTP_USER_AGENT']) ? (string) $_SERVER['HTTP_USER_AGENT'] : ''; 156 } 157 158 /** 159 * Return privacy flags when cookie-less tracking is enabled. 160 * 161 * @return array 162 */ 163 private function get_privacy_policies() { 164 if ($this->cookie_less_tracking) { 165 return array( 166 'cookie_policy' => 'strict', 167 'ip_policy' => 'strict', 168 ); 169 } 170 171 return array(); 95 172 } 96 173 } -
usermaven/trunk/includes/class-usermaven.php
r3262123 r3423385 81 81 $this->version = USERMAVEN_VERSION; 82 82 } else { 83 $this->version = '1.2. 2';83 $this->version = '1.2.4'; 84 84 } 85 85 $this->plugin_name = 'usermaven'; -
usermaven/trunk/usermaven.php
r3375626 r3423385 19 19 * Description: The Easiest Website and Product Analytics Platform 20 20 21 * Version: 1.2. 321 * Version: 1.2.4 22 22 * Author: Usermaven 23 23 * Author URI: https://usermaven.com/ … … 38 38 * Rename this for your plugin and update it as you release new versions. 39 39 */ 40 define( 'USERMAVEN_VERSION', '1.2. 3' );40 define( 'USERMAVEN_VERSION', '1.2.4' ); 41 41 42 42 /**
Note: See TracChangeset
for help on using the changeset viewer.