-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
76 lines (67 loc) · 1.86 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
<?php
require_once 'core/init.php';
ob_start();
require_once 'includes/header.php';
if(!$userID = Input::get('user')) {
Redirect::to('index.php');
} else {
$user = new User();
if($user->hasPermission('banned')){
Redirect::to('index.php');
return false;
}
if($user->data()->id !== $userID) {
Redirect::to('index.php');
} else {
$data = $user->data();
require_once 'includes/nav.php';
?>
<div id="profile_cont">
<img src="images/users/profile_pics/<?php echo $data->id; ?>.jpg" onerror="this.onerror=null;this.src='images/blank_prof.jpg';" alt="Profile Pic" />
<br /><br />
<p>Hello <?php echo escape($data->name); ?>!</p>
<br />
<?php
}
}
?>
<input id="update_btn" onclick="window.location.assign('update.php')" type="button" value="Edit Profile" />
<input id="changepass_btn" onclick="window.location.assign('changepassword.php')" type="button" value="Change Password" />
<br /><br />
<h4>Your Threads</h4>
<br />
<ul class="threads">
<?php
$threads = DB::getInstance();
$threads->get('threads', array('user_id', '=', $user->data()->id));
if($threads->count()){
foreach($threads->results() as $item){
echo "<li data-id='$item->id'>$item->thread_title</li>";
}
} else {
echo "<li>You have no threads..</li>";
}
?>
</ul>
<br /><br />
<h4>Threads you have recently participated in..</h4>
<br />
<ul class="posts">
<?php
$comments = DB::getInstance();
$comments->query("SELECT * FROM comments WHERE user_id = ? LIMIT 0,5", array($user->data()->id));
if($comments->count()){
foreach($comments->results() as $item){
$thread = DB::getInstance();
$thread->get('threads', array('id', '=', $item->thread_id));
echo "<li data-id='$item->thread_id'>$item->comment - ".$thread->first()->thread_title ."</li>";
}
} else {
echo "<li>No activity available..</li>";
}
?>
</ul>
</div>
<?php
require_once 'includes/footer.php';
ob_end_flush();