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