🔒️ getTheseByAuthor() now sanitize author name

This commit is contained in:
Florian Sylvain
2021-10-30 18:12:01 +02:00
parent b6c976b4b1
commit a97ee8fb2a
+8 -2
View File
@@ -24,12 +24,18 @@ class dump {
$pdo_obj = new conf(); $pdo_obj = new conf();
$pdo = $pdo_obj->getPDO(); $pdo = $pdo_obj->getPDO();
$stmt = $pdo->query("SELECT * FROM theses WHERE author LIKE '%$author%';");
$author = '%' . $author . '%';
$stmt = $pdo->prepare("SELECT * FROM theses WHERE author LIKE :author;");
$stmt->bindParam(':author', $author, PDO::PARAM_STR, 100);
$stmt->execute();
$i = 0; $i = 0;
while ($obj = $stmt->fetchObject()) { while ($obj = $stmt->fetchObject()) {
$theses_array[$i] = array(); $theses_array[$i] = array();
foreach ($obj as $elem) { foreach ($obj as $elem) {
array_push($theses_array[$i], empty($elem) ? "NULL" : $elem); array_push($theses_array[$i], empty($elem) ? "Non définit" : $elem);
} }
$i++; $i++;
} }