예제 #1
0
    protected override void Execute()
    {
        string ticket = web.Param("ticket");

        // get steam user id from auth ticket
        SteamApi api     = new SteamApi();
        string   SteamID = api.GetSteamId(ticket);

        if (SteamID.Length == 0)
        {
            Response.Write("WO_5");
            Response.Write(api.lastData_);
            return;
        }

        // try to login user based on his steamID
        SqlCommand sqcmd = new SqlCommand();

        sqcmd.CommandType = CommandType.StoredProcedure;
        sqcmd.CommandText = "WO_SteamLogin";
        sqcmd.Parameters.AddWithValue("@in_IP", LastIP);
        sqcmd.Parameters.AddWithValue("@in_SteamID", SteamID);

        if (!CallWOApi(sqcmd))
        {
            return;
        }

        reader.Read();
        int CustomerID    = getInt("CustomerID");;
        int AccountStatus = getInt("AccountStatus");
        int SessionID     = 0;
        int IsDeveloper   = 0;

        if (CustomerID > 0)
        {
            SessionID   = getInt("SessionID");
            IsDeveloper = getInt("IsDeveloper");
        }

        // region lock
        if (IsDeveloper == 0 && IPLocationCheck.IsRegionLocked(LastIP, CustomerID))
        {
            // special 600 code meaning we're IP locked.
            AccountStatus = 600;
        }

        Response.Write("WO_0");
        Response.Write(string.Format("{0} {1} {2}",
                                     CustomerID, SessionID, AccountStatus));
        return;
    }
        public GameRequierements GetFromWeb(Game game)
        {
            GameRequierements gameRequierements = GetDefault(game);

            string SourceName = string.Empty;

            try
            {
                SourceName = PlayniteTools.GetSourceName(_PlayniteApi, game);

                // Search datas
                logger.Info($"SystemChecker - Try find with PCGamingWikiRequierements for {game.Name}");
                gameRequierements = pCGamingWikiRequierements.GetRequirements(game);

                if (!pCGamingWikiRequierements.IsFind())
                {
                    logger.Info($"SystemChecker - Try find with SteamRequierements for {game.Name}");
                    switch (SourceName.ToLower())
                    {
                    case "steam":
                        gameRequierements      = steamRequierements.GetRequirements(game);
                        gameRequierements.Link = "https://store.steampowered.com/app/" + game.GameId;
                        break;

                    default:
                        SteamApi steamApi = new SteamApi(PluginUserDataPath);
                        int      SteamID  = steamApi.GetSteamId(game.Name);
                        if (SteamID != 0)
                        {
                            gameRequierements      = steamRequierements.GetRequirements(game, (uint)SteamID);
                            gameRequierements.Link = "https://store.steampowered.com/app/" + SteamID;
                        }
                        break;
                    }
                }

                gameRequierements = NormalizeRecommanded(gameRequierements);
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "SystemChecker");
            }

            return(gameRequierements);
        }
        public GameAchievements GetAchievementsLocal(string GameName, string apiKey)
        {
            List <Achievements> Achievements = new List <Achievements>();
            bool HaveAchivements             = false;
            int  Total    = 0;
            int  Unlocked = 0;
            int  Locked   = 0;

            SteamApi steamApi = new SteamApi(_PluginUserDataPath);

            SteamId = steamApi.GetSteamId(GameName);

            Achievements = Get(SteamId, apiKey);
            if (Achievements.Count > 0)
            {
                HaveAchivements = true;

                for (int i = 0; i < Achievements.Count; i++)
                {
                    if (Achievements[i].DateUnlocked == default(DateTime))
                    {
                        Locked += 1;
                    }
                    else
                    {
                        Unlocked += 1;
                    }
                }

                Total = Achievements.Count;
            }

            GameAchievements Result = new GameAchievements
            {
                Name            = GameName,
                HaveAchivements = HaveAchivements,
                Total           = Total,
                Unlocked        = Unlocked,
                Locked          = Locked,
                Progression     = (Total != 0) ? (int)Math.Ceiling((double)(Unlocked * 100 / Total)) : 0,
                Achievements    = Achievements
            };

            return(Result);
        }
        public List <Localization> GetLocalizations(Game game)
        {
            string urlPCGamingWiki = string.Empty;
            int    SteamId         = 0;

            if (game.SourceId != Guid.Parse("00000000-0000-0000-0000-000000000000"))
            {
                if (game.Source.Name.ToLower() == "steam")
                {
                    SteamId = int.Parse(game.GameId);
                }
            }
            if (SteamId == 0)
            {
                SteamId = steamApi.GetSteamId(game.Name);
            }

            urlPCGamingWiki = FindGoodUrl(game, SteamId);

            List <Localization> Localizations = new List <Localization>();

            if (SteamId != 0)
            {
                Localizations = GetLocalizations(string.Format(urlSteamId, SteamId));
                if (Localizations.Count > 0)
                {
                    return(Localizations);
                }
            }
            if (!urlPCGamingWiki.IsNullOrEmpty())
            {
                Localizations = GetLocalizations(urlPCGamingWiki);
                if (Localizations.Count > 0)
                {
                    return(Localizations);
                }
            }

            logger.Warn($"CheckLocalizations - Not find for {game.Name}");
            return(Localizations);
        }
        public GameRequierements GetRequirements(Game game)
        {
            _game           = game;
            SteamId         = 0;
            UrlPCGamingWiki = string.Empty;


            if (_game.SourceId != Guid.Parse("00000000-0000-0000-0000-000000000000"))
            {
                if (game.Source.Name.ToLower() == "steam")
                {
                    SteamId = int.Parse(game.GameId);
                }
            }
            if (SteamId == 0)
            {
                SteamId = steamApi.GetSteamId(game.Name);
            }


            return(GetRequirements());
        }
