Exemplo n.º 1
0
        public void ReturnNormalizedFrameworkDescriptionWhenItStartsWithKeywordAndCodeBaseHasKeyword(string runtimeAssemblyCodeBase, string expectedVersion)
        {
            // Keyword for runtimeDescription = ".NET Core"
            // Keyword for codeBase = "Microsoft.NETCore.App"
            var frameworkInfo = UserAgentHelper.GetFrameworkDescription(".NET Core", runtimeAssemblyCodeBase);

            frameworkInfo.Should().Be($".NET Core {expectedVersion}");
        }
Exemplo n.º 2
0
        public void ReturnPassedFrameworkDescriptionWhenAssemblyCodeBaseDoesNotContainKeyword(string runtimeAssemblyCodeBase)
        {
            // Keyword for runtimeDescription = ".NET Core"
            // Keyword for codeBase = "Microsoft.NETCore.App"
            var frameworkInfo = UserAgentHelper.GetFrameworkDescription(".NET Core foo", runtimeAssemblyCodeBase);

            frameworkInfo.Should().Be(".NET Core foo");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardId">The board id.</param>
        /// <param name="forumId">The forum identifier.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        private bool CheckAccessRights([NotNull] int boardId, [NotNull] int forumId)
        {
            // Find user name
            var user = this.Get <IAspNetUsersHelper>().GetUser();

            var browser =
                $"{HttpContext.Current.Request.Browser.Browser} {HttpContext.Current.Request.Browser.Version}";
            var platform       = HttpContext.Current.Request.Browser.Platform;
            var isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            var userAgent      = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out var isSearchEngine,
                out var doNotTrack);

            this.Get <StartupInitializeDb>().Run();

            string userKey;

            if (user != null)
            {
                userKey = user.Id;
            }
            else
            {
                return(false);
            }

            if (forumId == 0)
            {
                // is private message upload
                return(true);
            }

            var pageRow = this.Get <DataBroker>().GetPageLoad(
                HttpContext.Current.Session.SessionID,
                boardId,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                0,
                forumId,
                0,
                0,
                isSearchEngine,
                isMobileDevice,
                doNotTrack);

            return(pageRow.UploadAccess || pageRow.ModeratorAccess);
        }
Exemplo n.º 4
0
 protected override void PageLoad()
 {
     if (UserAgentHelper.IsMobile(HttpContext.Current.Request.UserAgent))
     {
         ResponseHelper.Redirect("http://m.mostool.com");
     }
     base.CheckUserLogin();
     User = UserBLL.ReadUser(base.UserID);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardID">The board id.</param>
        /// <param name="forumID">The forum identifier.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        private bool CheckAccessRights([NotNull] int boardID, [NotNull] int forumID)
        {
            if (forumID == 0)
            {
                // is private message upload
                return(true);
            }

            // Find user name
            var user = UserMembershipHelper.GetUser();

            var browser = "{0} {1}".FormatWith(
                HttpContext.Current.Request.Browser.Browser, HttpContext.Current.Request.Browser.Version);
            var  platform       = HttpContext.Current.Request.Browser.Platform;
            var  isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            bool isSearchEngine;
            bool dontTrack;
            var  userAgent = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out isSearchEngine,
                out dontTrack);

            this.Get <StartupInitializeDb>().Run();

            object userKey = DBNull.Value;

            if (user != null)
            {
                userKey = user.ProviderUserKey;
            }

            DataRow pageRow = LegacyDb.pageload(
                HttpContext.Current.Session.SessionID,
                boardID,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                null,
                forumID,
                null,
                null,
                isSearchEngine, // don't track if this is a search engine
                isMobileDevice,
                dontTrack);

            return(pageRow["UploadAccess"].ToType <bool>() || pageRow["ModeratorAccess"].ToType <bool>());
        }
