Пример #1
0
        private void HandleResource(HPages Page, ref string Body)
        {
            PlayerID    = int.Parse(Body.GetChild("var habboId = ", ';'));
            _PlayerName = Body.GetChild("var habboName = \"", '\"');
            _Age        = int.Parse(Body.GetChild("kvage=", ';'));
            _Gender     = (HGenders)Char.ToUpper(Body.GetChild("kvgender=", ';')[0]);
            _CSRFToken  = Body.GetChild("<meta name=\"csrf-token\" content=\"", '\"');

            switch (Page)
            {
            case HPages.Me:
            {
                string[] InfoBoxes = Body.GetChilds("<div class=\"content\">", '<');
                _Motto      = InfoBoxes[6].Split('>')[1];
                _LastSignIn = InfoBoxes[12].Split('>')[1];
                break;
            }

            case HPages.Home:
            {
                _CreatedOn = Body.GetChild("<div class=\"birthday date\">", '<');
                _Motto     = Body.GetChild("<div class=\"profile-motto\">", '<');
                break;
            }

            case HPages.Profile:
            {
                _URLToken = Body.GetChild("name=\"urlToken\" value=\"", '\"');
                break;
            }

            case HPages.Client:
            {
                _Host      = Body.GetChild("\"connection.info.host\" : \"", '\"');
                _Port      = int.Parse(Body.GetChild("\"connection.info.port\" : \"", '\"').Split(',')[0]);
                _Addresses = Dns.GetHostAddresses(_Host).Select(IP => IP.ToString()).ToArray();
                _SSOTicket = Body.GetChild("\"sso.ticket\" : \"", '\"');

                if (string.IsNullOrEmpty(ClientStarting))
                {
                    ClientStarting = Body.GetChild("\"client.starting\" : \"", '\"');
                }
                else
                {
                    Body = Body.Replace(Body.GetChild("\"client.starting\" : \"", '\"'), ClientStarting);
                }

                _UserHash = Body.GetChild("\"user.hash\" : \"", '\"');
                _GameData = HGameData.Parse(Body);

                _FlashClientURL      = "http://" + Body.GetChild("\"flash.client.url\" : \"", '\"').Substring(3) + "Habbo.swf";
                _FlashClientRevision = _FlashClientURL.Split('/')[4];
                break;
            }
            }
        }
Пример #2
0
        private void HandleResource(HPage page, ref string body)
        {
            PlayerId    = int.Parse(body.GetChild("var habboId = ", ';'));
            _playerName = body.GetChild("var habboName = \"", '\"');
            _age        = int.Parse(body.GetChild("kvage=", ';'));
            _gender     = (HGender)Char.ToUpper(body.GetChild("kvgender=", ';')[0]);
            _csrfToken  = body.GetChild("<meta name=\"csrf-token\" content=\"", '\"');

            switch (page)
            {
            case HPage.Me:
            {
                string[] infoBoxes = body.GetChilds("<div class=\"content\">", '<');
                _motto      = infoBoxes[6].Split('>')[1];
                _lastSignIn = infoBoxes[12].Split('>')[1];
                break;
            }

            case HPage.Home:
            {
                _createdOn = body.GetChild("<div class=\"birthday date\">", '<');
                _motto     = body.GetChild("<div class=\"profile-motto\">", '<');
                break;
            }

            case HPage.Profile:
            {
                _firstTimeLoadProfile = false;
                _urlToken             = body.GetChild("name=\"urlToken\" value=\"", '\"');

                _homepageVisible      = body.GetChild("name=\"visibility\" value=\"EVERYONE\"", '/').Contains("checked");
                _friendRequestAllowed = body.GetChild("name=\"friendRequestsAllowed\"", '/').Contains("checked");
                _showOnlineStatus     = body.GetChild("name=\"showOnlineStatus\" value=\"true\"", '/').Contains("checked");
                _offlineMessaging     = body.GetChild("name=\"persistentMessagingAllowed\" checked=\"checked\"", '/').Contains("true");
                _friendsCanFollow     = body.GetChild("name=\"followFriendMode\" value=\"1\"").Contains("checked");
                break;
            }

            case HPage.Client:
            {
                _host      = body.GetChild("\"connection.info.host\" : \"", '\"');
                _port      = int.Parse(body.GetChild("\"connection.info.port\" : \"", '\"').Split(',')[0]);
                _addresses = Dns.GetHostAddresses(_host).Select(ip => ip.ToString()).ToArray();
                _ssoTicket = body.GetChild("\"sso.ticket\" : \"", '\"');

                if (string.IsNullOrEmpty(ClientStarting))
                {
                    ClientStarting = body.GetChild("\"client.starting\" : \"", '\"');
                }
                else
                {
                    body = body.Replace(body.GetChild("\"client.starting\" : \"", '\"'), ClientStarting);
                }

                _userHash = body.GetChild("\"user.hash\" : \"", '\"');
                _gameData = HGameData.Parse(body);

                _flashClientUrl   = "http://" + body.GetChild("\"flash.client.url\" : \"", '\"').Substring(3) + "Habbo.swf";
                _flashClientBuild = _flashClientUrl.Split('/')[4];

                body = body.Replace("\"\\//", "\"http://");
                break;
            }
            }
        }