Skip to content

Commit

Permalink
Check for values being unique per parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHana committed Apr 4, 2017
1 parent 860a2f5 commit 5fe3adf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand Down
14 changes: 13 additions & 1 deletion includes/engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();

Expand Down

0 comments on commit 5fe3adf

Please sign in to comment.