Exemplo n.º 6
0
        public async Task Should_GetProductAsync_3029330003533()
        {
            string             barcode         = "3029330003533";
            String             userAgent       = UserAgentHelper.GetUserAgent("OpenFoodFacts4Net.ApiClient.Tests", ".Net Platform", "0.1", null);
            Uri                baseAddress     = new Uri(Constants.BaseUrl);
            HttpClient         httpClient      = HttpClientHelper.Create(baseAddress, userAgent);
            GetProductResponse productResponse = await httpClient.GetProductAsync(barcode);

            Assert.Equal("Pain de mie complet", productResponse.Product.GenericName);
        }
Exemplo n.º 7
0
 private void HomeView_Loaded(object sender, RoutedEventArgs e)
 {
     UserAgentHelper.GetUserAgent(
         LayoutRoot,
         userAgent =>
     {
         // TODO: Store this wherever you want
         ApplicationSettings.Current.UserAgent = userAgent;
     });
 }
Exemplo n.º 8
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardId">The board id.</param>
        /// <param name="messageId">The message id.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        public bool CheckAccessRights([NotNull] int boardId, [NotNull] int messageId)
        {
            if (messageId.Equals(0))
            {
                return(true);
            }

            // Find user name
            var user = UserMembershipHelper.GetUser();

            var browser =
                $"{HttpContext.Current.Request.Browser.Browser} {HttpContext.Current.Request.Browser.Version}";
            var  platform       = HttpContext.Current.Request.Browser.Platform;
            var  isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            bool isSearchEngine;
            bool dontTrack;
            var  userAgent = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out isSearchEngine,
                out dontTrack);

            YafContext.Current.Get <StartupInitializeDb>().Run();

            object userKey = DBNull.Value;

            if (user != null)
            {
                userKey = user.ProviderUserKey;
            }

            var pageRow = YafContext.Current.GetRepository <ActiveAccess>().PageLoad(
                HttpContext.Current.Session.SessionID,
                boardId,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                null,
                null,
                null,
                messageId,
                isSearchEngine, // don't track if this is a search engine
                isMobileDevice,
                dontTrack);

            return(pageRow["DownloadAccess"].ToType <bool>() || pageRow["ModeratorAccess"].ToType <bool>());
        }
Exemplo n.º 9
0
        /// <summary>
        /// Checks the access rights.
        /// </summary>
        /// <param name="boardId">The board id.</param>
        /// <param name="forumId">The forum identifier.</param>
        /// <returns>
        /// The check access rights.
        /// </returns>
        private bool CheckAccessRights([NotNull] int boardId, [NotNull] int forumId)
        {
            if (forumId == 0)
            {
                // is private message upload
                return(true);
            }

            // Find user name
            var user = UserMembershipHelper.GetUser();

            var browser =
                $"{HttpContext.Current.Request.Browser.Browser} {HttpContext.Current.Request.Browser.Version}";
            var platform       = HttpContext.Current.Request.Browser.Platform;
            var isMobileDevice = HttpContext.Current.Request.Browser.IsMobileDevice;
            var userAgent      = HttpContext.Current.Request.UserAgent;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                HttpContext.Current.Request.Browser.Crawler,
                ref platform,
                ref browser,
                out var isSearchEngine,
                out var doNotTrack);

            this.Get <StartupInitializeDb>().Run();

            object userKey = DBNull.Value;

            if (user != null)
            {
                userKey = user.ProviderUserKey;
            }

            var pageRow = this.GetRepository <ActiveAccess>().PageLoad(
                HttpContext.Current.Session.SessionID,
                boardId,
                userKey,
                HttpContext.Current.Request.GetUserRealIPAddress(),
                HttpContext.Current.Request.FilePath,
                HttpContext.Current.Request.QueryString.ToString(),
                browser,
                platform,
                null,
                forumId,
                null,
                null,
                isSearchEngine,
                isMobileDevice,
                doNotTrack);

            return(pageRow["UploadAccess"].ToType <bool>() || pageRow["ModeratorAccess"].ToType <bool>());
        }
