-
Notifications
You must be signed in to change notification settings - Fork 3
/
viewProfile.php
123 lines (98 loc) · 3.62 KB
/
viewProfile.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
<script>
var username = window.location.hash.substring(1);
document.cookie = "theirUsername = " + username;
if( window.localStorage )
{
if( !localStorage.getItem('firstLoad') )
{
localStorage['firstLoad'] = true;
window.location.reload();
}
else
localStorage.removeItem('firstLoad');
}
</script>
<?php
session_start();
include 'database.php';
$dbConn = getDatabaseConnection();
function getImages() {
global $dbConn;
$sql = "SELECT pictures.imageID, users.username
FROM `pictures`
LEFT JOIN `users` on pictures.userID = users.user_id
WHERE users.username = :username";
$stmt = $dbConn->prepare($sql);
$stmt->execute(array(":username"=> $_COOKIE['theirUsername']));
$records = $stmt->fetchAll();
$j = 0;
echo "<div class='postedImages'>";
for($i=0; $i < count($records); $i++) {
echo "<img src='downloadFile.php?imageID=" . $records[$i]["imageID"] . "' id='images'>";
$j++;
if($j % 3 == 0) {
echo "<br>";
}
}
echo "</div>";
}
function getProfilePicture() {
global $dbConn;
$sql = "SELECT profile_pictures.imageID, users.username
FROM `profile_pictures`
LEFT JOIN `users` on profile_pictures.userID = users.user_id
WHERE users.username = :username";
$stmt = $dbConn->prepare($sql);
$stmt->execute(array(":username"=> $_COOKIE['theirUsername']));
$records = $stmt->fetchAll();
if(count($records) >= 1){
echo "<img src='downloadProfilePicture.php?imageID=" . $records[0]["imageID"] . "' class='profilePic' alt='Avatar' style='border-radius: 50%; width:10%'>";
}
else{
echo "<img src='images/avatar.png' class='profilePic' style='border-radius: 50%; width:10%'>";
}
}
function getLimeData(){
global $dbConn;
$sql = "SELECT lime.referralCode, lime.rides
FROM `lime`
LEFT JOIN `users` on lime.userID = users.user_id
WHERE users.username = :username";
$stmt = $dbConn->prepare($sql);
$stmt->execute(array(":username"=> $_COOKIE['theirUsername']));
$records = $stmt->fetchAll();
if(count($records) == 1){
echo "<br><div id= 'bio'><h3>Referral Code: <br>" . $records[0]["referralCode"] . "<br> History:<br> I've been on " . $records[0]['rides'] . " rides</h3></div>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo "@" . $_COOKIE['theirUsername']; ?> | Scoot</title>
<link rel="stylesheet" type="text/css" href="styles/profilePageStyle.css">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<link rel="icon" type="image/png" sizes="96x96" href="icon/favicon-96x96.png">
</head>
<body>
<h1><img src="images/scoot.png" id="logo" onclick="window.location.href='home.php'" style="cursor:pointer"></h1>
<div id="nav_div">
<nav>
<a style="margin-right:200px"href="home.php"> Home </a>
<a href="logout.php"> Logout </a>
</nav>
</div>
<?php
getProfilePicture();
echo "<br>";
getLimeData();
?>
<h2><?php echo "@{$_COOKIE['theirUsername']}"; ?></h2>
<div align="center" class="postedImages">
<?php
getImages();
?>
</div>
</body>
</html>