1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 05.03.2018 12:57 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Pages\Deprecated; |
7
|
|
|
|
8
|
|
|
use Account; |
9
|
|
|
use Modules\sn_module; |
10
|
|
|
use SN; |
11
|
|
|
use template; |
12
|
|
|
|
13
|
|
|
class PageAdminUserView extends PageDeprecated { |
14
|
|
|
private static $formats = [ |
15
|
|
|
'sys_time_human_system' => [ |
16
|
|
|
'register_time', |
17
|
|
|
'onlinetime', |
18
|
|
|
'ally_register_time', |
19
|
|
|
'news_lastread', |
20
|
|
|
'banaday', |
21
|
|
|
'vacation', |
22
|
|
|
'vacation_next', |
23
|
|
|
'deltime', |
24
|
|
|
'que_processed', |
25
|
|
|
], |
26
|
|
|
'prettyNumberStyledDefault' => [ |
27
|
|
|
'account_metamatter', |
28
|
|
|
'account_metamatter_total', |
29
|
|
|
|
30
|
|
|
'metal', |
31
|
|
|
'crystal', |
32
|
|
|
'deuterium', |
33
|
|
|
'dark_matter', |
34
|
|
|
'dark_matter_total', |
35
|
|
|
'metamatter', |
36
|
|
|
'metamatter_total', |
37
|
|
|
|
38
|
|
|
'player_rpg_explore_xp', |
39
|
|
|
'player_rpg_explore_level', |
40
|
|
|
'lvl_minier', |
41
|
|
|
'xpminier', |
42
|
|
|
'player_rpg_tech_xp', |
43
|
|
|
'player_rpg_tech_level', |
44
|
|
|
'lvl_raid', |
45
|
|
|
'xpraid', |
46
|
|
|
'raids', |
47
|
|
|
'raidsloose', |
48
|
|
|
'raidswin', |
49
|
|
|
'total_rank', |
50
|
|
|
'total_points', |
51
|
|
|
|
52
|
|
|
// Message counts |
53
|
|
|
'new_message', |
54
|
|
|
'mnl_alliance', |
55
|
|
|
'mnl_joueur', |
56
|
|
|
'mnl_attaque', |
57
|
|
|
'mnl_spy', |
58
|
|
|
'mnl_exploit', |
59
|
|
|
'mnl_transport', |
60
|
|
|
'mnl_expedition', |
61
|
|
|
'mnl_buildlist', |
62
|
|
|
'msg_admin', |
63
|
|
|
], |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
private static $blocks = [ |
67
|
|
|
'Аккаунт' => [ |
68
|
|
|
// 'account_id', |
69
|
|
|
'account_name', |
70
|
|
|
'account_password', |
71
|
|
|
'account_salt', |
72
|
|
|
'account_email', |
73
|
|
|
'account_email_verified', |
74
|
|
|
'account_register_time', |
75
|
|
|
'account_language', |
76
|
|
|
'account_metamatter', |
77
|
|
|
'account_metamatter_total', |
78
|
|
|
], |
79
|
|
|
'Основная информация' => [ |
80
|
|
|
'id', |
81
|
|
|
'username', |
82
|
|
|
'password', |
83
|
|
|
'salt', |
84
|
|
|
'user_last_browser_id', |
85
|
|
|
'browser_user_agent', |
86
|
|
|
'user_lastip', |
87
|
|
|
'user_last_proxy', |
88
|
|
|
'register_time', |
89
|
|
|
'onlinetime', |
90
|
|
|
'authlevel', |
91
|
|
|
'admin_protection', |
92
|
|
|
'id_planet', |
93
|
|
|
'galaxy', |
94
|
|
|
'system', |
95
|
|
|
'planet', |
96
|
|
|
'current_planet', |
97
|
|
|
'server_name', |
98
|
|
|
], |
99
|
|
|
'Профиль пользователя' => [ |
100
|
|
|
'email', |
101
|
|
|
'email_2', |
102
|
|
|
'gender', |
103
|
|
|
'avatar', |
104
|
|
|
'sign', |
105
|
|
|
'user_birthday', |
106
|
|
|
], |
107
|
|
|
'Ресурсы' => [ |
108
|
|
|
'metal', |
109
|
|
|
'crystal', |
110
|
|
|
'deuterium', |
111
|
|
|
'dark_matter', |
112
|
|
|
'dark_matter_total', |
113
|
|
|
'metamatter', |
114
|
|
|
'metamatter_total', |
115
|
|
|
'player_race', |
116
|
|
|
], |
117
|
|
|
'Альянс' => [ |
118
|
|
|
'ally_id', |
119
|
|
|
'ally_tag', |
120
|
|
|
'ally_name', |
121
|
|
|
'ally_register_time', |
122
|
|
|
'ally_rank_id', |
123
|
|
|
'user_as_ally', |
124
|
|
|
], |
125
|
|
|
'Очки' => [ |
126
|
|
|
'player_rpg_explore_xp', |
127
|
|
|
'player_rpg_explore_level', |
128
|
|
|
'lvl_minier', |
129
|
|
|
'xpminier', |
130
|
|
|
'player_rpg_tech_xp', |
131
|
|
|
'player_rpg_tech_level', |
132
|
|
|
'lvl_raid', |
133
|
|
|
'xpraid', |
134
|
|
|
'raids', |
135
|
|
|
'raidsloose', |
136
|
|
|
'raidswin', |
137
|
|
|
'total_rank', |
138
|
|
|
'total_points', |
139
|
|
|
], |
140
|
|
|
'Блокировка, отпуск и удаление' => [ |
141
|
|
|
'immortal', |
142
|
|
|
'bana', |
143
|
|
|
'banaday', |
144
|
|
|
'vacation', |
145
|
|
|
'vacation_next', |
146
|
|
|
'deltime', |
147
|
|
|
], |
148
|
|
|
'Основные настройки интерфейса' => [ |
149
|
|
|
'lang', |
150
|
|
|
'template', |
151
|
|
|
'skin', |
152
|
|
|
'design', |
153
|
|
|
], |
154
|
|
|
'Новости и сообщения' => [ |
155
|
|
|
'news_lastread', |
156
|
|
|
'new_message', |
157
|
|
|
'mnl_alliance', |
158
|
|
|
'mnl_joueur', |
159
|
|
|
'mnl_attaque', |
160
|
|
|
'mnl_spy', |
161
|
|
|
'mnl_exploit', |
162
|
|
|
'mnl_transport', |
163
|
|
|
'mnl_expedition', |
164
|
|
|
'mnl_buildlist', |
165
|
|
|
'msg_admin', |
166
|
|
|
], |
167
|
|
|
'Прочие настройки' => [ |
168
|
|
|
'noipcheck', |
169
|
|
|
'options', |
170
|
|
|
'user_time_measured', |
171
|
|
|
], |
172
|
|
|
'Системные поля' => [ |
173
|
|
|
'que_processed', |
174
|
|
|
'user_birthday_celebrated', |
175
|
|
|
'user_bot', |
176
|
|
|
'parent_account_id', |
177
|
|
|
'parent_account_global', |
178
|
|
|
], |
179
|
|
|
]; |
180
|
|
|
|
181
|
|
|
private static $extras = [ |
182
|
|
|
'account_password' => [ |
183
|
|
|
'TYPE' => 'password', |
184
|
|
|
], |
185
|
|
|
]; |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @param null|template $template |
189
|
|
|
* |
190
|
|
|
* @return null|template |
191
|
|
|
*/ |
192
|
|
|
public static function modelStatic($template = null) { |
193
|
|
|
global $user; |
|
|
|
|
194
|
|
|
|
195
|
|
|
$user_id = sys_get_param_id('uid'); |
196
|
|
|
if (!($user_row = db_user_by_id($user_id))) { |
|
|
|
|
197
|
|
|
return $template; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
if (empty($user['authlevel']) || $user['authlevel'] < $user_row['authlevel']) { |
201
|
|
|
messageBoxAdmin(SN::$lang['admin_title_access_denied']); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
|
205
|
|
|
if (!empty(sys_get_param('account_password_change')) && ($password = trim(sys_get_param('account_password')))) { |
|
|
|
|
206
|
|
|
$account = new Account(); |
207
|
|
|
$account->dbGetByPlayerId($user_id); |
208
|
|
|
|
209
|
|
|
$account->db_set_password($password, ''); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
return $template; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public static function viewStatic($template = null) { |
|
|
|
|
216
|
|
|
global $user; |
|
|
|
|
217
|
|
|
|
218
|
|
|
define('IN_ADMIN', true); |
219
|
|
|
|
220
|
|
|
messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
221
|
|
|
|
222
|
|
|
$user_id = sys_get_param_id('uid'); |
223
|
|
|
if (!($user_row = db_user_by_id($user_id))) { |
|
|
|
|
224
|
|
|
messageBoxAdmin(sprintf(SN::$lang['adm_dm_user_none'], $user_id)); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
if (empty($user['authlevel']) || $user['authlevel'] <= $user_row['authlevel']) { |
228
|
|
|
messageBoxAdmin(SN::$lang['admin_title_access_denied']); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$account = new \Account(); |
232
|
|
|
$account->dbGetByPlayerId($user_id); |
233
|
|
|
foreach ([ |
234
|
|
|
'account_id', |
235
|
|
|
'account_name', |
236
|
|
|
'account_password', |
237
|
|
|
'account_salt', |
238
|
|
|
'account_email', |
239
|
|
|
'account_email_verified', |
240
|
|
|
'account_register_time', |
241
|
|
|
'account_language', |
242
|
|
|
'account_metamatter', |
243
|
|
|
'account_metamatter_total', |
244
|
|
|
] as $accountField) { |
245
|
|
|
$user_row[$accountField] = $account->$accountField; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
if (!empty($user_row['user_last_browser_id'])) { |
249
|
|
|
$temp = doquery("SELECT `browser_user_agent` FROM `{{security_browser}}` WHERE `browser_id` = {$user_row['user_last_browser_id']}", true); |
250
|
|
|
$user_row['browser_user_agent'] = $temp['browser_user_agent']; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
foreach (self::$formats as $callable => $field_list) { |
254
|
|
|
foreach ($field_list as $field_name) { |
255
|
|
|
$user_row[$field_name] = call_user_func($callable, $user_row[$field_name]); |
256
|
|
|
} |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
$template = gettemplate('admin/admin_user', true); |
|
|
|
|
260
|
|
|
|
261
|
|
|
$result = [ |
262
|
|
|
'PAGE_HEADER' => "[{$user_row['id']}] {$user_row['username']}", |
263
|
|
|
'USER_ID' => $user_row['id'], |
264
|
|
|
]; |
265
|
|
|
$exclude = $user_row; |
266
|
|
|
foreach (self::$blocks as $title => $fields) { |
267
|
|
|
// $template->assign_recursive(['.' => ['block' => [self::userBlockAssign($exclude, $title, $fields)]]]); |
|
|
|
|
268
|
|
|
$result['.']['block'][] = self::userBlockAssign($exclude, $title, $fields); |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
if (!empty($exclude)) { |
272
|
|
|
$result['.']['block'][] = self::userBlockAssign($exclude, '!!! НЕИЗВЕСТНЫЕ ПАРАМЕТРЫ !!!', array_keys($exclude)); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
$template->assign_recursive($result); |
276
|
|
|
|
277
|
|
|
return $template; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @param array $exclude |
282
|
|
|
* @param int|string $title |
283
|
|
|
* @param array $fields |
284
|
|
|
* |
285
|
|
|
* @return array |
286
|
|
|
*/ |
287
|
|
|
private static function userBlockAssign(&$exclude, $title, $fields) { |
288
|
|
|
$block = [ |
289
|
|
|
'TITLE' => $title, |
290
|
|
|
]; |
291
|
|
|
foreach ($fields as $field) { |
292
|
|
|
$fieldBlock = [ |
293
|
|
|
'NAME' => $field, |
294
|
|
|
'VALUE' => isset($exclude[$field]) ? $exclude[$field] : 'N/A', |
295
|
|
|
]; |
296
|
|
|
$fieldBlock += self::renderExtra($field); |
297
|
|
|
$block['.']['field'][] = $fieldBlock; |
298
|
|
|
unset($exclude[$field]); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
return $block; |
302
|
|
|
|
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
private static function renderExtra($field) { |
306
|
|
|
$result = []; |
307
|
|
|
|
308
|
|
|
if (isset(self::$extras[$field])) { |
309
|
|
|
foreach (self::$extras[$field] as $extraName => $extraContent) { |
310
|
|
|
$result[$extraName] = $extraContent; |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
return $result; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
} |
318
|
|
|
|
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state