Implement viewing others profiles

This commit is contained in:
Retrofoxxo 2024-08-05 17:27:27 +02:00 committed by GitHub
parent 1e097d4331
commit 0e43e746e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 83 additions and 0 deletions

View file

@ -77,6 +77,21 @@ header('Content-Type: application/json');
echo '{"code": 420, "data": "", "success": false, "error": "Please try again later."}';
}
$stmt->close();
} else if (isset($put['avatarUrl'])) {
$avatarUrl = $put['avatarUrl'];
// Prepare the SQL query to update account
$sql = "UPDATE accounts SET picture = ? WHERE SID = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $avatarUrl, $sid);
if ($stmt->execute() === TRUE) {
echo '{"code": "", "data": {}, "success": true, "error": ""}';
} else {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
echo '{"code": 420, "data": "", "success": false, "error": "Please try again later."}';
}
$stmt->close();
} else {
echo '{"code": "", "data": {}, "success": true, "error": ""}';

68
user/profile/profile.php Normal file
View file

@ -0,0 +1,68 @@
<?php
// Attach Config
include('../../config.php');
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
echo '{"code": 420, "data": "", "success": false, "error": "Please try again later."}';
die("");
}
?>
<?php
// The vine-session-id you want to search for
$headers = getallheaders();
$vine_id = $_GET['id'];
// Prepare the SQL query
$sql = "SELECT * FROM accounts WHERE ID = ?";
// Prepare and bind
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $vine_id);
// Execute the statement
$stmt->execute();
// Get the result
$result = $stmt->get_result();
// Check if any rows were returned
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
if ($row["description"] == NULL) {
$description = "null";
} else {
$description = '"' . $row["description"] . '"';
}
if ($row["location"] == NULL) {
$location = "null";
} else {
$location = '"' . $row["location"] . '"';
}
if ($row["picture"] == NULL) {
$picture = "null";
} else {
$picture = '"' . $row["picture"] . '"';
}
header('Content-Type: application/json');
echo '{"code": "", "data": {"username": "' . $row['username'] . '", "profileBackground": "' . $row['color'] . '", "followerCount": ' . $row['followersc'] . ', "verified": ' . $row['verified'] . ', "vanityUrls": [], "loopCount": ' . $row['loopc'] . ', "avatarUrl": ' . $picture . ', "authoredPostCount": 22, "shareUrl": "https://vine.co/u/' . $row['id'] . '", "userId": ' . $row['id'] . ', "private": 0, "likeCount": ' . $row['likec'] . ', "postCount": ' . $row['postc'] . ', "location": ' . $location . ', "followingCount": ' . $row['followingc'] . ', "explicitContent": 0, "description": ' . $description . '}, "success": true, "error": ""}';
}
} else {
header('HTTP/1.1 404 Not Found');
header('Content-Type: application/json');
echo '{"code": 115, "data": "", "success": false, "error": "User id is not valid"}';
}
// Close the statement and connection
$stmt->close();
$conn->close();
?>