-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
222 lines (184 loc) · 7.44 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
<?php
/*
* Page Name: Profile Page
* Purpose: A user's profile page
* Last Updated: 6/5/2014
* Signature: Tyler Nickerson
* Copyright 2014 eDart
*
* [Do not remove this header. One MUST be included at the start of every page/script]
*
*/
include_once $_SERVER ["DOC_ROOT"] . "/scripts/php/core.php"; //Import core functionality
//If no user ID is specified, throw a not found page
if (empty($_GET['id']))
{
header ( 'Location:/notfound.php' );
exit;
}
//Get info about the given user
$newPerson = new User(array("action"=>"get", "id"=>$_GET["id"]));
$personInfo = $newPerson->run(true);
if (count($personInfo[0])==0)
{
header ( 'Location:/notfound.php' );
exit;
}
try {
//We're using 'r' for compatibility purposes
//Get the first user's info
$r = $personInfo[0];
$fname = $r ["fname"]; //First Name
$lname = $r ["lname"]; //Last Name
$profile_pic = $r ["profile_pic"]; //Profile picture
$join_date = $r ["join_date"]; //Join Date
$dob = $r ["dob"]; //Date of Birth
$gender_index = $r ["gender"]; //Gender
$gender = Lookup::Gender($gender_index); //Gender string
$pronoun = Lookup::Pronoun($gender_index); //Pronoun to describe user's gender
$lastlogin = $r["last_login"]; //Last time they were logged in
$lastseen = json_decode($r["last_location"], true); //Last location they logged in
$privacy = json_decode($r["privacy"], true); //The privacy array
$privacy = (!$privacy) ? array() : $privacy;
//If a load parameter is specified and this is 'image'
if(isset($_GET["load"]) && $_GET["load"]=="image")
{
//We're just going to print the user's image
header("Content-type: image/jpg"); //Set JPG image header
//If they don't have a profile picture
if((trim($profile_pic)=="")||(count($personInfo)==0))
{
//Use the default one
$profile_pic = file_get_contents($_SERVER["DOC_ROOT"]."/img/user_icon_200.png");
}
//If a filter is specified...
if(isset($_GET["filter"]))
{
//Apply it accordingly
switch(strtolower(trim($_GET["filter"])))
{
case "blur": //Blur the image
$feat_data_binary_blur = WideImage::loadFromString($profile_pic)->applyFilter(IMG_FILTER_GAUSSIAN_BLUR);
for($i = 0; $i < 50; $i++)
{
$get_cur_blur = $feat_data_binary_blur->asString('jpg');
$feat_data_binary_blur = WideImage::loadFromString($get_cur_blur)->applyFilter(IMG_FILTER_GAUSSIAN_BLUR);
}
$profile_pic = $feat_data_binary_blur->asString('jpg');
break;
}
}
//If a size is specified...
if(isset($_GET["size"]))
{
//Resize it accordingly
switch(strtolower(trim($_GET["size"])))
{
case "small": //(60x60)
$profile_pic = WideImage::load($profile_pic)->resize(50)->asString('jpg');
break;
case "huge": //(60x60)
$profile_pic = WideImage::load($profile_pic)->resize(1000)->asString('jpg');
break;
}
}
echo $profile_pic; //Print the image contents
exit; //Exit
}
//Change the profile picture to use the URL instead
$profile_pic = "/profile.php?id=".$_GET["id"]."&load=image";
} catch(Exception $e) {
//If the person can't be found, throw a not found page
if($personInfo==404)
{
header ( 'Location:/notfound.php' );
exit;
}
}
HTML::begin();
Head::make("$fname $lname", true);
Body::begin(true, true);
?>
<style type="text/css">
.prefix{ display:inline-block; margin-left:25px; vertical-align:top;margin-right:10px; display:inline-block; font-size:18px; }
</style>
<div id="profile_container">
<div id="profile">
<div id="cover" style="background-image:url('/profile.php?id=<?php echo $_GET["id"]; ?>&load=image&filter=blur&size=huge')">
<div class="layout-1200 uk-container-center">
<div class="uk-grid">
<div class="uk-width-1-1 reset_padding">
<div id="picture">
<?php if(isset($_SESSION["userid"])&&$_SESSION["userid"]==$_GET["id"]): ?><div onclick="pp_change_begin();" class="uk-width-1-1 uk-height-1-1 overlay"><i class="uk-icon-upload"></i></div><?php endif; ?>
<img src="/profile.php?id=<?php echo $_GET['id']; ?>&load=image">
</div>
</div>
<div class="uk-width-1-1 reset_padding">
<div id="header">
<h1><?php echo "$fname $lname"; ?></h1><br/>
<?php echo (trim($lastlogin!="")) ? "Active " . getRelativeDT(time(), $lastlogin) . " ago" : ""; ?>
</div>
</div>
</div>
</div>
</div>
<h1 id="title">Recent Activity</h1>
<div class="layout-978 uk-container-center">
<div class="uk-grid">
<!-- USER INFO -->
<div id="left" class="uk-width-1-4 uk-hidden-small">
<div class="child">
<div class="title uk-text-center">About <?php echo $fname; ?></div>
<div id="info">
<ul>
<li><span class='uk-icon-bolt'></span>eDart user #<?php echo $_GET["id"]; ?></li>
<li><span class='uk-icon-calendar'></span>Joined on <?php echo date("m/d/Y", $join_date); ?></li>
<?php echo (!in_array("last_location", $privacy)&&(count($lastseen)!=0)) ? "<li><span class='uk-icon-location-arrow'></span>Last seen near {$lastseen["properties"]["city"]}</li>" : ""; ?>
<?php echo (!in_array("gender", $privacy)&&$gender_index!=0) ? "<li><span class='uk-icon-user'></span>$gender</li>" : ""; ?>
<?php echo (!in_array("dob", $privacy)&&$dob!=0) ? "<li><span class='uk-icon-birthday-cake'></span>" . getRelativeDT(time(), $dob) . " old</li>" : ""; ?>
<li><span class='uk-icon-institution'></span>Attends WPI</li>
</ul>
</div>
</div>
<?php if(isset($_SESSION["userid"])&&$_SESSION["userid"]==$_GET["id"]): ?>
<div class="uk-text-center">
<input type="button" id="edit_button" value="Edit Profile" data-link="edit_profile" class="uk-align-center small_text uk-button uk-width-1-1" value="Edit" />
</div>
<div class="hidden">
<form id="user_image_upload_form" method="post" action="/scripts/php/widget/me/crop.php" enctype="multipart/form-data">
<input style="z-index:-200" accept="image/*" onchange="document.getElementById('user_image_upload_form').submit();" type="file" name="pp_upload" id="user_image_upload" />
</form>
</div>
<?php endif; ?>
</div>
<div class="uk-width-medium-3-4 uk-width-small-1-1">
<div class="uk-grid uk-grid-preserve reset_padding">
<!-- MAIN CONTENT -->
<div class="uk-width-medium-9-10 uk-width-small-1-1">
<div id="post_container">
<?php
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/widget/profile/recent_activity.php";
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/widget/profile/item.php";
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/widget/profile/review.php";
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/widget/profile/edit.php";
?>
</div>
</div>
<div id="right" class="uk-width-1-10 uk-hidden-small">
<ul>
<li class="profile_tab active" value="Recent Activity" title="Recent Activity" data-link="recent_activity"><span class="uk-icon-bars"></span></li>
<li class="profile_tab" value="Item Inventory" title="Recent Activity" data-link="item_board"><span class="uk-icon-cube"></span></li>
<li class="profile_tab" value="User Reviews" title="User Reviews" data-link="user_reviews" ><span class="uk-icon-star"></span></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
Body::end();
HTML::end();
?>