Finish chatroom backporting for 1.5.1
This commit is contained in:
@@ -5,8 +5,8 @@ $stmt = $conn->prepare("
|
|||||||
SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data
|
SELECT c.id AS chat_id, c.content, u.username, u.id AS user_id, u.save_data
|
||||||
FROM chats c
|
FROM chats c
|
||||||
JOIN users u ON c.userId = u.id
|
JOIN users u ON c.userId = u.id
|
||||||
WHERE u.banned = 0
|
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||||
ORDER BY c.id ASC LIMIT 50
|
ORDER BY c.id DESC LIMIT 50
|
||||||
");
|
");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
@@ -35,6 +35,6 @@ while ($row = $result->fetch_assoc()) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo encrypt("1" . ":" . implode("|", $rows));
|
echo encrypt("1" . ":" . implode("|", array_reverse($rows)));
|
||||||
|
|
||||||
$conn->close();
|
$conn->close();
|
||||||
31
database/backported/1.5.1/sendChatroomMessage.php
Normal file
31
database/backported/1.5.1/sendChatroomMessage.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
$post = getPostData();
|
||||||
|
$request_content = $post['content'] ?? '';
|
||||||
|
$token = $post['gameSession'] ?? '';
|
||||||
|
|
||||||
|
if (!preg_match('/^[ a-zA-Z0-9!@#\$%\^&\*\(\)_\+\-=\[\]\{\};\':",\.<>\/\?\\\\|`~]+$/', $request_content)) {
|
||||||
|
exitWithMessage("-1");
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = newConnection();
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM users WHERE token = ?");
|
||||||
|
$stmt->bind_param("s", $token);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
if (!$row) exitWithMessage("-1");
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
$id = $row["id"];
|
||||||
|
$content = base64_encode($request_content);
|
||||||
|
$time = time();
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("INSERT INTO chats (userId, content, timestamp) VALUES (?, ?, ?)");
|
||||||
|
$stmt->bind_param("isi", $id, $content, $time);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
echo encrypt("1");
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
require __DIR__ . '/../incl/util.php';
|
require __DIR__ . '/../incl/util.php';
|
||||||
setPlainHeader();
|
setPlainHeader();
|
||||||
if (isAllowedDatabaseVersion(getClientVersion())) {
|
// if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||||
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
// if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||||
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
|
require __DIR__ . '/backported/1.5.1/getChatroomMessages.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
checkClientDatabaseVersion();
|
checkClientDatabaseVersion();
|
||||||
$conn = newConnection();
|
$conn = newConnection();
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ $stmt = $conn->prepare("
|
|||||||
SELECT c.id AS chat_id, c.content, c.deleted_at, u.id AS user_id, u.username, u.save_data
|
SELECT c.id AS chat_id, c.content, c.deleted_at, u.id AS user_id, u.username, u.save_data
|
||||||
FROM chats c
|
FROM chats c
|
||||||
JOIN users u ON c.userId = u.id
|
JOIN users u ON c.userId = u.id
|
||||||
WHERE u.banned = 0
|
WHERE u.banned = 0 AND c.deleted_at = 0
|
||||||
ORDER BY c.id DESC
|
ORDER BY c.id DESC
|
||||||
LIMIT 50
|
LIMIT 50
|
||||||
");
|
");
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
require __DIR__ . '/../incl/util.php';
|
require __DIR__ . '/../incl/util.php';
|
||||||
setPlainHeader();
|
setPlainHeader();
|
||||||
|
if (isAllowedDatabaseVersion(getClientVersion())) {
|
||||||
|
if (getClientVersion() == "1.5.1" || getClientVersion() == "1.5.2") {
|
||||||
|
require __DIR__ . '/backported/1.5.1/sendChatroomMessage.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
checkClientDatabaseVersion();
|
checkClientDatabaseVersion();
|
||||||
|
|
||||||
$post = getPostData();
|
$post = getPostData();
|
||||||
|
|||||||
Reference in New Issue
Block a user