This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
profile.php
99 lines (92 loc) · 3 KB
/
profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
require_once "pdo.php";
require_once "head.php";
if (!isset($_GET['id']) && !isset($_SESSION['user_id'])) {
include 'head.php';
echo "<p align='center'>PLEASE LOGIN</p>";
echo "<br />";
echo "<p align='center'>Redirecting in 3 seconds</p>";
header("refresh:3;url=login.php");
die();
}
if (isset($_GET['id'])) {
$userpfp = './assets/images/default-user-square.png';
$stmt = $pdo->prepare("SELECT * FROM account WHERE user_id=?");
$stmt->execute([$_GET['id']]);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) > 0) {
foreach ($rows as $test) {
if ($test['pfp'] != null) {
$userpfp = $test['pfp'];
}
$show_email = $test['show_email'];
$username = $test['username'];
$name = $test['name'];
$pfp = $userpfp;
$about = $test['about'];
$email = ($show_email === "True") ? $test['email'] : 'Hidden';
}
} else {
echo "<p align='center' class='text-danger'>User not found</p>";
die();
}
} else if (isset($_SESSION['user_id'])) {
$userpfp = './assets/images/default-user-square.png';
$stmt = $pdo->prepare("SELECT * FROM account WHERE user_id=?");
$stmt->execute([$_SESSION['user_id']]);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) > 0) {
foreach ($rows as $test) {
if ($test['pfp'] != null) {
$userpfp = $test['pfp'];
}
$show_email = $test['show_email'];
$username = $test['username'];
$name = $test['name'];
$pfp = $userpfp;
$about = $test['about'];
$email = ($show_email === "True") ? $test['email'] : 'Hidden';
}
} else {
echo "<p align='center' class='text-danger'>User not found</p>";
die();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?= (isset($name)) ? $username . " ($name)" : $username ?></title>
<style>
iframe {
height: 150px !important;
width: 250px !important;
float: right;
right: 0;
position: absolute;
}
</style>
</head>
<body>
<?php
include_once "navbar.php";
?>
<br />
<div class="card" style="width: 18rem;margin: auto;">
<img src="<?= $pfp ?>" height="280px" class="card-img-top" alt="User profile picture">
<div class="card-body">
<h5 class="card-title"><?= htmlentities($username) ?></h5>
<p class="card-text"><?= htmlentities($name) ?></p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"><?= htmlentities($about) ?></li>
<li class="list-group-item">Undefined</li>
<li class="list-group-item">Undefined</li>
</ul>
<div class="card-body">
<a href="#" class="card-link">Undefined</a>
<a href="#" class="card-link">Undefined</a>
</div>
</div>
</body>
</html>