Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to fix the injection issues in collections/list.php #1401

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions classes/OccurrenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,16 @@ public function getQueryTermStr(){
$retStr = '';
foreach($this->searchTermArr as $k => $v){
if(is_array($v)) $v = implode(',', $v);
if($v) $retStr .= '&'.$this->cleanOutStr($k).'='.$this->cleanOutStr($v);
if($v) $retStr .= '&'.$this->cleanOutStr($k).'='. $this->cleanOutStr($v);
}
if(isset($this->taxaArr['search'])){
$retStr .= '&taxa='.$this->cleanOutStr($this->taxaArr['search']);
$retStr .= '&taxa='. $this->cleanOutStr($this->taxaArr['search']);
if($this->taxaArr['usethes']) $retStr .= '&usethes=1';
$retStr .= '&taxontype='.$this->taxaArr['taxontype'];
if(is_numeric($this->taxaArr['taxontype'])) {
$retStr .= '&taxontype=' . intval($this->taxaArr['taxontype']);
} else {
$retStr .= '&taxontype=1';
}
}
return substr($retStr, 1);
}
Expand Down
28 changes: 16 additions & 12 deletions classes/OccurrenceTaxaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,25 @@ private function setSciNamesByVerns(&$searchTerm) {
$sql = 'SELECT DISTINCT v.VernacularName, t.tid, t.sciname, t.rankid
FROM taxstatus ts INNER JOIN taxavernaculars v ON ts.TID = v.TID
INNER JOIN taxa t ON t.TID = ts.tidaccepted
WHERE (ts.taxauthid = '.$this->taxAuthId.') AND (v.VernacularName IN("'.$searchTerm.'"))
WHERE (ts.taxauthid = ?) AND (v.VernacularName IN(?))
ORDER BY t.rankid LIMIT 10';
$rs = $this->conn->query($sql);
while($row = $rs->fetch_object()){
//$vernName = strtolower($row->VernacularName);
$vernName = $row->VernacularName;
if($row->rankid == 140){
$this->taxaArr['taxa'][$vernName]['families'][] = $row->sciname;
}
else{
$this->taxaArr['taxa'][$vernName]['scinames'][] = $row->sciname;
if ($statement = $this->conn->prepare($sql)) {
$statement->bind_param("ss", $this->taxAuthId, $searchTerm);
$statement->execute();
$result = $statement->get_result();
while($row = $result->fetch_object()){
$vernName = $row->VernacularName;
if($row->rankid == 140){
$this->taxaArr['taxa'][$vernName]['families'][] = $row->sciname;
}
else{
$this->taxaArr['taxa'][$vernName]['scinames'][] = $row->sciname;
}
$this->taxaArr['taxa'][$vernName]['tid'][$row->tid] = $row->rankid;
}
$this->taxaArr['taxa'][$vernName]['tid'][$row->tid] = $row->rankid;
$result->free();
$statement->close();
}
$rs->free();
}
}

Expand Down