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;
    }