Make deleteChatroomMessage.php work with new db method - Finished
This commit is contained in:
@@ -7,22 +7,32 @@ $id = $post['id'] ?? '';
|
||||
$token = $post['token'] ?? '';
|
||||
$username = $post['username'] ?? '';
|
||||
|
||||
$conn = newConnection();
|
||||
$conn0 = newConnection(0);
|
||||
$conn1 = newConnection(1);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ? AND username = ?");
|
||||
$stmt->bind_param("ss", $token, $username);
|
||||
$stmt = $conn0->prepare("SELECT id FROM users WHERE username = ? LIMIT 1");
|
||||
$stmt->bind_param("s", $username);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
if (!$row) exit;
|
||||
if ($result->num_rows != 1) exit;
|
||||
$stmt->close();
|
||||
|
||||
$user_id = $row["id"];
|
||||
|
||||
$stmt = $conn1->prepare("SELECT 1 FROM userdata WHERE token = ? AND id = ? LIMIT 1");
|
||||
$stmt->bind_param("si", $token, $user_id);
|
||||
$stmt->execute();
|
||||
$result2 = $stmt->get_result();
|
||||
if ($result2->num_rows != 1) exit;
|
||||
$stmt->close();
|
||||
|
||||
$time = time();
|
||||
|
||||
$stmt = $conn->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
|
||||
$stmt = $conn1->prepare("UPDATE chats SET deleted_at = ? WHERE userId = ? AND id = ?");
|
||||
$stmt->bind_param("iii", $time, $user_id, $id);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
$conn->close();
|
||||
$conn0->close();
|
||||
$conn1->close();
|
||||
Reference in New Issue
Block a user