-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuserProfile.php
75 lines (58 loc) · 2.36 KB
/
userProfile.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
<?php
require_once("bootstrap/bootstrap.php");
//Check if user session is active (Is user logged in?)
User::userLoggedIn();
// Get username from username paramater in URL
$username = $_GET['username'];
//get user_id of the loggedin user
$user_id = User::getUserId();
//retrieve all information for this user from the DB via User class
$profile = Follow::getUserProfile($username);
//if user is visiting his own profile, we should redirect to his full user profile with edit buttons
if($user_id === $profile['id']){
header("location: profile.php");
}
//check if following this user
$follows = Follow::isFollowing($user_id, $profile['id']);
//Get all posts for this user profile
$userPosts = User::getUserPosts($profile['id']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/normalize.css">
<title><?php echo $username; ?></title>
</head>
<body>
<?php include_once("nav.incl.php"); ?>
<div class="profile">
<h2><?php echo $profile['username']; ?></h2>
<?php if ($profile['image'] != "filler.png"): ?>
<img src="images/profilePictures/<?php echo $profile['id'] . $profile['image']; ?>" alt="Profile Picture"
class="profilePicture">
<?php else: ?>
<img src="images/profilePictures/filler.png" alt="Profile Picture" class="profilePicture">
<?php endif ?>
<div class="profileContainer lastItem">
<p class="profileLabel">Description</p>
<p><?php echo $profile['description']; ?></p>
</div>
<?php if (Follow::NotTryingToFollowMyself($user_id, $profile['id'])): ?>
<a href="#" id="followBtn" class="btnProfile" data-id="<?php echo $profile['id'] ?>"><?php echo $follows ?></a>
<?php endif; ?>
<div class="userPosts">
<?php foreach ($userPosts as $u): ?>
<a href="details.php?id=<?php echo $u['id']; ?>"><img src="images/<?php echo $u['url_cropped'] ?>"></a>
<?php endforeach; ?>
</div>
</div>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="js/follow.js"></script>
<script src="js/navigation.js"></script>
</body>
</html>