Changeset 2326883
- Timestamp:
- 06/18/2020 04:38:20 PM (6 years ago)
- Location:
- wecantrack
- Files:
-
- 21 added
- 4 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/README.md (added)
-
tags/1.1.0/WecantrackAdmin.php (added)
-
tags/1.1.0/WecantrackApp.php (added)
-
tags/1.1.0/css (added)
-
tags/1.1.0/css/admin.css (added)
-
tags/1.1.0/images (added)
-
tags/1.1.0/images/favicon.png (added)
-
tags/1.1.0/images/favicon2.png (added)
-
tags/1.1.0/images/wct-logo-normal.svg (added)
-
tags/1.1.0/index.php (added)
-
tags/1.1.0/js (added)
-
tags/1.1.0/js/.gitignore (added)
-
tags/1.1.0/js/admin.js (added)
-
tags/1.1.0/license.txt (added)
-
tags/1.1.0/locale (added)
-
tags/1.1.0/readme.txt (added)
-
tags/1.1.0/views (added)
-
tags/1.1.0/views/settings.php (added)
-
tags/1.1.0/wecantrack.php (added)
-
tags/1.1.0/wecantrack.pot (added)
-
trunk/WecantrackApp.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wecantrack.php (modified) (2 diffs)
-
trunk/wecantrack.pot (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wecantrack/trunk/WecantrackApp.php
r2325087 r2326883 82 82 } 83 83 84 $domain_starts_at = strpos($url, '/', 2); 85 86 if ($domain_starts_at !== false) { 87 $url = substr($url, 0, $domain_starts_at); 88 } else { 89 return true; 90 } 91 92 if (isset($patterns['origins'][$url])) { 93 return true; 94 } 84 // search if domain key matches to the origin keys 85 if (isset($patterns['origins'][substr($url, 0, strpos($url, '/', 2))])) { 86 return true; 87 } 88 89 // check if the full url matches to any regex patterns 95 90 foreach($patterns['regexOrigins'] as $pattern) { 96 91 if (preg_match('~'.$pattern.'~i', $original_url)) { … … 121 116 } 122 117 123 $api_url = "https://app.wecantrack.com/api/v1/clickout"; 118 // wecantrack will not process bots 119 if (!isset($_SERVER['HTTP_USER_AGENT']) || self::useragent_is_bot($_SERVER['HTTP_USER_AGENT'])) { 120 return $original_affiliate_url; 121 } 124 122 125 123 $post_data = array( … … 127 125 'clickout_url' => !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : self::get_site_url(), 128 126 '_ga' => !empty($_COOKIE['_ga']) ? sanitize_text_field($_COOKIE['_ga']) : null, 129 '_wctrck' => !empty($_COOKIE['_wctrck']) ? sanitize_text_field($_COOKIE['_wctrck']) : null 127 '_wctrck' => !empty($_COOKIE['_wctrck']) ? sanitize_text_field($_COOKIE['_wctrck']) : null, 128 'ua' => $_SERVER['HTTP_USER_AGENT'], 129 'ip' => self::get_user_real_ip(), 130 130 ); 131 131 132 $response = wp_remote_post( $api_url, array(132 $response = wp_remote_post('https://app.wecantrack.com/api/v1/clickout', array( 133 133 'timeout' => self::CURL_TIMEOUT_S, 134 134 'headers' => array( … … 155 155 156 156 return $original_affiliate_url; 157 } 158 159 /** 160 * Gets the real user IP 161 * 162 * @return string 163 */ 164 private static function get_user_real_ip() 165 { 166 $ip_headers = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); 167 foreach ($ip_headers as $header) { 168 if (array_key_exists($header, $_SERVER) === true) { 169 foreach (array_map('trim', explode(',', $_SERVER[$header])) as $ip) { 170 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) { 171 return $ip; 172 } 173 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE) !== false) { 174 return $ip; 175 } 176 } 177 } 178 } 179 return null; 180 } 181 182 /** 183 * Detects if it's a bot depending on user agent 184 * 185 * @param $user_agent 186 * 187 * @return bool 188 */ 189 private static function useragent_is_bot($user_agent) 190 { 191 $bots = ['bot/', 'crawler', 'semrush', 'bot.', ' bot ', '@bot', 'guzzle']; 192 193 foreach ($bots as $bot) { 194 if (stripos($user_agent, $bot) !== false) { 195 return true; 196 }; 197 } 198 199 return false; 157 200 } 158 201 -
wecantrack/trunk/readme.txt
r2325087 r2326883 5 5 Tested up to: 5.4 6 6 Requires PHP: 5.6.20 7 Stable tag: 1. 0.97 Stable tag: 1.1.0 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 62 62 == Changelog == 63 63 64 = 1.1.0 - 18th June 2020 = 65 * Affiliate link checker regex fix 66 * Bot detection 67 64 68 = 1.0.9 - 16th June 2020 = 65 69 * Use rawurldecode -
wecantrack/trunk/wecantrack.php
r2325087 r2326883 7 7 Plugin URI: https://wecantrack.com/wordpress 8 8 Description: Integrate all you affiliate sales in Google Analytics, Google Ads, Facebook, Data Studio and more! 9 Version: 1. 0.99 Version: 1.1.0 10 10 Author: wecantrack.com 11 11 Author URI: https://wecantrack.com … … 17 17 if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); } 18 18 19 define('WECANTRACK_VERSION', '1. 0.9');19 define('WECANTRACK_VERSION', '1.1.0'); 20 20 define('WECANTRACK_PLUGIN_NAME', 'wecantrack'); 21 21 define('WECANTRACK_PATH', WP_PLUGIN_DIR.'/'.WECANTRACK_PLUGIN_NAME); -
wecantrack/trunk/wecantrack.pot
r2314056 r2326883 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: WeCanTrack 1. 0.8\n"5 "Project-Id-Version: WeCanTrack 1.1.0\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wecantrack\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2020-0 5-28T22:12:23+00:00\n"12 "POT-Creation-Date: 2020-06-18T16:09:52+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.4.0\n"
Note: See TracChangeset
for help on using the changeset viewer.