예제 #6
0
    protected override void Execute()
    {
        string ticket = web.Param("ticket");

        // get steam user id from auth ticket
        SteamApi api     = new SteamApi();
        string   SteamID = api.GetSteamId(ticket);

        if (SteamID.Length == 0)
        {
            Response.Write("WO_5");
            Response.Write(api.lastData_);
            return;
        }

        string apiAnswer   = "";
        bool   Have_Game   = false;
        int    Have_227660 = 0; // old 15$
        int    Have_227661 = 0; // old 50$
        int    Have_267590 = 0; // 12-2013 15$
        int    Have_267591 = 0; // 12-2013 50$

        SteamXML.appownershipAppsApp[] apps = api.GetPublisherAppOwnership(SteamID, ref apiAnswer);
        if (apps != null)
        {
            foreach (SteamXML.appownershipAppsApp app in apps)
            {
                if (app.ownsapp == false)
                {
                    continue;
                }
                if (app.permanent == false && SteamID != "76561198043252597") // ignore that flag for denis steam acc (i have game as developer)
                {
                    continue;
                }
                switch (app.appid)
                {
                case 226700: Have_Game = true; break;        // base game

                case 227660: Have_227660 = app.appid; break; // 15$

                case 227661: Have_227661 = app.appid; break; // 50$

                case 267590: Have_267590 = app.appid; break; // new 15$

                case 267591: Have_267591 = app.appid; break; // new 50$
                }
            }
        }

        if (!Have_Game)
        {
            // special 1001 code for running under steam but without game.
            Response.Write("WO_0");
            Response.Write(string.Format("{0} {1} {2}",
                                         0, 0, 1001));
            return;
        }

        string countryIP = "";

        if (!String.IsNullOrEmpty(Request["HTTP_CF_IPCOUNTRY"]))
        {
            countryIP = Request["HTTP_CF_IPCOUNTRY"];
        }

        // try to login user based on his steam id
        SqlCommand sqcmd = new SqlCommand();

        sqcmd.CommandType = CommandType.StoredProcedure;
        sqcmd.CommandText = "WZ_SteamLogin";
        sqcmd.Parameters.AddWithValue("@in_IP", LastIP);
        sqcmd.Parameters.AddWithValue("@in_SteamID", SteamID);
        sqcmd.Parameters.AddWithValue("@in_Country", countryIP);

        if (!CallWOApi(sqcmd))
        {
            return;
        }

        reader.Read();
        int CustomerID    = getInt("CustomerID");
        int AccountStatus = getInt("AccountStatus");
        int SessionID     = 0;
        int IsDeveloper   = 0;

        if (CustomerID > 0)
        {
            SessionID   = getInt("SessionID");
            IsDeveloper = getInt("IsDeveloper");
        }

        Response.Write("WO_0");
        Response.Write(string.Format("{0} {1} {2}",
                                     CustomerID, SessionID, AccountStatus));

        // DLC logic
        // because of totally retarded steam setup our bundles will look like this:
        //  base: 226700
        //  15$:  226700 & 227660
        //  50$:  226700 & 227660 & 227661

        // activate 1st DLC ONLY if we don't have second
        if (CustomerID > 0 && Have_227660 > 0 && Have_227661 == 0)
        {
            if (ActivateDLC(CustomerID, Have_227660, apiAnswer, SteamID))
            {
                return;
            }
        }
        if (CustomerID > 0 && Have_227660 > 0 && Have_227661 > 0)
        {
            if (ActivateDLC(CustomerID, Have_227661, apiAnswer, SteamID))
            {
                return;
            }
        }

        // NEW 12-2013 packages
        // activate 1st DLC ONLY if we don't have second
        if (CustomerID > 0 && Have_267590 > 0 && Have_267591 == 0)
        {
            if (ActivateDLC(CustomerID, Have_267590, apiAnswer, SteamID))
            {
                return;
            }
        }

        if (CustomerID > 0 && Have_267590 > 0 && Have_267591 > 0)
        {
            if (ActivateDLC(CustomerID, Have_267591, apiAnswer, SteamID))
            {
                return;
            }
        }

        return;
    }
        public List <Localization> GetLocalizations(Game game)
        {
            List <Localization> Localizations = new List <Localization>();

            try
            {
                int SteamId = steamApi.GetSteamId(game.Name);

                if (SteamId != 0)
                {
                    string data       = GetSteamData(SteamId);
                    var    parsedData = JsonConvert.DeserializeObject <Dictionary <string, StoreAppDetailsResult> >(data);

                    if (parsedData[SteamId.ToString()].data != null)
                    {
                        var dataSplited       = parsedData[SteamId.ToString()].data.supported_languages.Split(new string[] { "<br>" }, StringSplitOptions.None);
                        var ListLocalizations = dataSplited[0].Split(',');

                        foreach (string Loc in ListLocalizations)
                        {
                            string        Language = string.Empty;
                            SupportStatus Ui       = SupportStatus.Native;
                            SupportStatus Audio    = SupportStatus.Unknown;
                            SupportStatus Sub      = SupportStatus.Unknown;

                            if (Loc.Contains("<strong>*</strong>"))
                            {
                                Audio = SupportStatus.Native;
                                Sub   = SupportStatus.Native;
                            }

                            Language = Loc.Replace("<strong>*</strong>", string.Empty).Trim();

                            switch (Language)
                            {
                            case "Portuguese - Brazil":
                                Language = "Brazilian Portuguese";
                                break;

                            case "Spanish - Spain":
                                Language = "Spanish";
                                break;
                            }

                            Localizations.Add(new Localization
                            {
                                Language = Language,
                                Ui       = Ui,
                                Audio    = Audio,
                                Sub      = Sub,
                                Notes    = string.Empty,
                                IsManual = false
                            });
                        }
                    }
                }
                else
                {
                    logger.Warn($"CheckLocalizations - No SteamId find for {game.Name}");
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "CheckLocalizations");
            }

            return(Localizations);
        }
