Ejemplo n.º 1
0
/**
 * Get a user id from their real name
 *
 * @param string $p_realname Realname
 * @return array
 */
function user_get_id_by_realname($p_realname)
{
    global $g_cache_user;
    if ($t_user = user_search_cache('realname', $p_realname)) {
        return $t_user['id'];
    }
    $t_user_table = db_get_table('user');
    $query = "SELECT * FROM {$t_user_table} WHERE realname=" . db_param();
    $result = db_query_bound($query, array($p_realname));
    $row = db_fetch_array($result);
    if (!$row) {
        return false;
    } else {
        user_cache_database_result($row);
        return $row['id'];
    }
}
Ejemplo n.º 2
0
/**
 * Get a user id from their real name
 *
 * @param string $p_realname The realname to retrieve data for.
 * @return array
 */
function user_get_id_by_realname($p_realname)
{
    global $g_cache_user;
    if ($t_user = user_search_cache('realname', $p_realname)) {
        return $t_user['id'];
    }
    $t_query = 'SELECT * FROM {user} WHERE realname=' . db_param();
    $t_result = db_query($t_query, array($p_realname));
    $t_row = db_fetch_array($t_result);
    if (!$t_row) {
        return false;
    } else {
        user_cache_database_result($t_row);
        return $t_row['id'];
    }
}
Ejemplo n.º 3
0
/**
 * is cookie valid?
 * @param string $p_cookie_string
 * @return bool
 * @access public
 */
function auth_is_cookie_valid($p_cookie_string)
{
    global $g_cache_current_user_id;
    # fail if DB isn't accessible
    if (!db_is_connected()) {
        return false;
    }
    # fail if cookie is blank
    if ('' === $p_cookie_string) {
        return false;
    }
    # succeeed if user has already been authenticated
    if (null !== $g_cache_current_user_id) {
        return true;
    }
    if (user_search_cache('cookie_string', $p_cookie_string)) {
        return true;
    }
    # look up cookie in the database to see if it is valid
    $t_user_table = db_get_table('user');
    $query = "SELECT *\n\t\t\t\t  FROM {$t_user_table}\n\t\t\t\t  WHERE cookie_string=" . db_param();
    $result = db_query_bound($query, array($p_cookie_string));
    # return true if a matching cookie was found
    if (1 == db_num_rows($result)) {
        user_cache_database_result(db_fetch_array($result));
        return true;
    } else {
        return false;
    }
}