Esempio n. 1
0
        internal static bool TryParseGalleryPopup(UriHandlerData data, out GalleryInfo info, out GalleryLaunchStatus type)
        {
            info = default;
            type = default;
            if (data.Paths.Count >= 1 &&
                (data.Path0 == "gallerytorrents.php" ||
                 data.Path0 == "gallerypopups.php" ||
                 data.Path0 == "stats.php" ||
                 data.Path0 == "archiver.php"))
            {
                if (long.TryParse(data.Queries.GetString("gid"), out var gId))
                {
                    var token = data.Queries.GetString("t") + data.Queries.GetString("token");
                    if (token.IsNullOrWhiteSpace())
                    {
                        return(false);
                    }
                    info = new GalleryInfo(gId, token.ToToken());
                    type = GalleryLaunchStatus.Default;
                    switch (data.Path0)
                    {
                    case "gallerytorrents.php":
                        type = GalleryLaunchStatus.Torrent;
                        break;

                    case "stats.php":
                        type = GalleryLaunchStatus.Stats;
                        break;

                    case "archiver.php":
                        type = GalleryLaunchStatus.Archive;
                        break;

                    default:
                        switch (data.Queries.GetString("act"))
                        {
                        case "addfav":
                            type = GalleryLaunchStatus.Favorite;
                            break;

                        case "expunge":
                            type = GalleryLaunchStatus.Expunge;
                            break;

                        case "rename":
                            type = GalleryLaunchStatus.Rename;
                            break;
                        }
                        break;
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        internal static bool TryParseGalleryPopup(UriHandlerData data, out GalleryInfo info, out GalleryLaunchStatus type)
        {
            info = default;
            type = default;
            if (data.Paths.Count < 1)
            {
                return(false);
            }
            if (!Array.Exists(_Popups, s => data.Path0.Equals(s, StringComparison.OrdinalIgnoreCase)))
            {
                return(false);
            }
            if (!long.TryParse(data.Queries.GetString("gid"), out var gId))
            {
                return(false);
            }

            var tokenstr = data.Queries.GetString("t") + data.Queries.GetString("token");

            if (!EToken.TryParse(tokenstr, out var token))
            {
                return(false);
            }
            info = new GalleryInfo(gId, token);
            type = GalleryLaunchStatus.Default;
            switch (data.Path0)
            {
            case "gallerytorrents.php":
                type = GalleryLaunchStatus.Torrent;
                break;

            case "stats.php":
                type = GalleryLaunchStatus.Stats;
                break;

            case "archiver.php":
                type = GalleryLaunchStatus.Archive;
                break;

            default:
                switch (data.Queries.GetString("act"))
                {
                case "addfav":
                    type = GalleryLaunchStatus.Favorite;
                    break;

                case "expunge":
                    type = GalleryLaunchStatus.Expunge;
                    break;

                case "rename":
                    type = GalleryLaunchStatus.Rename;
                    break;
                }
                break;
            }
            return(true);
        }
Esempio n. 3
0
 internal GalleryLaunchResult(Api.GalleryInfo gInfo, int index, GalleryLaunchStatus status)
 {
     GalleryInfo  = gInfo;
     CurrentIndex = index;
     Status       = status;
 }
Esempio n. 4
0
        internal static bool TryParseGalleryPopup(UriHandlerData data, out GalleryInfo info, out GalleryLaunchStatus type)
        {
            if (data.Paths.Count == 1 &&
                (data.Path0 == "gallerytorrents.php" ||
                 data.Path0 == "gallerypopups.php" ||
                 data.Path0 == "stats.php" ||
                 data.Path0 == "archiver.php"))
            {
                if (data.Queries.TryGetValue("gid", out var gidStr) &&
                    (data.Queries.TryGetValue("t", out var gtoken) || data.Queries.TryGetValue("token", out gtoken)) &&
                    long.TryParse(data.Queries["gid"], out var gId))
                {
                    info = new GalleryInfo(gId, gtoken.ToToken());
                    type = GalleryLaunchStatus.Default;
                    switch (data.Path0)
                    {
                    case "gallerytorrents.php":
                        type = GalleryLaunchStatus.Torrent;
                        break;

                    case "stats.php":
                        type = GalleryLaunchStatus.Stats;
                        break;

                    case "archiver.php":
                        type = GalleryLaunchStatus.Archive;
                        break;

                    default:
                        if (data.Queries.TryGetValue("act", out var action))
                        {
                            switch (action)
                            {
                            case "addfav":
                                type = GalleryLaunchStatus.Favorite;
                                break;

                            case "expunge":
                                type = GalleryLaunchStatus.Expunge;
                                break;

                            case "rename":
                                type = GalleryLaunchStatus.Rename;
                                break;
                            }
                        }

                        break;
                    }
                    return(true);
                }
            }
            info = default;
            type = default;
            return(false);
        }