Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
sanitize insrert queries in db-func (#11651)
Browse files Browse the repository at this point in the history
MON-14667
  • Loading branch information
emabassi-ext authored Aug 30, 2022
1 parent 1f54f65 commit 8d0309a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions www/include/configuration/configObject/contactgroup/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,24 @@ function multipleContactGroupInDB($contactGroups = array(), $nbrDup = array())
"WHERE `cg_cg_id` = " . (int)$key;
$dbResult = $pearDB->query($query);
$fields["cg_aclRelation"] = "";
$aclContactStatement = $pearDB->prepare("INSERT INTO `acl_group_contactgroups_relations` " .
"VALUES (:maxId, :cgAcl)");
while ($cgAcl = $dbResult->fetch()) {
$query = "INSERT INTO `acl_group_contactgroups_relations` VALUES ('" .
$maxId["MAX(cg_id)"] . "', '" . $cgAcl['acl_group_id'] . "')";
$pearDB->query($query);
$aclContactStatement->bindValue(":maxId", (int) $maxId["MAX(cg_id)"], PDO::PARAM_INT);
$aclContactStatement->bindValue(":cgAcl", (int) $cgAcl['acl_group_id'], PDO::PARAM_INT);
$aclContactStatement->execute();
$fields["cg_aclRelation"] .= $cgAcl["acl_group_id"] . ",";
}
$query = "SELECT DISTINCT `cgcr`.`contact_contact_id` FROM `contactgroup_contact_relation` `cgcr`" .
" WHERE `cgcr`.`contactgroup_cg_id` = '" . (int)$key . "'";
$dbResult = $pearDB->query($query);
$fields["cg_contacts"] = "";
$contactStatement = $pearDB->prepare("INSERT INTO `contactgroup_contact_relation` " .
"VALUES (:cct, :maxId)");
while ($cct = $dbResult->fetch()) {
$query = "INSERT INTO `contactgroup_contact_relation` " .
"VALUES ('" . $cct["contact_contact_id"] . "', '" . $maxId["MAX(cg_id)"] . "')";
$pearDB->query($query);
$contactStatement->bindValue(":cct", (int) $cct["contact_contact_id"], \PDO::PARAM_INT);
$contactStatement->bindValue(":maxId", (int) $maxId["MAX(cg_id)"], \PDO::PARAM_INT);
$contactStatement->execute();
$fields["cg_contacts"] .= $cct["contact_contact_id"] . ",";
}
$fields["cg_contacts"] = trim($fields["cg_contacts"], ",");
Expand Down

0 comments on commit 8d0309a

Please sign in to comment.