Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Dedup files in UserSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jul 4, 2016
1 parent 00c4fe6 commit 902373e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion core/src/core/classes/class.AuthService.php
Expand Up @@ -195,8 +195,10 @@ public static function checkBruteForceLogin(&$loginArray)
{
if (isSet($_SERVER['REMOTE_ADDR'])) {
$serverAddress = $_SERVER['REMOTE_ADDR'];
} else {
} else if(isSet($_SERVER['SERVER_ADDR'])) {
$serverAddress = $_SERVER['SERVER_ADDR'];
} else {
return TRUE;
}
$login = null;
if (isSet($loginArray[$serverAddress])) {
Expand Down
26 changes: 17 additions & 9 deletions core/src/core/classes/class.UserSelection.php
Expand Up @@ -90,7 +90,7 @@ public function initFromNodes($nodes)
$this->files = array();
$this->inZip = false;
foreach ($nodes as $n) {
$this->files[] = $n->getPath();
$this->addFile($n->getPath());
}

}
Expand All @@ -110,7 +110,7 @@ public function initFromArray($array)
if(strpos($v, "base64encoded:") === 0){
$v = base64_decode(array_pop(explode(':', $v, 2)));
}
$this->files[] = AJXP_Utils::decodeSecureMagic($v);
$this->addFile(AJXP_Utils::decodeSecureMagic($v));
$this->isUnique = true;
//return ;
}
Expand All @@ -121,7 +121,7 @@ public function initFromArray($array)
if(strpos($v, "base64encoded:") === 0){
$v = base64_decode(array_pop(explode(':', $v, 2)));
}
$this->files[] = AJXP_Utils::decodeSecureMagic($v);
$this->addFile(AJXP_Utils::decodeSecureMagic($v));
$index ++;
}
$this->isUnique = false;
Expand All @@ -133,7 +133,7 @@ public function initFromArray($array)
if (isSet($array["nodes"]) && is_array($array["nodes"])) {
$this->files = array();
foreach($array["nodes"] as $value){
$this->files[] = AJXP_Utils::decodeSecureMagic($value);
$this->addFile(AJXP_Utils::decodeSecureMagic($value));
}
$this->isUnique = count($this->files) == 1;
}
Expand All @@ -152,6 +152,18 @@ public function initFromArray($array)
}
}
}

/**
* Add file to selection
* @param string $filePath
*/
public function addFile($filePath){
if(!in_array($filePath, $this->files)){
$this->files[] = $filePath;
}
}


/**
* Does the selection have one or more items
* @return bool
Expand Down Expand Up @@ -318,9 +330,5 @@ public function removeFile($file){
$this->nodes = $newNodes;
}
}

public function addFile($file){
$this->files[] = $file;
}


}

0 comments on commit 902373e

Please sign in to comment.