public static function loginFromToken($token)
    {
        $token = self::Database()->cleanValue($token);

        if (strlen(trim($token)) == 0) {
            return false;
        }

        if (strlen($token) == 6 || strlen($token) == 16) {
            $row = self::Database()->fetchRow(0, sprintf(
                "SELECT `a`.`id`, `a`.`username`, `a`.`password`
                FROM `tbl_authors` AS `a`, `tbl_forgotpass` AS `f`
                WHERE `a`.`id` = `f`.`author_id`
                AND `f`.`expiry` > '%s'
                AND `f`.`token` = '%s'
                LIMIT 1",
                DateTimeObj::getGMT('c'),
                $token
            ));

            self::Database()->delete('tbl_forgotpass', sprintf(" `token` = '%s' ", $token));
        } else {
            $row = self::Database()->fetchRow(0, sprintf(
                "SELECT `id`, `username`, `password`
                FROM `tbl_authors`
                WHERE SUBSTR(%s(CONCAT(`username`, `password`)), 1, 8) = '%s'
                AND `auth_token_active` = 'yes'
                LIMIT 1",
                'SHA1',
                $token
            ));
        }

        if ($row) {
            self::$Author = AuthorManager::fetchByID($row['id']);
            self::$Cookie->set('username', $row['username']);
            self::$Cookie->set('pass', $row['password']);
            self::Database()->update(array('last_seen' => DateTimeObj::getGMT('Y-m-d H:i:s')), 'tbl_authors', sprintf("
                `id` = %d", $row['id']
            ));

            return true;
        }

        return false;
    }
public static function loginFromToken($token)
    {
        $token = self::Database()->cleanValue($token);

        if (strlen(trim($token)) == 0) {
            return false;
        }

        if (strlen($token) == 6 || strlen($token) == 16) {
            $row = self::Database()->fetchRow(0, sprintf(
                "SELECT `a`.`id`, `a`.`username`, `a`.`password`
                FROM `tbl_authors` AS `a`, `tbl_forgotpass` AS `f`
                WHERE `a`.`id` = `f`.`author_id`
                AND `f`.`expiry` > '%s'
                AND `f`.`token` = '%s'
                LIMIT 1",
                DateTimeObj::getGMT('c'),
                $token
            ));

            self::Database()->delete('tbl_forgotpass', sprintf(" `token` = '%s' ", $token));
        } else {
            $row = self::Database()->fetchRow(0, sprintf(
                "SELECT `id`, `username`, `password`
                FROM `tbl_authors`
                WHERE SUBSTR(%s(CONCAT(`username`, `password`)), 1, 8) = '%s'
                AND `auth_token_active` = 'yes'
                LIMIT 1",
                'SHA1',
                $token
            ));
        }

        if ($row) {
            self::$Author = AuthorManager::fetchByID($row['id']);
            self::$Cookie->set('username', $row['username']);
            self::$Cookie->set('pass', $row['password']);
            self::Database()->update(array('last_seen' => DateTimeObj::getGMT('Y-m-d H:i:s')), 'tbl_authors', sprintf("
                `id` = %d", $row['id']
            ));

            return true;
        }

        return false;
    }
public static function loginFromToken ( $ token ) { $ token = self :: Database ( ) -> cleanValue ( $ token ) ; if ( strlen ( trim ( $ token ) ) == 0 ) { return false ; } if ( strlen ( $ token ) == 6 || strlen ( $ token ) == 16 ) { $ row = self :: Database ( ) -> fetchRow ( 0 , sprintf ( "SELECT `a`.`id`, `a`.`username`, `a`.`password`
                FROM `tbl_authors` AS `a`, `tbl_forgotpass` AS `f`
                WHERE `a`.`id` = `f`.`author_id`
                AND `f`.`expiry` > '%s'
                AND `f`.`token` = '%s'
                LIMIT 1" , DateTimeObj :: getGMT ( 'c' ) , $ token ) ) ; self :: Database ( ) -> delete ( 'tbl_forgotpass' , sprintf ( " `token` = '%s' " , $ token ) ) ; } else { $ row = self :: Database ( ) -> fetchRow ( 0 , sprintf ( "SELECT `id`, `username`, `password`
                FROM `tbl_authors`
                WHERE SUBSTR(%s(CONCAT(`username`, `password`)), 1, 8) = '%s'
                AND `auth_token_active` = 'yes'
                LIMIT 1" , 'SHA1' , $ token ) ) ; } if ( $ row ) { self :: $ Author = AuthorManager :: fetchByID ( $ row [ 'id' ] ) ; self :: $ Cookie -> set ( 'username' , $ row [ 'username' ] ) ; self :: $ Cookie -> set ( 'pass' , $ row [ 'password' ] ) ; self :: Database ( ) -> update ( array ( 'last_seen' => DateTimeObj :: getGMT ( 'Y-m-d H:i:s' ) ) , 'tbl_authors' , sprintf ( "
                `id` = %d" , $ row [ 'id' ] ) ) ; return true ; } return false ; }
Symphony allows Authors to login via the use of tokens instead of
a username and password. A token is derived from concatenating the
Author's username and password and applying the sha1 hash to
it, from this, a portion of the hash is used as the token. This is a useful
feature often used when setting up other Authors accounts or if an
Author forgets their password.

@param string $token
The Author token, which is a portion of the hashed string concatenation
of the Author's username and password
@throws DatabaseException
@return boolean
true if the Author is logged in, false otherwise
Symphony allows Authors to login via the use of tokens instead of a username and password . A token is derived from concatenating the Author s username and password and applying the sha1 hash to it from this a portion of the hash is used as the token . This is a useful feature often used when setting up other Authors accounts or if an Author forgets their password .