Make getAccountProfile.php and getAccountProfileMessages.php work with new db method

This commit is contained in:
2025-12-31 23:31:52 -07:00
parent 2d78565f77
commit 34328de9b6
2 changed files with 30 additions and 10 deletions

View File

@@ -1,20 +1,31 @@
<?php <?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/../incl/util.php'; require __DIR__ . '/../incl/util.php';
setPlainHeader(); setPlainHeader();
$post = getPostData(); $post = getPostData();
$uesrId = $post['uesrId'] ?? ''; $uesrId = $post['uesrId'] ?? '';
$conn = newConnection(); $conn0 = newConnection(0);
$conn1 = newConnection(1);
$stmt = $conn->prepare("SELECT * FROM users WHERE id = ?"); $stmt = $conn0->prepare("SELECT username, id FROM users WHERE id = ?");
$stmt->bind_param("i", $uesrId); $stmt->bind_param("i", $uesrId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
if ($result->num_rows > 0) { if ($result->num_rows > 0) {
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
$savedata = json_decode($row['save_data'], true);
$stmt2 = $conn1->prepare("SELECT save_data FROM userdata WHERE id = ?");
$stmt2->bind_param("i", $row['id']);
$stmt2->execute();
$result2 = $stmt2->get_result();
$row2 = $result2->fetch_assoc();
$savedata = json_decode($row2['save_data'], true);
$custom = null; $custom = null;
if (isset($savedata['bird']['customIcon']['selected'])) { if (isset($savedata['bird']['customIcon']['selected'])) {
$selected = $savedata['bird']['customIcon']['selected']; $selected = $savedata['bird']['customIcon']['selected'];
@@ -48,4 +59,5 @@ if ($result->num_rows > 0) {
} }
$stmt->close(); $stmt->close();
$conn->close(); $conn0->close();
$conn1->close();

View File

@@ -7,16 +7,24 @@ $post = getPostData();
$targetId = (int)$post['targetId'] ?? 0; $targetId = (int)$post['targetId'] ?? 0;
$stmt = $conn->prepare(" $stmt = $conn->prepare("
SELECT p.id, p.content, p.timestamp, p.likes, u.id as userId SELECT id, content, timestamp, likes, userId
FROM userposts p FROM userposts
JOIN users u ON p.userId = u.id WHERE userId = ? AND deleted_at = 0
WHERE u.id = ? AND p.deleted_at = 0 ORDER BY id DESC
ORDER BY p.id DESC
"); ");
$stmt->bind_param("i", $targetId); $stmt->bind_param("i", $targetId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
echo encrypt(json_encode(array_map(fn($row) => ['id' => $row['id'], 'userId' => $row['userId'], 'content' => $row['content'], 'timestamp' => genTimestamp($row['timestamp']) . " ago", 'likes' => $row['likes']], $result->fetch_all(MYSQLI_ASSOC)))); echo encrypt(json_encode(array_map(
fn($row) => [
'id' => $row['id'],
'userId' => $row['userId'],
'content' => $row['content'],
'timestamp' => genTimestamp($row['timestamp']) . " ago",
'likes' => $row['likes']
],
$result->fetch_all(MYSQLI_ASSOC)
)));
$conn->close(); $conn->close();