supernova-ws /
SuperNova
| 1 | <?php |
||||||
| 2 | /** @noinspection SqlResolve */ |
||||||
| 3 | /** @noinspection PhpUnnecessaryCurlyVarSyntaxInspection */ |
||||||
| 4 | /** @noinspection PhpDeprecationInspection */ |
||||||
| 5 | |||||||
| 6 | /** |
||||||
| 7 | * Project "SuperNova.WS" copyright (c) 2009-2025 Gorlum |
||||||
| 8 | * @version #46a157# |
||||||
| 9 | **/ |
||||||
| 10 | |||||||
| 11 | use Player\PlayerStatic; |
||||||
| 12 | |||||||
| 13 | const INSIDE = true; |
||||||
| 14 | const INSTALL = false; |
||||||
| 15 | const IN_ADMIN = true; |
||||||
| 16 | |||||||
| 17 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
||||||
| 18 | |||||||
| 19 | SnTemplate::messageBoxAdminAccessDenied(3); |
||||||
| 20 | |||||||
| 21 | global $config, $lang, $user; |
||||||
| 22 | |||||||
| 23 | if ($user['authlevel'] < 3) { |
||||||
| 24 | sys_redirect(SN_ROOT_VIRTUAL . 'admin/banned.php'); |
||||||
| 25 | } |
||||||
| 26 | |||||||
| 27 | ini_set('memory_limit', SN::$config->stats_php_memory ?: '256M'); |
||||||
| 28 | |||||||
| 29 | lng_include('admin'); |
||||||
| 30 | |||||||
| 31 | $is_players_online_page = defined('ADMIN_USER_OVERVIEW') && ADMIN_USER_OVERVIEW === true; |
||||||
| 32 | |||||||
| 33 | $sort_fields = array( |
||||||
| 34 | SORT_ID => 'id', |
||||||
| 35 | SORT_NAME => 'username', |
||||||
| 36 | SORT_EMAIL => 'email', |
||||||
| 37 | SORT_IP => 'user_lastip', |
||||||
| 38 | SORT_TIME_REGISTERED => 'register_time', |
||||||
| 39 | SORT_TIME_LAST_VISIT => 'onlinetime', |
||||||
| 40 | SORT_TIME_BAN_UNTIL => 'banaday', |
||||||
| 41 | SORT_REFERRAL_COUNT => 'referral_count', |
||||||
| 42 | SORT_REFERRAL_DM => 'referral_dm', |
||||||
| 43 | SORT_VACATION => 'vacation', |
||||||
| 44 | ); |
||||||
| 45 | |||||||
| 46 | $sort = sys_get_param_int('sort', SORT_ID); |
||||||
| 47 | $sort = $sort_fields[$sort] ? $sort : SORT_ID; |
||||||
| 48 | |||||||
| 49 | if (($action = sys_get_param_int('action')) && ($user_id = sys_get_param_id('uid')) && ($user_selected = db_user_by_id($user_id, false))) { |
||||||
|
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...
|
|||||||
| 50 | if ($user_selected['authlevel'] < $user['authlevel'] && $user['authlevel'] >= 3) { |
||||||
| 51 | switch ($action) { |
||||||
| 52 | case ACTION_DELETE: |
||||||
| 53 | PlayerStatic::DeleteSelectedUser($user_id); |
||||||
| 54 | sys_redirect("{$_SERVER['SCRIPT_NAME']}?sort={$sort}"); |
||||||
| 55 | break; |
||||||
| 56 | |||||||
| 57 | case ACTION_USE: |
||||||
| 58 | // Impersonate |
||||||
| 59 | SN::$auth->impersonate($user_selected); |
||||||
| 60 | break; |
||||||
| 61 | } |
||||||
| 62 | } else { |
||||||
| 63 | // Restricted try to delete user higher or equal level |
||||||
| 64 | SnTemplate::messageBoxAdmin($lang['adm_err_denied']); |
||||||
| 65 | } |
||||||
| 66 | } |
||||||
| 67 | |||||||
| 68 | /** @noinspection SpellCheckingInspection */ |
||||||
| 69 | $template = SnTemplate::gettemplate('admin/userlist', true); |
||||||
|
0 ignored issues
–
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 70 | |||||||
| 71 | $multi_ip = array(); |
||||||
| 72 | $ip_query = db_user_list_admin_multi_accounts(); |
||||||
| 73 | while ($ip = db_fetch($ip_query)) { |
||||||
|
0 ignored issues
–
show
The function
db_fetch() 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...
|
|||||||
| 74 | $multi_ip[$ip['user_lastip']] = $ip['ip_count']; |
||||||
| 75 | } |
||||||
| 76 | |||||||
| 77 | $geoIp = geoip_status(); |
||||||
| 78 | |||||||
| 79 | $query = db_user_list_admin_sorted($sort_fields[$sort], $is_players_online_page); |
||||||
| 80 | while ($user_row = db_fetch($query)) { |
||||||
|
0 ignored issues
–
show
The function
db_fetch() 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...
|
|||||||
| 81 | if ($user_row['banaday']) { |
||||||
| 82 | $ban_details = doquery("SELECT * FROM {{banned}} WHERE `ban_user_id` = {$user_row['id']} ORDER BY ban_id DESC LIMIT 1", 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...
true of type true is incompatible with the type string expected by parameter $table of doquery().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 83 | } else { |
||||||
| 84 | $ban_details = [ |
||||||
| 85 | 'ban_time' => 0, |
||||||
| 86 | 'ban_issuer_name' => '', |
||||||
| 87 | 'ban_reason' => '', |
||||||
| 88 | ]; |
||||||
| 89 | } |
||||||
| 90 | |||||||
| 91 | $geoIpInfo = $geoIp ? geoip_ip_info(ip2longu($user_row['user_lastip'])) : array(); |
||||||
| 92 | foreach ($geoIpInfo as $key => $value) { |
||||||
| 93 | $geoIpInfo[strtoupper($key)] = $value; |
||||||
| 94 | unset($geoIpInfo[$key]); |
||||||
| 95 | } |
||||||
| 96 | |||||||
| 97 | $template->assign_block_vars('user', array( |
||||||
| 98 | 'ID' => $user_row['id'], |
||||||
| 99 | 'NAME' => $renderedNick = player_nick_render_to_html($user_row, ['player_rank' => true, 'vacancy' => true, 'birthday' => true, 'award' => true, NICK_RANK_NO_TEXT => true,]), |
||||||
| 100 | 'NAME_HTML' => htmlentities($user_row['username'], ENT_QUOTES, 'UTF-8'), |
||||||
| 101 | 'IP' => $user_row['user_lastip'], |
||||||
| 102 | 'IP_MULTI' => intval($multi_ip[$user_row['user_lastip']]), |
||||||
| 103 | 'TIME_REGISTERED' => date(FMT_DATE_TIME_SQL, $user_row['register_time']), |
||||||
| 104 | 'TIME_PLAYED' => date(FMT_DATE_TIME_SQL, $user_row['onlinetime']), |
||||||
| 105 | 'ACTIVITY' => pretty_time(SN_TIME_NOW - $user_row['onlinetime']), |
||||||
| 106 | 'REFERRAL_COUNT' => $user_row['referral_count'], |
||||||
| 107 | 'REFERRAL_DM' => HelperString::numberFloorAndFormat($user_row['referral_dm']), |
||||||
| 108 | 'BANNED' => $user_row['banaday'] ? date(FMT_DATE_TIME_SQL, $user_row['banaday']) : 0, |
||||||
| 109 | 'BAN_DATE' => date(FMT_DATE_TIME_SQL, $ban_details['ban_time']), |
||||||
| 110 | 'BAN_ISSUER' => $ban_details['ban_issuer_name'], |
||||||
| 111 | 'BAN_REASON' => $ban_details['ban_reason'], |
||||||
| 112 | 'METAMATTER' => HelperString::numberFloorAndFormat($user_row['metamatter_total']), |
||||||
| 113 | 'ACTION' => $user_row['authlevel'] < $user['authlevel'], |
||||||
| 114 | 'RESTRICTED' => $user['authlevel'] < 3, |
||||||
| 115 | 'EMAIL' => $user_row['email_2'], |
||||||
| 116 | 'VACATION' => $user_row['vacation'] ? date(FMT_DATE_TIME_SQL, $user_row['vacation']) : '-', |
||||||
| 117 | ) + $geoIpInfo); |
||||||
| 118 | } |
||||||
| 119 | |||||||
| 120 | /** @noinspection SpellCheckingInspection */ |
||||||
| 121 | $template->assign_vars(array( |
||||||
| 122 | 'USER_COUNT' => SN::$db->db_num_rows($query), |
||||||
| 123 | 'SORT' => $sort, |
||||||
| 124 | 'GEOIP' => $geoIp, |
||||||
| 125 | 'METAMATTER' => !empty(SN::$gc->modules->getModule('unit_res_metamatter')), |
||||||
| 126 | 'GEOIP_WHOIS_URL' => SN::$config->geoip_whois_url, |
||||||
| 127 | |||||||
| 128 | 'PAGE_URL' => $_SERVER['SCRIPT_NAME'], |
||||||
| 129 | 'PAGE_HEADER' => $is_players_online_page ? $lang['adm_ul_title_online'] : $lang['adm_ul_title'], |
||||||
| 130 | )); |
||||||
| 131 | |||||||
| 132 | SnTemplate::display($template); |
||||||
| 133 |