mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Fixed null $u_data if user not found (#781)
This commit is contained in:
parent
cb94b703cc
commit
1d1f9fa4aa
1 changed files with 3 additions and 10 deletions
|
@ -958,7 +958,7 @@ function clean_username($username)
|
|||
}
|
||||
|
||||
// Get Userdata, $u can be username or user_id. If $force_name is true, the username will be forced.
|
||||
function get_userdata($u, $force_name = false, $allow_guest = false)
|
||||
function get_userdata($u, bool $force_name = false, bool $allow_guest = false)
|
||||
{
|
||||
if (!$u) {
|
||||
return false;
|
||||
|
@ -970,12 +970,9 @@ function get_userdata($u, $force_name = false, $allow_guest = false)
|
|||
}
|
||||
}
|
||||
|
||||
$u_data = array();
|
||||
$name_search = false;
|
||||
$exclude_anon_sql = (!$allow_guest) ? "AND user_id != " . GUEST_UID : '';
|
||||
|
||||
if ($force_name || !is_numeric($u)) {
|
||||
$name_search = true;
|
||||
if ($force_name || !is_int($u)) {
|
||||
$where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'";
|
||||
} else {
|
||||
$where_sql = "WHERE user_id = " . (int)$u;
|
||||
|
@ -984,11 +981,7 @@ function get_userdata($u, $force_name = false, $allow_guest = false)
|
|||
$sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||
|
||||
if (!$u_data = DB()->fetch_row($sql)) {
|
||||
if (!is_int($u) && !$name_search) {
|
||||
$where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'";
|
||||
$sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||
$u_data = DB()->fetch_row($sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($u_data['user_id'] == GUEST_UID) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue