diff --git a/README.txt b/README.txt index babb09e..b46e839 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Donate link: http://paypal.me/anex Tags: forms, referer, tracking Requires at least: 4.5.0 Tested up to: 4.7 -Stable tag: 1.1.0 +Stable tag: 1.1.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -25,6 +25,9 @@ Saves Referers within a Cookie and submits them within hidden fields from a (gra == Changelog == += 1.1.1 - 04/04/2017 = +* Improved parameter check. Check now to submit only unique values per parameter + = 1.1.0 - 28/03/2017 = * Improved "merging" of parameters with the same key; now getting displayed grouped. diff --git a/includes/engine.php b/includes/engine.php index 7fd74bb..e24263e 100644 --- a/includes/engine.php +++ b/includes/engine.php @@ -81,6 +81,18 @@ protected function _hash($str) { return hash_hmac($this->_algo, $str, NONCE_KEY); } + protected function _arrayUniqueRecursive($array) { + + $result = array_map("unserialize", array_unique(array_map("serialize", $array))); + + foreach ($result as $key => $value) { + if(is_array($value)) + $result[$key] = $this->_arrayUniqueRecursive($value); + } + + return $result; + } + public function updateCookie() { $strategy = $this->_plugin->getOption('cookie_merge_strategy'); @@ -94,7 +106,7 @@ public function updateCookie() { $data = $this->getUrlData(); if($cookieData !== false && $strategy == 'merge') - $data = array_merge_recursive($cookieData, $data); + $data = $this->_arrayUniqueRecursive(array_merge_recursive($cookieData, $data)); $data['timestamp'] = time();