mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 05:43:55 -07:00
Support simultaneous id & username inputs for browsing profiles (#1166)
This commit is contained in:
parent
c3b9a781eb
commit
82251ece8c
2 changed files with 6 additions and 2 deletions
|
@ -980,7 +980,7 @@ function clean_username($username)
|
||||||
* @param bool $allow_guest
|
* @param bool $allow_guest
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function get_userdata($u, bool $is_name = false, bool $allow_guest = false)
|
function get_userdata($u, bool $is_name = false, bool $allow_guest = false, bool $profile_view = false)
|
||||||
{
|
{
|
||||||
if (empty($u)) {
|
if (empty($u)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -998,6 +998,10 @@ function get_userdata($u, bool $is_name = false, bool $allow_guest = false)
|
||||||
$where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'";
|
$where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($profile_view) {
|
||||||
|
$where_sql = "WHERE user_id = " . (int)$u . " OR username = '" . DB()->escape(clean_username($u)) . "'";
|
||||||
|
}
|
||||||
|
|
||||||
$exclude_anon_sql = (!$allow_guest) ? "AND user_id != " . GUEST_UID : '';
|
$exclude_anon_sql = (!$allow_guest) ? "AND user_id != " . GUEST_UID : '';
|
||||||
$sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
$sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ if (!$userdata['session_logged_in']) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$profiledata = get_userdata($_GET[POST_USERS_URL], !is_numeric($_GET[POST_USERS_URL]))) {
|
if (!$profiledata = get_userdata($_GET[POST_USERS_URL], profile_view: true)) {
|
||||||
bb_die($lang['NO_USER_ID_SPECIFIED']);
|
bb_die($lang['NO_USER_ID_SPECIFIED']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue