-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
executable file
·83 lines (72 loc) · 5.1 KB
/
profile.php
File metadata and controls
executable file
·83 lines (72 loc) · 5.1 KB
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
<?php /*====================================================================================
SamNews [http://samjlevy.com/samnews], open-source PHP social news application
sam j levy [http://samjlevy.com]
This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this
program. If not, see <http://www.gnu.org/licenses/>.
====================================================================================*/
include('config.php');
$profile = samq_c("SELECT login, about, last_visit, created, perm_mod, perm_admin, post_count, comment_count, vote_count, email, ip, voted_count AS score FROM users WHERE login = '" . esc($_GET['user']) . "'",1);
include('head.php');
if(count($profile) > 0) { ?>
<br />
<div class="content">
<?php foreach ($profile as $e) { ?>
<span class="page_title"><?php echo $e['login']; ?></span> <span class="profile_score"><?php echo $e['score']; ?></span><br />
<?php if(isset($e['about']) && trim($e['about']) != "") { ?>
<table class="form_table" width="350">
<tr><td><strong>about</strong><br />
<?php echo $e['about']; ?></td></tr>
</table>
<br />
<?php } ?>
<?php if((isset($e['perm_mod']) && $e['perm_mod'] == 1) || (isset($e['perm_admin']) && $e['perm_admin'] == 1)) { ?>
<table class="form_table" width="350">
<tr><td><strong>badges</strong><br />
<?php if($e['perm_mod'] == 1) echo "<img src='" . IMAGES_PATH . "mod_badge.png' title='moderator' alt='moderator' />"; ?>
<?php if($e['perm_admin'] == 1) echo "<img src='" . IMAGES_PATH . "admin_badge.png' title='administrator' alt='administrator' />"; ?>
</td></tr>
</table>
<?php } ?>
<br />
<table class="form_table" width="350">
<tr><td><strong>stats</strong><br />
last visit: <?php if(isset($e['last_visit'])) echo time_since(strtotime($e['last_visit'])); else echo "never"; ?><br />
joined: <?php echo time_since(strtotime($e['created'])) . " (" . date("M j, Y",strtotime($e['created'])) . ")"; ?><br />
<br />
<?php if($e['post_count'] != 0) { ?><a href="<?php echo SITE_URL; ?>/submissions/<?php echo $e['login']; ?>"><?php } ?><?php echo $e['post_count']; ?> submissions<?php if($e['post_count'] != 0) { ?></a><?php } ?> | <?php if($e['vote_count'] != 0) { ?><a href="<?php echo SITE_URL; ?>/voted/<?php echo $e['login']; ?>"><?php } ?><?php echo $e['vote_count']; ?> votes cast<?php if($e['vote_count'] != 0) { ?></a><?php } ?> | <?php if($e['comment_count'] != 0) { ?><a href="<?php echo SITE_URL; ?>/u/<?php echo $e['login']; ?>/comments"><?php } ?><?php echo $e['comment_count']; ?> comments<?php if($e['comment_count'] != 0) { ?></a><?php } ?>
</td></tr>
</table>
<?php // if the user is looking at his own profile, show controls
if(isset($_SESSION['user']) && $_SESSION['user'] == $e['login']) { ?>
<br />
<table class="uc_table" width="350">
<tr><td><strong>user controls</strong><br />
account email: <?php echo $e['email']; ?><br />
change: <a href="<?php echo SITE_URL; ?>/reset/about">about</a> | <a href="<?php echo SITE_URL; ?>/reset/email">email</a> | <a href="<?php echo SITE_URL; ?>/reset/pw">password</a></td></tr>
</table>
<?php } ?>
<?php // if user is logged in as admin or moderator, moderators cannot pass if they are trying to edit another moderator or admin
if( isset($_SESSION['access']) && (($_SESSION['access'] == 2 && $e['perm_mod'] != 1 && $e['perm_admin'] != 1) || $_SESSION['access'] == 3)) { ?>
<br />
<table class="admin_table" width="350">
<tr><td><strong>admin controls</strong><br />
email: <a href="mailto:<?php echo $e['email']; ?>"><?php echo $e['email']; ?></a><br />
last ip: <?php if(isset($e['ip'])) echo $e['ip']; else echo "none"; ?><br />
<br />
<a href="<?php echo SITE_URL; ?>/edit/u/<?php echo $e['login']; ?>">edit user</a> |<?php if($_GET['user'] != "[deleted]" && $_GET['user'] != $_SESSION['user']) { ?> <a href="<?php echo SITE_URL; ?>/delete/u/<?php echo $e['login']; ?>">delete user</a> |<?php } ?> <a href="<?php echo SITE_URL; ?>/ulist">user list</a><?php if($_SESSION['access'] == 3) { ?> | <a href="<?php echo SITE_URL; ?>/ctlist">category list</a><?php } ?></td></tr>
</table>
<?php } ?>
<?php }?>
</div>
<br /><br />
<? } else { ?>
<div class="content"><br />doesn't exist, <a href="javascript:history.go(-1);">back</a></div><br /><br />
<?php }
include('foot.php'); ?>