-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
204 lines (158 loc) · 8.99 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
namespace src;
spl_autoload_register();
include_once("./header.inc.php");
$user = new classes\User();
$posts = new classes\Post();
// TO GET ID FROM URL
if(!empty($_GET['username'])){
$username = $_GET['username'];
$users = $user->getUsernameFrom($username);
$user_id = $users[0]['id'];
$postsUserResults = $posts->getPostsUser($user_id);
// STACKING OF THE BOOTSTRAP DIVS IN 3 COLUMNS
$numberOfColumns = 3;
$bootstrapColWidth = 12 / $numberOfColumns ;
$arrayChunks = array_chunk($postsUserResults, $numberOfColumns);
}
if(!empty($_GET["username"])){
$usernameUrl = $_GET["username"];
$loggedinUser = $user->getUsernameFrom($usernameUrl);
}
$user = new classes\User();
$user->setUsername($_SESSION['user']);
$currentlyLoggedIn = $user->showUser();
$userId = $_GET["username"];
//FOLLOW
$follow = new classes\Follow();
$follow->setIsFollower((int)$currentlyLoggedIn[0]['id']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="stylesheet" href="css/style-feed.css">
<link rel="stylesheet" href="css/style-profile.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cssgram/0.1.10/cssgram.min.css">
<script src="https://kit.fontawesome.com/a7dc01cef9.js" crossorigin="anonymous"></script>
<title>Profile</title>
</head>
<body>
<main>
<?php foreach ($users as $user) : ?>
<?php
$follow->setIsFollowing($user['id']);
$userid = $follow->getIsFollowing();
?>
<div class="container-fluid container-profile clearfix">
<div class="row row-first">
<div class="col-3">
<div class="avatar">
<a href="#">
<img src="./user_avatar/<?php echo htmlspecialchars($user['avatar']); ?>" class="profile-pic-profile rounded-circle">
</a>
</div>
</div>
<div class="col-5 profile-about">
<p><span class="profile-name"><?php echo htmlspecialchars($user["username"]); ?></span></p><br>
<p class="bio"><?php echo htmlspecialchars($user["bio"]); ?></p>
</div>
<!-- EDIT BTN WEG WANNEER IK KIJK NAAR ANDER PROFIEL -->
<?php if ($_SESSION['user'] == $_GET['username']) : ?>
<div class="col-4 col-lg-4">
<a href="profileEdit.php" class="btn edit-btn">Edit profile</a>
<a href="savedPosts.php?username=<?php echo htmlspecialchars($user['username']);?>" class="btn edit-btn">Saved posts</a>
</div>
<?php endif; ?>
</div>
<div class="container-follow ">
<div class="row ">
<?php $countPosts = $posts->countPostsUser($user_id); ?>
<div class="col-4 text-center follow">
<h7 class="number-profile mb-0 d-block"><?php echo $countPosts['count'] ; ?></h7><small class="text-muted">
Posts</small>
</div>
<?php $countFollowers = $follow->countFollowers(); ?>
<div class="col-4 text-center follow">
<a href="followers.php?follower=<?php echo htmlspecialchars($user['username']);?>" name="follower">
<h7 class="number-profile mb-0 d-block"><?php echo $countFollowers['count'] ; ?></h7><small class="text-muted">Followers</small>
</a>
</div>
<?php $countFollowing = $follow->countFollowing(); ?>
<div class="col-4 text-center follow">
<a href="following.php?following=<?php echo htmlspecialchars($user['username']);?>" name="following">
<h7 class="number-profile mb-0 d-block"><?php echo $countFollowing['count'] ; ?></h7><small class="text-muted">Following</small>
</a>
</div>
</div>
<div class="row ">
<?php if ($_SESSION['user'] != $_GET['username']) : ?>
<?php $isFollowing = $follow->isFollowing(); ?>
<?php $isRequested = $follow->isRequested(); ?>
<?php $isPrivate = classes\User::isPrivateUser($user_id); ?>
<?php if (!empty($isFollowing)):?>
<div class="col-sm-12 text-center follow">
<!-- FOLLOW BTN WEG WANNEER IK KIJK NAAR EIGEN PROFIEL -->
<a href="#" class="float-left btn btn-unfollow followBtn" data-followid="<?php echo $user_id ?>">Unfollow</a>
</div>
<?php elseif (!empty($isRequested)):?>
<div class="col-sm-12 text-center follow">
<!-- Requested -->
<a href="#" class="float-left btn btn-requested requestBtn followBtn " data-followid="<?php echo $user_id ?>">Requested</a>
</div>
<?php elseif (!empty($isPrivate)):?>
<div class="col-sm-12 text-center follow">
<!-- Private-->
<a href="#" class="float-left btn btn-sendRequest requestBtn followBtn " data-followid="<?php echo $user_id ?>">Send request</a>
</div>
<?php else:?>
<div class="col-sm-12 text-center follow">
<a href="#" class="float-left btn btn-follow followBtn" data-followid="<?php echo $user_id ?>">Follow</a>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
<!-- LOOPEN OVER POSTS !-->
<div class="container-fluid container-gallery">
<?php foreach ($arrayChunks as $postsUserResults) : ?>
<div class="row">
<?php $isPrivate = classes\User::isPrivateUser($user_id); ?>
<?php if ( $isPrivate == false|| !empty($isFollowing) || $_SESSION['user'] == $_GET['username']):?>
<?php foreach ($postsUserResults as $post) : ?>
<div class="col-4">
<div class="square-image">
<a href="postDetail.php?id=<?php echo $post['id']; ?>">
<?php
$folder = "uploads/";
$file = "";
if (is_dir($folder)) {
if ($open = opendir($folder)) {
if ($file == "." || $post['photo'] == "..") continue;
$file = classes\Post::getPhoto($post['id']);
?>
<img src=<?php echo '"uploads/' . $file . '"'; ?> class=<?php echo '" img-thumbnail img-responsive ' . $posts->getSelectedFilter($post["filter_id"]) . '"'; ?>>
<?php closedir($open);
}
} ?>
</a>
</div>
</div>
<?php endforeach; ?>
<?php endif ;?>
</div>
<?php endforeach; ?>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/follow.js"></script>
<script src="js/sendRequest.js"></script>
</body>
</html>