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