コード例 #1
0
function authenticate_account($l = '', $p = '')
{
    // If login and password passed, check DB (standard login)
    if ($l && $p) {
        /*** TODO: Create Proper Abstraction Interface - don't use file binding -- ugh ***/
        return login_database($l, $p);
    }
    // Already logged in, we're done
    //if($_SESSION['userid'] > 0) return 1;
    if (egw_bridge && egw_get_id_by_lid() > 0) {
        egw_is_new_user();
        $egw_user = egw_get_account_info(egw_get_id_by_lid());
        return login_database($egw_user->username, $egw_user->password);
    }
    // Check to see if there's a persistent cookie
    if ($ticket = md5($_COOKIE[AUTH_COOKIE])) {
        $sql = "SELECT ident, code from " . tbl_prefix . "users WHERE code = '{$ticket}'";
        $result = db_query($sql);
        if ($row = $result[0]) {
            if ($ticket == $row->code) {
                /*** TODO: Create Proper Abstraction Interface - don't use file binding -- ugh ***/
                init_session_database($row->ident);
                return 1;
            }
        }
    }
    // Everything failed
    return 0;
}
コード例 #2
0
function egw_is_new_user()
{
    global $egw;
    $id = egw_get_id_by_lid();
    if ($id > 0) {
        return 0;
    }
    //veb: special fix. We have already eLgg profile. So we don't need to create it.
    $sql = "SELECT ident from " . tbl_prefix . "users WHERE ident = " . $id;
    $result = db_query($sql);
    if (!$result[0]) {
        $row = egw_get_account_info($id);
        $sql = "insert into " . tbl_prefix . "users (ident, username, password, email, name) values(" . $row->ident . ",'" . $row->username . "','" . $row->password . "','" . $row->email . "','" . $row->name . "')";
        $result = db_query($sql);
        if (!$result) {
            echo mysql_error();
        }
        $sql = "insert into " . tbl_prefix . "profile_data (ident, owner, access, name, value) values(" . '\'\',' . $row->ident . "," . '\'PUBLIC\',' . '\'linkedin\',' . '\'' . $row->linkedin . '\')';
        $result = db_query($sql);
        if (!$result) {
            echo mysql_error();
        }
        $sql = "insert into " . tbl_prefix . "profile_data (ident, owner, access, name, value) values(" . '\'\',' . $row->ident . "," . '\'PUBLIC\',' . '\'membership_date\',' . '\'' . $row->account_membership_date . '\')';
        $result = db_query($sql);
        if (!$result) {
            echo mysql_error();
        }
        return 1;
    }
    return 0;
}