-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
278 lines (257 loc) · 9.1 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
include_once('classes/Nudge.php');
include_once('classes/User.php');
include_once("functions.php");
session_start();
if (!isset($_SESSION["user"])) {
header("Location: login.php");
}
if (!empty($_GET['nudge'])) {
$nudge = new Nudge();
$nudge->setMyid($_SESSION['id']);
$nudgeCollection = $nudge->showNudges();
if (!empty($_GET['nid'])) {
$nudge->setPostId($_GET['nid']);
$nudge->markAsRead();
$nudgeCollection = $nudge->showNudges();
}
}
$nudges = new Nudge();
$nudges->setUserId2($_SESSION['id']);
$nudgeCount = $nudges->unreadNudges();
include_once('classes/User.php');
$user = new User();
$user->setId($_SESSION['id']);
$token = $user->tokenFromSession();
if (empty($_GET["u"])) {
header("Location: index.php");
} else {
$user = new User();
$user->setToken($_GET['u']);
$profile = $user->userFromToken();
$user->setId($profile['id']);
$myData = $user->getAllUserData();
if (!$profile) {
header("Location: index.php");
}
}
if (!empty($_POST)) {
if (!empty($_FILES['avatar']['name'])) {
$image = $_FILES['avatar']['name'];
uploadImage($image);
$user->setAvatar($image);
$user->changeImg();
header('Location: profile.php?u=' . $_GET["u"]);
} //no else, field not required
}
$nudges->setMyid($myData['id']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>profile</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans:300,400,500,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css" />
</head>
<body>
<div class="profileList">
<div class="line nudgeLine"></div>
<h2 class="profile__head">profile</h2>
<!-- profile name and page -->
<div class="white__field">
<form class="form__field form__field--profile" action="" method="POST" enctype="multipart/form-data">
<label for="avatar">
<?php if (!empty($myData['avatar'])): ?>
<img src="uploads/<?php echo $myData['avatar']; ?>"
alt="profile img" class="profile__avatar form__avatar">
<?php else: ?>
<img src="uploads/photolessUser.jpg" alt="profile img" class="profile__avatar form__avatar">
<?php endif; ?></label>
<input type="file" class="form-control white" name="avatar" id="avatar" accept="image/*">
<div>
<h2><?php echo $myData['name'] ?>
</h2>
<input type="hidden" class="form-control white" name="test" id="test" placeholder="test">
<input type="submit" value="update profile picture" name="submit"
class="btn btn--reverse btn--primary btn--hidden">
</div>
</form>
</div>
<!-- end profile name and page -->
<!-- crops -->
<h2 class="profile__head">crops</h2>
<div class="white__field white__field--crops">
<h2 class="zero">crop 1</h2>
<div class="profile__crop">
<?php if (!empty($myData['crop1'])): ?>
<p class="crop__name"><?php echo $myData['crop1'] ?>
</p>
<?php else: ?>
<?php if ($token['activationToken'] == $_GET['u']): ?>
<p class="crop__name crop1"><img src="images/plus.svg" class="img__plus">
</p>
<?php endif; ?>
<?php endif; ?>
</div>
<h2 class="zero">crop 2</h2>
<div class="profile__crop">
<?php if (!empty($myData['crop2'])): ?>
<p class="crop__name"><?php echo $myData['crop2'] ?>
</p>
<?php else: ?>
<?php if ($token['activationToken'] == $_GET['u']): ?>
<p class="crop__name crop2"><img src="images/plus.svg" class="img__plus">
</p>
<?php endif; ?>
<?php endif; ?>
</div>
<h2 class="zero">crop 3</h2>
<div class="profile__crop profile__crop--end">
<?php if (!empty($myData['crop3'])): ?>
<p class="crop__name"><?php echo $myData['crop3'] ?>
</p>
<?php else: ?>
<?php if ($token['activationToken'] == $_GET['u']): ?>
<p class="crop__name crop3"><img src="images/plus.svg" class="img__plus">
</p>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<!-- crops -->
<div class="crop1__popup">
<img src="images/nudged.svg" alt="nudge alert popup">
<h2 class="crop1Title">Add a crop to your profile.</h2>
<textarea name="nudgeMessage" id="crop1"></textarea>
<button id="crop1Btn" class="crop__popup__send" data-userId1=<?php echo $_SESSION['id'] ?>>Send</button>
</div>
<div class="crop2__popup">
<img src="images/nudged.svg" alt="nudge alert popup">
<h2 class="crop2Title">Add a crop to your profile.</h2>
<textarea name="nudgeMessage" id="crop2"></textarea>
<button id="crop2Btn" class="crop__popup__send" data-userId1=<?php echo $_SESSION['id'] ?>>Send</button>
</div>
<div class="crop3__popup">
<img src="images/nudged.svg" alt="nudge alert popup">
<h2 class="crop3Title">Add a crop to your profile.</h2>
<textarea name="nudgeMessage" id="crop3"></textarea>
<button id="crop3Btn" class="crop__popup__send" data-userId1=<?php echo $_SESSION['id'] ?>>Send</button>
</div>
<h2 class="profile__head">Nudges</h2>
<!-- send nudge -->
<?php if ($token['activationToken'] != $myData['activationToken']): ?>
<textarea name="nudgeMessage" id="nudgeMessage"></textarea>
<button class="nudge__popup__send" data-userId2=<?php echo $profile['id']; ?>
data-userId1 = <?php echo $_SESSION['id'] ?>>Send</button>
<?php else: ?>
<h4 class="profile__head--small profile__head--top">You have <?php $nudgeCount = $nudges->countNudges(); echo $nudgeCount['COUNT(*)'];?>
unread
nudges.</h4>
<?php if ($nudgeCount['COUNT(*)'] > 0): ?>
<h4 class="profile__head--small">Click <a class="anchor__profile"
href="?u=<?php echo $myData['activationToken']?>&nudge=true">here</a>
to read them!</h4>
<?php endif; ?>
<?php endif; ?>
<div class="nudge__popup nudge__complete nudge__profile">
<img src="images/nudged.svg" alt="nudge alert popup">
<h2>Nudge has been send</h2>
</div>
</div>
<div class="blur"></div>
<!-- end send nudge -->
<!-- nudge notifications -->
<?php if (isset($nudgeCollection)): ?>
<div class="blur blur--active"></div>
<div class="nudgeList">
<div class="line nudgeLine"></div>
<div class="nudgeFolder">
<?php foreach ($nudgeCollection as $nudgeItem): ?>
<?php
$nudger = new User();
$nudger->setId($nudgeItem["userId1"]);
$nudgeData = $nudger->getAllUserData();
?>
<div class="nudgeItem">
<a class="avatarlink"
href="profile.php?u=<?php echo $nudgeData['activationToken'] ?>">
<div class="member--avatar nudge--avatar"><?php if (!empty($nudgeData["avatar"])): ?>
<img src="<?php echo "uploads/" . $nudgeData["avatar"]; ?>"
alt="profile picture"><?php endif; ?>
</div>
</a>
<div class="nudge--name">
<p class="p__member--name"><?php echo $nudgeData['name']; ?>
<span>nudged you</span>
</p>
</div>
<div class="nudge--text">
<p><?php echo $nudgeItem['text']; ?>
</p>
</div>
<a href="?u=<?php echo $myData['activationToken']?>&nudge=true&nid=<?php echo $nudgeItem['id'] ?>"
class="nudgeLink">X</a>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- end nudge notifications -->
<!-- footer navigation -->
<footer>
<div class="middle">
<a href="map.php"><img src="images/map.svg" alt="map button" class="mapbtn"></a>
<div class="line"></div>
</div>
<nav>
<a href="index.php"><img src="images/home.svg" alt="home icon"></a>
<a href="allMyCommunities.php"><img src="images/list.svg" alt="list icon"></a>
<div>
<?php if ($nudgeCount['COUNT(*)'] > 0):?>
<div class="test"></div>
<?php endif; ?>
<a
href="?u=<?php echo $myData['activationToken']?>&nudge=true"><img
src="images/notification.svg" alt="notification icon"></a>
</div>
<a
href="profile.php?u=<?php echo $token['activationToken']; ?>"><img
src="images/profile.svg" alt="profile icon"></a>
</nav>
<!-- end footer navigation -->
<script src="js/nudgeBlur.js"></script>
<script src="js/profileNudge.js"></script>
<script src="js/fillCrops.js"></script>
<script src="js/registerImg.js"></script>
<?php if (isset($nudgeCollection)): ?>
<script>
const queryString = window.location.search;
topcss = 100
opacitycss = 0
if (queryString.includes("nudge")) {
if (queryString.includes('nid')) {
document.querySelector('.blur--active').style.opacity = 1
document.querySelector('.nudgeList').style.top = "46vh"
} else {
let animation = setInterval(myMethod, 2);
function myMethod() {
if (topcss <= 45) {
clearInterval(animation)
}
if (topcss >= 45) {
document.querySelector('.blur--active').style.opacity = opacitycss
document.querySelector('.nudgeList').style.top = topcss + "vh"
topcss -= 3
opacitycss += 0.1
}
}
}
}
</script>
<?php endif; ?>
</body>
</html>