Browse Source

fix unbuffered query execution

master
R4SAS 2 years ago
parent
commit
28aadecc6c
  1. 12
      views/add.php

12
views/add.php

@ -90,7 +90,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { @@ -90,7 +90,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
} else {
$base32 = $util->b32from64($parsed["b64"]);
if (!$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)')->execute([$domain, $parsed["b64"], $base32])) {
$STH = !$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)');
if (!$STH->execute([$domain, $parsed["b64"], $base32])) {
$result["error"] = "Error happened while inserting record to database. Please try again later.";
} else {
@ -119,7 +120,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { @@ -119,7 +120,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
} else {
$base32 = $util->b32from64($parsed["b64"]);
if (!$pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ? WHERE `host` = ?')->execute([$parsed["b64"], $base32, $domain])) {
$STH = $pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ? WHERE `host` = ?');
if (!$STH->execute([$parsed["b64"], $base32, $domain])) {
$result["error"] = "Error happened while updating record in database. Please try again later.";
} else {
@ -158,7 +160,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { @@ -158,7 +160,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
} else {
$base32 = $util->b32from64($parsed["b64"]);
if (!$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)')->execute([$domain, $parsed["b64"], $base32])) {
$STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)');
if (!$STH->execute([$domain, $parsed["b64"], $base32])) {
$result["error"] = "Error happened while updating record in database. Please try again later.";
} else {
@ -223,7 +226,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { @@ -223,7 +226,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
$base32 = $util->b32from64($parsed["b64"]);
/* Adding to database 2LD domain */
if (!$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)')->execute([$domain, $parsed["b64"], $base32])) {
$STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)');
if (!$STH->execute([$domain, $parsed["b64"], $base32])) {
$result["error"] = "Error happened while inserting record to database. Please try again later.";
} else {

Loading…
Cancel
Save