"Fossies" - the Fresh Open Source Software Archive

Member "flyspray-1.0-rc9/js/callbacks/searchnames.php" (22 Apr 2019, 1316 Bytes) of package /linux/privat/flyspray-1.0-rc9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "searchnames.php" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.0-rc7_vs_1.0-rc8.

    1 <?php
    2 
    3 /**
    4  * This script is the AJAX callback that performs a search
    5  *  for users, and returns true if the user_name is not given.
    6  */
    7 
    8 define('IN_FS', true);
    9 
   10 header('Content-type: text/html; charset=utf-8');
   11 
   12 require_once('../../header.php');
   13 
   14 
   15 if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) {
   16     $user = new User(Cookie::val('flyspray_userid'));
   17     $user->check_account_ok();
   18 } else {
   19     $user = new User(0, $proj);
   20 }
   21 
   22 if ($user->isAnon()) {
   23     # at least allow for guests when user registration is enabled, fix FS#2528
   24     if( !($user->can_register() or $user->can_self_register()) ){
   25         die();
   26     }
   27 }
   28 
   29 if (Req::has('name')) {
   30     $searchterm = strtolower(Req::val('name'));
   31 } else {
   32     die();
   33 }
   34 
   35 // Get the list of users from the global groups above
   36 $get_users = $db->query('
   37     SELECT count(u.user_name) AS anz_u_user, count(r.user_name) AS anz_r_user 
   38     FROM {users} u
   39     LEFT JOIN {registrations} r ON u.user_name = r.user_name
   40     WHERE LOWER(u.user_name) = ? OR LOWER(r.user_name) = ?',
   41     array($searchterm, $searchterm)
   42 );
   43 
   44 load_translations();
   45 
   46 while ($row = $db->fetchRow($get_users)){
   47     if ($row['anz_u_user'] > '0' || $row['anz_r_user'] > '0') {
   48         $html = 'false|' . eL('usernametaken');
   49     } else {
   50         $html = 'true';
   51     }
   52 }
   53 
   54 echo $html;
   55 ?>