mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
remove get_user_info() + get_user_id() to global
This commit is contained in:
@@ -464,23 +464,6 @@ function highlight($search,$subject,$hlstart='<b><font class="striking">',$hlend
|
|||||||
return $subject;
|
return $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_class()
|
|
||||||
{
|
|
||||||
if (IN_NEXUS) {
|
|
||||||
global $CURUSER;
|
|
||||||
return $CURUSER["class"] ?? '';
|
|
||||||
}
|
|
||||||
return auth()->user()->class;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_user_id()
|
|
||||||
{
|
|
||||||
if (IN_NEXUS) {
|
|
||||||
global $CURUSER;
|
|
||||||
return $CURUSER["id"] ?? 0;
|
|
||||||
}
|
|
||||||
return auth()->user()->id ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_user_class_name($class, $compact = false, $b_colored = false, $I18N = false, array $options = [])
|
function get_user_class_name($class, $compact = false, $b_colored = false, $I18N = false, array $options = [])
|
||||||
{
|
{
|
||||||
@@ -1931,47 +1914,6 @@ function dbconn($autoclean = false, $doLogin = true)
|
|||||||
register_shutdown_function("autoclean");
|
register_shutdown_function("autoclean");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function get_user_row($id)
|
|
||||||
{
|
|
||||||
global $Cache, $CURUSER;
|
|
||||||
static $curuserRowUpdated = false;
|
|
||||||
static $neededColumns = array('id', 'noad', 'class', 'enabled', 'privacy', 'avatar', 'signature', 'uploaded', 'downloaded', 'last_access', 'username', 'donor', 'donoruntil', 'leechwarn', 'warned', 'title');
|
|
||||||
$cacheKey = 'user_'.$id.'_content';
|
|
||||||
$row = \Nexus\Database\NexusDB::remember($cacheKey, 900, function () use ($id, $neededColumns) {
|
|
||||||
$user = \App\Models\User::query()->with(['wearing_medals'])->find($id, $neededColumns);
|
|
||||||
if ($user) {
|
|
||||||
$userRep = new \App\Repositories\UserRepository();
|
|
||||||
$metas = $userRep->listMetas($id, \App\Models\UserMeta::META_KEY_PERSONALIZED_USERNAME);
|
|
||||||
$arr = $user->toArray();
|
|
||||||
if ($metas->isNotEmpty()) {
|
|
||||||
$arr['__is_rainbow'] = 1;
|
|
||||||
} else {
|
|
||||||
$arr['__is_rainbow'] = 0;
|
|
||||||
}
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
|
|
||||||
// if ($CURUSER && $id == $CURUSER['id']) {
|
|
||||||
// $row = array();
|
|
||||||
// foreach($neededColumns as $column) {
|
|
||||||
// $row[$column] = $CURUSER[$column];
|
|
||||||
// }
|
|
||||||
// if (!$curuserRowUpdated) {
|
|
||||||
// $Cache->cache_value('user_'.$CURUSER['id'].'_content', $row, 900);
|
|
||||||
// $curuserRowUpdated = true;
|
|
||||||
// }
|
|
||||||
// } elseif (!$row = $Cache->get_value('user_'.$id.'_content')){
|
|
||||||
// $res = sql_query("SELECT ".implode(',', $neededColumns)." FROM users WHERE id = ".sqlesc($id)) or sqlerr(__FILE__,__LINE__);
|
|
||||||
// $row = mysql_fetch_array($res);
|
|
||||||
// $Cache->cache_value('user_'.$id.'_content', $row, 900);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!$row)
|
|
||||||
return false;
|
|
||||||
else return $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
function userlogin() {
|
function userlogin() {
|
||||||
// do_log("COOKIE:" . json_encode($_COOKIE) . ", uid: " . (isset($_COOKIE['c_secure_uid']) ? base64($_COOKIE["c_secure_uid"],false) : ''));
|
// do_log("COOKIE:" . json_encode($_COOKIE) . ", uid: " . (isset($_COOKIE['c_secure_uid']) ? base64($_COOKIE["c_secure_uid"],false) : ''));
|
||||||
|
|||||||
@@ -701,6 +701,66 @@ function get_row_count($table, $suffix = "")
|
|||||||
return $a[0];
|
return $a[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_user_row($id)
|
||||||
|
{
|
||||||
|
global $Cache, $CURUSER;
|
||||||
|
static $curuserRowUpdated = false;
|
||||||
|
static $neededColumns = array('id', 'noad', 'class', 'enabled', 'privacy', 'avatar', 'signature', 'uploaded', 'downloaded', 'last_access', 'username', 'donor', 'donoruntil', 'leechwarn', 'warned', 'title');
|
||||||
|
$cacheKey = 'user_'.$id.'_content';
|
||||||
|
$row = \Nexus\Database\NexusDB::remember($cacheKey, 900, function () use ($id, $neededColumns) {
|
||||||
|
$user = \App\Models\User::query()->with(['wearing_medals'])->find($id, $neededColumns);
|
||||||
|
if ($user) {
|
||||||
|
$userRep = new \App\Repositories\UserRepository();
|
||||||
|
$metas = $userRep->listMetas($id, \App\Models\UserMeta::META_KEY_PERSONALIZED_USERNAME);
|
||||||
|
$arr = $user->toArray();
|
||||||
|
if ($metas->isNotEmpty()) {
|
||||||
|
$arr['__is_rainbow'] = 1;
|
||||||
|
} else {
|
||||||
|
$arr['__is_rainbow'] = 0;
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// if ($CURUSER && $id == $CURUSER['id']) {
|
||||||
|
// $row = array();
|
||||||
|
// foreach($neededColumns as $column) {
|
||||||
|
// $row[$column] = $CURUSER[$column];
|
||||||
|
// }
|
||||||
|
// if (!$curuserRowUpdated) {
|
||||||
|
// $Cache->cache_value('user_'.$CURUSER['id'].'_content', $row, 900);
|
||||||
|
// $curuserRowUpdated = true;
|
||||||
|
// }
|
||||||
|
// } elseif (!$row = $Cache->get_value('user_'.$id.'_content')){
|
||||||
|
// $res = sql_query("SELECT ".implode(',', $neededColumns)." FROM users WHERE id = ".sqlesc($id)) or sqlerr(__FILE__,__LINE__);
|
||||||
|
// $row = mysql_fetch_array($res);
|
||||||
|
// $Cache->cache_value('user_'.$id.'_content', $row, 900);
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (!$row)
|
||||||
|
return false;
|
||||||
|
else return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_class()
|
||||||
|
{
|
||||||
|
if (IN_NEXUS) {
|
||||||
|
global $CURUSER;
|
||||||
|
return $CURUSER["class"] ?? '';
|
||||||
|
}
|
||||||
|
return auth()->user()->class;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_id()
|
||||||
|
{
|
||||||
|
if (IN_NEXUS) {
|
||||||
|
global $CURUSER;
|
||||||
|
return $CURUSER["id"] ?? 0;
|
||||||
|
}
|
||||||
|
return auth()->user()->id ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
function nexus()
|
function nexus()
|
||||||
{
|
{
|
||||||
return \Nexus\Nexus::instance();
|
return \Nexus\Nexus::instance();
|
||||||
|
|||||||
Reference in New Issue
Block a user