예제 #8
0
    protected override void Execute()
    {
        string SerialKey  = web.Param("serial");
        int    ReferralID = 0;

        // if we got steam ticket, auth it and link it to account
        string SteamID = "";

        try
        {
            string ticket = web.Param("ticket");

            // get steam user id from auth ticket
            SteamApi api = new SteamApi();
            SteamID = api.GetSteamId(ticket);
            if (SteamID.Length == 0)
            {
                Response.Write("WO_5");
                Response.Write("steam: can't auth");
                return;
            }

            bool Have_Game = api.CheckAppOwnership(SteamID, "226700"); // base game
            if (!Have_Game)
            {
                Response.Write("WO_5");
                Response.Write("steam: does not own game");
                return;
            }

            // check if we already have linked account (to prevent multiple accounts registering)
            if (CheckIfHaveSteamAccount(SteamID))
            {
                Response.Write("WO_7");
                Response.Write("steam: already have account");
                return;
            }

            // 227662 DLC is a special DLC that says that user bought game from Steam and not converted user
            bool Have_SteamKey = api.CheckAppOwnership(SteamID, "227662");
            if (!Have_SteamKey)
            {
                Response.Write("WO_B");
                Response.Write("steam: does not own 227662");
                return;
            }

            // overwrite serial key with special key for steam
            SerialKey  = "STEAM-226700-FGHYT-AWRTS-HZRTA";
            ReferralID = 10;
        }
        catch { }


        SqlCommand sqcmd = new SqlCommand();

        sqcmd.CommandType = CommandType.StoredProcedure;
        sqcmd.CommandText = "WZ_ACCOUNT_CREATE";
        sqcmd.Parameters.AddWithValue("@in_IP", LastIP);
        sqcmd.Parameters.AddWithValue("@in_EMail", web.Param("username")); // login name from updater
        sqcmd.Parameters.AddWithValue("@in_Password", web.Param("password"));
        sqcmd.Parameters.AddWithValue("@in_ReferralID", ReferralID);
        sqcmd.Parameters.AddWithValue("@in_SerialKey", SerialKey);
        sqcmd.Parameters.AddWithValue("@in_SerialEmail", web.Param("email"));   // email used in serial key purchase

        if (!CallWOApi(sqcmd))
        {
            return;
        }

        reader.Read();
        int CustomerID = getInt("CustomerID");

        Response.Write("WO_0");
        Response.Write(string.Format("{0}", CustomerID));

        // if we got steam id - link it to customer id
        if (SteamID.Length > 0)
        {
            sqcmd             = new SqlCommand();
            sqcmd.CommandType = CommandType.StoredProcedure;
            sqcmd.CommandText = "WZ_SteamLinkAccount";
            sqcmd.Parameters.AddWithValue("@in_CustomerID", CustomerID);
            sqcmd.Parameters.AddWithValue("@in_SteamID", SteamID);

            CallWOApi(sqcmd);
        }
    }