Exemplo n.º 10
0
        public void ModifyHeader_NewHeader()
        {
            var modifier = UserAgentHelper.CreateRequestModifier(typeof(UserAgentHelperTest));

            var request = new HttpRequestMessage();

            modifier(request);
            var values = request.Headers.GetValues(VersionHeaderBuilder.HeaderName).ToList();

            Assert.Equal(1, values.Count);
            Assert.Contains("gccl/", values[0]);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 初始化单一实例应用程序对象。这是执行的创作代码的第一行,
        /// 已执行,逻辑上等同于 main() 或 WinMain()。
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            if ("Windows.Mobile" == Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily)
            {
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            }
            //调用类构造函数
            UserAgentHelper.SetDefaultUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.143930");
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserAgentHelper.IsMobile(HttpContext.Current.Request.UserAgent))
            {
                ResponseHelper.Redirect("http://ems.mostool.com");
            }

            if (Cookies.User.GetUserID(true) > 0)
            {
                Response.Redirect("Default.aspx");
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending         += OnSuspending;
     this.UnhandledException += App_UnhandledException;
     App.Current.Suspending  += Current_Suspending;
     try
     {
         UserAgentHelper.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36");
     }
     catch { }
 }
 public List <SniperInfo> FindAll()
 {
     try
     {
         var userAgent = UserAgentHelper.GetRandomUseragent();
         var content   = getContent(userAgent);
         return(GetJsonList(content));
     }
     catch (Exception e)
     {
         return(FallbackFindAll());
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            ConfigureFilters(global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory);

            this.InitializeComponent();
            this.Suspending += OnSuspending;

#if NETFX_CORE
            //User-Agent의 헤더 텍스트 입력
            UserAgentHelper.SetDefaultUserAgent(
                "Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Mobile Safari/537.36 Edge/15.14900");
#endif
        }
        private void DoExpCol(object sender)
        {
            Button     btn       = (Button)sender;
            TreeLbItem tiCurrent = (TreeLbItem)btn.Tag;

            if (tiCurrent.Expanded)
            {
                tiCurrent.Collapse();
            }
            else
            {
                if (tiCurrent.ContainerID != "IE")
                {
                    tiCurrent.Expand();
                }
                else
                {
                    if (m_tiLoading != null)
                    {
                        MessageBox.Show("Load in progress!\n\nPlease wait...");
                        return;
                    }

                    m_tiLoading         = tiCurrent;
                    m_tiLoading.Loading = true;

                    UserAgentHelper.GetUserAgent(
                        iePanel,
                        userAgent =>
                    {
                        if (m_tiLoading != null)
                        {
                            m_tiLoading.Loading = false;

                            m_tiLoading.PreInserts();

                            TreeLbItem ti;

                            ti = new TreeLbItem(m_tiLoading.Holder, m_tiLoading, "UserAgent",
                                                "User Agent",
                                                userAgent);
                            m_tiLoading.Insert(ti);

                            m_tiLoading.Expand_Base();

                            m_tiLoading = null;
                        }
                    });
                }
            }
        }
        private void HomeView_Loaded(object sender, RoutedEventArgs e)
        {
            bool UAexists = MowblyClientManager.Instance.DoesUAexists();

            if (!UAexists)
            {
                UserAgentHelper.GetUserAgent(
                    LayoutRoot,
                    userAgent =>
                {
                    MowblyClientManager.Instance.PutUA(userAgent);
                });
            }
        }
Exemplo n.º 18
0
        public async void StartChallengeV2(InstaChallengeLoginInfo challengeLoginInfo)
        {
            try
            {
                try
                {
                    var device = Helper.InstaApi.GetCurrentDevice();
                    //UserAgentHelper.SetUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
                    UserAgentHelper.SetUserAgent($"Mozilla/5.0 (Linux; Android {device.AndroidVer.VersionNumber}; {device.DeviceModelIdentifier}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.86 Mobile Safari/537.36");
                }
                catch
                {
                    try
                    {
                        UserAgentHelper.SetUserAgent($"Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.86 Mobile Safari/537.36");
                    }
                    catch { }
                }
                try
                {
                    SignInView.DeleteFacebookCookies();
                }
                catch { }
                Visibility = Visibility.Visible;
                ChallengeV2LoadingOn();
                await Task.Delay(1500);

                Uri baseUri = new Uri(challengeLoginInfo.Url);
                HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
                var cookies = Helper.InstaApi.HttpRequestProcessor.HttpHandler.CookieContainer
                              .GetCookies(Helper.InstaApi.HttpRequestProcessor.Client.BaseAddress);
                foreach (System.Net.Cookie c in cookies)
                {
                    HttpCookie cookie = new HttpCookie(c.Name, baseUri.Host, "/")
                    {
                        Value = c.Value
                    };
                    filter.CookieManager.SetCookie(cookie, false);
                }

                HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, baseUri);
                ChallengeV2kWebView.NavigateWithHttpRequestMessage(httpRequestMessage);
            }
            catch (Exception ex)
            {
                ChallengeV2LoadingOff();
                Helper.ShowErr("Something unexpected happened", ex);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.PollList.Visible     = this.PageContext.BoardSettings.BoardPollID > 0;
            this.PollList.PollGroupId = this.PageContext.BoardSettings.BoardPollID;
            this.PollList.BoardId     = this.PageContext.Settings.BoardID;

            if (!this.IsPostBack)
            {
                // vzrus: needs testing, potentially can cause problems
                if (!(UserAgentHelper.IsSearchEngineSpider(HttpContext.Current.Request.UserAgent)))
                {
                    if (!HttpContext.Current.Request.Browser.Cookies)
                    {
                        YafBuildLink.RedirectInfoPage(InfoMessage.RequiresCookies);
                    }

                    Version ecmaVersion = HttpContext.Current.Request.Browser.EcmaScriptVersion;

                    if (ecmaVersion != null)
                    {
                        if (!(ecmaVersion.Major > 0))
                        {
                            YafBuildLink.RedirectInfoPage(InfoMessage.EcmaScriptVersionUnsupported);
                        }
                    }
                    else
                    {
                        YafBuildLink.RedirectInfoPage(InfoMessage.RequiresEcmaScript);
                    }
                }

                this.ShoutBox1.Visible         = this.PageContext.BoardSettings.ShowShoutbox;
                this.ForumStats.Visible        = this.PageContext.BoardSettings.ShowForumStatistics;
                this.ActiveDiscussions.Visible = this.PageContext.BoardSettings.ShowActiveDiscussions;


                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                    if (this.PageContext.PageCategoryID != 0)
                    {
                        this.PageLinks.AddLink(
                            this.PageContext.PageCategoryName,
                            YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                        this.Welcome.Visible = false;
                    }
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// The page load event.
        /// </summary>
        /// <param name="sender">
        /// the sender.
        /// </param>
        /// <param name="e">
        /// the e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.PageContext.BoardSettings.EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Request.QueryString.GetFirstOrDefault("u") == null || this.Request.QueryString.GetFirstOrDefault("a") == null)
            {
                YafBuildLink.AccessDenied();
            }

            var userId  = Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u"));
            var albumId = Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("a"));

            // setup jQuery, LightBox and YAF JS...
            YafContext.Current.PageElements.RegisterJQuery();
            YafContext.Current.PageElements.RegisterJsResourceInclude("yafjs", "js/yaf.js");
            YafContext.Current.PageElements.RegisterJsBlock("toggleMessageJs", JavaScriptBlocks.ToggleMessageJs);

            // lightbox only need if the browser is not IE6...
            if (!UserAgentHelper.IsBrowserIE6())
            {
                YafContext.Current.PageElements.RegisterJsResourceInclude("lightboxjs", "js/jquery.lightbox.min.js");
                YafContext.Current.PageElements.RegisterCssIncludeResource("css/jquery.lightbox.css");
                YafContext.Current.PageElements.RegisterJsBlock("lightboxloadjs", JavaScriptBlocks.LightBoxLoadJs);
            }

            string displayName = this.PageContext.UserDisplayName.GetName((int)userId);

            // Generate the page links.
            this.PageLinks.Clear();
            this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(displayName, YafBuildLink.GetLink(ForumPages.profile, "u={0}", userId));
            this.PageLinks.AddLink(this.GetText("ALBUMS"), YafBuildLink.GetLink(ForumPages.albums, "u={0}", userId));
            this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty);

            // Set the title text.
            this.LocalizedLabel1.Param0 = !string.IsNullOrEmpty(displayName) ? this.Server.HtmlEncode(displayName) : this.Server.HtmlEncode(this.PageContext.User.UserName);
            this.LocalizedLabel1.Param1 = this.Server.HtmlEncode(DB.album_gettitle(albumId));

            // Initialize the Album Image List control.
            this.AlbumImageList1.UserID  = (int)userId;
            this.AlbumImageList1.AlbumID = (int)albumId;
        }
Exemplo n.º 21
0
        private void InitUserAgent()
        {
            if (_userAgentHelper == null)
            {
                _userAgentHelper = new UserAgentHelper();

                //填充列表
                foreach (string line in _userAgentHelper.PCUserAgentList)
                {
                    this.dgvPCUserAgent.Rows.Add(line);
                }

                foreach (string line in _userAgentHelper.MobileUserAgentList)
                {
                    this.dgvMobileUserAgent.Rows.Add(line);
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        ///   The page load event.
        /// </summary>
        /// <param name = "sender">
        ///   the sender.
        /// </param>
        /// <param name = "e">
        ///   the e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.PageContext.BoardSettings.EnableAlbum)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.Request.QueryString.GetFirstOrDefault("u") == null)
            {
                YafBuildLink.AccessDenied();
            }

            // setup jQuery, LightBox and YAF JS...
            YafContext.Current.PageElements.RegisterJQuery();
            YafContext.Current.PageElements.RegisterJsResourceInclude("yafjs", "js/yaf.js");
            YafContext.Current.PageElements.RegisterJsBlock("toggleMessageJs", JavaScriptBlocks.ToggleMessageJs);

            // lightbox only need if the browser is not IE6...
            if (!UserAgentHelper.IsBrowserIE6())
            {
                YafContext.Current.PageElements.RegisterJsResourceInclude("lightboxjs", "js/jquery.lightbox.min.js");
                YafContext.Current.PageElements.RegisterCssIncludeResource("css/jquery.lightbox.css");
                YafContext.Current.PageElements.RegisterJsBlock("lightboxloadjs", JavaScriptBlocks.LightBoxLoadJs);
            }

            string displayName =
                UserMembershipHelper.GetDisplayNameFromID(
                    Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u")));

            // Generate the Page Links.

            this.PageLinks.Clear();
            this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                displayName.IsSet()
          ? displayName
          : UserMembershipHelper.GetUserNameFromID(
                    Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("u"))),
                YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.Request.QueryString.GetFirstOrDefault("u")));
            this.PageLinks.AddLink(this.GetText("ALBUMS"), string.Empty);

            // Initialize the Album List control.
            this.AlbumList1.UserID = this.Request.QueryString.GetFirstOrDefault("u").ToType <int>();
        }
        // Token: 0x06000073 RID: 115 RVA: 0x00004148 File Offset: 0x00002348
        public static CallerRequestedCapabilities GetInstance(HttpContext requestHttpContext)
        {
            if (requestHttpContext == null)
            {
                throw new ArgumentNullException("requestHttpContext", "You must call this GetInstance method only in the cases where an HttpContext is available");
            }
            Version requestingClientVersion = null;
            Version windowsVersion          = null;
            string  text = Common.SafeGetUserAgent(requestHttpContext.Request);
            bool    canFollowRedirect = !AutodiscoverProxy.CanRedirectOutlookClient(text);
            bool    canHandleExHttpNodesInResponse = UserAgentHelper.IsWindowsClient(text);
            bool    flag = UserAgentHelper.ValidateClientSoftwareVersions(text, delegate(int major, int minor)
            {
                windowsVersion = new Version(major, minor);
                return(true);
            }, delegate(int major, int minor, int buildMajor)
            {
                requestingClientVersion = new Version(major, minor, buildMajor, 0);
                return(true);
            }) && windowsVersion != null && requestingClientVersion != null;
            bool isCallerCrossForestAvailabilityService = !string.IsNullOrWhiteSpace(text) && text.StartsWith("ASAutoDiscover/CrossForest", StringComparison.OrdinalIgnoreCase) && requestHttpContext.User != null && requestHttpContext.User.Identity is ExternalIdentity;
            bool flag2 = flag && UserAgentHelper.IsClientWin7OrGreater(text);
            bool flag3 = false;
            bool flag4 = false;

            if (flag2 && CallerRequestedCapabilities.CheckIfClientSupportsNegotiate(requestingClientVersion, out flag3))
            {
                flag4 = true;
            }
            OptInCapabilities optInCapabilities;

            if (CallerRequestedCapabilities.TryParseOptInCapabillitiesHeader(requestHttpContext, out optInCapabilities))
            {
                if ((optInCapabilities & OptInCapabilities.Negotiate) != OptInCapabilities.None)
                {
                    flag4 = true;
                }
                if ((optInCapabilities & OptInCapabilities.ExHttpInfo) != OptInCapabilities.None)
                {
                    canHandleExHttpNodesInResponse = true;
                }
            }
            return(new CallerRequestedCapabilities(canFollowRedirect, canHandleExHttpNodesInResponse, requestingClientVersion, isCallerCrossForestAvailabilityService, flag2, flag4, flag4 && flag3));
        }
Exemplo n.º 24
0
        private async void FbStart()
        {
            try
            {
                FacebookGrid.Visibility = Visibility.Visible;
                SignInVM.LoadingOn();
                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync(InstaFbHelper.FacebookAddress);

                    if (!response.IsSuccessStatusCode)
                    {
                        FacebookGrid.Visibility = Visibility.Collapsed;
                        SignInVM.LoadingOff();
                        FacebookBlockedMsg.ShowMsg();
                        return;
                    }
                }
            }
            catch
            {
                FacebookGrid.Visibility = Visibility.Collapsed;
                SignInVM.LoadingOff();
                FacebookBlockedMsg.ShowMsg();
                return;
            }
            try
            {
                UserAgentHelper.SetUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
            }
            catch { }
            try
            {
                DeleteFacebookCookies();
            }
            catch { }
            FacebookGrid.Visibility = Visibility.Visible;
            SignInVM.LoadingOn();
            await Task.Delay(1500);

            var facebookLogin = InstaFbHelper.GetFacebookLoginUri();

            FacebookWebView.Navigate(facebookLogin);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 将用户登录成功信息写入Cookie
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="Remembered"></param>
        private void ResponseLoginCookie(Administrator entity, bool Remembered = false)
        {
            DateTime expiration = Remembered ? DateTime.Now.AddDays(7) : DateTime.Now.Add(FormsAuthentication.Timeout);
            var      userData   = new { Id = entity.Id, AdminName = entity.Member.MemberName, RealName = entity.Member.RealName };
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(2, (userData.AdminName + userData.Id.ToString()), DateTime.Now, expiration, Remembered, userData.ToJsonString(), FormsAuthentication.FormsCookiePath);
            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket))
            {
                HttpOnly = true,
                Secure   = FormsAuthentication.RequireSSL,
                Domain   = FormsAuthentication.CookieDomain,
                Path     = FormsAuthentication.FormsCookiePath,
            };

            if (Remembered)
            {
                cookie.Expires = DateTime.Now.AddDays(7);
            }
            Response.Cookies.Remove(cookie.Name);
            Response.Cookies.Add(cookie);

            #region 临时客户端tcid = 11.1.1.111;Windows 10;Chrome;2016/11/25 10:30:15
            try
            {
                var hostaddress = Request.UserHostAddress;

                //var hostname = Request.LogonUserIdentity.Name;//获取得不正确,暂时弃用

                var        systemname  = UserAgentHelper.GetOperatingSystemName(Request.UserAgent);
                var        browsername = UserAgentHelper.GetBrowserName(Request.UserAgent);
                var        logintime   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                var        tcid        = AesHelper.Encrypt(string.Format("{0};{1};{2};{3}", hostaddress, systemname, browsername, logintime), userData.Id.ToString());
                HttpCookie tcCookie    = new HttpCookie("tcid", tcid);
                tcCookie.Expires  = cookie.Expires;
                tcCookie.HttpOnly = cookie.HttpOnly;
                tcCookie.Secure   = cookie.Secure;
                tcCookie.Domain   = cookie.Domain;
                tcCookie.Path     = cookie.Path;
                Response.Cookies.Add(tcCookie);
            }
            catch { }
            #endregion
        }
        private static ScanResult QuerySkipLagged(double boundLowerLeftLat, double boundLowerLeftLng, double boundUpperRightLat, double boundUpperRightLng)
        {
            var uri =
                $"http://skiplagged.com/api/pokemon.php?bounds={boundLowerLeftLat.ToString(CultureInfo.InvariantCulture)},{boundLowerLeftLng.ToString(CultureInfo.InvariantCulture)},{boundUpperRightLat.ToString(CultureInfo.InvariantCulture)},{boundUpperRightLng.ToString(CultureInfo.InvariantCulture)}";

            ScanResult scanResult;

            try
            {
                var request = WebRequest.CreateHttp(uri);
                request.UserAgent        = UserAgentHelper.GetRandomUseragent();
                request.Accept           = "application/json";
                request.Method           = "GET";
                request.Timeout          = 15000;
                request.ReadWriteTimeout = 32000;
                request.CookieContainer  = new CookieContainer();

                using (var resp = request.GetResponse())
                {
                    using (var reader = new StreamReader(resp.GetResponseStream()))
                    {
                        var fullresp =
                            reader.ReadToEnd()
                            .Replace(" M", "Male")
                            .Replace(" F", "Female")
                            .Replace("Farfetch'd", "Farfetchd")
                            .Replace("Mr.Maleime", "MrMime");
                        scanResult = JsonConvert.DeserializeObject <ScanResult>(fullresp);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Debug("Error querying skiplagged", ex);
                scanResult = new ScanResult
                {
                    Status   = "fail",
                    pokemons = new List <PokemonLocation>()
                };
            }
            return(scanResult);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Handles the specified @event.
        /// </summary>
        /// <param name="event">The @event.</param>
        public void Handle([NotNull] InitPageLoadEvent @event)
        {
            string browser = "{0} {1}".FormatWith(
                this.HttpRequestBase.Browser.Browser, this.HttpRequestBase.Browser.Version);
            string platform = this.HttpRequestBase.Browser.Platform;

            bool isSearchEngine;
            bool dontTrack;

            string userAgent = this.HttpRequestBase.UserAgent;

            bool isMobileDevice = UserAgentHelper.IsMobileDevice(userAgent) ||
                                  this.HttpRequestBase.Browser.IsMobileDevice;

            // try and get more verbose platform name by ref and other parameters
            UserAgentHelper.Platform(
                userAgent,
                this.HttpRequestBase.Browser.Crawler,
                ref platform,
                ref browser,
                out isSearchEngine,
                out dontTrack);

            dontTrack = !this.Get <YafBoardSettings>().ShowCrawlersInActiveList&& isSearchEngine;

            // don't track if this is a feed reader. May be to make it switchable in host settings.
            // we don't have page 'g' token for the feed page.
            if (browser.Contains("Unknown") && !dontTrack)
            {
                dontTrack = UserAgentHelper.IsFeedReader(userAgent);
            }

            @event.Data.DontTrack      = dontTrack;
            @event.Data.UserAgent      = userAgent;
            @event.Data.IsSearchEngine = isSearchEngine;
            @event.Data.IsMobileDevice = isMobileDevice;
            @event.Data.Browser        = browser;
            @event.Data.Platform       = platform;

            YafContext.Current.Vars["DontTrack"] = dontTrack;
        }
Exemplo n.º 28
0
        public async void NavigateToInstagramForFacebookLogin()
        {
            if (WebViewFacebook == null)
            {
                return;
            }
            try
            {
                LoadingOn();
                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync(new Uri("https://m.facebook.com/"));

                    if (!response.IsSuccessStatusCode)
                    {
                        LoadingOff();
                        await new MessageDialog(FacebookBlockedMsg).ShowAsync();
                        return;
                    }
                }
            }
            catch
            {
                LoadingOff();
                await new MessageDialog(FacebookBlockedMsg).ShowAsync();
                return;
            }
            try
            {
                UserAgentHelper.SetUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
            }
            catch { }
            DeleteInstagramCookies();
            DeleteFacebookCookies();
            FacebookFirstTime      = true;
            FacebookPassed         = false;
            CancelFacebookLogin    = false;
            FacebookGridVisibility = Visibility.Visible;
            LoadingOn();
            WebViewFacebook.Navigate(InstagramUri);
        }
Exemplo n.º 29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal productTotalPrice = Sessions.ProductTotalPrice;
            string  key = RequestHelper.GetForm <string>("Pay");

            //默认选择支付宝AliPay
            if (UserAgentHelper.IsWx(Request.UserAgent))
            {
                key = "WxPay";
            }
            else
            {
                key = "AliPay";
            }
            PayPluginsInfo info  = PayPlugins.ReadPayPlugins(key);
            OrderInfo      order = new OrderInfo();

            order.PayKey      = key;
            order.PayName     = info.Name;
            order.OrderNumber = ShopCommon.CreateOrderNumber();
            if (info.IsCod == 1)
            {
                order.OrderStatus = 2;
            }
            else
            {
                order.OrderStatus = 1;
            }
            order.OrderNote    = string.Empty;
            order.ProductMoney = productTotalPrice;
            //order.PayDate = RequestHelper.DateNow;
            order.UserID = UserID;
            //order.UserName = base.UserName;
            int orderID = OrderBLL.AddOrder(order);

            this.AddOrderProduct(orderID);
            if (order.OrderStatus == (int)OrderStatus.WaitPay && info.IsOnline == (int)BoolType.True)
            {
                ResponseHelper.Redirect("/Plugins/Pay/" + key + "/Pay.aspx?OrderID=" + orderID + "&Action=PayOrder");
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Returns string to identify a cache.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="custom">like "$IsMobile;foo;bar"</param>
        /// <returns>like "true_"</returns>
        public override string GetVaryByCustomString(HttpContext context, string custom)
        {
            var tokens = custom.Split(';');
            var strs   = new List <string>();

            foreach (var token in tokens)
            {
                switch (token)
                {
                case "$IsMobile":
                    strs.Add(UserAgentHelper.IsMobile(context.Request.UserAgent).ToString());
                    break;

                default:
                    break;
                }
            }
            var str = string.Join("_", strs);

            return(str);
        }