Browse Source

fix LIKE statements in SQL query

master
R4SAS 2 years ago
parent
commit
eb94626b2e
  1. 4
      views/add.php

4
views/add.php

@ -201,7 +201,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { @@ -201,7 +201,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
/* print all records, which will be deleted*/
$STH = $pdo->prepare('SELECT `host`, `base32`, `base64` FROM `hosts` WHERE `host` = ? OR `host` LIKE ?');
$STH->execute(['%'.$domain, '%'.$domain]);
$STH->execute([$domain, '%'.$domain]);
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
foreach ($hosts as $host) {
$log .= "Host: " . $host['host'] . PHP_EOL . "Base32: " . $host['base32'] . PHP_EOL . "Base64: " . $host['base64'] . PHP_EOL;
@ -210,7 +210,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { @@ -210,7 +210,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
file_put_contents(__DIR__ . '/../logs/reg.log', $log, FILE_APPEND);
/* remove domain and subdomains if any found */
$pdo->prepare('DELETE FROM `hosts` WHERE `host` = ? OR `host` LIKE %?')->execute(['%'.$domain, '%'.$domain]);
$pdo->prepare('DELETE FROM `hosts` WHERE `host` = ? OR `host` LIKE ?')->execute([$domain, '%'.$domain]);
$result["reregister"] = true;
}

Loading…
Cancel
Save