コード例 #1
0
 protected void TrafficRefreshUpdatePanel_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Request.Params.Get("__EVENTARGUMENT")))
     {
         string agrument = Request.Params.Get("__EVENTARGUMENT");
         if (PTCSercurityManager.IsTrafficAdvertFound(agrument))
         {
             PTCSercurityManager.Release();
             L_Clicked.Text = Member.Current.TrafficGridHitsToday.ToString();
         }
     }
 }
コード例 #2
0
 public static void SetWatchingAdCookie(int seconds)
 {
     PTCSercurityManager.Lock(seconds);
 }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.PtcAdverts.IsExternalIFrameEnabled);

        if (TitanFeatures.IsAhmed)
        {
            RedirectToBannersPlaceHolder.Visible = true;
            TokenAdsPlaceHolder.Visible          = true;
            TimerStylesPlaceHolder.Visible       = true;
        }

        SiteName.Text = AppSettings.Site.Name;
        LangAdder.Add(CustomValidator1, L1.ER_BADCAPTCHA);
        LangAdder.Add(CreditAfterCaptcha, L1.SEND);
        LangAdder.Add(CloseRefreshButton, U4000.CLOSE);

        if (Request.Params.Get("__WATCHEDID") != null)
        {
            //Ad watched, proceed (with captcha)
            BeforePanel.Visible = false;
            string AdId = Request.Params.Get("__WATCHEDID");
            int    Id   = Int32.Parse(AdId);
            StoredAdId = Id;

            HashedTrafficAd = PTCSercurityManager.HashAd(AdId);

            if (IsCaptchaEnabled && Member.IsLogged)
            {
                AnimatedHeight       = 260;
                CaptchaPanel.Visible = true;
                AdInfoContainer.Text = ""; //Disable the timer
            }
            else
            {
                ProcceedWithCredit(Id);
            }
        }
        else if (Request.Params.Get("__EVENTARGUMENT5") != null)
        {
            //Display ad before watch
            string AdId = Request.Params.Get("__EVENTARGUMENT5");
            Form.Action = "user/earn/asurf/asurf.aspx";
            if (!Prem.PTC.Security.SecurityManager.IsWatchingAdCookieSet())
            {
                PtcAdvert ad = new PtcAdvert();
                try
                {
                    ad = new PtcAdvert(Int32.Parse(AdId));

                    string AdTime = ad.DisplayTime.TotalSeconds.ToString(); //get ad time in seconds

                    AdInfoContainer.Text  = "<input type=\"hidden\" name=\"__WATCHEDID\" id=\"__WATCHEDID\" value=\"" + AdId + "\" />";
                    AdInfoContainer.Text += "<input type=\"hidden\" id=\"adtime\" value=\"" + AdTime + "\"/>";
                    targetUrl             = ad.TargetUrl;
                    Prem.PTC.Security.SecurityManager.SetWatchingAdCookie(Convert.ToInt32(ad.DisplayTime.TotalSeconds));
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex);
                    throw ex;
                }
            }
            else
            {
                MultiplePanel.Visible = true;
            }
        }
        WatchAdButton.OnClientClick = "openedWindow = window.open('" + targetUrl + "','_blank'); startTimer(); hideButton(); return false; ";
    }
コード例 #4
0
ファイル: ads.aspx.cs プロジェクト: dovanduy/titan
    protected void LoadAds()
    {
        Form.Action = Request.RawUrl;

        List <PtcAdvert> AvailableAdList;

        CreatedCustomCategories = new List <int>();

        Member user = null;

        if (Member.IsLogged)
        {
            user = Member.Current;
            int temporaryAdvertId = 0;
            if (AppSettings.PtcAdverts.BlockPtcAdvertsAfterMissingPointer &&
                Request.Params.Get("__EVENTARGUMENT5") != null && Int32.TryParse(Request.Params.Get("__EVENTARGUMENT5"), out temporaryAdvertId))
            {
                // User missed the anti-robot button 3 times
                // Blocking this particualr ad for him
                List <int> av = user.AdsViewed;
                av.Add(temporaryAdvertId); // Blocking = adding to watched
                user.AdsViewed = av;
                user.Save();

                NotificationManager.RefreshWithMember(NotificationType.NewAds, user);
            }

            AvailableAdList = PtcAdvert.GetActiveAdsForUser(user);
        }
        else
        {
            AvailableAdList = PtcAdvert.GetAllActiveAds();
        }

        if (AvailableAdList.Count == 0)
        {
            MenuMultiView.Visible     = false;
            NoPTCpanelWrapper.Visible = true;
            NoPTCpanel.Visible        = true;
            NoPTCpanel.Text           = U6003.NOPTC;
        }
        else
        {
            if (!string.IsNullOrWhiteSpace(Request.Params.Get("__EVENTARGUMENT")))
            {
                string agrument = Request.Params.Get("__EVENTARGUMENT");
                if (PTCSercurityManager.IsPTCAdvertFound(agrument, AvailableAdList))
                {
                    PTCSercurityManager.Release();
                }
            }

            //Sort by favorite?
            if (Member.IsLogged)
            {
                if (SortBy1.SelectedValue == "Favorite")
                {
                    var favorites = FavoriteAd.GetUserFavorites(Member.CurrentId, FavoriteAdType.PTC);
                    AvailableAdList = AvailableAdList.OrderByDescending(i => favorites.Contains(i.Id)).ToList();
                }
                else if (SortBy1.SelectedValue == "Voted")
                {
                    var favorites = FavoriteAd.GetUserFavorites(Member.CurrentId, FavoriteAdType.PTC);
                    AvailableAdList = AvailableAdList.OrderByDescending(i => i.CaptchaYesAnswers - i.CaptchaNoAnswers).ToList();
                }
            }

            //Display proper ads to the Member
            try
            {
                //Lets get the proper ads to the member
                foreach (PtcAdvert Ad in AvailableAdList)
                {
                    bool IsSearch = !string.IsNullOrWhiteSpace(SearchTextBox.Text);

                    if (!IsSearch || (IsSearch && IsSearchRequirementsMeet(Ad, SearchTextBox.Text)))
                    {
                        if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
                        {
                            //Display Custom Categories
                            CustomCategoriesPlaceHolder.Visible = true;
                            if (!CreatedCustomCategories.Contains(Ad.CategoryId))
                            {
                                CreatedCustomCategories.Add(Ad.CategoryId);
                            }

                            CustomCategoriesPlaceHolder.Controls.Add(GetAdHTML(Ad, user));
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(Ad.Description) && Ad.IsStarredAd == false)
                            {
                                SmallAdsLiteral.Controls.Add(GetAdHTML(Ad, user, ""));
                            }
                            else
                            {
                                AdsLiteral.Controls.Add(GetAdHTML(Ad, user, ""));
                            }
                        }
                    }
                }
                if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
                {
                    foreach (var categoryId in CreatedCustomCategories)
                    {
                        LoadCustomCategoryButton(categoryId);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw ex;
            }
        }
    }