This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.php
158 lines (144 loc) · 3.95 KB
/
user.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
<?php
include_once 'common/base.php';
$user = trim($_REQUEST['user']);
$title = "User: " . $user;
include_once 'common/header.php';
if (empty($user)) {
terminalError('Need to specify a user!');
}
$userinfo = $users->getUserInfo($user);
if (!isset($userinfo['user_id'])) {
terminalError('User does not exist!');
}
$usergroups = $users->getUserGroups($userinfo['user_id']);
?>
<div class="page-header">
<div class="page-tools">
<?php
if (in_array('admin', $mygroups)) {
// leet admin tools
if (in_array('blocked', $usergroups)) {
echo '<button type="submit" id="action-unblock"> unblock user</button>';
} else {
echo '<button type="submit" id="action-block"><i class="icon-ban-circle"></i> block user</button>';
}
if (in_array('admin', $usergroups)) {
echo ' <button type="submit" id="action-demote"><i class="icon-remove"></i> de-admin</button>';
} else {
echo ' <button type="submit" id="action-promote"><i class="icon-star"></i> make admin</button>';
}
}
?>
</div>
<h1>User: <?php echo $user; ?></h1>
</div>
<table class="table table-bordered">
<tr>
<th scope="row">User id</th>
<td>
<?php echo $userinfo['user_id']; ?>
</td>
</tr>
<tr>
<th scope="row">Registered</th>
<td>
<?php echo $userinfo['user_timestamp']; ?>
</td>
</tr>
<tr>
<th scope="row">Groups</th>
<td>
<?php echo $users->formatGroups($usergroups); ?>
</td>
</tr>
</table>
<h2>Edits</h2>
<?php
$useredits = $users->getUserEdits($user);
if (empty($useredits)) {
echo '<p>User has no edits yet.</p>';
} else {
include_once 'common/classes/Pages.php'; // need for tags
$pages = new Pages($db);
?>
<table class="table table-striped">
<thead>
<tr>
<th style="width: 12em;">Timestamp</th>
<th>Page</th>
<th>Comment</th>
<th>Tags</th>
</tr>
</thead>
<tbody>
<?php
foreach ($useredits as $row) {
echo '<tr>';
echo sprintf('<td><a href="viewrev.php?revid=%1$s">%2$s</a></td>', $row['rev_id'], formatTimestamp($row['rev_timestamp']) );
echo sprintf('<td><a href="view.php?page=%1$s">%1$s</a></td>', $row['page_title']);
echo '<td>' . $row['rev_comment'] . '</td>';
$revtags = $pages->getRevTags($row['rev_id']);
echo '<td>' . $pages->formatTags($revtags) . '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
<?php
}
include_once 'common/footer.php';
?>
<script>
$('#action-block').click(function() {
$.post(
'common/ajax.users.php',
{
action: 'block',
userid: <?php echo $userinfo['user_id']; ?>
},
// success
function(data) {
document.location.reload(true);
}
);
});
$('#action-unblock').click(function() {
$.post(
'common/ajax.users.php',
{
action: 'unblock',
userid: <?php echo $userinfo['user_id']; ?>
},
// success
function(data) {
document.location.reload(true);
}
);
});
$('#action-promote').click(function() {
$.post(
'common/ajax.users.php',
{
action: 'promote',
userid: <?php echo $userinfo['user_id']; ?>
},
// success
function(data) {
document.location.reload(true);
}
);
});
$('#action-demote').click(function() {
$.post(
'common/ajax.users.php',
{
action: 'demote',
userid: <?php echo $userinfo['user_id']; ?>
},
// success
function(data) {
document.location.reload(true);
}
);
});
</script>