From 6854cb3f4d8219cf1829e32122eb2502a916eae9 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 1 Feb 2020 09:05:48 +0100 Subject: initial checkin --- js/callbacks/searchnames.php | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 js/callbacks/searchnames.php (limited to 'js/callbacks/searchnames.php') diff --git a/js/callbacks/searchnames.php b/js/callbacks/searchnames.php new file mode 100644 index 0000000..f696955 --- /dev/null +++ b/js/callbacks/searchnames.php @@ -0,0 +1,55 @@ +check_account_ok(); +} else { + $user = new User(0, $proj); +} + +if ($user->isAnon()) { + # at least allow for guests when user registration is enabled, fix FS#2528 + if( !($user->can_register() or $user->can_self_register()) ){ + die(); + } +} + +if (Req::has('name')) { + $searchterm = strtolower(Req::val('name')); +} else { + die(); +} + +// Get the list of users from the global groups above +$get_users = $db->query(' + SELECT count(u.user_name) AS anz_u_user, count(r.user_name) AS anz_r_user + FROM {users} u + LEFT JOIN {registrations} r ON u.user_name = r.user_name + WHERE LOWER(u.user_name) = ? OR LOWER(r.user_name) = ?', + array($searchterm, $searchterm) +); + +load_translations(); + +while ($row = $db->fetchRow($get_users)){ + if ($row['anz_u_user'] > '0' || $row['anz_r_user'] > '0') { + $html = 'false|' . eL('usernametaken'); + } else { + $html = 'true'; + } +} + +echo $html; +?> -- cgit v1.2.3-70-g09d2