mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
system/Variable_model: replaced concatenation of names array with ? (parameter replacement by CI) to prevent SQL injections
This commit is contained in:
@@ -24,30 +24,32 @@ class Variable_model extends DB_Model
|
||||
*/
|
||||
public function getVariables($uid, $names = null)
|
||||
{
|
||||
if (isEmptyString($uid) || (isset($names) && !is_array($names)))
|
||||
if (isEmptyString($uid))
|
||||
$result = error('wrong parameters passed');
|
||||
else
|
||||
{
|
||||
$vardata = array();
|
||||
$parametersArray = array($uid);
|
||||
|
||||
$qry = "SELECT name, wert FROM public.tbl_variable WHERE uid = ?";
|
||||
|
||||
if (isset($names))
|
||||
if (!isEmptyArray($names))
|
||||
{
|
||||
$qry .= " AND name IN ('".implode(',', $names)."')";
|
||||
$qry .= " AND name IN ?";
|
||||
$parametersArray[] = $names;
|
||||
}
|
||||
$qry .= ";";
|
||||
|
||||
$varresults = $this->execQuery($qry, array($uid));
|
||||
$varresults = $this->execQuery($qry, $parametersArray);
|
||||
|
||||
if (hasData($varresults))
|
||||
{
|
||||
$varresults = getData($varresults);
|
||||
foreach ($varresults as $varresult)
|
||||
{
|
||||
if (isset($varresult->wert))
|
||||
$vardata[$varresult->name] = $varresult->wert;
|
||||
}
|
||||
foreach ($varresults as $varresult)
|
||||
{
|
||||
if (isset($varresult->wert))
|
||||
$vardata[$varresult->name] = $varresult->wert;
|
||||
}
|
||||
}
|
||||
|
||||
$vardefaults = $this->VariablennameModel->getDefaults($names);
|
||||
@@ -56,7 +58,6 @@ class Variable_model extends DB_Model
|
||||
{
|
||||
$vardefaults = getData($vardefaults);
|
||||
|
||||
|
||||
foreach ($vardefaults as $vardefault)
|
||||
{
|
||||
if (!isset($vardata[$vardefault->name]) && isset($vardefault->defaultwert))
|
||||
|
||||
Reference in New Issue
Block a user