forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_users.php
executable file
·168 lines (141 loc) · 8.76 KB
/
admin_users.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
<?php
use Utils\Database\XDb;
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
if ($usr['admin']) {
if (isset($_REQUEST['userid'])) {
$user_id = $_REQUEST['userid'];
tpl_set_var('userid', $user_id);
}
if (checkField('countries', $lang))
$lang_db = $lang;
else
$lang_db = "en";
$rsuser = XDb::xSql("SELECT hidden_count, founds_count, log_notes_count, notfounds_count,last_login,
username, date_created,description, email,is_active_flag,
stat_ban,activation_code,hide_flag,countries.$lang_db country, verify_all
FROM `user` LEFT JOIN countries ON (user.country=countries.short) WHERE user_id=? ", $user_id);
$record = XDb::xFetchArray($rsuser);
$user = new \lib\Objects\User\User(array('userId'=>$_REQUEST['userid']));
$user->loadExtendedSettings();
if(isset($_POST['save']) && isset($_POST['note_content']) && $_POST['note_content']!="") {
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, false, $_POST['note_content']);
Header("Location: viewprofile.php?userid=".$user_id);
}
if (isset($_GET['stat_ban']) && $_GET['stat_ban'] == 1 && $usr['admin']) {
$q = "UPDATE user SET stat_ban = 1 - stat_ban WHERE user_id = " . intval($user_id);
if ($record["stat_ban"] == 0) {
$record["stat_ban"] = 1;
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, true, lib\Objects\User\AdminNote::BAN_STATS);
}
else if($record["stat_ban"] == 1) {
$record["stat_ban"] = 0;
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, true, lib\Objects\User\AdminNote::UNBAN_STATS);
}
XDb::xQuery($q);
}
if(isset($_GET['hide_flag'])){
if ($_GET['hide_flag'] == 10 && $usr['admin']) {
$q = "UPDATE user SET hide_flag = 10 WHERE user_id = " . intval($user_id);
XDb::xQuery($q);
}
if ($_GET['hide_flag'] == 0 && $usr['admin']) {
$q = "UPDATE user SET hide_flag = 0 WHERE user_id = " . intval($user_id);
XDb::xQuery($q);
}
}
// force all caches to be verified - sql
if(isset($_GET['verify_all'])) {
if ($_GET['verify_all'] == 1 && $usr['admin']) {
$q = "UPDATE user SET verify_all = '1' WHERE user_id = '" . intval($user_id) . "'";
$record["verify_all"] = 1;
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, true, lib\Objects\User\AdminNote::VERIFY_ALL);
XDb::xQuery($q);
}
if ($_GET['verify_all'] == 0 && $usr['admin']) {
$q = "UPDATE user SET verify_all = 0 WHERE user_id = " . intval($user_id);
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, true, lib\Objects\User\AdminNote::NO_VERIFY_ALL);
$record["verify_all"] = 0;
XDb::xQuery($q);
}
}
// end force
if(isset($_REQUEST['ignoreFoundLimit']) && $_REQUEST['ignoreFoundLimit'] != ''){
$newIgnoreFoundLimit = intval($_REQUEST['ignoreFoundLimit']);
if ($newIgnoreFoundLimit == 1) {
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user->getUserId(), true, lib\Objects\User\AdminNote::IGNORE_FOUND_LIMIT);
} else {
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user->getUserId(), true, lib\Objects\User\AdminNote::IGNORE_FOUND_LIMIT_RM);
}
$db = \lib\Database\DataBaseSingleton::Instance();
$db->multiVariableQuery('INSERT INTO user_settings (user_id, newcaches_no_limit) VALUES (:2, :1) ON DUPLICATE KEY UPDATE newcaches_no_limit = :1', $newIgnoreFoundLimit, $user->getUserId());
$db->reset();
unset ($user);
$user = new \lib\Objects\User\User(array('userId'=>$_REQUEST['userid']));
$user->loadExtendedSettings();;
}
//ban
if (isset($_GET['is_active_flag']) && $_GET['is_active_flag'] == 1 && $usr['admin']) {
$q = "UPDATE user SET is_active_flag = 1 - is_active_flag, `activation_code`='' WHERE user_id = " . intval($user_id);
if ($record["is_active_flag"] == 0) {
$record["is_active_flag"] = 1;
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, true, lib\Objects\User\AdminNote::UNBAN);
}
else if($record["is_active_flag"] == 1) {
$record["is_active_flag"] = 0;
lib\Objects\User\AdminNote::addAdminNote($usr['userid'], $user_id, true, lib\Objects\User\AdminNote::BAN);
}
XDb::xQuery($q);
}
if ($usr['userid'] == $super_admin_id) {
tpl_set_var('remove_all_logs', '<p><img src="tpl/stdstyle/images/blue/arrow2.png" alt="" align="middle" /> <a href="removelog.php?userid=' . $user_id . '"><font color="#ff0000">' . tr('admin_users_remove_logs') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-red.png" align="top" alt="" /></p>');
} else
tpl_set_var('remove_all_logs', '');
if (!$record['activation_code']) {
tpl_set_var('activation_codes', tr('account_is_actived'));
} else {
tpl_set_var('activation_codes', $record['activation_code']);
}
if ($record['last_login'] == "0000-00-00 00:00:00") {
$userlogin = tr('NoDataAvailable');
} else {
$userlogin = strftime("%d-%m-%Y", strtotime($record['last_login']));
}
tpl_set_var('lastlogin', $userlogin);
tpl_set_var('username', $record['username']);
tpl_set_var('country', htmlspecialchars($record['country'], ENT_COMPAT, 'UTF-8'));
tpl_set_var('registered', strftime("%d-%m-%Y", strtotime($record['date_created'])));
tpl_set_var('email', strip_tags($record['email']));
tpl_set_var('description', nl2br($record['description']));
if ($record['is_active_flag'])
tpl_set_var('is_active_flags', ' <a href="admin_users.php?userid=' . $user_id . '&is_active_flag=1"><font color="#ff0000">' . tr('lock') . ' ' . tr('user_account') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-red.png" align="top" alt="" />');
else
tpl_set_var('is_active_flags', ' <a href="admin_users.php?userid=' . $user_id . '&is_active_flag=1"><font color="#228b22">' . tr('unlock') . ' ' . tr('user_account') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-green.png" align="bottom" alt="" />');
if (!$record['stat_ban'])
tpl_set_var('stat_ban', ' <a href="admin_users.php?userid=' . $user_id . '&stat_ban=1"><font color="#ff0000">' . tr('lock') . ' ' . tr('user_stats') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-red.png" align="top" alt="" />');
else
tpl_set_var('stat_ban', ' <a href="admin_users.php?userid=' . $user_id . '&stat_ban=1"><font color="#228b22">' . tr('unlock') . ' ' . tr('user_stats') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-green.png" align="top" alt="" />');
if($user->getFoundGeocachesCount() < 10){
$ignoreFoundLimit = $user->isIngnoreGeocacheLimitWhileCreatingNewGeocache();
if($ignoreFoundLimit){
$translation = tr('ignoreFoundLimitRm');
} else {
$translation = tr('ignoreFoundLimitAdd');
}
$ignoreFoundLimitHtml = '<p><img src="tpl/stdstyle/images/blue/arrow2.png" alt="" align="middle" /> <span class="content-title-noshade txt-blue08"><a href="admin_users.php?userid=' . $user_id . '&ignoreFoundLimit='. (int) !$ignoreFoundLimit .'"><font color="#ff0000">'.$translation.'</font></a><img src="' . $stylepath . '/images/blue/atten-red.png" align="top" alt="" /></span></p>';
tpl_set_var('ignoreFoundLimit', $ignoreFoundLimitHtml);
} else {
tpl_set_var('ignoreFoundLimit', '');
}
// force all caches to be verified - form
$verify_all = $record['verify_all'];
if ($verify_all == 0) {
tpl_set_var('hide_flag', '<p><img src="tpl/stdstyle/images/blue/arrow2.png" alt="" align="middle" /> <a href="admin_users.php?userid=' . $user_id . '&verify_all=1"><font color="#ff0000">' . tr('admin_users_verify_all') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-red.png" align="top" alt="" /></p>');
} else {
tpl_set_var('hide_flag', '<p><img src="tpl/stdstyle/images/blue/arrow2.png" alt="" align="middle" /> <a href="admin_users.php?userid=' . $user_id . '&verify_all=0"><font color="#228b22">' . tr('admin_users_verify_none') . '</font></a> <img src="' . $stylepath . '/images/blue/atten-green.png" align="top" alt="" /></p>');
}
tpl_set_var('form_title', tr('admin_notes_content'));
tpl_set_var('submit_button', tr('pt032'));
$tplname = 'admin_users';
tpl_BuildTemplate();
}